:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #151821;
  --muted: #697386;
  --line: #dde2ea;
  --brand: #176bff;
  --brand-dark: #0c4ec5;
  --danger: #c62828;
  --shadow: 0 18px 45px rgba(20, 28, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 0.75rem 1rem;
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

button.is-loading::after {
  animation: pulseDots 1s infinite;
  content: "";
}

button.secondary {
  background: #eef3ff;
  color: var(--brand-dark);
}

button.danger {
  background: #ffebeb;
  color: var(--danger);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 0.75rem;
}

textarea {
  min-height: 260px;
  resize: vertical;
}

textarea.code-box {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  min-height: 120px;
  white-space: pre;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
}

.site,
.article,
.admin {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  padding: 4rem 0 2rem;
}

.hero h1,
.article h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero p,
.lede {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.65;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  padding: 1rem 0 4rem;
}

.post-card,
.panel,
.login-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.post-card {
  overflow: hidden;
  color: inherit;
  display: block;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.post-card:hover {
  box-shadow: 0 22px 55px rgba(20, 28, 45, 0.12);
  transform: translateY(-2px);
}

.post-card img,
figure img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.post-card div,
.panel {
  padding: 1rem;
}

.post-card h2 {
  margin: 0.2rem 0 0.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.article {
  padding-bottom: 4rem;
}

.content {
  max-width: 760px;
  font-size: 1.08rem;
  line-height: 1.75;
}

.content h2,
.content h3 {
  margin-top: 2rem;
}

.article-image {
  margin: 2rem 0;
}

.cover-image {
  margin: 1.25rem 0 2.5rem;
  max-width: 900px;
}

.article-image img {
  width: 100%;
  border-radius: 8px;
  display: block;
  max-height: 520px;
  object-fit: cover;
}

.article-gallery {
  margin-top: 2.5rem;
  max-width: 980px;
}

.gallery-header {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.gallery-header h2 {
  margin: 0;
}

.gallery-header > div {
  display: flex;
  gap: 0.5rem;
}

.carousel-btn {
  align-items: center;
  aspect-ratio: 1;
  border-radius: 999px;
  display: inline-flex;
  font-size: 1.6rem;
  height: 42px;
  justify-content: center;
  padding: 0;
  width: 42px;
}

.gallery-track {
  display: grid;
  gap: 1rem;
  grid-auto-columns: minmax(260px, 360px);
  grid-auto-flow: column;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 0.25rem 0 1rem;
  scroll-snap-type: inline mandatory;
  scrollbar-width: thin;
}

.gallery-image {
  margin: 0;
  scroll-snap-align: start;
}

.gallery-image img {
  width: 100%;
  border-radius: 8px;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.source {
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin-top: 2rem;
  padding-top: 1rem;
}

.ad-slot {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  clear: both;
  margin: 2rem 0;
  padding: 1rem 0;
  text-align: center;
}

.ad-slot > span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.ad-slot-article,
.ad-slot-bottom {
  max-width: 760px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.login-box {
  width: min(420px, 100%);
  padding: 1.25rem;
}

.login-box h1 {
  margin-top: 0;
}

.stack {
  display: grid;
  gap: 1rem;
}

.admin-header {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 1.5rem 0;
}

.admin-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
  padding: 1rem 0 3rem;
}

.post-list {
  display: grid;
  gap: 0.65rem;
}

.post-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  padding: 0.8rem;
}

.post-row.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 255, 0.1);
}

.post-row strong,
.post-row span {
  display: block;
}

.post-row span,
.muted,
.message {
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 0.55rem;
}

.check-row input {
  width: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}

.image-choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.image-choice img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.image-choice input {
  width: auto;
  margin: 0.6rem;
}

.message.error {
  color: var(--danger);
}

.message.loading {
  color: var(--brand-dark);
  font-weight: 700;
}

.message.success {
  background: #eaf7ef;
  border: 1px solid #bfe6cb;
  border-radius: 8px;
  color: #166534;
  font-weight: 800;
  padding: 0.8rem;
}

@keyframes pulseDots {
  0% {
    content: "";
  }
  33% {
    content: ".";
  }
  66% {
    content: "..";
  }
  100% {
    content: "...";
  }
}

@media (max-width: 820px) {
  .admin-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .admin-header {
    display: grid;
    gap: 1rem;
  }
}
