/* ─────────────────────────────────────────────────────────
   Base — reset, body, typography baseline.
   ───────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-weight: var(--fw-regular);
  overflow: hidden;     /* shell handles scrolling per-pane */
}

/* ─── Type scale ───────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--c-ink);
  font-variation-settings: "opsz" 144, "SOFT" 0;
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); }

h1 em, h2 em, h3 em { font-style: italic; font-variation-settings: "opsz" 144, "SOFT" 100; }

p { margin: 0 0 var(--s-3); line-height: var(--lh-normal); }

a {
  color: var(--c-accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--c-accent-ink); text-decoration: underline; }

code, pre, kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
code {
  padding: 1px 5px;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  color: var(--c-accent-ink);
}
pre {
  padding: var(--s-4);
  border-radius: var(--r);
  background: var(--c-surface-2);
  overflow-x: auto;
}
kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--c-line);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-ink-2);
  font-size: 0.78em;
  font-weight: var(--fw-semibold);
}

hr {
  border: none;
  border-top: 1px solid var(--c-line);
  margin: var(--s-6) 0;
}

/* ─── Form baseline ────────────────────────────────────── */

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

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

/* ─── Scrollbars ──────────────────────────────────────── */

.scroll, .scroll-y, .pane, .drawer-body, .nav-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--c-line-strong) transparent;
}
.scroll::-webkit-scrollbar,
.scroll-y::-webkit-scrollbar,
.pane::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar,
.nav-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb,
.scroll-y::-webkit-scrollbar-thumb,
.pane::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb,
.nav-scroll::-webkit-scrollbar-thumb {
  background: var(--c-line-strong);
  border-radius: var(--r-full);
}
.scroll::-webkit-scrollbar-thumb:hover,
.pane::-webkit-scrollbar-thumb:hover { background: var(--c-ink-4); }

/* ─── Utility ─────────────────────────────────────────── */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-muted { color: var(--c-ink-3); }
.text-strong { color: var(--c-ink); font-weight: var(--fw-semibold); }
.text-accent { color: var(--c-accent); }
.text-ai { color: var(--c-ai); }
.text-danger { color: var(--c-danger); }
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-6 { gap: var(--s-6); }
.flex-1 { flex: 1; min-width: 0; }
.grow { flex-grow: 1; }
.center { align-items: center; justify-content: center; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }

.p-2 { padding: var(--s-2); }
.p-3 { padding: var(--s-3); }
.p-4 { padding: var(--s-4); }
.p-6 { padding: var(--s-6); }
.px-3 { padding-left: var(--s-3); padding-right: var(--s-3); }
.px-4 { padding-left: var(--s-4); padding-right: var(--s-4); }
.py-2 { padding-top: var(--s-2); padding-bottom: var(--s-2); }
.py-3 { padding-top: var(--s-3); padding-bottom: var(--s-3); }

.m-0 { margin: 0; }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }

.hidden { display: none !important; }

/* ─── Selection ──────────────────────────────────────── */
::selection {
  background: var(--c-accent-soft);
  color: var(--c-accent-ink);
}

/* ─── Focus ring ─────────────────────────────────────── */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

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