/* ── Tokens ──────────────────────────────────────────────────── */
:root {
  --bg:        #0f0f10;
  --surface:   #1a1a1c;
  --surface-2: #222225;
  --border:    #2c2c30;
  --border-2:  #404046;
  --text:      #f0ece4;
  --text-2:    #c5c0b9;
  --text-3:    #9c9690;
  --gold:      #d4a847;
  --gold-dim:  #ab8435;
  --gold-glow: rgba(212,168,71,.1);
  --focus:     #d4a847;
  --red:       #e06c6c;
  --red-soft:  rgba(224,108,108,.12);

  /* Type scale — 5 steps */
  --text-xs:   0.8125rem;  /* 13px — metadata, kbd, copyright */
  --text-sm:   0.9375rem;  /* 15px — UI: chips, buttons, nav, labels */
  --text-base: 1.0625rem;  /* 17px — body: textarea, descriptions */
  --text-lg:   1.375rem;   /* 22px — logo */
  --text-xl:   2.25rem;    /* 36px — hero heading */

  --r:    8px;
  --r-lg: 12px;
  --max:  780px;

  --sidebar-w: 290px;
  --header-h:  56px;
}

:root[data-theme="light"] {
  --bg:        #f8f6f0;
  --surface:   #ffffff;
  --surface-2: #efebe2;
  --border:    #dfd8cc;
  --border-2:  #c8c0b2;
  --text:      #1a1714;
  --text-2:    #3d3832;
  --text-3:    #5c564f;
  --gold:      #855306;
  --gold-dim:  #996007;
  --gold-glow: rgba(133,83,6,.12);
  --focus:     #855306;
  --red:       #903030;
  --red-soft:  rgba(144,48,48,.08);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:        #f8f6f0;
    --surface:   #ffffff;
    --surface-2: #efebe2;
    --border:    #dfd8cc;
    --border-2:  #c8c0b2;
    --text:      #1a1714;
    --text-2:    #3d3832;
    --text-3:    #5c564f;
    --gold:      #855306;
    --gold-dim:  #996007;
    --gold-glow: rgba(133,83,6,.12);
    --focus:     #855306;
    --red:       #903030;
    --red-soft:  rgba(144,48,48,.08);
  }
}

:root[data-theme="dark"] {
  --bg:        #0f0f10;
  --surface:   #1a1a1c;
  --surface-2: #222225;
  --border:    #2c2c30;
  --border-2:  #404046;
  --text:      #f0ece4;
  --text-2:    #c5c0b9;
  --text-3:    #9c9690;
  --gold:      #d4a847;
  --gold-dim:  #ab8435;
  --gold-glow: rgba(212,168,71,.1);
  --focus:     #d4a847;
  --red:       #e06c6c;
  --red-soft:  rgba(224,108,108,.12);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Focus & Accessibility ──────────────────────────────────── */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r); }
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Page shell ──────────────────────────────────────────────── */
.page { width: 100%; max-width: var(--max); padding: 0 28px; }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  width: 100%; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  display: flex; justify-content: center;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}
.topbar-inner {
  width: 100%; max-width: var(--max); padding: 12px 28px;
  display: flex; align-items: center; justify-content: space-between;
}

.logo, h1.logo {
  font-size: inherit; font-weight: inherit; margin: 0;
}
.logo a { text-decoration: none; display: flex; align-items: baseline; gap: 6px; }
.logo-a {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto; font-weight: 600;
  font-size: var(--text-lg); letter-spacing: -0.02em;
  line-height: 1; color: var(--text);
}
.logo-b {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto; font-weight: 200; font-style: italic;
  font-size: var(--text-lg); letter-spacing: -0.02em;
  line-height: 1; color: var(--gold);
}

.nav-links {
  display: flex; gap: 4px; align-items: center;
}
.nav-links a {
  font-size: var(--text-sm); color: var(--text-2);
  text-decoration: none; letter-spacing: 0;
  padding: 6px 12px; border-radius: 100px;
  transition: color .12s, background .12s;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a.active {
  color: var(--gold); background: var(--gold-glow);
}
.nav-sep {
  width: 1px; height: 16px; background: var(--border);
  margin: 0 4px; flex-shrink: 0;
}

/* Theme Toggle Button in Topbar */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  transition: color .12s, background .12s, border-color .12s;
  flex-shrink: 0;
  margin-left: 4px;
}
.theme-toggle-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-2);
}
.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  width: 100%; border-top: 1px solid var(--border);
  display: flex; justify-content: center; margin-top: 8px;
}
.footer-inner {
  width: 100%; max-width: var(--max);
  padding: 36px 28px 48px;
  display: flex; flex-direction: column; gap: 24px;
}
.footer-section { display: flex; flex-direction: column; gap: 12px; }
.footer-heading {
  font-size: var(--text-xs); font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-2);
}
.footer-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px 16px;
}
.footer-grid a {
  font-size: var(--text-sm); color: var(--text-3);
  text-decoration: none; letter-spacing: 0;
  padding: 4px 0; transition: color .12s;
}
.footer-grid a:hover { color: var(--gold); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex; flex-direction: column; gap: 20px;
}
.footer-links {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.footer-links a {
  font-size: var(--text-sm); color: var(--text-2);
  text-decoration: none; font-weight: 500;
  letter-spacing: 0; transition: color .12s;
}
.footer-links a:hover { color: var(--gold); }
.footer-copy { font-size: var(--text-xs); color: var(--text-3); }
.footer-made {
  font-size: var(--text-xs);
  color: var(--text-3);
  text-align: center;
}
.footer-sep { width: 100%; height: 1px; background: var(--border); }
.footer-doodle {
  display: block; margin: 4px auto 0; width: 180px; height: auto;
  opacity: .18; transition: opacity .3s;
  filter: invert(1) brightness(1.5);
}
.footer-doodle:hover { opacity: .35; }

[data-theme="light"] .footer-doodle { filter: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .footer-doodle { filter: none; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 360px) {
  .page, .footer-inner { padding-left: 16px; padding-right: 16px; }
}
