/* ------------------------------------------------------------------
   Base: reset, typography scale, app shell layout (sidebar + main).
   ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-2);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0;
  color: var(--ink);
}
h1 { font-size: var(--fs-6); font-weight: 700; }
h2 { font-size: var(--fs-5); }
h3 { font-size: var(--fs-4); }
h4 { font-size: var(--fs-3); }
p { margin: 0; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1.1rem; overflow-x: auto; line-height: 1.5; margin: 0; }
pre code { background: none; padding: 0; font-size: 0.86rem; }
strong { font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
.num, .tabular { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-0);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 1.25rem 1rem 2rem;
  display: flex; flex-direction: column; gap: 1.25rem;
  font-family: var(--font-display);
  font-size: var(--fs-1);
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group + .nav-group { border-top: 1px solid var(--line); padding-top: 1rem; }
.nav-label { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 0 0.5rem 0.35rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.42rem 0.55rem; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; }
.nav-link .dot.done { background: var(--gain); border-color: var(--gain); }
.nav-link .dot.part { background: linear-gradient(90deg, var(--gain) 50%, transparent 50%); border-color: var(--gain); }
.nav-link .badge { margin-left: auto; font-family: var(--font-mono); font-size: 0.68rem; background: var(--surface-2); color: var(--muted); padding: 0.05rem 0.4rem; border-radius: 99px; }
.nav-link.active .badge { background: var(--accent); color: var(--accent-ink); }

.progress-wrap { display: flex; flex-direction: column; gap: 0.35rem; padding: 0 0.5rem; }
.progress-meta { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.progress-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-bar > i { display: block; height: 100%; background: var(--gain); width: 0; transition: width 0.4s ease; }

.sidebar-foot { margin-top: auto; display: flex; gap: 0.5rem; padding: 0 0.25rem; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 0.35rem 0.6rem; cursor: pointer; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

.main { min-width: 0; }
.page { padding: 2.5rem clamp(1rem, 4vw, 3.5rem) 6rem; max-width: 1180px; }
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1.1rem; }
.prose h2 { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.prose h3 { margin-top: 2.25rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35rem; }

/* mobile top bar */
.topbar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(85vw, 320px); z-index: 30; transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 0.75rem; position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0.6rem 1rem; font-family: var(--font-display); }
  .topbar .brand-mark { width: 26px; height: 26px; }
  .page { padding: 1.5rem 1rem 5rem; }
  h1 { font-size: var(--fs-5); }
  h2 { font-size: var(--fs-4); }
}
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 25; }
.scrim.show { display: block; }
