:root {
  color-scheme: light dark;
  --bg: #f5efe4;
  --bg-soft: rgba(255, 252, 246, 0.78);
  --surface: rgba(255, 252, 247, 0.86);
  --surface-strong: #fffaf1;
  --surface-muted: rgba(255, 249, 239, 0.7);
  --text: #16211d;
  --muted: #51625c;
  --accent: #0c6b6f;
  --accent-strong: #064e52;
  --accent-soft: rgba(12, 107, 111, 0.12);
  --warm: #c7663d;
  --border: rgba(21, 43, 37, 0.1);
  --shadow: 0 24px 70px rgba(18, 32, 29, 0.12);
  --logo-surface: rgba(255, 255, 255, 0.96);
  --logo-border: rgba(21, 43, 37, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 999px;
  --max-width: 1120px;
  --content-width: 780px;
  --header-height: 88px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1412;
  --bg-soft: rgba(18, 24, 22, 0.74);
  --surface: rgba(16, 23, 21, 0.88);
  --surface-strong: #151d1b;
  --surface-muted: rgba(20, 28, 26, 0.72);
  --text: #edf4ef;
  --muted: #a8bab1;
  --accent: #67d0c0;
  --accent-strong: #bff6ee;
  --accent-soft: rgba(103, 208, 192, 0.14);
  --warm: #ff9a6c;
  --border: rgba(203, 235, 225, 0.12);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.38);
  --logo-surface: rgba(255, 255, 255, 0.98);
  --logo-border: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(199, 102, 61, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(12, 107, 111, 0.16), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  line-height: 1.65;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration-color: rgba(12, 107, 111, 0.35);
  text-underline-offset: 0.18em;
}

button,
input {
  font: inherit;
}

code,
pre {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.site-shell {
  position: relative;
  overflow-x: clip;
}

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28%),
    url("/assets/grid.svg") center top / 200px 200px repeat;
  opacity: 0.6;
  mask-image: linear-gradient(180deg, black 0%, rgba(0, 0, 0, 0.48) 55%, transparent 100%);
}

.site-header,
.page-content,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header,
.site-footer,
.page-content {
  width: min(calc(100% - 2rem), var(--max-width));
  margin-inline: auto;
}

.site-header {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem 0 0.9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
}

.brand img {
  width: 64px;
  height: 64px;
  padding: 0.38rem;
  object-fit: contain;
  border-radius: 20px;
  background: var(--logo-surface);
  border: 1px solid var(--logo-border);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
  filter: saturate(1.04) contrast(1.03);
}

.brand-copy {
  display: inline-flex;
  flex-direction: column;
  gap: 0.08rem;
}

.brand-copy strong,
.theme-toggle,
.eyebrow,
.meta-label,
.stat-label,
.tag,
.search-label {
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
}

.brand-copy strong {
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-copy span {
  color: var(--muted);
  font-size: 0.96rem;
}

.header-actions,
.site-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.72rem 0.95rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  transition: background 180ms ease, color 180ms ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--surface);
  color: var(--text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8.5rem;
  padding: 0.78rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.chip-button:hover,
.chip-button:focus-visible,
.post-card:hover,
.post-card:focus-within {
  transform: translateY(-2px);
}

.theme-toggle:focus-visible,
.search-field input:focus-visible,
.chip-button:focus-visible,
.post-link:focus-visible,
.back-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.page-content {
  padding-bottom: 4rem;
}

.page-content-compact {
  padding-top: 0.2rem;
}

.hero-panel,
.control-panel,
.post-card,
.article-shell,
.site-footer {
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hero-panel,
.control-panel,
.article-shell,
.site-footer,
.empty-state {
  border: 1px solid var(--border);
  background: var(--surface);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.95fr);
  gap: 1.4rem;
  padding: 2rem;
  border-radius: var(--radius-xl);
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-panel h1,
.section-heading h2,
.article-header h1 {
  margin: 0;
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.hero-panel h1 {
  max-width: 12ch;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
}

.hero-text,
.section-copy,
.article-description {
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-text {
  max-width: 57ch;
  margin: 1rem 0 0;
}

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

.stat-card {
  padding: 1.2rem;
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.stat-label,
.meta-label,
.search-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.1;
}

.stat-value-small {
  font-size: 1rem;
  line-height: 1.35;
}

.control-panel,
.post-section {
  margin-top: 1.5rem;
}

.search-strip,
.post-feed {
  width: min(100%, 860px);
  margin-inline: auto;
}

.search-strip {
  margin-bottom: 1.35rem;
}

.search-field-standalone input {
  padding: 1.1rem 1.15rem;
  border-radius: 18px;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 1rem;
  padding: 1.2rem;
  border-radius: var(--radius-xl);
}

.search-field,
.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.search-field input {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.chip-button,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.48rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
}

.chip-button {
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.chip-button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: #f9fffc;
}

html[data-theme="dark"] .chip-button[aria-pressed="true"] {
  color: #08110e;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  font-size: clamp(2rem, 5vw, 3rem);
}

.section-copy {
  max-width: 32ch;
  margin: 0;
  text-align: right;
}

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

.home-page .page-glow {
  opacity: 0.18;
}

.home-page .post-grid {
  grid-template-columns: 1fr;
  gap: 1.1rem;
}

.home-page .post-card {
  padding: 1.5rem;
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform 180ms ease, border-color 180ms ease;
}

.post-link {
  text-decoration: none;
}

.post-link h3 {
  margin: 0 0 0.55rem;
  font-size: 1.55rem;
  line-height: 1.15;
}

.post-link p {
  margin: 0;
  color: var(--muted);
}

.meta-row,
.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.94rem;
}

.meta-pill strong {
  color: var(--text);
  font-weight: 600;
}

.loading-state,
.empty-state {
  text-align: center;
  padding: 2rem 1.2rem;
  border-radius: var(--radius-lg);
  color: var(--muted);
}

.empty-state h3 {
  margin-top: 0;
  color: var(--text);
}

.site-footer {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-xl);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  text-decoration: none;
}

.back-link {
  display: inline-flex;
  margin-bottom: 1rem;
  text-decoration: none;
  color: var(--accent);
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
}

.article-shell {
  width: min(100%, calc(var(--content-width) + 5rem));
  margin-inline: auto;
  padding: clamp(1.4rem, 4vw, 2.4rem);
  border-radius: var(--radius-xl);
}

.article-header h1 {
  font-size: clamp(2.5rem, 6vw, 4.6rem);
  max-width: 12ch;
}

.article-description {
  margin: 1rem 0 1.4rem;
  max-width: 58ch;
}

.meta-grid {
  margin-bottom: 1.2rem;
}

.meta-grid > div {
  flex: 1 1 180px;
  padding: 0.9rem 1rem;
  background: var(--surface-muted);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.meta-grid strong {
  display: block;
  font-size: 1rem;
}

.article-content {
  margin-top: 2rem;
}

.prose {
  font-size: 1.06rem;
}

.prose > * + * {
  margin-top: 1.15rem;
}

.prose h2,
.prose h3,
.prose h4 {
  margin-top: 2.4rem;
  margin-bottom: 0.8rem;
  line-height: 1.15;
}

.prose h2 {
  font-size: clamp(1.8rem, 4vw, 2.3rem);
}

.prose h3 {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
}

.prose p,
.prose li,
.prose blockquote {
  color: var(--text);
}

.prose p {
  margin: 0;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
}

.prose li + li {
  margin-top: 0.55rem;
}

.prose blockquote {
  margin: 1.6rem 0;
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 18px 18px 0;
  background: var(--accent-soft);
}

.prose hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.prose pre {
  overflow-x: auto;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(8, 17, 15, 0.94);
  color: #ebfff9;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.prose code {
  padding: 0.15rem 0.38rem;
  border-radius: 0.45rem;
  background: var(--surface-muted);
  font-size: 0.92em;
}

.prose pre code {
  padding: 0;
  background: transparent;
}

.prose img {
  display: block;
  margin-inline: auto;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.noscript-note {
  display: block;
  margin-top: 1rem;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .hero-panel,
  .control-panel,
  .section-heading,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .site-footer {
    display: grid;
  }

  .section-copy {
    text-align: left;
  }

  .search-strip,
  .post-feed {
    width: min(100%, 100%);
  }
}

@media (max-width: 720px) {
  .site-header {
    align-items: flex-start;
    gap: 1rem;
  }

  .brand {
    width: 100%;
    gap: 0.8rem;
  }

  .brand-copy {
    min-width: 0;
  }

  .brand-copy strong {
    font-size: 0.94rem;
    letter-spacing: 0.12em;
  }

  .brand-copy span {
    font-size: 0.88rem;
    line-height: 1.35;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.65rem;
  }

  .site-nav {
    flex: 1 1 auto;
  }

  .nav-link,
  .theme-toggle {
    min-height: 44px;
  }

  .page-content {
    padding-bottom: 3rem;
  }

  .home-page .post-card,
  .post-card {
    padding: 1.2rem;
  }

  .post-link h3 {
    font-size: 1.35rem;
  }

  .meta-row {
    gap: 0.55rem 0.8rem;
  }

  .meta-pill {
    font-size: 0.9rem;
  }

  .article-shell {
    width: 100%;
    padding: 1.25rem;
    border-radius: 22px;
  }

  .article-header h1 {
    max-width: 100%;
    font-size: clamp(2rem, 9vw, 3rem);
  }

  .article-description,
  .prose {
    font-size: 1rem;
  }

  .meta-grid {
    gap: 0.7rem;
  }

  .meta-grid > div {
    flex: 1 1 calc(50% - 0.7rem);
    padding: 0.8rem 0.9rem;
  }

  .prose blockquote,
  .prose pre {
    border-radius: 16px;
  }

  .site-footer {
    gap: 0.55rem;
    padding: 1rem 1.05rem;
    font-size: 0.92rem;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 76px;
  }

  .site-header,
  .site-footer,
  .page-content {
    width: min(calc(100% - 1.1rem), var(--max-width));
  }

  .site-header {
    padding-top: 0.9rem;
  }

  .brand img {
    width: 56px;
    height: 56px;
    padding: 0.32rem;
  }

  .brand-copy strong {
    font-size: 0.92rem;
  }

  .brand-copy span {
    font-size: 0.84rem;
  }

  .theme-toggle {
    min-width: 0;
    padding-inline: 0.85rem;
  }

  .header-actions {
    align-items: stretch;
    gap: 0.55rem;
  }

  .site-nav,
  .theme-toggle {
    width: 100%;
  }

  .nav-link,
  .theme-toggle {
    justify-content: center;
  }

  .hero-panel,
  .control-panel,
  .article-shell {
    padding: 1.2rem;
  }

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

  .post-grid {
    grid-template-columns: 1fr;
  }

  .search-strip {
    margin-bottom: 1rem;
  }

  .search-field-standalone input {
    padding: 1rem 1rem;
    border-radius: 16px;
  }

  .home-page .post-card,
  .post-card {
    padding: 1rem;
    gap: 0.85rem;
  }

  .post-link h3 {
    font-size: 1.2rem;
  }

  .meta-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .meta-grid > div {
    flex-basis: 100%;
  }

  .article-description {
    margin: 0.85rem 0 1.1rem;
  }

  .article-content {
    margin-top: 1.5rem;
  }

  .prose ul,
  .prose ol {
    padding-left: 1.1rem;
  }

  .site-footer {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .site-header,
  .site-footer,
  .page-content {
    width: min(calc(100% - 0.85rem), var(--max-width));
  }

  .brand {
    align-items: center;
    gap: 0.7rem;
  }

  .brand img {
    width: 52px;
    height: 52px;
    border-radius: 18px;
  }

  .brand-copy strong {
    font-size: 0.88rem;
    letter-spacing: 0.1em;
  }

  .brand-copy span {
    font-size: 0.8rem;
  }

  .nav-link,
  .theme-toggle {
    width: 100%;
    padding: 0.78rem 0.9rem;
    font-size: 0.92rem;
  }

  .back-link {
    margin-bottom: 0.8rem;
    font-size: 0.92rem;
  }

  .article-shell {
    padding: 1rem;
    border-radius: 20px;
  }

  .article-header h1 {
    font-size: clamp(1.75rem, 10vw, 2.35rem);
  }

  .prose {
    font-size: 0.98rem;
  }

  .prose blockquote {
    margin: 1.2rem 0;
    padding: 0.9rem 1rem;
  }

  .prose pre {
    padding: 0.9rem;
    font-size: 0.86rem;
  }

  .site-footer {
    padding: 0.9rem;
    border-radius: 20px;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
