/* ==========================================================================
   /study — foundation stylesheet
   Tokens (six themes), reset, app frame, and the shared component library.
   Page-specific rules live in css/study/pages/*.css and use only these
   tokens + classes. Design source: docs/study/design-reference.md.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
/* Theme-independent: layout metrics that no theme changes. */
:root {
    --st-sidebar-w: 232px;
    --st-main-pad-x: 40px;
    --st-main-pad-y: 32px;
    --st-rail-w: 320px;
    --st-content-max: 1280px;
    --st-tap: 44px;
}

/* The default theme is declared for both `:root` and an explicit
   `[data-theme="midots"]`, so a MiDOTs swatch nested inside a page running
   another theme still resolves its own tokens (the settings previews rely on
   this). Every theme below follows the same rule: one selector, all of it. */
:root, [data-theme="midots"] {
    /* Type */
    --st-font-display: 'Unbounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --st-font-body: 'Karla', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --st-display-weight: 800;
    --st-display-weight-2: 700;
    --st-display-tracking: -0.01em;

    /* Shape — the MiDOTs theme takes the marketing "sticker" look; the
       mockup themes are flat exactly as drawn. */
    --st-radius-btn: 999px;
    --st-radius-input: 10px;
    --st-radius-card: 16px;
    --st-radius-card-sm: 12px;
    --st-card-border-w: 2px;
    --st-btn-border-w: 2px;
    --st-shadow-primary: 4px 4px 0 var(--st-warm);
    --st-shadow-primary-hover: 6px 6px 0 var(--st-warm);
    --st-shadow-soft: 4px 4px 0 var(--st-shadow-tint);
    --st-shadow-soft-hover: 6px 6px 0 var(--st-shadow-tint);
    --st-shadow-card: 3px 3px 0 var(--st-shadow-tint);
    --st-lift: translate(-2px, -2px);
    /* Chrome rules that differ by theme, expressed as tokens so a theme never
       needs a descendant selector (which would leak into nested previews). */
    --st-frame-border-w: 2px;
    --st-frame-border: var(--st-border);
    --st-input-border-w: 2px;
    --st-btn-primary-border: var(--st-border-strong);
    --st-btn-primary-hover-bg: var(--st-accent);
    --st-btn-secondary-hover-bg: var(--st-surface);
    --st-card-link-hover-border: var(--st-border);
    --st-hero-border: var(--st-border);

    /* Colour — MiDOTs (default) */
    --st-bg: #f4f4f8;
    --st-surface: #ffffff;
    --st-surface-2: #fafafd;
    --st-fill: #e9e9f2;
    --st-border: #1e2235;
    --st-border-soft: #e6e7ef;
    --st-border-strong: #1e2235;
    --st-ink: #1e2235;
    --st-ink-2: #565c74;
    --st-ink-3: #6b7089;
    --st-ink-4: #8a8fa6;
    --st-ink-on-dark-muted: #c9cbea;
    --st-accent: #5b5bd6;
    --st-accent-hover: #4646b8;
    --st-accent-soft: #ebebf9;
    --st-warm: #ffb454;
    --st-warm-soft: #fff1dc;
    --st-warm-ink: #8a5a10;
    --st-violet: #ff6b87;
    --st-violet-soft: #ffe4ea;
    --st-green: #1f9d6a;
    --st-green-soft: #dff5ea;
    --st-green-ink: #146b47;
    --st-danger: #d63c52;
    --st-danger-soft: #fde3e8;
    --st-danger-ink: #9c2436;
    --st-teal: #1f8f8a;
    --st-on-accent: #ffffff;
    --st-on-ink: #ffffff;
    --st-hero-bg: #5b5bd6;
    --st-hero-fg: #ffffff;
    --st-hero-muted: #c9cbea;
    --st-hero-btn-bg: #ffffff;
    --st-hero-btn-fg: #1e2235;
    --st-hero-outline: rgba(255, 255, 255, 0.55);
    --st-hero-pattern: radial-gradient(rgba(255, 255, 255, 0.22) 1.6px, transparent 1.6px);
    --st-shadow-tint: rgba(30, 34, 53, 0.16);
    --st-focus: #5b5bd6;
    --st-scrim: rgba(30, 34, 53, 0.45);
    --st-kbd-border: #b7b9cc;
    --st-dot-1: #ffb454;
    --st-dot-2: #ff6b87;
    --st-dot-3: #5b5bd6;
    color-scheme: light;
}

/* Shared shape for the five mockup themes: flat, as drawn. */
[data-theme="paper"], [data-theme="midnight"], [data-theme="campus"],
[data-theme="studio"], [data-theme="sage"] {
    --st-radius-btn: 10px;
    --st-radius-input: 8px;
    --st-radius-card: 14px;
    --st-radius-card-sm: 12px;
    --st-card-border-w: 1px;
    --st-btn-border-w: 1px;
    --st-shadow-primary: none;
    --st-shadow-primary-hover: none;
    --st-shadow-soft: none;
    --st-shadow-soft-hover: none;
    --st-shadow-card: none;
    --st-lift: none;
    --st-frame-border-w: 1px;
    --st-frame-border: var(--st-border-soft);
    --st-input-border-w: 1px;
    --st-btn-primary-border: transparent;
    --st-btn-primary-hover-bg: var(--st-accent-hover);
    --st-btn-secondary-hover-bg: var(--st-surface-2);
    --st-card-link-hover-border: var(--st-border-strong);
    --st-hero-border: transparent;
    --st-hero-pattern: none;
    --st-hero-bg: var(--st-ink);
    --st-hero-fg: var(--st-on-ink);
    --st-hero-muted: var(--st-ink-on-dark-muted);
    --st-hero-btn-bg: var(--st-bg);
    --st-hero-btn-fg: var(--st-ink);
    --st-hero-outline: #5a554b;
    --st-shadow-tint: rgba(0, 0, 0, 0.12);
    --st-focus: var(--st-accent);
    --st-dot-1: var(--st-warm);
    --st-dot-2: var(--st-violet);
    --st-dot-3: var(--st-accent);
}

[data-theme="paper"] {
    --st-font-display: 'Bricolage Grotesque', Georgia, serif;
    --st-font-body: 'Instrument Sans', system-ui, sans-serif;
    --st-display-weight: 700; --st-display-weight-2: 700;
    --st-bg: #f4f1ea; --st-surface: #ffffff; --st-surface-2: #faf8f3; --st-fill: #e8e2d4;
    --st-border: #e3ded3; --st-border-soft: #efebe2; --st-border-strong: #cfc8b8;
    --st-ink: #1c1b19; --st-ink-2: #57524a; --st-ink-3: #6b665c; --st-ink-4: #8a8477; --st-ink-on-dark-muted: #b8b1a3;
    --st-accent: #2f5f8a; --st-accent-hover: #234a6d; --st-accent-soft: #e4ecf4;
    --st-warm: #c8772a; --st-warm-soft: #fbeadb; --st-warm-ink: #8a4d12;
    --st-violet: #6a4c93; --st-violet-soft: #ece5f3;
    --st-green: #2e7d57; --st-green-soft: #e2efe7; --st-green-ink: #1f5a3e;
    --st-danger: #b94a3e; --st-danger-soft: #f6dede; --st-danger-ink: #8c2f26;
    --st-teal: #1f6f6b; --st-on-accent: #ffffff; --st-on-ink: #f4f1ea;
    --st-kbd-border: #d8d2c4; --st-scrim: rgba(28, 27, 25, 0.45);
}

[data-theme="midnight"] {
    --st-font-display: 'Space Grotesk', Georgia, serif;
    --st-font-body: 'IBM Plex Sans', system-ui, sans-serif;
    --st-display-weight: 700; --st-display-weight-2: 700;
    --st-bg: #141416; --st-surface: #232328; --st-surface-2: #1c1c20; --st-fill: #2f2f36;
    --st-border: #2e2e35; --st-border-soft: #2a2a30; --st-border-strong: #3d3d46;
    --st-ink: #f0ede6; --st-ink-2: #b9b5ad; --st-ink-3: #9a968e; --st-ink-4: #7d7972; --st-ink-on-dark-muted: #5c5952;
    --st-accent: #4d8fe6; --st-accent-hover: #7eb0f0; --st-accent-soft: #1d2c42;
    --st-warm: #f0b562; --st-warm-soft: #3a2c17; --st-warm-ink: #f6d7a3;
    --st-violet: #b39ddb; --st-violet-soft: #2d2540;
    --st-green: #8fd18f; --st-green-soft: #1c3327; --st-green-ink: #b9e6c4;
    --st-danger: #f08c80; --st-danger-soft: #3d1f1c; --st-danger-ink: #f6b3ab;
    --st-teal: #6cc7c1; --st-on-accent: #ffffff; --st-on-ink: #141416;
    --st-hero-outline: #5c5952; --st-kbd-border: #3d3d46; --st-scrim: rgba(0, 0, 0, 0.6);
    --st-shadow-tint: rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}

[data-theme="campus"] {
    --st-font-display: 'Playfair Display', Georgia, serif;
    --st-font-body: 'Libre Franklin', system-ui, sans-serif;
    --st-display-weight: 700; --st-display-weight-2: 600;
    --st-bg: #fbf7ee; --st-surface: #fffdf8; --st-surface-2: #f5efe1; --st-fill: #ede4cf;
    --st-border: #e6dcc6; --st-border-soft: #efe7d6; --st-border-strong: #d3c6a6;
    --st-ink: #1f2a3a; --st-ink-2: #4f5868; --st-ink-3: #6c7483; --st-ink-4: #8b91a0; --st-ink-on-dark-muted: #b7bcc8;
    --st-accent: #8b2332; --st-accent-hover: #6e1a27; --st-accent-soft: #f6e3e5;
    --st-warm: #b8761a; --st-warm-soft: #f8e9d1; --st-warm-ink: #7a4b0e;
    --st-violet: #2f6b4f; --st-violet-soft: #dfeee5;
    --st-green: #2f7a4e; --st-green-soft: #e3f0e7; --st-green-ink: #1f5a3e;
    --st-danger: #b23a2a; --st-danger-soft: #f6e0dc; --st-danger-ink: #862a1e;
    --st-teal: #1f6f6b; --st-on-accent: #ffffff; --st-on-ink: #fbf7ee;
    --st-hero-outline: #6c7483; --st-kbd-border: #d3c6a6; --st-scrim: rgba(31, 42, 58, 0.45);
}

[data-theme="studio"] {
    --st-font-display: 'Syne', Georgia, serif;
    --st-font-body: 'Manrope', system-ui, sans-serif;
    --st-display-weight: 800; --st-display-weight-2: 600;
    --st-bg: #f3f4ff; --st-surface: #ffffff; --st-surface-2: #ebedff; --st-fill: #e3e5fb;
    --st-border: #d9dcf5; --st-border-soft: #e6e8f8; --st-border-strong: #b9bdea;
    --st-ink: #17143a; --st-ink-2: #4a4770; --st-ink-3: #67648c; --st-ink-4: #8785a6; --st-ink-on-dark-muted: #b5b2d6;
    --st-accent: #5b2ee6; --st-accent-hover: #4620bd; --st-accent-soft: #e9e3fc;
    --st-warm: #f0533d; --st-warm-soft: #fde2dd; --st-warm-ink: #a1301f;
    --st-violet: #0a8fa8; --st-violet-soft: #d9f3f7;
    --st-green: #14996b; --st-green-soft: #dcf5ea; --st-green-ink: #0d6b4a;
    --st-danger: #d92c6d; --st-danger-soft: #fde0ea; --st-danger-ink: #9c1c4c;
    --st-teal: #0a8fa8; --st-on-accent: #ffffff; --st-on-ink: #f3f4ff;
    --st-hero-outline: #67648c; --st-kbd-border: #b9bdea; --st-scrim: rgba(23, 20, 58, 0.45);
}

[data-theme="sage"] {
    --st-font-display: 'Fraunces', Georgia, serif;
    --st-font-body: 'Nunito Sans', system-ui, sans-serif;
    --st-display-weight: 700; --st-display-weight-2: 600;
    --st-bg: #eef1ec; --st-surface: #ffffff; --st-surface-2: #f5f7f3; --st-fill: #dde4d9;
    --st-border: #d9e0d5; --st-border-soft: #e4e9e1; --st-border-strong: #b9c5b3;
    --st-ink: #1f2b23; --st-ink-2: #4b5a50; --st-ink-3: #66756b; --st-ink-4: #85938a; --st-ink-on-dark-muted: #aebcb2;
    --st-accent: #2f6b57; --st-accent-hover: #24523f; --st-accent-soft: #dcebe4;
    --st-warm: #a8722a; --st-warm-soft: #f4e8d5; --st-warm-ink: #71480f;
    --st-violet: #4d6a8f; --st-violet-soft: #e0e8f1;
    --st-green: #3d8a5f; --st-green-soft: #e0efe6; --st-green-ink: #1f5a3e;
    --st-danger: #b0483d; --st-danger-soft: #f3dfdc; --st-danger-ink: #853228;
    --st-teal: #2f7d78; --st-on-accent: #ffffff; --st-on-ink: #eef1ec;
    --st-hero-outline: #66756b; --st-kbd-border: #b9c5b3; --st-scrim: rgba(31, 43, 35, 0.45);
}

/* Space colour names → tokens. Set `data-color` on any element (card, dot,
   header icon) and use var(--st-space) inside it. */
[data-color="accent"] { --st-space: var(--st-accent); --st-space-soft: var(--st-accent-soft); }
[data-color="warm"]   { --st-space: var(--st-warm);   --st-space-soft: var(--st-warm-soft); }
[data-color="violet"] { --st-space: var(--st-violet); --st-space-soft: var(--st-violet-soft); }
[data-color="green"]  { --st-space: var(--st-green);  --st-space-soft: var(--st-green-soft); }
[data-color="teal"]   { --st-space: var(--st-teal);   --st-space-soft: var(--st-accent-soft); }
[data-color="danger"] { --st-space: var(--st-danger); --st-space-soft: var(--st-danger-soft); }

/* --------------------------------------------------------------------------
   2. Reset + base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body.st-body {
    margin: 0;
    min-height: 100%;
    background: var(--st-bg);
    color: var(--st-ink);
    font-family: var(--st-font-body);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: inherit; font-size: inherit; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--st-accent); text-decoration: none; }
a:hover { color: var(--st-accent-hover); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 2px; }
::selection { background: var(--st-accent-soft); }

.st-skip {
    position: absolute; left: 12px; top: -60px; z-index: 200;
    padding: 10px 14px; background: var(--st-ink); color: var(--st-on-ink);
    border-radius: 8px; font-weight: 700;
}
.st-skip:focus { top: 12px; }

.st-display { font-family: var(--st-font-display); font-weight: var(--st-display-weight); letter-spacing: var(--st-display-tracking); }
.st-display-2 { font-family: var(--st-font-display); font-weight: var(--st-display-weight-2); letter-spacing: var(--st-display-tracking); }
.st-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--st-ink-3); }
.st-muted { color: var(--st-ink-2); }
.st-muted-2 { color: var(--st-ink-4); }
.st-small { font-size: 12px; }
.st-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.st-hidden { display: none !important; }

/* --------------------------------------------------------------------------
   3. App frame
   -------------------------------------------------------------------------- */
/* Column, not row: the mobile topbar stacks above the frame. On desktop the
   topbar is display:none, so the frame fills either way. */
.st-app { min-height: 100vh; display: flex; flex-direction: column; }
.st-app[aria-busy="true"] { align-items: center; justify-content: center; }
.st-boot { display: flex; align-items: center; gap: 12px; color: var(--st-ink-2); font-weight: 600; }
.st-boot__dots, .st-logo__dots { display: inline-flex; align-items: flex-end; gap: 4px; }
.st-boot__dots span, .st-logo__dots span { display: block; border-radius: 50%; }
.st-boot__dots span:nth-child(1), .st-logo__dots span:nth-child(1) { width: 8px; height: 8px; background: var(--st-dot-1); }
.st-boot__dots span:nth-child(2), .st-logo__dots span:nth-child(2) { width: 11px; height: 11px; background: var(--st-dot-2); }
.st-boot__dots span:nth-child(3), .st-logo__dots span:nth-child(3) { width: 14px; height: 14px; background: var(--st-dot-3); }
.st-boot__dots span { animation: st-bounce 1.1s ease-in-out infinite; }
.st-boot__dots span:nth-child(2) { animation-delay: 0.15s; }
.st-boot__dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes st-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.st-frame { flex: 1 1 auto; display: flex; min-height: 100vh; min-width: 0; }
.st-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.st-page { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.st-page__inner { width: 100%; max-width: var(--st-content-max); margin: 0 auto; padding: var(--st-main-pad-y) var(--st-main-pad-x); display: flex; flex-direction: column; gap: 28px; }

/* Sidebar */
.st-sidebar {
    flex: 0 0 var(--st-sidebar-w); width: var(--st-sidebar-w);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 24px 16px; display: flex; flex-direction: column; gap: 6px;
    background: var(--st-surface-2);
    border-right: var(--st-frame-border-w) solid var(--st-frame-border);
}

.st-logo { display: flex; align-items: center; gap: 10px; padding: 4px 12px 18px; color: var(--st-ink); font-family: var(--st-font-display); font-weight: var(--st-display-weight); font-size: 20px; letter-spacing: -0.01em; }
.st-logo:hover { color: var(--st-ink); }
/* Part of the wordmark ("Study·notes"), so it sits snug against the name. */
.st-logo__sub { font-family: var(--st-font-body); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--st-ink-3); margin-left: 2px; padding: 2px 7px; border: 1px solid var(--st-kbd-border); border-radius: 6px; }
.st-nav__item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    padding: 10px 12px; border-radius: 8px; border: 0; background: transparent;
    color: var(--st-ink); font-size: 14px; font-weight: 500; line-height: 1.2;
}
.st-nav__item:hover { background: var(--st-fill); color: var(--st-ink); }
.st-nav__item[aria-current="page"], .st-nav__item.is-active { background: var(--st-fill); font-weight: 700; }
.st-nav__item svg { flex: 0 0 auto; }
.st-nav__grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-kbd { font-size: 11px; color: var(--st-ink-3); border: 1px solid var(--st-kbd-border); border-radius: 4px; padding: 1px 5px; font-family: var(--st-font-body); }
.st-nav__section { display: flex; align-items: center; justify-content: space-between; padding: 18px 12px 6px; }
.st-nav__section .st-eyebrow { padding: 0; }
/* Solid primary so “Add a study space” doesn’t disappear into the section label. */
.st-nav__add {
    width: 32px; height: 32px; min-width: 32px; min-height: 32px;
    border-radius: 8px;
    border: var(--st-btn-border-w) solid var(--st-btn-primary-border);
    background: var(--st-accent); color: var(--st-on-accent);
    box-shadow: var(--st-shadow-primary);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}
.st-nav__add:hover {
    background: var(--st-btn-primary-hover-bg); color: var(--st-on-accent);
    transform: var(--st-lift); box-shadow: var(--st-shadow-primary-hover);
}
.st-nav__spaces { display: flex; flex-direction: column; gap: 2px; }
.st-nav__spaces .st-nav__item { padding: 9px 12px; }
/* Empty-sidebar CTA — same primary language as Start quiz / Pick a board. */
.st-nav__cta {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
    min-height: var(--st-tap); padding: 10px 14px; margin-top: 4px;
    border-radius: var(--st-radius-btn);
    border: var(--st-btn-border-w) solid var(--st-btn-primary-border);
    background: var(--st-accent); color: var(--st-on-accent);
    box-shadow: var(--st-shadow-primary);
    font-size: 14px; font-weight: 700; line-height: 1.2; text-align: center;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}
.st-nav__cta:hover {
    background: var(--st-btn-primary-hover-bg); color: var(--st-on-accent);
    transform: var(--st-lift); box-shadow: var(--st-shadow-primary-hover);
}
.st-nav__cta svg { flex: 0 0 auto; }
.st-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--st-space, var(--st-accent)); flex: 0 0 auto; }
.st-nav__spacer { flex: 1 1 auto; }
.st-nav__profile { margin-top: 8px; }
.st-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--st-accent); color: var(--st-on-accent); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.st-avatar--lg { width: 44px; height: 44px; font-size: 16px; }
.st-nav__profile-text { display: flex; flex-direction: column; min-width: 0; }
.st-nav__profile-text strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-nav__profile-text span { font-size: 12px; color: var(--st-ink-3); }
.st-nav__back { display: none; }

/* Mobile top bar (sidebar becomes a drawer) */
.st-topbar { display: none; }
.st-scrim { position: fixed; inset: 0; background: var(--st-scrim); z-index: 90; }

/* --------------------------------------------------------------------------
   4. Buttons
   -------------------------------------------------------------------------- */
.st-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--st-tap); padding: 10px 18px;
    border-radius: var(--st-radius-btn); border: var(--st-btn-border-w) solid transparent;
    font-weight: 700; font-size: 14px; line-height: 1.2; white-space: nowrap;
    text-decoration: none; cursor: pointer; user-select: none;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}
.st-btn:disabled, .st-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.st-btn svg { flex: 0 0 auto; }
.st-btn--primary { background: var(--st-accent); color: var(--st-on-accent); border-color: var(--st-btn-primary-border); box-shadow: var(--st-shadow-primary); }
.st-btn--primary:hover { background: var(--st-btn-primary-hover-bg); color: var(--st-on-accent); transform: var(--st-lift); box-shadow: var(--st-shadow-primary-hover); }

.st-btn--secondary { background: var(--st-surface); color: var(--st-ink); border-color: var(--st-border-strong); box-shadow: var(--st-shadow-soft); }
.st-btn--secondary:hover { color: var(--st-ink); transform: var(--st-lift); box-shadow: var(--st-shadow-soft-hover); background: var(--st-btn-secondary-hover-bg); }

.st-btn--ghost { background: transparent; color: var(--st-ink-2); border-color: transparent; }
.st-btn--ghost:hover { background: var(--st-fill); color: var(--st-ink); }
.st-btn--ink { background: var(--st-ink); color: var(--st-on-ink); border-color: var(--st-ink); box-shadow: var(--st-shadow-primary); }
.st-btn--ink:hover { color: var(--st-on-ink); transform: var(--st-lift); box-shadow: var(--st-shadow-primary-hover); }
.st-btn--danger { background: var(--st-danger-soft); color: var(--st-danger-ink); border-color: transparent; }
.st-btn--danger:hover { background: var(--st-danger); color: #fff; }
.st-btn--hero { background: var(--st-hero-btn-bg); color: var(--st-hero-btn-fg); border-color: var(--st-hero-btn-bg); box-shadow: var(--st-shadow-soft); }
.st-btn--hero:hover { color: var(--st-hero-btn-fg); transform: var(--st-lift); box-shadow: var(--st-shadow-soft-hover); }
.st-btn--hero-outline { background: transparent; color: var(--st-hero-fg); border-color: var(--st-hero-outline); font-weight: 600; }
.st-btn--hero-outline:hover { color: var(--st-hero-fg); background: rgba(255, 255, 255, 0.08); }
.st-btn--sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.st-btn--xs { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.st-btn--lg { min-height: 50px; padding: 12px 24px; font-size: 15px; }
.st-btn--block { width: 100%; }
.st-btn--icon { width: var(--st-tap); height: var(--st-tap); padding: 0; border-radius: var(--st-radius-input); }
.st-btn--icon.st-btn--sm { width: 36px; height: 36px; }
.st-btn--icon.st-btn--xs { width: 30px; height: 30px; }
.st-btn--pill { border-radius: 999px; }
.st-btn--chip { min-height: 32px; padding: 5px 11px; border-radius: 999px; background: var(--st-surface); border: 1px solid var(--st-border-strong); font-size: 12px; font-weight: 600; color: var(--st-ink); box-shadow: none; }
.st-btn--chip:hover { background: var(--st-fill); transform: none; }
.st-btn--chip.is-active { background: var(--st-ink); color: var(--st-on-ink); border-color: var(--st-ink); }
.st-btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Segmented control */
.st-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--st-fill); }
.st-seg__btn { padding: 6px 10px; border-radius: 6px; border: 0; background: transparent; color: var(--st-ink-2); font-size: 13px; font-weight: 500; min-height: 30px; }
.st-seg__btn:hover { color: var(--st-ink); }
.st-seg__btn.is-active, .st-seg__btn[aria-pressed="true"], .st-seg__btn[aria-selected="true"] { background: var(--st-surface); color: var(--st-ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }

/* Sort/filter pills (hub "Due first / Recent / A–Z") */
.st-pills { display: inline-flex; gap: 4px; font-size: 13px; }
.st-pills__btn { padding: 6px 10px; border-radius: 6px; border: 0; background: transparent; color: var(--st-ink-2); font-weight: 500; }
.st-pills__btn:hover { color: var(--st-ink); }
.st-pills__btn.is-active, .st-pills__btn[aria-pressed="true"] { background: var(--st-fill); color: var(--st-ink); font-weight: 700; }

/* --------------------------------------------------------------------------
   5. Forms
   -------------------------------------------------------------------------- */
.st-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.st-label { font-size: 13px; font-weight: 700; }
.st-label__opt { color: var(--st-ink-4); font-weight: 400; }
.st-label__req { color: var(--st-danger); }
.st-input, .st-textarea, .st-select {
    width: 100%; min-height: var(--st-tap); padding: 11px 14px;
    border-radius: var(--st-radius-input); border: 1px solid var(--st-border-strong);
    background: var(--st-surface-2); color: var(--st-ink); font-size: 15px; line-height: 1.35;
    border-width: var(--st-input-border-w);
}

.st-input::placeholder, .st-textarea::placeholder { color: var(--st-ink-4); }
.st-input:focus, .st-textarea:focus, .st-select:focus { outline: 2px solid var(--st-focus); outline-offset: 1px; }
.st-input[aria-invalid="true"], .st-textarea[aria-invalid="true"] { border-color: var(--st-danger); }
.st-textarea { resize: vertical; min-height: 88px; }
.st-select { appearance: none; -webkit-appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
.st-help { font-size: 12px; color: var(--st-ink-4); }
.st-error { font-size: 12px; color: var(--st-danger-ink); font-weight: 600; }
.st-check { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--st-border-strong); background: var(--st-surface); cursor: pointer; font-size: 14px; }
.st-check input { width: 18px; height: 18px; accent-color: var(--st-accent); margin: 0; flex: 0 0 auto; }
.st-radio { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.st-radio input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--st-accent); flex: 0 0 auto; }
.st-radio__text { display: flex; flex-direction: column; gap: 2px; }
.st-radio__text strong { font-weight: 700; }
.st-radio__text span { font-size: 13px; color: var(--st-ink-2); }
.st-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.st-swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; background: var(--st-space); box-shadow: 0 0 0 2px var(--st-surface) inset; cursor: pointer; padding: 0; }
.st-swatch.is-active, .st-swatch[aria-pressed="true"] { border-color: var(--st-ink); }
.st-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* --------------------------------------------------------------------------
   6. Surfaces: cards, panels, rows
   -------------------------------------------------------------------------- */
.st-card {
    background: var(--st-surface); color: var(--st-ink);
    border: var(--st-card-border-w) solid var(--st-border); border-radius: var(--st-radius-card);
    box-shadow: var(--st-shadow-card);
}
.st-card--sm { border-radius: var(--st-radius-card-sm); }
.st-card--pad { padding: 20px; }
.st-card--pad-lg { padding: 32px; }
.st-card--flat { box-shadow: none; }
.st-card--soft { background: var(--st-surface-2); }
.st-card--link { display: flex; flex-direction: column; gap: 14px; color: var(--st-ink); transition: transform 0.14s ease, box-shadow 0.14s ease; }
.st-card--link:hover { color: var(--st-ink); transform: var(--st-lift); box-shadow: var(--st-shadow-soft-hover); border-color: var(--st-card-link-hover-border); }

.st-card--dashed { border: 2px dashed var(--st-border-strong); background: transparent; box-shadow: none; color: var(--st-ink-2); }
.st-card--dashed.is-dragover { border-color: var(--st-accent); background: var(--st-accent-soft); color: var(--st-ink); }
.st-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.st-card__title { font-size: 15px; font-weight: 700; }
.st-list { display: flex; flex-direction: column; }
.st-list--card { border-radius: var(--st-radius-card); overflow: hidden; }
.st-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--st-ink); border-bottom: 1px solid var(--st-border-soft); }
.st-row:last-child { border-bottom: 0; }
a.st-row:hover, button.st-row:hover { background: var(--st-surface-2); color: var(--st-ink); }
button.st-row { width: 100%; text-align: left; border: 0; background: transparent; font: inherit; }
.st-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; font-size: 13px; }
.st-row__text strong { font-weight: 700; }
.st-row__text .st-muted { font-size: 13px; }
.st-row__time { font-size: 12px; color: var(--st-ink-4); }
.st-subrow { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; background: var(--st-surface-2); color: var(--st-ink); font-size: 13px; }
a.st-subrow:hover, button.st-subrow:hover { background: var(--st-fill); color: var(--st-ink); }
button.st-subrow { width: 100%; text-align: left; border: 0; }
.st-subrow__grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Icon tiles */
.st-tile { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; background: var(--st-fill); color: var(--st-ink-2); }
.st-tile--lg { width: 40px; height: 40px; border-radius: 10px; }
.st-tile--accent { background: var(--st-accent-soft); color: var(--st-accent); }
.st-tile--warm { background: var(--st-warm-soft); color: var(--st-warm-ink); }
.st-tile--violet { background: var(--st-violet-soft); color: var(--st-violet); }
.st-tile--green { background: var(--st-green-soft); color: var(--st-green); }
.st-tile--danger { background: var(--st-danger-soft); color: var(--st-danger-ink); }
.st-tile--space { background: var(--st-space-soft, var(--st-fill)); color: var(--st-space, var(--st-ink)); }
.st-space-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--st-space, var(--st-accent)); flex: 0 0 auto; }
.st-space-icon--sm { width: 32px; height: 32px; border-radius: 9px; }

/* Chips */
.st-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--st-fill); color: var(--st-ink-2); white-space: nowrap; line-height: 1.3; }
.st-chip--warm { background: var(--st-warm-soft); color: var(--st-warm-ink); }
.st-chip--danger { background: var(--st-danger-soft); color: var(--st-danger-ink); }
.st-chip--green { background: var(--st-green-soft); color: var(--st-green-ink); }
.st-chip--accent { background: var(--st-accent-soft); color: var(--st-accent); }
.st-chip--violet { background: var(--st-violet-soft); color: var(--st-violet); }
.st-chip--outline { background: transparent; border: 1px solid var(--st-border-strong); color: var(--st-ink-2); }
.st-chip--space { background: var(--st-space-soft, var(--st-fill)); color: var(--st-space, var(--st-ink)); }
.st-chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* Stat tile */
.st-stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; }
.st-stat__label { font-size: 12px; color: var(--st-ink-2); }
.st-stat__value { font-family: var(--st-font-display); font-weight: var(--st-display-weight); font-size: 24px; letter-spacing: var(--st-display-tracking); line-height: 1.1; }
.st-stat__delta { font-size: 12px; color: var(--st-ink-2); }
.st-stat__delta--up { color: var(--st-green); font-weight: 700; }
.st-stat__delta--down { color: var(--st-danger-ink); font-weight: 700; }
.st-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* Hero (dark/indigo band) */
.st-hero {
    display: flex; align-items: center; gap: 20px; padding: 20px 24px;
    border-radius: var(--st-radius-card); background: var(--st-hero-bg); color: var(--st-hero-fg);
    background-image: var(--st-hero-pattern); background-size: 14px 14px;
    border: var(--st-card-border-w) solid var(--st-hero-border); box-shadow: var(--st-shadow-card);
}

.st-hero__text { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-width: 0; }
.st-hero__eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--st-hero-muted); font-weight: 700; }
.st-hero__title { font-size: 16px; font-weight: 600; }
.st-hero__title--display { font-family: var(--st-font-display); font-weight: var(--st-display-weight); font-size: 22px; letter-spacing: var(--st-display-tracking); line-height: 1.25; }
.st-hero__meta { font-size: 13px; color: var(--st-hero-muted); }
.st-hero__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Progress */
.st-progress { display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--st-fill); overflow: hidden; }
.st-progress--track-dark { background: rgba(255, 255, 255, 0.25); }
.st-progress__fill { display: block; height: 100%; width: 0; background: var(--st-accent); border-radius: 3px; transition: width 0.3s ease; }
/* One fill per tone returned by masteryTone(), so a progress bar can be
   coloured straight from a mastery band without a page-local rule. */
.st-progress__fill--accent { background: var(--st-accent); }
.st-progress__fill--warm { background: var(--st-warm); }
.st-progress__fill--green { background: var(--st-green); }
.st-progress__fill--danger { background: var(--st-danger); }
.st-progress__fill--space { background: var(--st-space, var(--st-accent)); }
/* Indeterminate: used while totals are still unknown (e.g. choosing quiz
   learning points). The fill slides inside the clipped track. */
.st-progress--indeterminate .st-progress__fill {
    width: 36% !important;
    animation: st-progress-indeterminate 1.15s ease-in-out infinite;
}
@keyframes st-progress-indeterminate {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
    .st-progress--indeterminate .st-progress__fill { animation: none; width: 45% !important; }
}
.st-ring { flex: 0 0 auto; }
.st-ring__track { fill: none; stroke: var(--st-fill); }
.st-ring__fill { fill: none; stroke: var(--st-space, var(--st-accent)); stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.st-ring__label { font-size: 12px; font-weight: 700; fill: var(--st-ink); font-family: var(--st-font-body); }

/* Tabs */
.st-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.st-tabs::-webkit-scrollbar { display: none; }
.st-tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px 12px; color: var(--st-ink-2); font-size: 14px; font-weight: 500; border: 0; background: transparent; border-bottom: 2px solid transparent; white-space: nowrap; border-radius: 0; }
.st-tab:hover { color: var(--st-ink); }
.st-tab[aria-selected="true"], .st-tab.is-active { color: var(--st-ink); font-weight: 700; border-bottom-color: var(--st-ink); }
.st-tab__count { font-size: 12px; color: var(--st-ink-4); font-weight: 500; }

/* Stepper */
.st-stepper { display: flex; gap: 12px; align-items: center; font-size: 13px; justify-content: center; }
.st-step { display: flex; align-items: center; gap: 8px; color: var(--st-ink-2); font-weight: 700; }
.st-step__num { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--st-fill); color: var(--st-ink-2); font-size: 12px; }
.st-step.is-current, .st-step.is-done { color: var(--st-ink); }
.st-step.is-current .st-step__num, .st-step.is-done .st-step__num { background: var(--st-ink); color: var(--st-on-ink); }
.st-step__line { width: 48px; height: 1px; background: var(--st-border-strong); }

/* Toast + banners */
.st-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.st-toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--st-ink); color: var(--st-on-ink); font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); animation: st-toast-in 0.18s ease; }
.st-toast--success { background: var(--st-green-soft); color: var(--st-green-ink); }
.st-toast--danger { background: var(--st-danger-soft); color: var(--st-danger-ink); }
.st-toast__close { margin-left: auto; border: 0; background: transparent; color: inherit; opacity: 0.7; padding: 4px; border-radius: 6px; }
.st-toast__close:hover { opacity: 1; }
@keyframes st-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.st-banner { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.st-banner--success { background: var(--st-green-soft); color: var(--st-green-ink); }
.st-banner--info { background: var(--st-accent-soft); color: var(--st-accent); }
.st-banner--warm { background: var(--st-warm-soft); color: var(--st-warm-ink); }
.st-banner--danger { background: var(--st-danger-soft); color: var(--st-danger-ink); }

/* Modal / sheet */
.st-layer { position: relative; z-index: 100; }
.st-modal { position: fixed; inset: 0; z-index: 110; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--st-scrim); animation: st-fade 0.15s ease; }
.st-modal__card { width: 100%; max-width: 560px; max-height: calc(100vh - 48px); overflow: auto; display: flex; flex-direction: column; gap: 20px; padding: 28px; background: var(--st-surface); border: var(--st-card-border-w) solid var(--st-border); border-radius: var(--st-radius-card); box-shadow: var(--st-shadow-soft), 0 20px 60px rgba(0, 0, 0, 0.2); animation: st-pop 0.18s ease; }
.st-modal__card--lg { max-width: 820px; }
.st-modal__card--xl { max-width: 1040px; }
.st-modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.st-modal__title { font-family: var(--st-font-display); font-weight: var(--st-display-weight); font-size: 20px; letter-spacing: var(--st-display-tracking); }
.st-modal__sub { font-size: 14px; color: var(--st-ink-2); margin-top: 4px; }
.st-modal__body { display: flex; flex-direction: column; gap: 16px; }
.st-modal__foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 8px; border-top: 1px solid var(--st-border-soft); }
.st-modal__foot--split { justify-content: space-between; }

/* Board share modal — mirrors notes board-history share options, study tokens */
.st-share { display: flex; flex-direction: column; gap: 14px; }
.st-share-types {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--st-fill);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-card, 10px);
}
.st-share-type {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--st-ink);
    margin: 0;
}
.st-share-type input { margin-top: 2px; accent-color: var(--st-accent); flex: 0 0 auto; }
.st-share-type__text { display: flex; flex-direction: column; gap: 2px; }
.st-share-type__text strong { font-weight: 700; }
.st-share-type__text span { font-size: 12px; color: var(--st-ink-2); }
.st-share-hint {
    font-size: 13px;
    color: var(--st-ink-2);
    padding: 10px 12px;
    background: var(--st-fill);
    border-radius: 8px;
}
.st-share-lookup { position: relative; }
.st-share-dropdown {
    position: absolute;
    left: 0; right: 0;
    top: calc(100% + 4px);
    z-index: 5;
    max-height: 200px;
    overflow-y: auto;
    background: var(--st-surface);
    border: 1px solid var(--st-border);
    border-radius: 8px;
    box-shadow: var(--st-shadow-soft);
}
.st-share-dropdown__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-bottom: 1px solid var(--st-border-soft);
    background: transparent;
    color: var(--st-ink);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.st-share-dropdown__item:last-child { border-bottom: none; }
.st-share-dropdown__item:hover { background: var(--st-fill); }
.st-share-dropdown__item.is-muted { color: var(--st-ink-2); cursor: default; }
.st-share-dropdown__email { font-size: 12px; color: var(--st-ink-2); }
.st-share-perm {
    display: flex;
    align-items: center;
    gap: 10px;
}
.st-share-perm label {
    font-size: 13px;
    font-weight: 600;
    color: var(--st-ink-2);
    white-space: nowrap;
    margin: 0;
}
.st-share-perm select,
.st-select {
    padding: 8px 10px;
    border: 1px solid var(--st-border);
    border-radius: 8px;
    background: var(--st-surface);
    color: var(--st-ink);
    font-size: 14px;
}
.st-share-error { color: var(--st-danger-ink); font-size: 13px; }
.st-share-current { display: flex; flex-direction: column; gap: 8px; }
.st-share-empty { font-size: 13px; color: var(--st-ink-2); font-style: italic; margin: 0; }
.st-share-list { display: flex; flex-direction: column; }
.st-share-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--st-border-soft);
}
.st-share-row:last-child { border-bottom: none; }
.st-share-row__info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.st-share-row__name { font-weight: 600; font-size: 14px; color: var(--st-ink); }
.st-share-row__email { font-size: 12px; color: var(--st-ink-2); }
.st-share-row__status { font-size: 12px; color: var(--st-ink-2); }
.st-share-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    background: var(--st-accent-soft);
    color: var(--st-accent);
    flex: 0 0 auto;
}
.st-share-badge--copy {
    background: var(--st-violet-soft, var(--st-fill));
    color: var(--st-violet-ink, var(--st-ink));
}

@keyframes st-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes st-pop { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }

/* Menu (dropdown) */
.st-menu { position: absolute; z-index: 115; min-width: 200px; padding: 6px; background: var(--st-surface); border: var(--st-card-border-w) solid var(--st-border); border-radius: 12px; box-shadow: var(--st-shadow-soft), 0 12px 32px rgba(0, 0, 0, 0.14); animation: st-pop 0.14s ease; }
.st-menu__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--st-ink); font-size: 13px; font-weight: 500; text-align: left; }
.st-menu__item:hover { background: var(--st-fill); color: var(--st-ink); }
.st-menu__item--danger { color: var(--st-danger-ink); }
.st-menu__sep { height: 1px; background: var(--st-border-soft); margin: 6px 4px; }

/* Empty state */
.st-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 480px; margin: 0 auto; }
.st-empty__title { font-family: var(--st-font-display); font-weight: var(--st-display-weight); font-size: 24px; letter-spacing: -0.02em; }
.st-empty__text { font-size: 15px; color: var(--st-ink-2); line-height: 1.5; }

/* Skeleton */
.st-skel { background: linear-gradient(90deg, var(--st-fill) 25%, var(--st-surface-2) 50%, var(--st-fill) 75%); background-size: 200% 100%; animation: st-shimmer 1.2s infinite; border-radius: 8px; }
@keyframes st-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Section headers */
.st-section { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.st-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.st-section__title { font-size: 16px; font-weight: 700; }
.st-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.st-page-head__text { display: flex; flex-direction: column; gap: 6px; }
.st-page-title { font-family: var(--st-font-display); font-weight: var(--st-display-weight); font-size: 34px; letter-spacing: -0.02em; line-height: 1.1; }
.st-page-sub { font-size: 15px; color: var(--st-ink-2); }

/* Kbd hints, dividers, misc */
.st-divider { height: 1px; background: var(--st-border-soft); }
.st-inline-link { font-weight: 700; }
.st-count { font-variant-numeric: tabular-nums; }
.st-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.st-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.st-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.st-stack { display: flex; flex-direction: column; gap: 12px; }
.st-stack--lg { gap: 22px; }
.st-cluster { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Space page frame: header with tabs, then body */
.st-space-head { display: flex; flex-direction: column; padding: 28px var(--st-main-pad-x) 0; background: var(--st-surface-2); border-bottom: var(--st-frame-border-w) solid var(--st-frame-border); }

.st-space-head__inner { width: 100%; max-width: var(--st-content-max); margin: 0 auto; }
.st-space-head__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.st-space-head__id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.st-space-head__title { font-family: var(--st-font-display); font-weight: var(--st-display-weight); font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; }
.st-space-head__meta { font-size: 13px; color: var(--st-ink-2); }
.st-space-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.st-space-head .st-tabs { margin-top: 22px; }
.st-space-body { flex: 1 1 auto; width: 100%; max-width: var(--st-content-max); margin: 0 auto; padding: 28px var(--st-main-pad-x); display: flex; flex-direction: column; gap: 22px; }
.st-space-body--rail { display: grid; grid-template-columns: minmax(0, 1fr) var(--st-rail-w); gap: 24px; align-items: start; }
.st-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Command palette */
.st-palette { position: fixed; inset: 0; z-index: 110; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 24px 24px; background: var(--st-scrim); animation: st-fade 0.12s ease; }
.st-palette__card { width: 100%; max-width: 640px; display: flex; flex-direction: column; background: var(--st-surface); border: var(--st-card-border-w) solid var(--st-border); border-radius: var(--st-radius-card); box-shadow: var(--st-shadow-soft), 0 24px 64px rgba(0, 0, 0, 0.25); overflow: hidden; animation: st-pop 0.16s ease; }
.st-palette__input { width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--st-border-soft); background: transparent; font-size: 16px; outline: none; }
.st-palette__list { max-height: 50vh; overflow: auto; padding: 6px; }
.st-palette__group { padding: 10px 10px 4px; }
.st-palette__item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; color: var(--st-ink); font-size: 14px; }
.st-palette__item.is-active, .st-palette__item:hover { background: var(--st-fill); }
.st-palette__item small { color: var(--st-ink-3); font-size: 12px; }
.st-palette__foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--st-border-soft); font-size: 12px; color: var(--st-ink-4); }

/* Print & motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* --------------------------------------------------------------------------
   7. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
    :root { --st-main-pad-x: 28px; --st-rail-w: 280px; }
    .st-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .st-space-body--rail { grid-template-columns: minmax(0, 1fr); }
    .st-grid-3, .st-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    :root { --st-main-pad-x: 18px; --st-main-pad-y: 20px; }
    .st-frame { flex-direction: column; }
    .st-topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--st-surface-2); border-bottom: 2px solid var(--st-border); position: sticky; top: 0; z-index: 80; }
    .st-topbar .st-logo { padding: 0; font-size: 18px; flex: 1 1 auto; }
    .st-sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; z-index: 95; transform: translateX(-104%); transition: transform 0.2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25); }
    .st-sidebar.is-open { transform: none; }
    .st-nav__back { display: flex; }
    .st-grid-2, .st-grid-3, .st-grid-4, .st-form-grid, .st-stats { grid-template-columns: minmax(0, 1fr); }
    .st-page-title { font-size: 28px; }
    .st-space-head { padding-top: 18px; }
    .st-space-head__title { font-size: 22px; }
    .st-hero { flex-direction: column; align-items: stretch; }
    /* Stacked hero buttons wrap their copy instead of forcing a page scroll. */
    .st-hero .st-btn { white-space: normal; }
    .st-modal { padding: 12px; align-items: flex-end; }
    .st-modal__card { max-height: calc(100vh - 24px); padding: 20px; }
    .st-stepper .st-step__line { width: 20px; }
    .st-stepper .st-step span:not(.st-step__num) { display: none; }
    .st-stepper .st-step.is-current span:not(.st-step__num) { display: inline; }
}

/* --------------------------------------------------------------------------
   8. Board picker (shell/board_picker.js)
   Turning an existing board into a study space. Lives here rather than in a
   page sheet because the picker is opened from the hub, the sidebar and the
   empty states.
   -------------------------------------------------------------------------- */
/* Global learning-note catalog browser (shell/catalog_browser.js) */
.st-catalog { gap: 14px; }
.st-catalog__filters { display: flex; flex-direction: column; gap: 12px; }
.st-catalog__filter-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}
.st-catalog__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 46vh;
    overflow-y: auto;
    padding-right: 4px;
}
.st-catalog__row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--st-border-soft);
    border-radius: var(--st-radius-card-sm);
    background: var(--st-surface-2);
}
.st-catalog__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
    font-size: 14px;
}
.st-catalog__summary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}
.st-catalog__title {
    color: inherit;
    text-decoration: none;
}
.st-catalog__title:hover {
    text-decoration: underline;
}
.st-catalog__row .st-btn {
    flex: 0 0 auto;
    align-self: center;
}

.st-pick__list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.st-pick__row {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    padding: 10px 12px; border: 1px solid var(--st-border-soft); border-radius: var(--st-radius-card-sm);
    background: var(--st-surface); color: var(--st-ink);
}
.st-pick__row:hover { background: var(--st-surface-2); border-color: var(--st-border-strong); }
.st-pick__row:hover .st-pick__add { background: var(--st-accent); color: var(--st-on-accent); border-color: var(--st-accent); }
.st-pick__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; font-size: 14px; }
.st-pick__add { flex: 0 0 auto; pointer-events: none; }
@media (max-width: 760px) {
    .st-pick__list { max-height: 50vh; }
    .st-pick__add span { display: none; }
}
