*, *::before, *::after { box-sizing: border-box; }
/* The `hidden` attribute is a weak hint any author `display` rule
   overrides (e.g. `label { display: block }`). Make it authoritative so
   `hidden` and JS `el.hidden = true` reliably hide the element. */
[hidden] { display: none !important; }
html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.02em; margin: 0 0 var(--sp-3); }
h1 { font-size: var(--fs-display); font-weight: var(--fw-display); }
h2 { font-size: var(--fs-heading); font-weight: var(--fw-heading); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: var(--fs-mono); }

/* ---- App shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-3);
  /* Pin to the viewport so the footer (Sign out) stays at the bottom
     of the screen, not the bottom of a tall page. Without this the
     sidebar stretches to match the content column and its margin-top
     :auto footer rides thousands of pixels down a long results table. */
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar__brand { font-weight: var(--fw-display); padding: var(--sp-1) var(--sp-2) var(--sp-4); }
.sidebar__nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.sidebar__link {
  color: var(--ink); font-size: var(--fs-body); font-weight: 500;
  padding: var(--sp-2); border-radius: var(--r-control); text-decoration: none;
}
.sidebar__link:hover { background: var(--hairline); text-decoration: none; }
.sidebar__link--active { background: var(--accent-soft); color: var(--pill-ok-fg); font-weight: 600; }
.sidebar__footer { margin-top: auto; border-top: 1px solid var(--hairline); padding-top: var(--sp-3); }
.content { flex: 1; padding: var(--sp-6); max-width: 960px; }

/* ---- Marketing ---- */
.marketing-nav, .marketing-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
}
.marketing-foot { border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-caption); }
.hero { text-align: center; padding: var(--sp-8) var(--sp-6); max-width: 720px; margin: 0 auto; }
.hero h1 { font-size: 40px; line-height: 1.15; }

/* ---- Theme toggle ---- */
.theme-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: 0; color: var(--muted);
  font: inherit; font-size: var(--fs-caption); padding: var(--sp-2);
  cursor: pointer; border-radius: var(--r-control);
}
.theme-toggle:hover { background: var(--hairline); }

/* ---- Responsive: sidebar -> drawer ---- */
.drawer-toggle { display: none; }
.drawer-btn { display: none; }
@media (max-width: 720px) {
  .shell { display: block; }
  .drawer-btn {
    display: inline-block; position: fixed; top: var(--sp-3); left: var(--sp-3);
    z-index: 20; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-control); padding: var(--sp-2) var(--sp-3); cursor: pointer;
  }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: 250px;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .drawer-toggle:checked ~ .sidebar { transform: translateX(0); }
  .content { padding: calc(var(--sp-8) + var(--sp-4)) var(--sp-4) var(--sp-4); }
}
