:root {
  --bg: #f4ede2;
  --bg-strong: #f9f5ef;
  --surface: rgba(255, 250, 244, 0.86);
  --surface-strong: #fffdf9;
  --text: #1f1d1a;
  --muted: #625d55;
  --border: rgba(31, 29, 26, 0.12);
  --accent: #d76432;
  --accent-strong: #b24f25;
  --accent-soft: rgba(215, 100, 50, 0.14);
  --teal: #1f6c67;
  --shadow: 0 24px 60px rgba(51, 37, 19, 0.1);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --container: min(1120px, calc(100vw - 32px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  line-height: 1.72;
  background:
    radial-gradient(circle at top left, rgba(221, 133, 62, 0.22), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(31, 108, 103, 0.16), transparent 26%),
    linear-gradient(180deg, #f8f1e7 0%, #f4ede2 52%, #efe5d8 100%);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 72%);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.5em;
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif SC", serif;
}

p,
ul,
ol,
blockquote,
pre {
  margin: 0 0 1.1rem;
}

.container {
  width: var(--container);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(249, 245, 239, 0.78);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 46px;
  padding: 0 12px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), #f09f52);
  color: white;
  font-weight: 700;
  font-size: 0.96rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(215, 100, 50, 0.25);
}

.brand-text {
  display: grid;
  gap: 2px;
}

.brand-text strong {
  font-size: 0.96rem;
}

.brand-text small {
  color: var(--muted);
  font-size: 0.82rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.65);
}

.nav-toggle {
  display: none;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.hero,
.page-hero,
.article-hero {
  padding: 48px 0 20px;
}

.hero-grid,
.about-grid,
.feature-grid,
.article-layout {
  display: grid;
  gap: 24px;
}

.hero-grid {
  grid-template-columns: 1.2fr 0.8fr;
  align-items: stretch;
}

.hero-copy,
.page-hero .container,
.article-header {
  padding: 12px 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  margin-bottom: 18px;
  border-radius: 999px;
  color: var(--teal);
  background: rgba(31, 108, 103, 0.1);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1,
.page-hero h1,
.article-header h1 {
  max-width: 12ch;
  font-size: clamp(2.8rem, 6vw, 5.4rem);
}

.hero .lead,
.page-hero .lead,
.article-header .lead {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.25rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  padding: 14px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.button:hover,
.text-link:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), #f09f52);
  box-shadow: 0 16px 32px rgba(215, 100, 50, 0.24);
}

.button-secondary {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.68);
}

.text-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-panel,
.about-card {
  padding: 28px;
}

.avatar-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.hero-panel img,
.about-card img {
  width: min(100%, 220px);
  object-fit: cover;
  aspect-ratio: 1 / 1;
  border-radius: 28px;
}

.panel-title,
.footer-title {
  margin-bottom: 6px;
  font-size: 1rem;
  font-weight: 800;
}

.panel-subtitle,
.panel-text,
.meta-stack,
.post-meta,
.site-footer p {
  color: var(--muted);
}

.panel-text {
  margin-top: 12px;
}

.stats-grid {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.stats-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(160px, 1.25fr);
}

.stats-grid dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-grid dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
  word-break: keep-all;
  overflow-wrap: normal;
}

.stats-grid.compact > div:last-child dd {
  white-space: nowrap;
}

.section {
  padding: 34px 0;
}

.section-head {
  margin-bottom: 22px;
}

.section-head h2 {
  max-width: 14ch;
  font-size: clamp(2rem, 4vw, 3rem);
}

.feature-grid {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.feature-copy {
  padding: 18px 0;
}

.feature-copy h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.feature-copy p {
  max-width: 52ch;
  color: var(--muted);
}

.feature-cards {
  display: grid;
  gap: 16px;
}

.feature-cards .card,
.timeline-item,
.principles,
.post-card,
.featured-article,
.toc,
.article-side .card {
  padding: 22px;
}

.card-index {
  display: inline-flex;
  margin-bottom: 18px;
  color: var(--accent-strong);
  font-weight: 800;
}

.pill-list,
.post-tags,
.meta-stack,
.footer-links,
.side-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

.tag-ghost {
  color: var(--teal);
  background: rgba(31, 108, 103, 0.1);
}

.featured-article h3,
.post-card h3,
.timeline-item h3 {
  font-size: 1.5rem;
}

.featured-meta,
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.9rem;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.post-grid-wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-card-large {
  min-height: 260px;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto;
}

.about-grid {
  grid-template-columns: 1.1fr 0.9fr;
  align-items: start;
}

.timeline {
  display: grid;
  gap: 16px;
}

.timeline-item {
  position: relative;
  overflow: hidden;
}

.timeline-item::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), #f09f52);
  content: "";
}

.timeline-year {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--teal);
  font-weight: 800;
}

.principles ul,
.toc ul {
  padding-left: 18px;
  margin-bottom: 0;
}

.principles li,
.toc li {
  margin-bottom: 10px;
}

.centered {
  display: grid;
  justify-items: center;
  text-align: center;
}

.article-shell {
  padding-bottom: 28px;
}

.article-layout {
  grid-template-columns: minmax(0, 760px) minmax(260px, 320px);
  align-items: start;
}

.article-body {
  padding: clamp(22px, 3vw, 34px);
}

.about-markdown {
  max-width: 860px;
  margin: 0 auto;
}

.article-body h2,
.article-body h3,
.article-body h4 {
  margin-top: 2rem;
}

.article-body a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-color: rgba(178, 79, 37, 0.35);
  text-underline-offset: 0.18em;
}

.article-body ul,
.article-body ol {
  padding-left: 22px;
}

.article-body blockquote {
  padding: 16px 18px;
  border-left: 4px solid rgba(31, 108, 103, 0.4);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(31, 108, 103, 0.06);
}

.article-body code {
  padding: 0.16em 0.42em;
  border-radius: 8px;
  background: rgba(31, 29, 26, 0.08);
  font-family: "SFMono-Regular", "JetBrains Mono", "Menlo", monospace;
  font-size: 0.92em;
}

.article-body pre {
  overflow-x: auto;
  padding: 18px;
  border-radius: var(--radius-md);
  background: #1f1d1a;
  color: #f6f0e7;
}

.article-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.article-body hr {
  height: 1px;
  border: 0;
  background: var(--border);
}

.article-side {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 96px;
}

.toc li {
  list-style: none;
}

.toc ul {
  padding-left: 0;
}

.toc a {
  color: var(--muted);
}

.toc-level-3 {
  padding-left: 12px;
}

.side-links {
  flex-direction: column;
}

.side-links a,
.back-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.article-progress {
  width: 100%;
  height: 4px;
  margin-bottom: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(31, 29, 26, 0.08);
}

.article-progress::before {
  display: block;
  width: calc(var(--progress, 0) * 1%);
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f09f52);
  content: "";
  transition: width 120ms ease-out;
}

.site-footer {
  padding: 40px 0 54px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.footer-links a {
  color: var(--accent-strong);
  font-weight: 700;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 540ms ease, transform 540ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.admin-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(215, 100, 50, 0.16), transparent 28%),
    radial-gradient(circle at 86% 10%, rgba(31, 108, 103, 0.12), transparent 24%),
    linear-gradient(180deg, #fbf5ee 0%, #f3eadd 100%);
}

.admin-login-shell,
.admin-shell-page {
  width: var(--container);
  margin: 0 auto;
  padding: 38px 0 56px;
}

.admin-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.admin-login-card {
  width: min(560px, 100%);
  padding: 32px;
}

.admin-login-card h1,
.admin-shell-page h1 {
  font-size: clamp(2.2rem, 4vw, 3.5rem);
}

.admin-login-lead,
.admin-page-lead {
  color: var(--muted);
}

.admin-form,
.admin-form-card {
  display: grid;
  gap: 18px;
}

.admin-form-card,
.admin-side-card,
.admin-list-card {
  padding: 24px;
}

.admin-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-field {
  display: grid;
  gap: 8px;
}

.admin-field span {
  font-weight: 700;
}

.admin-input,
.admin-textarea,
.admin-field select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(31, 29, 26, 0.14);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.88);
  font: inherit;
}

.admin-input:focus,
.admin-textarea:focus,
.admin-field select:focus {
  outline: 2px solid rgba(215, 100, 50, 0.25);
  outline-offset: 2px;
}

.admin-textarea {
  resize: vertical;
  line-height: 1.7;
}

.admin-textarea-sm {
  min-height: 108px;
}

.admin-textarea-lg {
  min-height: 520px;
  font-family: "SFMono-Regular", "JetBrains Mono", "Menlo", monospace;
  font-size: 0.96rem;
}

.admin-submit {
  width: 100%;
}

.admin-helper,
.admin-empty-state,
.admin-list-card p,
.admin-post-title small,
.admin-muted,
.admin-tip-list {
  color: var(--muted);
}

.admin-banner {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 18px;
  font-weight: 600;
}

.admin-banner-notice {
  color: var(--teal);
  background: rgba(31, 108, 103, 0.1);
}

.admin-banner-error {
  color: #8d2f25;
  background: rgba(176, 63, 46, 0.12);
}

.admin-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.admin-topbar-compact {
  margin-bottom: 18px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.admin-actions-inline {
  justify-content: flex-start;
}

.admin-actions form {
  margin: 0;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0 24px;
}

.admin-stat-card {
  padding: 22px;
}

.admin-stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.admin-stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.admin-list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 16px 12px;
  border-top: 1px solid rgba(31, 29, 26, 0.08);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.admin-post-title {
  display: grid;
  gap: 4px;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-link-button {
  padding: 0;
  border: 0;
  color: #a63e2d;
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.admin-status {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.admin-status-published {
  color: var(--teal);
  background: rgba(31, 108, 103, 0.1);
}

.admin-status-draft {
  color: var(--accent-strong);
  background: rgba(215, 100, 50, 0.12);
}

.admin-empty-state {
  display: grid;
  justify-items: start;
  gap: 14px;
  padding: 12px 0 4px;
}

.admin-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 20px;
}

.admin-settings-layout {
  display: grid;
  gap: 18px;
}

.admin-section-head {
  margin-bottom: 18px;
}

.admin-section-head h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
}

.admin-section-head p,
.admin-section-subhead {
  color: var(--muted);
}

.admin-section-subhead {
  margin-top: 6px;
  font-weight: 700;
}

.admin-timeline-grid,
.admin-social-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-settings-actions {
  margin-top: 4px;
}

.admin-avatar-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-avatar-card {
  padding: 20px;
}

.admin-avatar-preview {
  display: grid;
  gap: 14px;
}

.admin-avatar-preview img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
}

.admin-avatar-meta {
  color: var(--muted);
  font-size: 0.92rem;
  word-break: break-all;
}

.admin-profile-preview {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.admin-profile-preview strong {
  color: var(--text);
  font-size: 1.2rem;
}

.admin-profile-preview p {
  margin: 4px 0 0;
}

.admin-side-card h2 {
  font-size: 1.4rem;
}

.admin-tip-list {
  padding-left: 18px;
  margin-bottom: 0;
}

.admin-tip-list li {
  margin-bottom: 10px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .button,
  .text-link,
  .nav-links a {
    transition: none;
  }
}

@media (max-width: 980px) {
  .hero-grid,
  .about-grid,
  .feature-grid,
  .article-layout,
  .post-grid,
  .post-grid-wide,
  .admin-editor-layout {
    grid-template-columns: 1fr;
  }

  .article-side {
    position: static;
  }

  .section-head h2,
  .feature-copy h2 {
    max-width: none;
  }
}

@media (max-width: 760px) {
  .header-inner {
    align-items: flex-start;
    min-height: 72px;
    padding: 12px 0;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-links {
    position: absolute;
    top: calc(100% + 10px);
    right: 16px;
    left: 16px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(255, 250, 244, 0.96);
    box-shadow: var(--shadow);
  }

  .nav-links[data-open="true"] {
    display: flex;
  }

  .nav-links a {
    width: 100%;
  }

  .hero,
  .page-hero,
  .article-hero {
    padding-top: 30px;
  }

  .hero h1,
  .page-hero h1,
  .article-header h1 {
    max-width: none;
    font-size: clamp(2.4rem, 12vw, 3.8rem);
  }

  .stats-grid.compact {
    grid-template-columns: 1fr;
  }

  .admin-login-card,
  .admin-form-card,
  .admin-side-card,
  .admin-list-card {
    padding: 20px;
  }

  .admin-field-grid,
  .admin-stats,
  .admin-timeline-grid,
  .admin-social-grid,
  .admin-avatar-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar,
  .admin-list-head {
    flex-direction: column;
  }

  .admin-table th,
  .admin-table td {
    min-width: 120px;
  }
}
