/* StudyPass styles.
   Every color lives in the tokens at the top. Change them to re-theme the whole app.
   Light is the default. Dark comes from the device setting (unless the student picked
   Light) or from <html data-theme="dark">. The accent color comes from <html data-accent>. */

/* ==========================================================================
   Tokens: light theme (default)
   ========================================================================== */
:root {
  /* Neutrals with a slight cool tint, so white cards don't look flat grey. */
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eceef3;
  --raised: #ffffff;          /* the picked button in a segmented control */
  --ink: #151821;
  --ink-2: #484e5e;
  --ink-3: #626979;
  --line: #e3e6ec;
  --line-strong: #cfd3dc;
  --navy: #1a1e29;            /* strong blocks: dark buttons, toasts, "me" chat bubbles */
  --on-navy: #f3f5f9;
  --hero: #1a1e29;            /* the big AI banner and the demo bar */
  --on-hero: #f3f5f9;

  /* Meaning colors. Text versions pass AA on white and on their soft backgrounds. */
  --star: #e9a800;
  --good: #11794a;
  --good-soft: #e2f4ea;
  --on-good: #ffffff;
  --bad: #c5283a;
  --bad-soft: #fce8ea;
  --on-bad: #ffffff;
  --learn: #a15200;
  --learn-soft: #fdf0dc;
  --learn-fill: #ec9a1e;      /* bars and dots only, not text */
  --info: #1d64b8;
  --info-soft: #e5eefa;
  --flame: #e8590c;
  --flame-soft: #fff0e6;
  --switch-off: #8c93a3;
  --overlay: rgba(12, 14, 20, .5);

  /* Avatar circles: the hue comes from --h on each avatar. */
  --av-s: 70%; --av-l: 88%; --av-ink-s: 60%; --av-ink-l: 26%;

  /* Accent palettes. Brand text passes AA on every surface, and white text passes AA on the brand. */
  --a-coral: #c6380f;  --a-coral-hover: #a82d09;  --a-coral-soft: #fdece6;  --a-coral-on: #ffffff;
  --a-ocean: #1a66c2;  --a-ocean-hover: #1554a3;  --a-ocean-soft: #e6f0fc;  --a-ocean-on: #ffffff;
  --a-grape: #7442cf;  --a-grape-hover: #6034b4;  --a-grape-soft: #f0e9fc;  --a-grape-on: #ffffff;
  --a-forest: #18784b; --a-forest-hover: #12623c; --a-forest-soft: #e2f4ea; --a-forest-on: #ffffff;
  --a-sunset: #b04a00; --a-sunset-hover: #903c00; --a-sunset-soft: #fdefdf; --a-sunset-on: #ffffff;
  --a-rose: #c52a64;   --a-rose-hover: #a71f52;   --a-rose-soft: #fdeaf1;   --a-rose-on: #ffffff;
  --a-sofia: #fd9db8;  --a-sofia-hover: #fb85a6;  --a-sofia-soft: #fff2f6;  --a-sofia-on: #6a1631;

  /* Coral is the default accent. html[data-accent] swaps these four (see below). */
  --brand: var(--a-coral);
  --brand-hover: var(--a-coral-hover);
  --brand-soft: var(--a-coral-soft);
  --on-brand: var(--a-coral-on);
  --focus: var(--brand);
  --ring: color-mix(in srgb, var(--brand) 26%, transparent);

  /* Shape and depth */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 16px;
  --r-xl: 22px;
  --radius: var(--r-lg);
  --shadow-sm: 0 1px 2px rgba(17, 20, 30, .06);
  --shadow: 0 1px 2px rgba(17, 20, 30, .05), 0 6px 18px -6px rgba(17, 20, 30, .12);
  --shadow-lg: 0 2px 6px rgba(17, 20, 30, .06), 0 24px 56px -14px rgba(17, 20, 30, .28);
  --header-h: 60px;

  --display: 'Bricolage Grotesque', 'Figtree', ui-sans-serif, system-ui, sans-serif;
  --body: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

/* Accent picker */
:root[data-accent="ocean"]  { --brand: var(--a-ocean);  --brand-hover: var(--a-ocean-hover);  --brand-soft: var(--a-ocean-soft);  --on-brand: var(--a-ocean-on); }
:root[data-accent="grape"]  { --brand: var(--a-grape);  --brand-hover: var(--a-grape-hover);  --brand-soft: var(--a-grape-soft);  --on-brand: var(--a-grape-on); }
:root[data-accent="forest"] { --brand: var(--a-forest); --brand-hover: var(--a-forest-hover); --brand-soft: var(--a-forest-soft); --on-brand: var(--a-forest-on); }
:root[data-accent="sunset"] { --brand: var(--a-sunset); --brand-hover: var(--a-sunset-hover); --brand-soft: var(--a-sunset-soft); --on-brand: var(--a-sunset-on); }
:root[data-accent="rose"]   { --brand: var(--a-rose);   --brand-hover: var(--a-rose-hover);   --brand-soft: var(--a-rose-soft);   --on-brand: var(--a-rose-on); }
:root[data-accent="sofia"]  { --brand: var(--a-sofia);  --brand-hover: var(--a-sofia-hover);  --brand-soft: var(--a-sofia-soft);  --on-brand: var(--a-sofia-on); }
/* Sofia's special look: a soft pink wash behind the whole app. */
html.sofia body { background: radial-gradient(1200px 520px at 50% -8%, color-mix(in srgb, var(--a-sofia) 30%, var(--bg)) 0%, var(--bg) 62%) fixed, var(--bg); }
html.sofia .topbar { background: color-mix(in srgb, var(--a-sofia) 10%, var(--surface)); }

/* ==========================================================================
   Tokens: dark theme. The same list twice: once for "follow my device",
   once for "always dark". Keep the two blocks the same.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14; --surface: #15181f; --surface-2: #1b1f27; --surface-3: #252a34; --raised: #353b48;
    --ink: #eceef3; --ink-2: #afb5c3; --ink-3: #8c93a4; --line: #262b35; --line-strong: #373d4a;
    --navy: #e6e9ef; --on-navy: #12151b; --hero: #1b1f29; --on-hero: #eceef3;
    --star: #ffc53d;
    --good: #4bd08f; --good-soft: #10301f; --on-good: #04160c;
    --bad: #ff7c86; --bad-soft: #3b1a1f; --on-bad: #22060a;
    --learn: #ffb44f; --learn-soft: #372812; --learn-fill: #ffb44f;
    --info: #74b4ff; --info-soft: #152840;
    --flame: #ff8a3d; --flame-soft: #3a2214;
    --switch-off: #5d6577; --overlay: rgba(0, 0, 0, .62);
    --av-s: 35%; --av-l: 27%; --av-ink-s: 85%; --av-ink-l: 86%;
    --a-coral: #ff8260;  --a-coral-hover: #ff9c80;  --a-coral-soft: #3a1e17;  --a-coral-on: #1c0b06;
    --a-ocean: #62aefc;  --a-ocean-hover: #86c1ff;  --a-ocean-soft: #15283f;  --a-ocean-on: #04121f;
    --a-grape: #b39aff;  --a-grape-hover: #c6b3ff;  --a-grape-soft: #2a2143;  --a-grape-on: #130b26;
    --a-forest: #4fcf8f; --a-forest-hover: #74dca7; --a-forest-soft: #12301f; --a-forest-on: #03170c;
    --a-sunset: #ffa94d; --a-sunset-hover: #ffbd75; --a-sunset-soft: #3a2812; --a-sunset-on: #1c0f02;
    --a-rose: #ff7eaa;   --a-rose-hover: #ff9dbf;   --a-rose-soft: #3c1826;   --a-rose-on: #210611;
    --a-sofia: #fd9db8;  --a-sofia-hover: #ffb3c8;  --a-sofia-soft: #3a1622;  --a-sofia-on: #2a0a15;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px -8px rgba(0, 0, 0, .55);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 28px 60px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14; --surface: #15181f; --surface-2: #1b1f27; --surface-3: #252a34; --raised: #353b48;
  --ink: #eceef3; --ink-2: #afb5c3; --ink-3: #8c93a4; --line: #262b35; --line-strong: #373d4a;
  --navy: #e6e9ef; --on-navy: #12151b; --hero: #1b1f29; --on-hero: #eceef3;
  --star: #ffc53d;
  --good: #4bd08f; --good-soft: #10301f; --on-good: #04160c;
  --bad: #ff7c86; --bad-soft: #3b1a1f; --on-bad: #22060a;
  --learn: #ffb44f; --learn-soft: #372812; --learn-fill: #ffb44f;
  --info: #74b4ff; --info-soft: #152840;
  --flame: #ff8a3d; --flame-soft: #3a2214;
  --switch-off: #5d6577; --overlay: rgba(0, 0, 0, .62);
  --av-s: 35%; --av-l: 27%; --av-ink-s: 85%; --av-ink-l: 86%;
  --a-coral: #ff8260;  --a-coral-hover: #ff9c80;  --a-coral-soft: #3a1e17;  --a-coral-on: #1c0b06;
  --a-ocean: #62aefc;  --a-ocean-hover: #86c1ff;  --a-ocean-soft: #15283f;  --a-ocean-on: #04121f;
  --a-grape: #b39aff;  --a-grape-hover: #c6b3ff;  --a-grape-soft: #2a2143;  --a-grape-on: #130b26;
  --a-forest: #4fcf8f; --a-forest-hover: #74dca7; --a-forest-soft: #12301f; --a-forest-on: #03170c;
  --a-sunset: #ffa94d; --a-sunset-hover: #ffbd75; --a-sunset-soft: #3a2812; --a-sunset-on: #1c0f02;
  --a-rose: #ff7eaa;   --a-rose-hover: #ff9dbf;   --a-rose-soft: #3c1826;   --a-rose-on: #210611;
  --a-sofia: #fd9db8;  --a-sofia-hover: #ffb3c8;  --a-sofia-soft: #3a1622;  --a-sofia-on: #2a0a15;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px -8px rgba(0, 0, 0, .55);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 28px 60px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* Text size setting: everything sized in rem grows or shrinks with it. */
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
html[data-size="small"] { font-size: 93.75%; }
html[data-size="large"] { font-size: 112.5%; }

/* Keyboard hints turned off in Settings */
html.hide-keys .keys { display: none !important; }

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
/* Safety net: one very long word should never make the whole page scroll sideways. */
@supports (overflow: clip) { body { overflow-x: clip; } }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img, svg { max-width: 100%; }
svg { flex-shrink: 0; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#app:focus, #app:focus-visible { outline: none; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.015em; }
h1 { font-size: clamp(1.75rem, 1.35rem + 1.6vw, 2.4rem); font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
b, strong { font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Plain text links (no class) and small links in headings use the accent. */
a:not([class]), a.small, a.link {
  color: var(--brand); font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}
a:not([class]):hover, a.small:hover, a.link:hover { text-decoration-color: currentColor; }

/* "Skip to content" shows up only when you Tab to it. */
.skip-link:focus {
  position: fixed; top: 10px; left: 10px; z-index: 100; width: auto; height: auto; margin: 0; clip: auto; overflow: visible;
  padding: 10px 16px; background: var(--surface); color: var(--ink); font-weight: 700; text-decoration: none;
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
body.auth-mode .topbar { display: none; }
.topbar-in { max-width: 1120px; height: var(--header-h); margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; border-radius: var(--r-sm); }
.logo-word { font-family: var(--display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em; }
.logo-mark { width: 32px; height: 32px; flex-shrink: 0; transform: rotate(-8deg); transition: transform .3s cubic-bezier(.3, .7, .3, 1.4); }
.logo-mark .lm-body { fill: var(--brand); }
.logo-mark .lm-check { fill: none; stroke: var(--on-brand); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.logo:hover .logo-mark { transform: rotate(4deg) translateY(-1px); }

.search {
  position: relative; flex: 1; min-width: 0; max-width: 440px; height: 40px;
  display: flex; align-items: center; gap: 8px; padding: 0 10px 0 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search:hover { border-color: var(--line-strong); }
.search svg { width: 17px; height: 17px; fill: none; stroke: var(--ink-3); stroke-width: 2.2; stroke-linecap: round; }
.search input { border: 0; background: none; outline: none; padding: 0; height: 100%; width: 100%; min-width: 0; }
.search input::placeholder { color: var(--ink-3); opacity: 1; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search:focus-within { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--ring); }
/* The "/" hint: press slash to jump to search. */
.search::after {
  content: '/'; flex-shrink: 0; display: grid; place-items: center; width: 20px; height: 20px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  font: 600 .72rem/1 var(--body); color: var(--ink-3); background: var(--surface);
}
.search:focus-within::after, html.hide-keys .search::after { display: none; }

.top-nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav-link {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px;
  border-radius: 999px; color: var(--ink-2); font-weight: 700; text-decoration: none; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link::before {
  content: ''; width: 18px; height: 18px; flex-shrink: 0; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.5 2.7 3.8 5.7 3.8 9s-1.3 6.3-3.8 9c-2.5-2.7-3.8-5.7-3.8-9S9.5 5.7 12 3Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.5 2.7 3.8 5.7 3.8 9s-1.3 6.3-3.8 9c-2.5-2.7-3.8-5.7-3.8-9S9.5 5.7 12 3Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-link.on, .nav-link[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
#messages-link::before { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.4 8.4 0 0 1-11.9 7.6L3 21l1.9-6.1A8.4 8.4 0 1 1 21 11.5Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.4 8.4 0 0 1-11.9 7.6L3 21l1.9-6.1A8.4 8.4 0 1 1 21 11.5Z'/%3E%3C/svg%3E") center / contain no-repeat; }
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; margin-left: 1px; }

/* ---------- Private chat (admins + Sofia) ---------- */
#app:has(.dm-wrap) { padding: 16px; gap: 0; } /* the chat fills the view instead of the usual tall page padding */
.dm-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 14px; height: calc(var(--chat-window-height, 100dvh) - var(--header-h, 56px) - 32px); min-height: 420px; }
.dm-list { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dm-list-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; font-weight: 800; border-bottom: 1px solid var(--line); }
.dm-list-head svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; color: var(--brand); }
#dm-contacts { overflow-y: auto; min-height: 0; flex: 1; }
.dm-pad { padding: 14px 16px; }
.dm-contact { display: flex; align-items: center; gap: 10px; padding: 11px 14px; text-decoration: none; color: inherit; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); position: relative; }
.dm-contact:hover { background: var(--surface-2); }
.dm-contact.on { background: var(--brand-soft); }
.dm-contact .avatar, .dm-contact img.avatar { flex-shrink: 0; }
.dm-contact-body { min-width: 0; flex: 1; }
.dm-contact-top { display: flex; align-items: baseline; gap: 8px; }
.dm-contact-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-time { font-size: .72rem; color: var(--ink-3); flex-shrink: 0; }
.dm-contact-last { margin: 1px 0 0; font-size: .85rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-badge { flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: .74rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.dm-main { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dm-empty { margin: auto; text-align: center; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px; }
.dm-empty svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.6; opacity: .6; }
.dm-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 800; position: relative; }
.dm-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-back { display: none; align-items: center; justify-content: center; width: 34px; height: 34px; margin-left: -6px; border-radius: 8px; color: var(--ink-2); }
.dm-back:hover { background: var(--surface-2); color: var(--ink); }
.dm-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.dm-tag { font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.dm-tag.sofia { background: color-mix(in srgb, var(--brand) 18%, var(--surface)); color: var(--brand); }
.dm-theme-btn { margin-left: auto; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dm-head-person { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.dm-presence { margin-top: 3px; color: var(--ink-3); font-size: .7rem; font-weight: 650; }
.dm-presence.online { color: #16a36a; }
.dm-presence.online::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.dm-theme-btn:hover { background: var(--surface-2); color: var(--brand); }
.dm-theme-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; }
.dm-theme-menu { position: absolute; top: calc(100% + 6px); right: 10px; z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: 0 14px 36px rgba(0,0,0,.2); width: 244px; }
.dm-theme-title { font-size: .8rem; font-weight: 800; color: var(--ink-2); margin-bottom: 9px; }
.dm-theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.dm-theme-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; cursor: pointer; padding: 1px; color: var(--ink-2); font-weight: 600; }
.dm-sw { width: 36px; height: 36px; border-radius: 11px; border: 2px solid var(--line); }
.dm-sw.sw-default { background: var(--surface-3); }
.dm-theme-opt.on { color: var(--brand); }
.dm-theme-opt.on .dm-sw { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.dm-sw-name { font-size: .68rem; }
/* chat background themes (the swatch and the real background share each rule) */
.dm-msgs.theme-rose, .dm-sw.theme-rose { background: linear-gradient(160deg, #ffdce9, #fff0f6 55%, #ffffff); }
.dm-msgs.theme-sunset, .dm-sw.theme-sunset { background: linear-gradient(160deg, #ffe0c4, #ffd0d6 50%, #f7c9e2); }
.dm-msgs.theme-ocean, .dm-sw.theme-ocean { background: linear-gradient(160deg, #cfe9ff, #e8f5ff 55%, #eef7ff); }
.dm-msgs.theme-mint, .dm-sw.theme-mint { background: linear-gradient(160deg, #ccf2e4, #e8fbf3 55%, #f2fff9); }
.dm-msgs.theme-violet, .dm-sw.theme-violet { background: linear-gradient(160deg, #e6dcff, #f1ecff 55%, #faf7ff); }
.dm-msgs.theme-midnight, .dm-sw.theme-midnight { background: linear-gradient(160deg, #0f1424, #171c2e 55%, #1b2136); }
.dm-msgs.theme-dots, .dm-sw.theme-dots { background: radial-gradient(color-mix(in srgb, var(--ink) 18%, transparent) 1px, transparent 1px) 0 0 / 14px 14px, var(--surface); }
/* keep "their" bubbles readable on the coloured wallpapers */
.dm-msgs.theme-rose .dm-row.theirs .dm-bubble, .dm-msgs.theme-sunset .dm-row.theirs .dm-bubble,
.dm-msgs.theme-ocean .dm-row.theirs .dm-bubble, .dm-msgs.theme-mint .dm-row.theirs .dm-bubble,
.dm-msgs.theme-violet .dm-row.theirs .dm-bubble { background: rgba(255, 255, 255, .92); color: #17181c; }
.dm-msgs.theme-rose .dm-stamp, .dm-msgs.theme-sunset .dm-stamp, .dm-msgs.theme-ocean .dm-stamp,
.dm-msgs.theme-mint .dm-stamp, .dm-msgs.theme-violet .dm-stamp, .dm-msgs.theme-rose .dm-seen,
.dm-msgs.theme-sunset .dm-seen, .dm-msgs.theme-ocean .dm-seen, .dm-msgs.theme-mint .dm-seen, .dm-msgs.theme-violet .dm-seen { color: rgba(0, 0, 0, .5); }
.dm-msgs.theme-midnight .dm-row.theirs .dm-bubble { background: rgba(255, 255, 255, .13); color: #eef1f7; }
.dm-msgs.theme-midnight .dm-stamp, .dm-msgs.theme-midnight .dm-seen { color: rgba(255, 255, 255, .55); }
.dm-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 3px; }
.dm-sayhi { margin: auto; color: var(--ink-3); }
.dm-row { display: flex; flex-direction: column; max-width: 76%; }
.dm-row.mine { align-self: flex-end; align-items: flex-end; }
.dm-row.theirs { align-self: flex-start; align-items: flex-start; }
.dm-bubble { padding: 9px 13px; border-radius: 16px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.dm-row.theirs .dm-bubble { background: var(--surface-3); color: var(--ink); border-bottom-left-radius: 5px; }
.dm-row.mine .dm-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.dm-row + .dm-row.mine, .dm-row + .dm-row.theirs { margin-top: 2px; }
.dm-stamp { font-size: .68rem; color: var(--ink-3); margin: 3px 4px 6px; }
.dm-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.dm-compose textarea { flex: 1; resize: none; max-height: 120px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2); color: var(--ink); font: inherit; line-height: 1.4; }
.dm-compose textarea:focus { outline: none; border-color: var(--brand); }

/* Hidden approval-only study session: intentionally resembles a quiet notes workspace. */
.focus-shell { min-height: calc(100vh - 170px); display: grid; place-items: center; padding: 28px 16px; background: radial-gradient(circle at 20% 10%, var(--brand-soft), transparent 38%); }
.focus-card { width: min(620px, 100%); display: grid; gap: 18px; padding: clamp(24px, 5vw, 42px); }
.focus-card h1, .focus-head h1 { margin: 2px 0 0; }
.focus-kicker { color: var(--brand); font-size: .75rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.focus-preview-badge { justify-self: start; display: inline-flex; padding: 4px 9px; border: 1px dashed var(--brand); border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: .72rem; font-weight: 800; }
.focus-head .focus-preview-badge { margin-bottom: 8px; }
.focus-request-note { padding: 16px 18px; border-left: 4px solid var(--brand); border-radius: 8px; background: var(--surface-2); }
.focus-request-note small { color: var(--muted); font-weight: 800; letter-spacing: .08em; }
.focus-request-note p { margin: 6px 0 0; white-space: pre-wrap; }
.focus-quiet-link { color: var(--muted); font-size: .85rem; justify-self: start; }
.focus-empty { text-align: center; justify-items: center; }
.focus-room { width: min(780px, 100%); height: min(720px, calc(var(--chat-window-height, 100dvh) - 150px)); min-height: 500px; display: grid; grid-template-rows: auto 4px 1fr auto; padding: 0; overflow: hidden; }
.focus-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px 24px 16px; }
.focus-head p { margin: 4px 0 0; }
.focus-progress { background: var(--surface-3); overflow: hidden; }
.focus-progress i { display: block; height: 100%; background: var(--brand); transition: width .4s; }
.focus-notes { overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 13px; background: repeating-linear-gradient(transparent 0 31px, color-mix(in srgb, var(--line) 55%, transparent) 32px); }
.focus-note { align-self: flex-start; max-width: min(78%, 560px); padding: 12px 14px 8px; border: 1px solid var(--line); border-radius: 4px 14px 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.focus-note.mine { align-self: flex-end; border-radius: 14px 4px 14px 14px; background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 25%, var(--line)); }
.focus-note p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.focus-photo { display: block; width: 100%; padding: 0; margin: 0 0 8px; border: 0; border-radius: 9px; overflow: hidden; background: transparent; cursor: zoom-in; }
.focus-photo:last-child { margin-bottom: 0; }
.focus-photo img { display: block; width: 100%; max-height: 360px; object-fit: contain; background: var(--surface-2); }
.focus-note small { display: block; margin-top: 5px; color: var(--muted); text-align: right; }
.focus-typing { align-self: flex-start; display: flex; align-items: center; gap: 4px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 4px 14px 14px; background: var(--surface); color: var(--muted); font-size: .78rem; }
.focus-typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); animation: dmTypingBounce 1.05s infinite ease-in-out; }
.focus-typing i:nth-child(2) { animation-delay: .14s; }
.focus-typing i:nth-child(3) { animation-delay: .28s; margin-right: 3px; }
.focus-blank { margin: auto; display: grid; gap: 5px; text-align: center; color: var(--muted); }
.focus-compose { display: flex; gap: 10px; align-items: end; padding: 16px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.focus-add-photo { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--muted); background: var(--surface-2); cursor: pointer; }
.focus-add-photo:hover { color: var(--brand); border-color: var(--brand); }
.focus-image-preview { position: relative; width: fit-content; max-width: 220px; margin: 10px 20px 0; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.focus-image-preview img { display: block; max-width: 200px; max-height: 140px; border-radius: 8px; object-fit: contain; }
.focus-image-preview button { position: absolute; top: -9px; right: -9px; width: 26px; height: 26px; border: 0; border-radius: 50%; color: #fff; background: var(--danger); font: 700 18px/1 sans-serif; cursor: pointer; }
.focus-compose textarea { flex: 1; resize: none; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink); background: var(--surface-2); font: inherit; }
.focus-compose textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
@media (max-width: 620px) { .focus-shell { padding: 0; min-height: calc(var(--chat-window-height, 100dvh) - 64px); } .focus-room { height: calc(var(--chat-window-height, 100dvh) - 64px); min-height: 0; border-radius: 0; } .focus-head { padding: 16px; } .focus-notes { padding: 16px; } .focus-compose { padding: 12px; } }
.dm-send { flex-shrink: 0; width: 42px; height: 42px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.dm-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.dm-photo { flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); }
.dm-photo:hover { color: var(--brand); border-color: var(--brand); }
.dm-photo svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.dm-preview { padding: 8px 12px 0; }
.dm-typing { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px 14px; color: var(--ink-3); font-size: .78rem; font-weight: 700; opacity: 0; transform: translateY(5px); }
.dm-typing[hidden] { display: none; }
.dm-typing.active { animation: dmTypingEnter .2s ease-out forwards; }
.dm-typing em { font-style: normal; }
.dm-typing-bubble { display: inline-flex; align-items: center; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 15px 15px 15px 5px; background: var(--surface-2); box-shadow: 0 3px 12px rgba(0,0,0,.08); }
.dm-typing-bubble i { display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: dmTypingBounce 1.05s infinite ease-in-out; }
.dm-typing-bubble i:nth-child(2) { animation-delay: .14s; }
.dm-typing-bubble i:nth-child(3) { animation-delay: .28s; }
@keyframes dmTypingEnter { to { opacity: 1; transform: translateY(0); } }
@keyframes dmTypingBounce { 0%,60%,100% { transform: translateY(0) scale(.8); opacity: .4; } 30% { transform: translateY(-4px) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dm-typing.active { animation: none; opacity: 1; transform: none; } .dm-typing-bubble i { animation: none; opacity: .75; } }
.dm-prev-chip { position: relative; display: inline-block; }
.dm-prev-chip img { max-height: 84px; max-width: 160px; border-radius: 12px; display: block; border: 1px solid var(--line); }
.dm-prev-chip video { max-height: 120px; max-width: min(240px, 72vw); border-radius: 12px; display: block; border: 1px solid var(--line); background: #000; }
.dm-prev-x { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--ink); color: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dm-prev-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; }
.dm-img { max-width: min(260px, 70vw); max-height: 300px; border-radius: 16px; display: block; cursor: zoom-in; object-fit: cover; }
.dm-video { width: min(360px, 76vw); max-height: 360px; border-radius: 16px; display: block; background: #000; }
.dm-row.mine .dm-img { border-bottom-right-radius: 5px; }
.dm-row.theirs .dm-img { border-bottom-left-radius: 5px; }
.dm-row.has-img .dm-bubble { margin-top: 3px; }
.dm-row.has-video .dm-bubble { margin-top: 3px; }
.dm-compose.sending { opacity: .72; pointer-events: none; }
.dm-seen { font-size: .66rem; font-weight: 700; color: var(--ink-3); margin: 1px 4px 4px; }
.dm-edited { font-size: .62rem; color: var(--ink-3); margin: 1px 4px 0; }
.dm-actions { display: flex; justify-content: flex-end; gap: 4px; margin: 3px 2px 0; opacity: 0; transition: opacity .15s ease; }
.dm-row.mine:hover .dm-actions, .dm-row.mine:focus-within .dm-actions { opacity: 1; }
.dm-actions button { border: 0; border-radius: 999px; padding: 3px 8px; background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink-2); font: inherit; font-size: .66rem; font-weight: 750; cursor: pointer; box-shadow: 0 1px 5px rgba(0,0,0,.12); }
.dm-actions button:hover, .dm-actions button:focus-visible { color: var(--brand); outline: none; }
@media (hover: none) { .dm-actions { opacity: 1; } }
.dm-message-tools { display: flex; align-items: center; gap: 4px; min-height: 22px; margin: 3px 2px 0; }
.dm-row.mine .dm-message-tools { justify-content: flex-end; }
.dm-heart { border: 0; border-radius: 999px; min-width: 28px; height: 24px; padding: 1px 7px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--ink-3); font: inherit; cursor: pointer; box-shadow: 0 1px 5px rgba(0,0,0,.12); transition: color .15s, background .15s, transform .15s; }
.dm-heart span { font-size: 1rem; line-height: 1; }
.dm-heart b { font-size: .66rem; }
.dm-heart.has-heart { color: #ef3f5a; }
.dm-heart.on { color: #fff; background: #ef3f5a; transform: scale(1.04); }
.dm-heart:hover, .dm-heart:focus-visible { color: #ef3f5a; outline: 2px solid color-mix(in srgb, #ef3f5a 45%, transparent); outline-offset: 1px; }
.dm-heart.on:hover, .dm-heart.on:focus-visible { color: #fff; }
.dm-lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.86); display: flex; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.dm-lightbox img { max-width: 96vw; max-height: 94vh; border-radius: 10px; }

/* Voice notes use one compact, predictable player in every browser. The native audio element
   stays available to assistive technology, while these controls avoid the oversized browser UI. */
.voice-player {
  --voice-player-accent: var(--brand);
  --voice-progress: 0%;
  display: grid;
  grid-template-columns: 36px minmax(110px, 1fr) 34px;
  align-items: center;
  gap: 10px;
  width: min(310px, 72vw);
  min-height: 58px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--ink);
  box-shadow: 0 7px 22px rgba(0,0,0,.12);
  isolation: isolate;
}
.voice-play, .voice-volume {
  display: inline-grid;
  place-items: center;
  flex: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}
.voice-play { width: 36px; height: 36px; color: #fff; background: var(--voice-player-accent); border-radius: 50%; }
.voice-play-mark { display: block; margin-left: 2px; font-size: .86rem; line-height: 1; }
.voice-player.playing .voice-play-mark { margin-left: 0; font-size: .72rem; letter-spacing: -2px; }
.voice-timeline { min-width: 0; display: grid; gap: 5px; }
.voice-time { display: flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: .72rem; font-variant-numeric: tabular-nums; line-height: 1; }
.voice-time b { color: var(--ink); font-weight: 750; }
.voice-time i { opacity: .55; font-style: normal; }
.voice-seek {
  width: 100%; height: 16px; margin: 0; padding: 0; cursor: pointer; appearance: none; background: transparent;
}
.voice-seek::-webkit-slider-runnable-track { height: 5px; border-radius: 99px; background: linear-gradient(90deg, var(--voice-player-accent) 0 var(--voice-progress), var(--line) var(--voice-progress) 100%); }
.voice-seek::-webkit-slider-thumb { width: 13px; height: 13px; margin-top: -4px; appearance: none; border: 2px solid var(--surface); border-radius: 50%; background: var(--voice-player-accent); box-shadow: 0 1px 5px rgba(0,0,0,.3); }
.voice-seek::-moz-range-track { height: 5px; border-radius: 99px; background: var(--line); }
.voice-seek::-moz-range-progress { height: 5px; border-radius: 99px; background: var(--voice-player-accent); }
.voice-seek::-moz-range-thumb { width: 11px; height: 11px; border: 2px solid var(--surface); border-radius: 50%; background: var(--voice-player-accent); box-shadow: 0 1px 4px rgba(0,0,0,.28); }
.voice-volume { width: 34px; height: 34px; border-radius: 50%; background: transparent; color: var(--ink-2); }
.voice-volume:hover, .voice-volume:focus-visible { color: var(--voice-player-accent); background: var(--surface-2); }
.voice-volume.muted { opacity: .48; }
.voice-play:focus-visible, .voice-volume:focus-visible, .voice-seek:focus-visible { outline: 2px solid var(--voice-player-accent); outline-offset: 2px; }
.voice-audio { position: absolute; width: 1px; height: 1px; opacity: .001; pointer-events: none; }
.voice-player.voice-error { border-color: var(--bad); }
.dm-bubble.voice { max-width: none; padding: 0; border: 0; background: none; }
.dm-prev-chip.audio .voice-player { width: min(270px, 68vw); }

/* Persona skin: a solid card keeps the decorative black thread behind the recording while the
   clipped red/white accents match the rest of Phantom Chat. */
.p5-voice { position: relative; z-index: 2; margin: 4px 0; }
.p5-voice .voice-player {
  --voice-player-accent: #e30613;
  width: min(300px, 70vw);
  border: 3px solid #0c0c0c;
  border-radius: 0;
  background: #f7f7f2;
  color: #0c0c0c;
  box-shadow: 5px 6px 0 #0c0c0c;
  clip-path: polygon(3% 0, 100% 0, 97% 100%, 0 100%);
}
.p5-voice .voice-time, .p5-voice .voice-time b, .p5-voice .voice-volume { color: #0c0c0c; }
.p5-voice .voice-seek::-webkit-slider-runnable-track { background: linear-gradient(90deg, #e30613 0 var(--voice-progress), #b8b8b2 var(--voice-progress) 100%); }
.p5-voice .voice-seek::-webkit-slider-thumb, .p5-voice .voice-seek::-moz-range-thumb { border-color: #f7f7f2; }
.p5-row.mine .p5-voice .voice-player { transform: rotate(-.7deg); }
.p5-row.theirs .p5-voice .voice-player { transform: rotate(.7deg); }

@media (max-width: 420px) {
  .voice-player { grid-template-columns: 34px minmax(88px, 1fr) 30px; gap: 7px; width: min(280px, 78vw); padding: 8px; }
  .voice-play { width: 34px; height: 34px; }
  .voice-volume { width: 30px; height: 30px; }
  .p5-voice .voice-player { width: min(270px, 74vw); }
}
@media (max-width: 720px) {
  #app:has(.dm-wrap) { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .dm-wrap { grid-template-columns: 1fr; height: calc(var(--chat-window-height, 100dvh) - var(--header-h, 56px) - 24px); min-height: 0; gap: 0; }
  .dm-wrap.show-convo .dm-list { display: none; }
  .dm-wrap:not(.show-convo) .dm-main { display: none; }
  .dm-wrap:not(.show-convo) .dm-list { border-radius: var(--radius); }
  .dm-back { display: inline-flex; }
  .dm-main, .dm-list { border-radius: var(--radius); }
  .dm-row { max-width: 85%; }
  .dm-compose { padding: 8px 10px; gap: 7px; }
  .dm-photo, .dm-send { width: 40px; height: 40px; }
  .dm-contact { padding: 12px 14px; }
  .dm-theme-menu { right: 6px; width: min(260px, calc(100vw - 24px)); }
}

.create-menu { position: relative; flex-shrink: 0; }
#create-btn span { font-size: 1.2em; line-height: 1; margin-top: -2px; }
.user-wrap { position: relative; flex-shrink: 0; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; max-width: 210px; padding: 3px 14px 3px 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-weight: 700; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.user-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.user-btn[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.user-btn .avatar { width: 32px; height: 32px; font-size: .85rem; }
.user-btn-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Drop-down menus (Create, the user menu, admin row menus) */
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 270px; padding: 6px; display: grid; gap: 1px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  transform-origin: top right; animation: menuIn .14s ease-out;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item {
  display: grid; gap: 1px; padding: 9px 12px; border-radius: var(--r-md); text-decoration: none; text-align: left;
  border: 0; background: none; cursor: pointer; width: 100%; transition: background .12s;
}
.menu-item b { font-weight: 700; }
.menu-item span { font-size: .85rem; color: var(--ink-2); font-weight: 400; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item:focus-visible { outline-offset: -2px; }
.user-menu { width: 260px; }
.user-menu-head { display: grid; gap: 1px; padding: 10px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.user-menu-head b { font-family: var(--display); font-size: 1.05rem; }
.user-menu-head span { font-size: .85rem; color: var(--ink-2); }

/* Announcement from the admins, under the header */
.announce { background: var(--brand-soft); color: var(--ink); border-bottom: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line)); }
.announce-in { max-width: 1120px; margin: 0 auto; padding: 7px 8px 7px 16px; display: flex; align-items: center; gap: 10px; min-height: 44px; }
.announce-in::before {
  content: ''; width: 20px; height: 20px; flex-shrink: 0; background: var(--brand);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10v4a1 1 0 0 0 1 1h3l6 4V5L7 9H4a1 1 0 0 0-1 1Z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19.5 5.5a9 9 0 0 1 0 13'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10v4a1 1 0 0 0 1 1h3l6 4V5L7 9H4a1 1 0 0 0-1 1Z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19.5 5.5a9 9 0 0 1 0 13'/%3E%3C/svg%3E") center / contain no-repeat;
}
.announce-text { flex: 1; min-width: 0; font-weight: 600; font-size: .925rem; overflow-wrap: anywhere; }
.announce .icon-btn { width: 32px; height: 32px; color: var(--ink-2); }
.announce .icon-btn:hover { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--ink); }

.demo-bar { background: var(--hero); color: var(--on-hero); font-size: .875rem; text-align: center; padding: 8px 16px; }
.demo-bar a { color: inherit; font-weight: 700; }

/* ==========================================================================
   Layout
   ========================================================================== */
.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 16px 88px; display: grid; gap: 30px; outline: none; }
.wrap > * { min-width: 0; }
.narrow { max-width: 780px; margin: 0 auto; width: 100%; }
.stack { display: grid; gap: 12px; }
.stack > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.back-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .95rem; justify-self: start; border-radius: var(--r-sm); min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.back-link svg { flex: none; }
/* Long unbroken words (a 45-letter title) wrap instead of running off a phone screen. */
.row > * { min-width: 0; }
.row > h1, .row > h2 { overflow-wrap: anywhere; }
.back-link:hover { color: var(--ink); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .input[type="search"] { flex: 1 1 220px; width: auto; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 42px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 700; line-height: 1.25; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm); white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--ink-3) 55%, var(--line-strong)); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:disabled:hover { background: var(--surface); border-color: var(--line-strong); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 1px 2px rgba(0, 0, 0, .12); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-primary:disabled:hover { background: var(--brand); border-color: var(--brand); }
.btn-dark { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.btn-dark:hover { background: color-mix(in srgb, var(--navy) 86%, var(--brand)); border-color: color-mix(in srgb, var(--navy) 86%, var(--brand)); }
.btn-ghost { border-color: transparent; background: none; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-ghost:disabled:hover { background: none; border-color: transparent; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-strong)); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-primary.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.btn-primary.btn-danger:hover { background: color-mix(in srgb, var(--bad) 86%, #000); border-color: color-mix(in srgb, var(--bad) 86%, #000); }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: .875rem; gap: 6px; }
.btn-lg { padding: 13px 24px; min-height: 50px; font-size: 1.05rem; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 999px; border: 0; background: none;
  cursor: pointer; color: var(--ink-2); flex-shrink: 0; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on { color: var(--star); }
.icon-btn.on svg { fill: currentColor; }
.spark { color: var(--brand); }

/* ==========================================================================
   Form controls
   ========================================================================== */
.field { display: grid; gap: 6px; }
.field label:not(.check):not(.switch) { font-size: .875rem; font-weight: 700; color: var(--ink); }
.label { font-size: .75rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.input, .textarea, .select {
  width: 100%; min-height: 42px; padding: 9px 13px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); outline: none; box-shadow: inset 0 1px 1px rgba(17, 20, 30, .03);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:hover, .textarea:hover, .select:hover { border-color: color-mix(in srgb, var(--ink-3) 55%, var(--line-strong)); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:disabled, .textarea:disabled, .select:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--bad); }
.input[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 24%, transparent); }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.textarea.drag { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
/* Selects get our own arrow so they match in every browser. */
.select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.select.btn-sm { min-height: 32px; padding-right: 30px !important; border-radius: 999px; font-weight: 600; background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; box-shadow: var(--shadow-sm); }
.select option { background: var(--surface); color: var(--ink); }
.title-input { font-family: var(--display); font-size: 1.4rem; font-weight: 800; letter-spacing: -.015em; }
.field-error { color: var(--bad); font-weight: 600; font-size: .875rem; }
.form-error { background: var(--bad-soft); color: var(--bad); font-weight: 600; padding: 10px 14px; border-radius: var(--r-md); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

/* Range slider in the accent color */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 24px; min-width: 0; background: transparent; cursor: pointer; accent-color: var(--brand); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: var(--brand); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--brand), 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .12s, box-shadow .15s;
}
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.1); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--brand), 0 0 0 5px var(--ring); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--brand); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--brand); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--brand), 0 0 0 5px var(--ring); }
output { font-variant-numeric: tabular-nums; }

/* On/off switch: <label class="switch"><input type="checkbox" role="switch"><span></span></label> */
.switch { position: relative; display: inline-flex; flex-shrink: 0; width: 46px; height: 28px; vertical-align: middle; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--switch-off); transition: background .18s, box-shadow .15s; }
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .28); transition: transform .2s cubic-bezier(.3, .7, .4, 1.2);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:hover:not(:disabled) + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 7%, transparent); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + span { opacity: .45; }

/* Segmented control. The older .tabs look the same. */
.segmented, .tabs {
  display: inline-flex; gap: 2px; padding: 3px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  background: var(--surface-3); border-radius: 999px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .04);
}
.segmented::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.tabs { flex-wrap: wrap; }
.segmented button, .tab {
  border: 0; background: none; padding: 7px 15px; border-radius: 999px; font-weight: 700; font-size: .9rem; line-height: 1.25;
  color: var(--ink-2); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button:hover, .tab:hover { color: var(--ink); }
.segmented button.on, .tab.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(17, 20, 30, .12), 0 0 0 1px color-mix(in srgb, var(--line-strong) 60%, transparent); }
.segmented button:focus-visible, .tab:focus-visible { outline-offset: 0; }
.segmented button:disabled { opacity: .5; cursor: not-allowed; }

/* Accent color chips. Each chip shows its own accent, tuned for the current theme. */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px; }
.swatch {
  --chip: var(--a-coral);
  position: relative; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--chip); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  transition: transform .12s, box-shadow .15s;
}
.swatch[data-accent="ocean"] { --chip: var(--a-ocean); }
.swatch[data-accent="grape"] { --chip: var(--a-grape); }
.swatch[data-accent="forest"] { --chip: var(--a-forest); }
.swatch[data-accent="sunset"] { --chip: var(--a-sunset); }
.swatch[data-accent="rose"] { --chip: var(--a-rose); }
.swatch[data-accent="sofia"] { --chip: var(--a-sofia); }
.swatch:hover { transform: scale(1.08); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--chip); }
.swatch.on::after {
  content: ''; position: absolute; left: 50%; top: 45%; width: 7px; height: 12px;
  border: solid var(--on-brand); border-width: 0 2.5px 2.5px 0; transform: translate(-50%, -50%) rotate(45deg);
}
.swatch:focus-visible { outline: 2px solid var(--ink); outline-offset: 5px; }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; }
.check:has(input:disabled) { opacity: .55; cursor: not-allowed; }

/* Password strength bar: <div class="pw-meter"><i data-score="0-4"></i></div> */
.pw-meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 6%; border-radius: 999px; background: var(--bad); transition: width .3s ease, background .3s; }
.pw-meter i[data-score="1"] { width: 25%; background: var(--bad); }
.pw-meter i[data-score="2"] { width: 50%; background: var(--learn-fill); }
.pw-meter i[data-score="3"] { width: 75%; background: var(--good); }
.pw-meter i[data-score="4"] { width: 100%; background: var(--good); }
.pw-toggle { color: var(--ink-2); }

/* ==========================================================================
   Cards, pills, badges, avatars
   ========================================================================== */
.set-tile {
  position: relative; display: grid; gap: 12px; align-content: start; padding: 18px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.set-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow), inset 0 3px 0 var(--brand); border-color: var(--line-strong); }
.set-tile h3, .set-tile p { overflow-wrap: anywhere; }
.set-tile-next { display: flex; align-items: center; gap: 7px; margin-top: auto; padding-top: 11px; border-top: 1px solid var(--line); color: var(--brand); font-size: .86rem; font-weight: 750; }
.set-tile-next span:nth-child(2) { flex: 1; }
.set-tile-next span:last-child { font-size: 1.05rem; transition: transform .15s; }
.set-tile:hover .set-tile-next span:last-child { transform: translateX(3px); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill.due { background: var(--brand-soft); color: var(--brand); }
.pill.good { background: var(--good-soft); color: var(--good); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; vertical-align: middle;
  font-size: .75rem; font-weight: 700; line-height: 1.5; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.badge svg { width: 12px; height: 12px; }
.badge-admin { background: var(--brand-soft); color: var(--brand); }
/* Study guides */
.guide-tile .tile-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; }
.guide-body { padding: 20px 22px; }
.guide-body .g-section { margin-bottom: 22px; }
.guide-body .g-section:last-child { margin-bottom: 0; }
.g-h { font-size: 1.15rem; margin: 0 0 10px; padding: 4px 8px; background: var(--brand-soft); color: var(--on-brand, var(--ink)); border-radius: 6px; display: inline-block; }
.g-sub { font-size: .98rem; font-weight: 700; margin: 14px 0 6px; }
.g-items, .g-points { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.g-items li, .g-points li { line-height: 1.5; }
.g-ref-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g-ref-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.g-ref-card .g-sub { margin-top: 0; }
/* Highlights the student adds to a guide */
.g-item.hl { background: linear-gradient(transparent 12%, #ffe37a 12%, #ffe37a 92%, transparent 92%); border-radius: 3px; padding: 0 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
:root:not([data-theme="light"]) .g-item.hl, :root[data-theme="dark"] .g-item.hl { background: color-mix(in srgb, #ffe37a 34%, transparent); color: var(--ink); }
.g-item.hl-pick { cursor: pointer; outline: 1px dashed transparent; }
.g-item.hl-pick:hover { background: color-mix(in srgb, #ffe37a 30%, transparent); outline-color: var(--line); border-radius: 4px; }
.g-item.hl.hl-pick:hover { outline-color: var(--brand); }
.g-hl-bar { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); gap: 10px; flex-wrap: wrap; }
.guide-cta { gap: 12px; flex-wrap: wrap; align-items: center; }
.guide-cta .desc { margin: 2px 0 0; }
/* Study-guide editor */
.g-edit-field { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; min-height: 1.6em; background: var(--surface); outline: none; overflow-wrap: anywhere; }
.g-edit-field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.g-edit-field:empty::before { content: attr(data-ph); color: var(--ink-2); }
.g-edit-field.g-term { flex: 0 0 34%; font-weight: 700; }
.g-edit-field.g-detail, .g-edit-field.g-point { flex: 1 1 auto; }
.g-edit-field.g-h { font-size: 1.05rem; font-weight: 700; flex: 1; }
.g-edit-field.g-sub { font-weight: 700; flex: 1; }
.guide-edit .icon-btn { flex: 0 0 auto; }
/* A textarea/box highlighted while a file is dragged over it */
.textarea.drag, .g-edit-field.drag { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.small.err { color: var(--bad); }
/* Math history */
.math-history-box > summary { cursor: pointer; padding: 6px 2px; }
.math-history-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.math-history-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.math-history-item:hover { border-color: var(--brand); background: var(--surface-2); }
.math-history-item .mh-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.math-history-item .mh-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.math-history-item .mh-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.math-history-item .mh-del { flex: 0 0 auto; opacity: .55; }
.math-history-item:hover .mh-del { opacity: 1; }
.math-history-item .mh-del:hover { color: var(--bad); }
/* StudyPass AI chat page */
.chat-layout { display: grid; grid-template-columns: 278px minmax(0, 1fr); gap: 18px; align-items: stretch; min-height: calc(100dvh - 150px); }
.chat-side-backdrop { display: none; }
.chat-side { position: sticky; top: 76px; height: calc(100dvh - 108px); overflow: auto; border: 1px solid var(--line); border-radius: var(--r-xl); background: color-mix(in srgb, var(--surface) 94%, var(--brand-soft)); padding: 10px; box-shadow: var(--shadow-sm); scrollbar-width: thin; }
.chat-side-head { align-items: center; padding: 7px 6px 13px; border-bottom: 1px solid var(--line); margin-bottom: 7px; }
.chat-side-head > div { display: grid; gap: 1px; }
.chat-side-head > div > b { font-family: var(--display); font-size: 1.02rem; }
.chat-side-head > div > span { color: var(--ink-3); font-size: .74rem; }
.chat-list { display: flex; flex-direction: column; gap: 4px; }
.chat-list-empty { margin: 18px 10px; color: var(--ink-3); font-size: .84rem; line-height: 1.45; text-align: center; }
.chat-item { position: relative; display: flex; align-items: center; gap: 5px; padding: 11px 9px 11px 12px; border: 1px solid transparent; border-radius: 12px; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.chat-item:hover { background: var(--surface); border-color: var(--line); transform: translateX(2px); }
.chat-item.on { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 25%, var(--line)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat-item.on { background: color-mix(in srgb, var(--brand) 24%, var(--surface)); } }
:root[data-theme="dark"] .chat-item.on { background: color-mix(in srgb, var(--brand) 24%, var(--surface)); }
.chat-item.on::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 99px; background: var(--brand); }
.chat-item-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.chat-item-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.chat-item-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
.chat-del { opacity: 0; flex: 0 0 auto; width: 32px; height: 32px; }
.chat-item:hover .chat-del, .chat-item.on .chat-del, .chat-del:focus-visible { opacity: .72; }
.chat-del:hover { opacity: 1; color: var(--bad); }
.chat-main { display: flex; flex-direction: column; height: calc(100dvh - 108px); min-height: 620px; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.chat-topbar { flex: 0 0 auto; min-height: 64px; padding: 10px 16px; border-bottom: 1px solid var(--line); gap: 12px; background: color-mix(in srgb, var(--surface) 92%, var(--brand-soft)); }
.chat-topbar #chat-side-toggle { display: none; }
.chat-title-group { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.chat-title-group > span { color: var(--ink-3); font-size: .72rem; }
.chat-title-top { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-size: 1rem; }
.chat-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 26px clamp(18px, 4vw, 46px); display: flex; flex-direction: column; gap: 18px; background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 65%, transparent), var(--surface) 34%); scrollbar-width: thin; }
.chat-row { display: flex; width: min(100%, 760px); margin-inline: auto; }
.chat-row.user { justify-content: flex-end; }
.chat-bubble { max-width: min(82%, 640px); padding: 12px 16px; border-radius: 19px; line-height: 1.55; overflow-wrap: anywhere; box-shadow: var(--shadow-sm); }
.chat-bubble.user { background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 6px; }
.chat-bubble.bot { padding-right: 40px; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; position: relative; }
.chat-bubble.bot p:first-child { margin-top: 0; } .chat-bubble.bot p:last-child { margin-bottom: 0; }
.chat-bubble.bot ul, .chat-bubble.bot ol { margin: 8px 0; padding-left: 22px; }
.chat-bubble.bot code { padding: 2px 5px; border-radius: 5px; background: var(--surface-3); font-size: .9em; }
.chat-img { max-width: 260px; max-height: 260px; border-radius: 13px; display: block; margin-bottom: 8px; }
/* Several photos in one sent message: a tidy little grid of thumbnails. */
.chat-imgs.multi { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-bottom: 8px; max-width: 320px; }
.chat-imgs.multi .chat-img { max-width: 100%; width: 100%; height: 125px; object-fit: cover; margin-bottom: 0; }
.chat-bubble-tools { position: absolute; top: 8px; right: 9px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
/* Drawings in AI answers: free-body diagrams and graphs */
.diagram { margin: 10px 0; }
.diagram svg { width: 100%; max-width: 440px; height: auto; display: block; }
.diagram figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.fbd text, .gph text { fill: currentColor; font-size: 12px; font-family: inherit; }
.fbd-arrow { stroke: var(--brand, #4f7cff); stroke-width: 2.5; stroke-linecap: round; }
.fbd-head { fill: var(--brand, #4f7cff); }
.fbd-obj { fill: var(--surface-3, #e8ecf3); stroke: currentColor; stroke-width: 1.5; }
.fbd-surface { stroke: currentColor; stroke-width: 2; }
.fbd-label { font-weight: 600; }
.fbd-note { font-size: 11px; opacity: .7; }
.gph-grid { stroke: var(--line, rgba(127, 127, 127, .25)); stroke-width: 1; }
.gph-axis { stroke: currentColor; stroke-width: 1.4; opacity: .7; }
.gph-curve { fill: none; stroke: var(--brand, #4f7cff); stroke-width: 2.4; stroke-linejoin: round; }
.gph-dot { fill: var(--accent, #e0567a); }
.gph-tick { font-size: 11px; opacity: .75; }
.gph-label { font-size: 12px; opacity: .85; }
/* What the AI read from a photo, one-tap replies, and the long-chat summary */
.chat-photo-note { max-width: min(560px, 92%); margin: -2px 0 6px auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 14px; }
.chat-photo-note summary { cursor: pointer; font-weight: 600; }
.chat-photo-note .chat-note-text, .chat-summary .chat-note-text { margin: 8px 0; white-space: normal; line-height: 1.5; }
.chat-photo-note.editing { display: grid; gap: 8px; width: min(560px, 92%); }
.chat-note-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 2px 4px; }
.chat-summary { margin: 0 0 10px; padding: 8px 12px; border: 1px dashed var(--line); border-radius: 12px; font-size: 13px; color: var(--muted); }
.chat-summary summary { cursor: pointer; }
/* Fractions, subscripts and charges in AI answers */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .18em; line-height: 1.2; font-size: .95em; }
.frac .num { padding: 0 .25em .05em; border-bottom: 1.5px solid currentColor; }
.frac .den { padding: .05em .25em 0; }
.frac .fslash { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat-bubble sup, .chat-bubble sub { font-size: .75em; line-height: 0; }
.chat-bubble.bot:hover .chat-bubble-tools, .chat-bubble.bot:focus-within .chat-bubble-tools { opacity: .72; }
.chat-copy { display: grid; place-items: center; width: 27px; height: 27px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; border-radius: 7px; }
.chat-copy:hover { opacity: 1; color: var(--ink); background: var(--surface-3); }
.chat-beta { font-size: .56rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent); border-radius: 5px; padding: 1px 4px; margin-left: 3px; }
#chat-mic.listening { color: #fff; background: var(--bad); border-radius: 12px; animation: chat-pulse 1.2s ease-in-out infinite; }
@keyframes chat-pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
html.reduce-motion #chat-mic.listening { animation: none; }
.chat-convo-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: .85rem; }
.chat-convo-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); animation: chat-pulse 1.2s ease-in-out infinite; flex: 0 0 auto; }
html.reduce-motion .chat-convo-dot { animation: none; }
.chat-hello { text-align: center; margin: auto; max-width: 650px; padding: 30px 16px; }
.chat-hello-icon { width: 58px; height: 58px; margin: 0 auto 13px; border-radius: 18px; color: var(--brand); background: var(--brand-soft); display: grid; place-items: center; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent); }
.chat-hello h1 { margin: 5px 0 9px; font-size: clamp(1.6rem, 4vw, 2.15rem); }
.chat-hello > p { max-width: 520px; margin-inline: auto; }
.chat-starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 22px; text-align: left; }
.chat-starters .chip { width: 100%; min-height: 48px; justify-content: flex-start; padding: 10px 13px; border-radius: 13px; white-space: normal; line-height: 1.35; }
.chat-composer { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 11px 14px 9px; background: color-mix(in srgb, var(--surface) 96%, var(--brand-soft)); }
.chat-modes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-height: 74px; overflow-y: auto; margin-bottom: 9px; scrollbar-width: thin; }
.chat-modes-label { margin-right: 2px; }
.chat-mode { min-height: 29px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 4px 11px; font-size: .78rem; font-weight: 650; cursor: pointer; }
.chat-mode:hover { border-color: var(--brand); color: var(--ink); }
.chat-mode.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.chat-bold { margin-left: 6px; }
.chat-bold b { font-weight: 800; }
.chat-free-tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--a-sofia, var(--brand)); background: color-mix(in srgb, var(--a-sofia, var(--brand)) 16%, transparent); padding: 1px 7px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.chat-input-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.chat-input-row textarea { flex: 1; resize: none; max-height: 150px; min-height: 42px; padding: 10px 7px; border: 0; background: transparent; box-shadow: none; }
.chat-input-row textarea:focus { box-shadow: none; }
.chat-input-row > .icon-btn { border-radius: 11px; background: var(--surface-2); }
#chat-send { width: 42px; height: 42px; min-height: 42px; padding: 0; border-radius: 12px; }
.chat-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.chat-attach-item { position: relative; }
.chat-attach-item img, .chat-attach img { width: 46px; height: 46px; object-fit: cover; border-radius: 7px; display: block; }
.chat-attach-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.chat-attach-x svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; }
.chat-note { margin: 6px 2px 0; text-align: center; font-size: .72rem; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; min-height: 0; }
  .chat-side-backdrop { position: fixed; inset: 0; z-index: 39; border: 0; background: var(--overlay); }
  .chat-layout.side-open .chat-side-backdrop { display: block; }
  .chat-side { position: fixed; z-index: 40; left: 10px; right: 10px; top: calc(var(--header-h) + 10px); height: auto; max-height: calc(100dvh - var(--header-h) - 22px); box-shadow: var(--shadow-lg); display: none; }
  .chat-layout.side-open .chat-side { display: block; animation: chatDrawerIn .18s ease-out; }
  .chat-topbar #chat-side-toggle { display: inline-flex; }
  .chat-main { height: calc(100dvh - var(--header-h) - 40px); min-height: 520px; }
  .chat-bubble { max-width: 90%; }
  .chat-topbar { padding: 8px 10px; }
  .chat-topbar > .row .btn { padding-inline: 9px; }
  .chat-thread { padding: 20px 14px; }
  .chat-modes { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding-bottom: 2px; }
  .chat-mode, .chat-modes-label { flex: 0 0 auto; }
  .chat-composer { padding: 9px 9px calc(8px + env(safe-area-inset-bottom)); }
}
@media (max-width: 500px) {
  .chat-starters { grid-template-columns: 1fr; }
  .chat-hello { padding: 24px 4px; }
  .chat-title-group > span { display: none; }
  .chat-topbar > .row { flex-wrap: nowrap; }
  #chat-memory { font-size: 0; width: 36px; padding: 0; }
  .chat-input-row { gap: 4px; padding: 5px; }
  .chat-input-row > .icon-btn { width: 38px; height: 38px; }
}
@keyframes chatDrawerIn { from { opacity: 0; transform: translateY(-8px); } }
/* Admin AI activity feed */
.ai-item { animation: ai-in .35s ease; }
.ai-item-err { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.ai-bubble { border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; background: var(--surface-2); }
.ai-bubble.ai-ans { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 22%, var(--line)); }
.ai-bubble.ai-err { background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.ai-lbl { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); margin-bottom: 4px; }
.ai-txt { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16em; overflow: auto; font-size: .92rem; line-height: 1.45; }
@keyframes ai-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
html.reduce-motion .ai-item { animation: none; }
.badge-sofia { background: color-mix(in srgb, var(--a-sofia) 22%, transparent); color: var(--a-sofia); border: 1px solid color-mix(in srgb, var(--a-sofia) 45%, transparent); }
.badge-sofia::before { content: "\2726"; margin-right: 1px; font-size: .8em; }
.badge-ok { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--learn-soft); color: var(--learn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-public { background: var(--info-soft); color: var(--info); }
.badge-ok:not(:has(svg))::before, .badge-bad:not(:has(svg))::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.avatar {
  --h: 215;
  display: inline-grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  background: hsl(var(--h) var(--av-s) var(--av-l)); color: hsl(var(--h) var(--av-ink-s) var(--av-ink-l));
  box-shadow: inset 0 0 0 1px hsl(var(--h) 40% 50% / .18);
  font: 800 .875rem/1 var(--display); letter-spacing: 0; user-select: none; overflow: hidden;
}
.avatar-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px rgba(127,127,127,.18); vertical-align: middle; }
.owner-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; color: var(--ink-2); }
.owner-line b { color: var(--ink); }
.meter { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.meter .m { background: var(--good); }
.meter .l { background: var(--learn-fill); }
.meter > i { display: block; transition: width .4s; }
.folder-tile { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.folder-tile svg { width: 28px; height: 28px; fill: var(--brand-soft); stroke: var(--brand); stroke-width: 1.6; }
.hero-ai {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--hero); color: var(--on-hero); border: 1px solid color-mix(in srgb, var(--on-hero) 8%, transparent);
  border-radius: var(--r-xl); padding: 26px 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
/* A field of accent dots that fades in toward the right */
.hero-ai::before {
  content: ''; position: absolute; inset: 0 0 0 40%; z-index: -1; opacity: .75;
  background-image: radial-gradient(var(--brand) 1.4px, transparent 1.9px); background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 85%); mask-image: linear-gradient(90deg, transparent, #000 85%);
}
.hero-ai h2 { font-size: 1.45rem; }
.hero-ai p { color: color-mix(in srgb, var(--on-hero) 78%, transparent); margin-top: 4px; }
.empty { text-align: center; padding: 48px 20px; display: grid; gap: 12px; justify-items: center; }
.empty > svg { color: var(--brand); }
.empty-note {
  padding: 18px 20px; text-align: center; color: var(--ink-2); font-size: .95rem;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 50%, transparent);
}

/* ==========================================================================
   Home: greeting, streak and daily goal
   ========================================================================== */
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 18px 28px; }
.today-row { display: grid; grid-template-columns: repeat(2, auto); gap: 12px; }
.streak, .goal {
  display: flex; align-items: center; gap: 14px; min-width: 0; padding: 12px 18px 12px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  color: inherit; text-decoration: none;
}
.goal { transition: transform .15s, box-shadow .15s, border-color .15s; }
.goal:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.streak-ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-3); color: var(--ink-3); }
.streak.on .streak-ico { background: var(--flame-soft); color: var(--flame); }
.streak.on .streak-ico svg { fill: currentColor; fill-opacity: .2; }
.streak > div { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 6px; align-items: baseline; min-width: 0; }
.streak b { font: 800 1.75rem/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.streak.on b { color: var(--flame); }
.streak span { font-weight: 700; color: var(--ink-2); }
.streak small { grid-column: 1 / -1; margin-top: 4px; font-size: .8rem; color: var(--ink-2); line-height: 1.3; }
.goal > div:last-child { display: grid; gap: 2px; min-width: 0; line-height: 1.3; }
/* Ring that fills up with --p (0 to 100) */
.goal-ring { --p: 0; position: relative; width: 56px; height: 56px; flex-shrink: 0; display: grid; place-content: center; justify-items: center; text-align: center; line-height: 1; }
.goal-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-3) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5.5px));
}
.goal-ring.done::before { background: var(--good); }
.goal-ring b { position: relative; font: 800 1.05rem/1 var(--display); font-variant-numeric: tabular-nums; }
.goal-ring small { position: relative; margin-top: 2px; font-size: .62rem; font-weight: 700; color: var(--ink-3); }
.goal-ring.done b { color: var(--good); }
.explore-promo h3 { display: flex; align-items: center; gap: 8px; }
.explore-promo h3 svg { color: var(--brand); }

/* ==========================================================================
   Set page
   ========================================================================== */
.set-head { display: grid; gap: 10px; }
.set-head > * { min-width: 0; }
.set-head h1, .set-head p { overflow-wrap: anywhere; }
.modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 960px) { .modes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* "Study next": the one suggested step on the set page */
.next-up {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--r-xl); text-decoration: none; color: inherit;
  background: linear-gradient(120deg, var(--brand-soft), var(--surface) 75%); border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
  box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s, border-color .15s;
}
.next-up:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--brand); }
.next-up .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brand); color: var(--on-brand); flex-shrink: 0; }
.next-up .ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.next-up-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.next-up-text small { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.next-up-text b { font-family: var(--display); font-size: 1.15rem; letter-spacing: -.01em; }
.next-up-text span { color: var(--ink-2); font-size: .92rem; }
.next-up > .btn { flex-shrink: 0; pointer-events: none; }
@media (max-width: 560px) {
  .next-up { flex-wrap: wrap; padding: 16px; gap: 12px; }
  .next-up .ico { width: 40px; height: 40px; }
  .next-up-text { flex-basis: calc(100% - 56px); }
  .next-up > .btn { width: 100%; justify-content: center; }
}

/* Flashcard preview on the set page */
.peek { display: grid; gap: 14px; min-width: 0; }
/* A set height, not an aspect ratio: an aspect ratio's minimum size made the card wider than a phone. */
.peek-card .flip-inner { aspect-ratio: auto; min-height: 0; height: clamp(220px, 30vw, 340px); }
.peek-nav { display: flex; align-items: center; justify-content: center; gap: 18px; position: relative; }
.peek-nav .count { min-width: 64px; text-align: center; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.peek-nav .round-btn { width: 46px; height: 46px; }
.peek-full { position: absolute; right: 0; }
.peek-full svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 560px) {
  .peek-full { position: static; }
  .peek-nav { flex-wrap: wrap; gap: 12px; }
}
.flip.no-anim .flip-inner { transition: none; }

/* Swiping a flashcard with Track progress on tints it: green = know it, orange = still learning */
.flip { transition: transform .2s ease; }
.flip.drag-yes .face { border-color: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 35%, transparent), var(--shadow); }
.flip.drag-no .face { border-color: var(--learn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--learn) 35%, transparent), var(--shadow); }
.swipe-hint { display: none; text-align: center; font-size: .82rem; color: var(--ink-3); }
@media (pointer: coarse) {
  .swipe-hint { display: block; }
  .keys { display: none; }
}

/* Mastery bar: mastered + still learning, out of every term */
.mastery { display: flex; align-items: baseline; gap: 6px 10px; flex-wrap: wrap; }
.mastery-bar { flex: 1 1 100%; display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-3); margin-bottom: 4px; }
.mastery-bar i { display: block; height: 100%; transition: width .5s ease; }
.mastery-bar i.m { background: var(--good); }
.mastery-bar i.l { background: var(--learn); opacity: .75; }
.mastery b { font-family: var(--display); font-size: 1.4rem; letter-spacing: -.02em; color: var(--good); font-variant-numeric: tabular-nums; }
.mastery span { color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.mode {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); min-width: 0;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); text-decoration: none; font-weight: 700;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.mode:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow); }
.mode > span:last-child { min-width: 0; }
.mode .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; transition: background .15s, color .15s; }
.mode:hover .ico { background: var(--brand); color: var(--on-brand); }
.mode .ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mode small { display: block; font-weight: 500; color: var(--ink-3); font-size: .8rem; line-height: 1.3; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); min-width: 0; }
.stat b { display: block; font-family: var(--display); font-size: 1.75rem; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.stat.s-new b { color: var(--ink-2); }
.stat.s-learn b { color: var(--learn); }
.stat.s-master b { color: var(--good); }
.term-list { display: grid; gap: 10px; }
.term-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 18px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 14px 10px 14px 18px;
}
.term-row .t { font-weight: 600; border-right: 1px solid var(--line); padding-right: 18px; overflow-wrap: anywhere; white-space: pre-wrap; }
.term-row .d { overflow-wrap: anywhere; white-space: pre-wrap; }
.term-row .tools { display: flex; margin-top: -8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: middle; background: var(--line-strong); }
.status-dot.learning { background: var(--learn-fill); }
.status-dot.mastered { background: var(--good); }
.panel.setting-row { padding: 16px 20px; }

/* ==========================================================================
   Editor
   ========================================================================== */
.card-edit { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: border-color .15s; }
.card-edit:focus-within { border-color: var(--line-strong); }
.card-edit-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3); font-weight: 700; font-variant-numeric: tabular-nums; }
.card-edit-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 16px 18px 18px; align-items: start; }
.line-input { display: grid; gap: 4px; }
.line-input textarea {
  border: 0; border-bottom: 2px solid var(--line-strong); background: none; resize: none; outline: none;
  padding: 6px 0; min-height: 36px; overflow: hidden; line-height: 1.4; transition: border-color .15s;
}
.line-input textarea:hover { border-bottom-color: var(--ink-3); }
.line-input textarea:focus { border-bottom-color: var(--brand); }
.line-input span { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.add-card {
  width: 100%; padding: 22px; border: 2px dashed var(--line-strong); background: none; border-radius: var(--radius);
  font-weight: 800; font-family: var(--display); font-size: 1.05rem; cursor: pointer; color: var(--ink-2); transition: border-color .15s, color .15s, background .15s;
}
.add-card:hover { border-color: var(--brand); color: var(--brand); background: color-mix(in srgb, var(--brand-soft) 50%, transparent); }
.editor-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(transparent, var(--bg) 35%);
}

/* ==========================================================================
   Study screens
   ========================================================================== */
.study-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.study-top .count { font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--good); border-radius: 99px; transition: width .4s; }
.options-row { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle {
  border: 1px solid var(--line-strong); background: var(--surface); padding: 6px 13px; border-radius: 999px;
  font-weight: 600; font-size: .875rem; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.toggle:hover { border-color: var(--ink-3); }
.toggle[aria-pressed="true"] { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }

/* flashcard */
.flip { perspective: 1400px; width: 100%; cursor: pointer; border-radius: 22px; }
.flip-inner { position: relative; width: 100%; aspect-ratio: 16 / 9; max-width: 100%; min-height: 280px; transition: transform .5s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateX(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); border: 1px solid var(--line);
  display: grid; place-items: center; padding: 48px 32px; text-align: center; overflow: auto;
}
.face.back { transform: rotateX(180deg); background: linear-gradient(var(--surface), var(--surface-2)); }
.face .txt { font-size: clamp(1.25rem, 1rem + 1.6vw, 2rem); font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35; }
.face.small-text .txt { font-size: clamp(1rem, .9rem + .8vw, 1.35rem); }
.face .side { position: absolute; top: 16px; left: 20px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.face .face-tools { position: absolute; top: 8px; right: 8px; display: flex; }
.card-nav { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.round-btn {
  width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: var(--shadow-sm);
  cursor: pointer; display: grid; place-items: center; transition: border-color .15s, background .15s, transform .1s;
}
.round-btn:hover { border-color: var(--ink-3); background: var(--surface-2); }
.round-btn:active { transform: scale(.95); }
.round-btn:disabled { opacity: .45; cursor: not-allowed; }
.round-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.know-btn { min-width: 150px; }
.know-btn.no { color: var(--learn); border-color: color-mix(in srgb, var(--learn) 55%, var(--line)); }
.know-btn.no:hover { background: var(--learn-soft); border-color: var(--learn); }
.know-btn.yes { color: var(--good); border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.know-btn.yes:hover { background: var(--good-soft); border-color: var(--good); }
.keys { text-align: center; font-size: .8rem; color: var(--ink-3); }
kbd {
  display: inline-block; min-width: 1.7em; text-align: center; font: 600 .75rem/1.5 var(--body); color: var(--ink-2);
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; background: var(--surface);
}
.slide-left { animation: slideL .25s ease; }
.slide-right { animation: slideR .25s ease; }
@keyframes slideL { from { transform: translateX(24px); opacity: 0; } }
@keyframes slideR { from { transform: translateX(-24px); opacity: 0; } }

/* question card (learn, review) */
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 26px; display: grid; gap: 22px; }
.q-prompt { font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem); font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2.5em; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 14px 16px;
  border: 2px solid var(--line); border-radius: 13px; background: var(--surface); cursor: pointer; font-weight: 500;
  overflow-wrap: anywhere; white-space: pre-wrap; transition: border-color .15s, background .15s;
}
.choice:hover:not(:disabled) { border-color: var(--ink-3); background: var(--surface-2); }
.choice .k { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.right .k { background: var(--good); color: var(--on-good); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.wrong .k { background: var(--bad); color: var(--on-bad); }
.choice:disabled { cursor: default; color: inherit; }
.choice.dim { opacity: .5; }
.answer-input { font-size: 1.1rem; padding: 13px 16px; }
.feedback { border-radius: 13px; padding: 14px 16px; display: grid; gap: 6px; border: 1px solid transparent; }
.feedback.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.feedback.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.feedback .fb-title { font-weight: 800; }
.feedback.good .fb-title { color: var(--good); }
.feedback.bad .fb-title { color: var(--bad); }
.feedback .ans { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* test */
.test-q { display: grid; gap: 16px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.test-q .qhead { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-3); font-size: .85rem; font-weight: 700; }
.test-q.ok { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.test-q.no { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.tf-shown { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.match-q { display: grid; gap: 10px; }
.match-q .mrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; }
.match-q .mrow.ok .select { border-color: var(--good); }
.match-q .mrow.no .select { border-color: var(--bad); }
.score-ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--bad-soft) 0); flex-shrink: 0; }
.score-ring b { width: 108px; height: 108px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--display); font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.result-head { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }

/* match game */
.match-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile {
  min-height: 120px; padding: 12px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface);
  display: grid; place-items: center; text-align: center; cursor: pointer; font-weight: 600; overflow-wrap: anywhere;
  transition: transform .15s, opacity .3s, border-color .15s, background .15s; font-size: .95rem; box-shadow: var(--shadow-sm);
}
.tile:hover { border-color: var(--ink-3); }
.tile.sel { border-color: var(--brand); background: var(--brand-soft); transform: scale(1.03); }
.tile.bad { border-color: var(--bad); background: var(--bad-soft); }
.tile.done { opacity: 0; transform: scale(.85); pointer-events: none; }
.timer { font-family: var(--display); font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.best-list { display: grid; gap: 6px; font-variant-numeric: tabular-nums; margin: 0; padding: 0; list-style: none; }
.best-list li { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.best-list li.me { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); font-weight: 700; }

/* finish screens */
.finish { text-align: center; display: grid; gap: 14px; justify-items: center; padding: 34px 20px; }
.finish .big { font-size: 3.2rem; line-height: 1; }
.burst { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 70; }
.burst i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* AI chat */
.chat { display: grid; gap: 12px; }
.chat-log { display: grid; gap: 12px; min-height: 240px; align-content: start; }
.bubble { max-width: 85%; padding: 12px 15px; border-radius: 18px; line-height: 1.5; overflow-wrap: anywhere; }
.bubble.me { justify-self: end; background: var(--navy); color: var(--on-navy); border-bottom-right-radius: 5px; white-space: pre-wrap; }
.bubble.bot { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: var(--shadow-sm); }
.bubble.bot p + p, .bubble.bot p + ul, .bubble.bot ul + p { margin-top: 8px; }
.bubble ul, .ai-text ul { margin: 6px 0 0; padding-left: 20px; }
.ai-text p + p, .ai-text p + ul, .ai-text ul + p { margin-top: 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 7px 13px;
  cursor: pointer; font-weight: 600; font-size: .875rem; transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.subject-chip.on { border-color: var(--brand); background: var(--brand); color: var(--on-brand); }
.subject-chip.on:hover { background: var(--brand); color: var(--on-brand); }
.chat-input { display: flex; gap: 10px; position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg); box-shadow: 0 -12px 12px -4px var(--bg); }
.dots::after { content: '…'; animation: dots 1s steps(3) infinite; display: inline-block; width: 1em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1em; } }

/* ==========================================================================
   Log in, sign up, first-time setup
   ========================================================================== */
body.auth-mode .wrap { min-height: 100vh; min-height: 100dvh; padding-top: 28px; padding-bottom: 28px; align-content: center; }
.auth-wrap {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); width: 100%; max-width: 1040px; margin: 0 auto;
  min-height: min(660px, calc(100dvh - 56px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.auth-side {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; gap: 26px; padding: 40px;
  background: var(--brand); color: var(--on-brand);
}
/* Dotted paper texture on the brand panel */
.auth-side::before {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: radial-gradient(color-mix(in srgb, var(--on-brand) 30%, transparent) 1.2px, transparent 1.7px);
  background-size: 18px 18px;
  -webkit-mask-image: linear-gradient(160deg, #000 10%, transparent 70%); mask-image: linear-gradient(160deg, #000 10%, transparent 70%);
}
.auth-side h2 { color: inherit; letter-spacing: -.025em; }
.auth-side .logo-mark .lm-body { fill: var(--on-brand); }
.auth-side .logo-mark .lm-check { stroke: var(--brand); }
.auth-points li > span:first-child { background: color-mix(in srgb, var(--on-brand) 15%, transparent) !important; }
.auth-points b { font-weight: 800; }
.free-badge {
  justify-self: start; display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px;
  background: var(--on-brand); color: var(--brand); font-weight: 800; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase;
}
.auth-join { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.auth-join p { margin: 0; color: var(--ink-2); }
.auth-deck { margin-top: auto !important; }
.auth-deck-card { border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent); transition: transform .35s cubic-bezier(.3, .7, .3, 1.3); }
/* The middle card would vanish into the brand panel, so it gets the strong ink color instead. */
.auth-deck-card:nth-child(2) { background: var(--navy) !important; color: var(--on-navy) !important; border-color: transparent; }
.auth-side:hover .auth-deck-card:nth-child(1) { transform: rotate(-12deg) translate(-6px, 4px) !important; }
.auth-side:hover .auth-deck-card:nth-child(2) { transform: rotate(10deg) translate(6px, -6px) !important; }
.auth-card { display: grid; align-content: center; gap: 18px; padding: clamp(24px, 5vw, 56px); min-width: 0; }
.auth-card h1 { font-size: clamp(1.7rem, 1.4rem + 1.2vw, 2.2rem); }
.auth-card form { width: 100%; }
.auth-card .input { min-height: 46px; }
.auth-switch { text-align: center; color: var(--ink-2); padding-top: 16px; border-top: 1px solid var(--line); }
.auth-switch a { color: var(--brand); font-weight: 700; }

/* ==========================================================================
   Settings and admin: sidebar layout, setting rows
   ========================================================================== */
.side-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.side-layout > * { min-width: 0; }
.side-nav {
  position: sticky; top: calc(var(--header-h) + 20px); display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-md);
  color: var(--ink-2); font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s;
}
.side-nav a:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.side-nav a:focus-visible { outline-offset: -2px; }
.side-content { min-width: 0; }

.setting-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; padding: 14px 0; }
.setting-row ~ .setting-row { border-top: 1px solid var(--line); }
.setting-row > :first-child { flex: 1 1 160px; min-width: 0; }
.setting-row > :last-child:not(:first-child) { margin-left: auto; }
.setting-row .desc { color: var(--ink-2); font-size: .875rem; margin-top: 2px; line-height: 1.45; }
.setting-text label { cursor: pointer; }
.setting-row b svg { vertical-align: -3px; margin-right: 2px; }
.setting-control { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.panel > .setting-row:first-child { padding-top: 0; }
.panel > .setting-row:last-child { padding-bottom: 0; }
/* Rows bring their own spacing and divider lines, so a stack of them drops its gap. */
.stack:has(> .setting-row) { gap: 0; }
.stack:has(> .setting-row) > * + * { margin-top: 12px; }
.stack:has(> .setting-row) > * + .setting-row, .stack:has(> .setting-row) > .setting-row + * { margin-top: 0; }
.stack:has(> .setting-row) > :not(.setting-row) + .setting-row { padding-top: 16px; }

.danger-zone {
  padding: 20px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--bad) 38%, var(--line));
  background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface));
}
.danger-zone h3 { color: var(--bad); }

/* ==========================================================================
   Data: KPI tiles and tables
   ========================================================================== */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } } /* 8 tiles = two even rows */
.kpi {
  position: relative; overflow: hidden; display: grid; gap: 3px; align-content: start; min-width: 0; padding: 18px 18px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.kpi::before { content: ''; position: absolute; top: 20px; left: 0; width: 3px; height: 26px; border-radius: 0 3px 3px 0; background: var(--brand); }
.kpi b { font: 800 2rem/1.05 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.03em; overflow-wrap: anywhere; }
.kpi span { font-weight: 700; font-size: .9rem; color: var(--ink-2); }
.kpi small { font-size: .8rem; color: var(--ink-3); line-height: 1.35; }

.table-wrap {
  overflow: auto; max-height: min(72vh, 760px); overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .925rem; }
table.data th {
  position: sticky; top: 0; z-index: 1; padding: 10px 14px; text-align: left; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 65%, var(--surface)); }
table.data tbody td { transition: background .1s; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--brand) 5%, var(--surface-2)); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data a:not([class]) { color: var(--ink); text-decoration: none; }
table.data a:not([class]):hover { color: var(--brand); text-decoration: underline; }

/* ==========================================================================
   Pop-ups, toasts, loading
   ========================================================================== */
.modal-back {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: var(--overlay); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fadeIn .15s ease;
}
.modal {
  width: min(560px, 100%); max-height: 88vh; max-height: 88dvh; overflow: auto; padding: 24px; display: grid; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.3, .7, .3, 1.2);
}
.modal h2 { font-size: 1.3rem; }
@keyframes pop { from { transform: scale(.96) translateY(6px); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--navy); color: var(--on-navy); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-weight: 600; animation: toastIn .22s cubic-bezier(.3, .7, .3, 1.2); }
.toast.good { background: var(--good); color: var(--on-good); }
.toast.error { background: var(--bad); color: var(--on-bad); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }
.toast.bump { animation: toastBump .25s ease; }
@keyframes toastBump { 30% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.bump { animation: none; } }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--line), var(--surface-3), var(--line)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Tablets and phones
   ========================================================================== */
@media (max-width: 860px) {
  .home-top { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .today-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-wrap { grid-template-columns: minmax(0, 1fr); min-height: 0; border-radius: var(--r-xl); }
  .auth-side { padding: 24px; gap: 14px; }
  .auth-side h2 { font-size: 1.45rem !important; }
  .auth-points, .auth-deck { display: none !important; }
  body.auth-mode .wrap { align-content: start; padding-top: 16px; }
}
@media (max-width: 800px) {
  .side-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  /* The sidebar turns into a strip of tabs you can swipe sideways. */
  .side-nav {
    position: static; display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px;
    background: none; border: 0; border-radius: 0; box-shadow: none; scrollbar-width: none; scroll-snap-type: x proximity;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav a { flex-shrink: 0; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); scroll-snap-align: start; font-size: .925rem; }
  .side-nav a.on { border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
}
@media (max-width: 900px) {
  .user-btn { padding: 3px; width: 40px; justify-content: center; }
  .user-btn-name { display: none; }
}
@media (max-width: 720px) {
  .top-nav { margin-left: 0; }
  /* Explore turns into a globe icon. The word stays for screen readers. */
  .nav-link { width: 40px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .nav-link::before { width: 20px; height: 20px; }
  .match-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .term-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .term-row .t { border-right: 0; padding-right: 0; }
  .term-row .d { grid-column: 1; grid-row: 2; color: var(--ink-2); }
  .term-row .tools { grid-row: 1 / span 2; grid-column: 2; flex-direction: column; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 1.5rem; }
  .card-edit-body { grid-template-columns: 1fr; gap: 14px; }
  .choices { grid-template-columns: 1fr; }
  .match-q .mrow { grid-template-columns: 1fr; gap: 6px; }
  .table-wrap { max-height: none; }
  table.data { font-size: .875rem; }
  table.data th { padding: 9px 10px; }
  table.data td { padding: 9px 10px; }
  .kpi { padding: 14px 14px 12px; }
  .kpi::before { top: 16px; height: 22px; }
  .kpi b { font-size: 1.6rem; }
  .hero-ai { padding: 22px; }
  .hero-ai::before { inset: 0 0 0 20%; opacity: .4; }
  .q-card { padding: 20px; }
  .test-q { padding: 18px; }
  .modal { padding: 20px; }
  .panel { padding: 16px; }
  .panel.setting-row { padding: 14px 16px; }
  .danger-zone { padding: 16px; }
}
@media (max-width: 560px) {
  :root { --header-h: 56px; }
  .logo-word { display: none; }
  .topbar-in { gap: 8px; padding: 0 12px; }
  .search { padding: 0 12px; }
  .search::after { display: none; }
  /* The Create button shows just its "+" on phones. Its name stays "Create" for screen readers. */
  #create-btn { width: 40px; height: 40px; min-height: 0; padding: 0; font-size: 0; gap: 0; }
  #create-btn span { font-size: 1.5rem; margin: -2px 0 0; }
  .btn { padding: 9px 15px; }
  .btn-sm { padding: 6px 11px; }
  .btn-lg { padding: 12px 20px; }
  .wrap { padding-top: 20px; gap: 22px; }
  .face { padding: 42px 18px; }
  .flip-inner { aspect-ratio: auto; height: 320px; }
  .streak, .goal { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 14px; }
  .streak-ico { width: 44px; height: 44px; border-radius: 12px; }
  .streak b { font-size: 1.5rem; }
  .goal-ring { width: 48px; height: 48px; }
  .goal-ring b { font-size: .95rem; }
  .auth-card { padding: 22px 20px 24px; gap: 16px; }
  /* A segmented control that drops under its label fills the row; color chips start at the left. */
  .setting-control:has(> .segmented) { flex: 1 1 100%; }
  .setting-control > .segmented { width: 100%; }
  .setting-control > .segmented button { flex: 1; padding-left: 8px; padding-right: 8px; }
  .setting-control:has(> .swatches) { flex: 1 1 100%; justify-content: flex-start; }
  .setting-control > .swatches { padding-left: 0; }
  .know-btn { min-width: 0; flex: 1; }
  .modes { gap: 10px; }
  .mode { padding: 12px; gap: 10px; }
  .mode .ico { width: 34px; height: 34px; }
}
@media (max-width: 440px) {
  .match-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bubble { max-width: 92%; }
  .result-head { justify-content: center; text-align: center; }
}

/* ==========================================================================
   Less motion: the Reduce motion setting, or the device setting
   ========================================================================== */
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
  transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
}
html.reduce-motion .set-tile:hover, html.reduce-motion .mode:hover, html.reduce-motion .goal:hover,
html.reduce-motion .swatch:hover, html.reduce-motion .tile.sel { transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* Editor: a language for terms and one for definitions */
.lang-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.lang-row label { display: grid; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--ink-2); flex: 1 1 180px; max-width: 260px; }
.lang-row .select { width: 100%; }
.lang-row p { flex-basis: 100%; margin: 0; }

/* ---------- Print / PDF ----------
   On screen the pages look like sheets of paper. When printing, only .print-sheet is shown. */
.print-sheet { display: grid; gap: 24px; justify-items: center; margin-top: 8px; }
.ps-page {
  width: 100%; max-width: 210mm; background: #fff; color: #111; border-radius: 6px; box-shadow: var(--shadow-lg);
  padding: 14mm 12mm; font-size: 11pt; line-height: 1.4; overflow-wrap: anywhere;
}
.ps-head h1 { font-size: 18pt; margin: 0 0 2mm; color: #111; }
.ps-head p { margin: 0 0 4mm; color: #444; }
.ps-grid { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 60mm; padding: 10mm; }
.ps-card { border: 1px dashed #999; display: grid; place-content: center; text-align: center; padding: 6mm; position: relative; font-size: 13pt; font-weight: 600; overflow: hidden; }
.ps-card small { position: absolute; top: 3mm; left: 4mm; font-size: 7pt; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #888; }
.ps-back .ps-card { font-weight: 400; font-size: 11.5pt; }
.ps-empty { border-color: transparent; }
.ps-name { display: flex; gap: 6mm; margin: 2mm 0 6mm; }
.ps-name span { flex: 1; border-bottom: 1px solid #333; padding-bottom: 1mm; font-size: 9pt; color: #555; }
.ps-name span:first-child { flex: 2; }
.ps-part { margin-bottom: 6mm; break-inside: auto; }
.ps-part h2 { font-size: 13pt; color: #111; margin: 0 0 3mm; padding-bottom: 1.5mm; border-bottom: 2px solid #111; }
.ps-part h2 small { font-weight: 400; font-size: 9.5pt; color: #555; margin-left: 2mm; }
.ps-part ol { margin: 0; padding-left: 7mm; }
.ps-part > ol > li { margin-bottom: 4mm; break-inside: avoid; }
.ps-line { border-bottom: 1px solid #999; height: 8mm; }
.ps-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 1mm 6mm; margin-top: 1.5mm !important; padding-left: 6mm !important; }
.ps-match { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
.ps-match li { margin-bottom: 3mm; break-inside: avoid; }
.ps-blank { display: inline-block; width: 10mm; border-bottom: 1px solid #333; margin-right: 2mm; }
.ps-key h2 { font-size: 14pt; color: #111; margin: 0 0 4mm; }
.ps-key ol { columns: 2; column-gap: 10mm; padding-left: 7mm; font-size: 10pt; }
.ps-key li { break-inside: avoid; margin-bottom: 1.5mm; }
.ps-list { width: 100%; border-collapse: collapse; }
.ps-list th, .ps-list td { text-align: left; vertical-align: top; padding: 2.5mm 3mm; border-bottom: 1px solid #ddd; }
.ps-list th { width: 38%; font-weight: 700; }
.ps-list tr { break-inside: avoid; }
@media (max-width: 640px) {
  .ps-page { padding: 16px 12px; font-size: 10pt; }
  .ps-grid { grid-auto-rows: 38vw; padding: 8px; }
  .ps-card { font-size: 10pt; padding: 12px 8px; }
  .ps-choices, .ps-match { grid-template-columns: 1fr; gap: 4px; }
}
@media print {
  @page { margin: 10mm; }
  html, body { background: #fff !important; }
  body > *:not(main), .print-tools, #app > .narrow:first-child { display: none !important; }
  #app { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .print-sheet { display: block; margin: 0; }
  .ps-page { box-shadow: none; border-radius: 0; max-width: none; padding: 0; break-after: page; }
  .ps-page:last-child { break-after: auto; }
  /* 255mm fits a Letter page (and A4) inside the 10mm margins */
  .ps-grid { padding: 0; height: 255mm; grid-template-rows: repeat(4, 1fr); grid-auto-rows: auto; }
}

/* ---------- Gravity ---------- */
.gravity { display: grid; gap: 14px; max-width: 760px; width: 100%; margin: 0 auto; }
.g-hud { display: flex; align-items: center; gap: 18px; font-weight: 600; color: var(--ink-2); }
.g-hud b { color: var(--ink); font-family: var(--display); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.g-hud .btn { margin-left: auto; }
.g-lives i { font-style: normal; color: var(--line-strong); font-size: 1.2rem; }
.g-lives i.on { color: var(--bad); }
.g-field {
  position: relative; height: clamp(260px, 50vh, 520px); border-radius: var(--r-xl); overflow: hidden;
  background: radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 55%), linear-gradient(var(--surface), var(--surface-2));
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.g-field.paused .g-rock { opacity: .35; filter: blur(3px); }
.g-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; background: repeating-linear-gradient(135deg, var(--line-strong) 0 8px, transparent 8px 16px); opacity: .7; }
.g-rock {
  position: absolute; top: 0; max-width: 54%; padding: 12px 16px; border-radius: 16px; will-change: transform;
  background: var(--raised, var(--surface)); border: 2px solid var(--brand); box-shadow: var(--shadow);
  font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; white-space: pre-wrap;
}
.g-rock::before { content: '☄️'; position: absolute; top: -14px; left: -10px; font-size: 1.1rem; }
.g-rock.g-low { border-color: var(--bad); }
.g-rock.g-hit { animation: gHit .35s ease forwards; }
.g-rock.g-landed { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
@keyframes gHit { to { transform: scale(1.35); opacity: 0; } }
.g-banner {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); padding: 10px 18px; border-radius: 999px; max-width: 90%; text-align: center;
  background: var(--ink); color: var(--surface); font-weight: 800; box-shadow: var(--shadow-lg); z-index: 2;
}
.g-banner.good { background: var(--good); color: var(--on-good, #fff); }
.g-banner.warn { background: var(--learn); color: #fff; }
.g-form { display: grid; gap: 6px; }
.g-label { font-size: .9rem; font-weight: 600; color: var(--ink-2); }
.g-label b { color: var(--ink); }
.g-form .input { flex: 1; min-width: 0; }
@media (max-width: 560px) { .g-rock { max-width: 80%; padding: 10px 12px; font-size: .95rem; } .g-hud { gap: 12px; } }

/* Home page reminder (uses the .next-up look) */
.reminder-wrap { display: grid; gap: 6px; }
.reminder.urgent { background: linear-gradient(120deg, color-mix(in srgb, var(--learn) 16%, var(--surface)), var(--surface) 75%); border-color: color-mix(in srgb, var(--learn) 45%, var(--line)); }
.reminder.urgent .ico { background: var(--learn); color: #fff; }
.reminder.urgent .next-up-text small { color: var(--learn); }
.reminder-setup { justify-self: end; color: var(--ink-3); font-weight: 600; }
.reminder-setup:hover { color: var(--brand); }

/* ---------- Card pictures ---------- */
.card-img { display: block; max-width: 100%; height: auto; object-fit: contain; border-radius: 10px; background: #fff; }
.def-col { display: grid; gap: 8px; min-width: 0; }
.card-pic { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.card-pic .thumb { width: 88px; height: 64px; object-fit: cover; border: 1px solid var(--line); }
.row-img { width: 72px; height: 54px; object-fit: cover; margin-top: 6px; border: 1px solid var(--line); }
.face-body { display: grid; gap: 12px; justify-items: center; align-content: center; max-height: 100%; min-height: 0; }
.face.has-img { padding-top: 40px; padding-bottom: 24px; }
.face-img { max-height: min(46vh, 190px); max-width: 90%; }
.face.has-img .txt { font-size: clamp(1.05rem, .95rem + .8vw, 1.45rem); }
.peek-card .face-img { max-height: 150px; }
.q-img { max-height: 220px; max-width: min(100%, 420px); margin-bottom: 4px; border: 1px solid var(--line); }
.tile { display: grid; gap: 6px; justify-items: center; align-content: center; }
.tile-img { max-height: 70px; max-width: 100%; }
.rock-img { max-height: 70px; max-width: 160px; margin-bottom: 6px; }
.ps-img { max-height: 30mm; max-width: 100%; margin: 0 auto 2mm; border-radius: 0; }
.ps-list .ps-img { margin: 0 0 1.5mm; max-height: 22mm; }

/* ---------- Live class game ---------- */
.live { display: grid; gap: 18px; max-width: 1040px; width: 100%; margin: 0 auto; }
.lv-player { max-width: 560px; }
.lv-head { display: flex; align-items: center; gap: 14px; }
.lv-head .eyebrow { margin-right: auto; }
.lv-num { font-weight: 800; color: var(--ink-2); }
.lv-conn { position: sticky; top: 8px; z-index: 5; justify-self: center; background: var(--ink); color: var(--surface); padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
/* lobby */
.lv-lobby { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; }
.lv-codebox { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 28px 20px; border-radius: var(--r-xl); background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow); }
.lv-code { font-family: var(--display); font-weight: 800; font-size: clamp(2.6rem, 5.6vw, 4.6rem); letter-spacing: .04em; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lv-codebox .btn { background: color-mix(in srgb, var(--on-brand) 16%, transparent); color: inherit; border-color: transparent; }
.lv-waiting { display: grid; gap: 14px; padding: 20px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); }
.lv-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lv-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--surface-3); font-weight: 700; }
.lv-chip.new { animation: popIn .25s ease; }
.lv-kick { border: 0; background: none; color: var(--ink-3); font-size: 1.1rem; line-height: 1; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; }
.lv-kick:hover { background: var(--bad-soft); color: var(--bad); }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
/* question */
.lv-q { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 26px 20px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.lv-prompt { font-family: var(--display); font-weight: 800; font-size: clamp(1.4rem, 1rem + 2vw, 2.4rem); line-height: 1.2; overflow-wrap: anywhere; white-space: pre-wrap; }
.lv-q.small { padding: 16px; }
.lv-q.small .lv-prompt { font-size: clamp(1.1rem, 1rem + 1vw, 1.5rem); }
.lv-img { max-height: 240px; max-width: min(100%, 460px); }
.lv-q.small .lv-img { max-height: 140px; }
.lv-timer { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.lv-timer b { font-family: var(--display); font-size: 1.8rem; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.lv-timer .progress > i { background: var(--brand); transition: width .2s linear; }
.lv-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.lv-choice {
  position: relative; display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 16px 18px; border-radius: 16px; border: 0;
  color: #fff; font: inherit; font-weight: 800; font-size: 1.1rem; text-align: left; overflow-wrap: break-word; hyphens: auto; box-shadow: 0 4px 0 rgba(0, 0, 0, .18);
}
.lv-shape { font-size: 1.5rem; line-height: 1; flex-shrink: 0; width: 1.4em; text-align: center; }
.lc-0 { background: #d8392b; } .lc-1 { background: #2563c9; } .lc-2 { background: #e6a700; color: #1d1600; } .lc-3 { background: #178a4c; }
button.lv-choice { cursor: pointer; transition: transform .1s, filter .15s; }
button.lv-choice:hover { filter: brightness(1.07); }
button.lv-choice:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
button.lv-choice:disabled { cursor: default; opacity: .45; }
button.lv-choice.picked { opacity: 1; outline: 4px solid var(--ink); outline-offset: 2px; }
.lv-buttons .lv-choice { min-height: 110px; font-size: 1.05rem; }
.lv-choice.dim { opacity: .45; }
.lv-choice.right { outline: 4px solid var(--good); outline-offset: 2px; }
.lv-count { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 90px; }
.lv-count i { display: block; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .75); }
/* results */
.lv-results { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); align-items: start; }
.lv-board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lv-board li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; }
.lv-board li.me { border-color: var(--brand); background: var(--brand-soft); }
.lv-board b { margin-left: auto; font-variant-numeric: tabular-nums; }
.lv-rank { width: 1.6em; color: var(--ink-3); font-weight: 800; }
.lv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lv-teams { display: grid; gap: 6px; }
.lv-team-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; color: #fff; font-weight: 800; }
.lv-team-row small { opacity: .85; font-weight: 600; }
.lv-team-row b { margin-left: auto; font-size: 1.2rem; }
.lv-team { font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.t-red { background: #d8392b; } .t-blue { background: #2563c9; } .t-green { background: #178a4c; } .t-gold { background: #e6a700; color: #1d1600; }
.lv-chip.t-red, .lv-chip.t-blue, .lv-chip.t-green { color: #fff; }
.lv-chip.t-red .lv-kick, .lv-chip.t-blue .lv-kick, .lv-chip.t-green .lv-kick { color: rgba(255, 255, 255, .8); }
/* player screens */
.lv-me { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; }
.lv-me b { margin-left: auto; font-family: var(--display); font-size: 1.2rem; }
.lv-wait { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 34px 20px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); }
.lv-wait .big { font-size: 3rem; line-height: 1; }
.lv-wait .lv-timer { width: 100%; max-width: 360px; }
.lv-verdict.good { background: var(--good-soft); border-color: var(--good); }
.lv-verdict.good .big { color: var(--good); }
.lv-verdict.bad { background: var(--bad-soft); border-color: var(--bad); }
.lv-verdict.bad .big { color: var(--bad); }
.lv-join .lv-code-input { font-family: var(--display); font-size: 2.2rem; font-weight: 800; letter-spacing: .3em; text-align: center; height: 72px; }
/* podium */
.lv-done { display: grid; gap: 22px; text-align: center; }
.lv-podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; }
.lv-step { display: grid; gap: 4px; width: min(30%, 200px); }
.lv-step b { overflow-wrap: anywhere; }
.lv-step span { color: var(--ink-2); font-weight: 700; }
.lv-step div { border-radius: 14px 14px 0 0; background: var(--brand); color: var(--on-brand); font-family: var(--display); font-weight: 800; font-size: 2rem; display: grid; place-items: center; }
.lv-step.s1 div { height: 150px; } .lv-step.s2 div { height: 105px; opacity: .85; } .lv-step.s3 div { height: 75px; opacity: .7; }
#join-link::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Cpath d='M16.2 7.8a6 6 0 0 1 0 8.4M7.8 16.2a6 6 0 0 1 0-8.4M19.1 4.9a10 10 0 0 1 0 14.2M4.9 19.1a10 10 0 0 1 0-14.2'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Cpath d='M16.2 7.8a6 6 0 0 1 0 8.4M7.8 16.2a6 6 0 0 1 0-8.4M19.1 4.9a10 10 0 0 1 0 14.2M4.9 19.1a10 10 0 0 1 0-14.2'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (max-width: 720px) {
  .lv-lobby { grid-template-columns: 1fr; }
  .lv-choice { min-height: 64px; padding: 12px 14px; font-size: 1rem; }
  .lv-count { min-width: 60px; }
}
@media (max-width: 440px) {
  .lv-choices:not(.lv-buttons) { grid-template-columns: 1fr; }
  /* one column on phones, so a long word fits on its line */
  .lv-buttons { grid-template-columns: 1fr; gap: 10px; }
  .lv-buttons .lv-choice { min-height: 68px; font-size: 1rem; gap: 12px; padding: 12px 16px; }
}

/* ---------- Privacy and Terms ---------- */
.legal { display: grid; gap: 12px; line-height: 1.6; }
.legal h2 { font-size: 1.2rem; margin-top: 14px; }
.legal ul { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.legal .lead { font-size: 1.05rem; }
.legal-note { background: var(--learn-soft); border-color: color-mix(in srgb, var(--learn) 40%, var(--line)); font-size: .92rem; }
.legal-links { margin-top: 16px; color: var(--ink-3); }

/* ---------- Public updates ---------- */
.updates-page { display: grid; gap: 22px; }
.updates-hero { padding: 18px 0 4px; }
.updates-hero h1 { margin: 5px 0 8px; }
.updates-hero .lead { margin: 0; max-width: 620px; }
.updates-list { display: grid; gap: 14px; }
.update-card { position: relative; padding: clamp(18px, 4vw, 26px); overflow: hidden; }
.update-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); }
.update-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.update-card time { color: var(--ink-3); font-size: .78rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.update-card h2 { margin: 5px 0 0; font-size: clamp(1.2rem, 3vw, 1.55rem); }
.update-card ul { display: grid; gap: 9px; margin: 16px 0 0; padding-left: 20px; color: var(--ink-2); }
.update-card li::marker { color: var(--brand); }
.update-badge { flex: 0 0 auto; padding: 5px 10px; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: .72rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.updates-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
.updates-cta p { margin: 3px 0 0; }
@media (max-width: 560px) { .updates-cta { align-items: stretch; flex-direction: column; } .updates-cta .btn { justify-content: center; } }
.site-footer { padding: 0 16px 24px; margin-top: -48px; color: var(--ink-3); }
.site-footer-in { max-width: 1088px; margin: 0 auto; padding-top: 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; font-size: .82rem; }
.site-footer-brand { color: var(--ink); font-family: var(--display); font-weight: 800; }
.site-footer-brand small { margin-left: 8px; color: var(--ink-3); font-family: var(--body); font-weight: 500; }
.site-footer nav { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px 18px; }
.site-footer a { color: var(--ink-2); font-weight: 650; text-decoration: none; }
.site-footer a:hover { color: var(--brand); }
body.auth-mode .site-footer { margin-top: -20px; }
@media (max-width: 640px) {
  .site-footer-in { align-items: flex-start; flex-direction: column; }
  .site-footer-brand small { display: block; margin: 2px 0 0; }
  .site-footer nav { justify-content: flex-start; }
}
.auth-legal a { color: inherit; text-decoration: underline; }
@media print { .site-footer { display: none; } }
.guest-links { display: flex; gap: 6px; margin-left: auto; }
.create-menu[hidden], #search-form[hidden] { display: none !important; }

/* Recovery code */
.recovery-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(1rem, .7rem + 1.8vw, 1.6rem); font-weight: 800; letter-spacing: .04em; white-space: nowrap; text-align: center; padding: 16px; border-radius: 14px; background: var(--surface-2); border: 2px dashed var(--line-strong); user-select: all; overflow-wrap: anywhere; }
.recovery-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; }
.recover { max-width: 460px; width: 100%; margin: 0 auto; }

/* Reports */
.report-btn { margin-left: auto; color: var(--ink-3); }
.report-reasons { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.report-reasons label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; }
.report-reasons label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.report-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.report-list li span { display: block; }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 800; display: inline-grid; place-items: center; }

/* Share link */
.share-link { display: flex; gap: 8px; }
.share-link .input { flex: 1; min-width: 0; font-size: .9rem; }
@media (max-width: 440px) { .share-link { flex-direction: column; } }

/* ---------- Classes ---------- */
#classes-link::before { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8'/%3E%3C/svg%3E") center / contain no-repeat; }
.cl-join { flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.cl-join label { display: grid; margin-right: auto; }
.cl-join .input { width: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.class-tile { position: relative; display: grid; gap: 6px; align-content: start; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; min-height: 110px; }
.class-tile:hover { border-color: var(--brand); transform: translateY(-1px); }
.class-tile b { font-family: var(--display); font-size: 1.1rem; overflow-wrap: anywhere; }
.class-code-chip { justify-self: start; margin-top: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 800; letter-spacing: .12em; padding: 3px 10px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); }
.class-codebox { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between; }
.class-codebox .row { flex: 1 1 380px; flex-wrap: nowrap; }
.class-codebox .input { flex: 1; min-width: 0; font-size: .88rem; }
.class-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 2.2rem; font-weight: 800; letter-spacing: .14em; color: var(--brand); line-height: 1.1; }
.class-set { position: relative; display: grid; }
.class-set-x { position: absolute; top: 8px; right: 8px; background: var(--surface); }
.progress-table th[scope="row"] { display: grid; gap: 1px; text-align: left; white-space: nowrap; }
.progress-table thead th { white-space: nowrap; }
.progress-table td { min-width: 130px; }
.pt-cell { display: flex; align-items: center; gap: 8px; }
.pt-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 50px; }
.pt-bar i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.pick-list { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.pick-list label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pick-list span { display: grid; }
@media (max-width: 640px) { .class-codebox .row { flex-wrap: wrap; } .class-codebox .input { flex-basis: 100%; } }
.progress-table tbody th { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--ink); background: var(--surface); font-weight: 700; }
.progress-table tbody th .small { font-weight: 500; }
/* Header links show just their icons (the name shows on hover), so the search box keeps its room */
@media (min-width: 561px) {
  .top-nav .nav-link { width: 40px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .top-nav .nav-link::before { width: 20px; height: 20px; }
}

/* Offline */
.offline-bar { background: var(--ink); color: var(--surface); text-align: center; font-weight: 600; font-size: .88rem; padding: 8px 16px; }

/* Card formatting */
.fmt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.fmt-btn { min-width: 34px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: .95rem; cursor: pointer; }
.fmt-btn:hover { background: var(--surface-3); }
.fmt-btn.sym { min-width: 28px; padding: 0 4px; }
.fmt-sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.fmt-help { margin-left: auto; padding: 0 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.term-col { display: grid; gap: 6px; min-width: 0; }
.fmt-preview { font-size: .95rem; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--line-strong); overflow-wrap: anywhere; white-space: pre-wrap; }
@media (max-width: 640px) { .fmt-help { display: none; } }
sup, sub { font-size: .7em; line-height: 0; }

/* QR codes */
.lv-or { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.lv-qr { width: min(220px, 60vw); background: #fff; padding: 6px; border-radius: 12px; line-height: 0; }
.lv-qr svg, .class-qr svg { width: 100%; height: auto; display: block; }
.class-qr { width: 112px; flex-shrink: 0; background: #fff; padding: 4px; border-radius: 10px; border: 1px solid var(--line); line-height: 0; }

/* Import */
.imp-seps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.imp-seps label { display: grid; gap: 4px; font-weight: 600; }
.imp-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.imp-table th, .imp-table td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.imp-table th { width: 40%; }
.imp-skipped:empty { display: none; }
.imp-skipped { color: var(--learn); }

/* Assignments and hardest cards */
.assign-row, .assign-card summary { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.assign-row.done { opacity: .75; }
.assign-main { display: grid; gap: 4px; flex: 1 1 240px; min-width: 0; }
.assign-main b { overflow-wrap: anywhere; }
.assign-main .pt-cell { max-width: 280px; }
.assign-card { display: block; }
.assign-card summary { cursor: pointer; list-style: none; }
.assign-card summary::-webkit-details-marker { display: none; }
.assign-card[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.assign-card > :not(summary) { margin: 0; padding: 0 16px; }
.assign-card[open] { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding-bottom: 12px; }
.assign-card[open] summary { box-shadow: none; border-width: 0 0 1px; margin-bottom: 10px; }
.assign-count { white-space: nowrap; color: var(--ink-2); }
.assign-count .late { color: var(--bad); font-weight: 700; }
.assign-left { list-style: none; display: grid; gap: 8px; margin: 6px 0 10px !important; }
.assign-left li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 200px) auto; align-items: center; gap: 12px; }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.good-text { color: var(--good); font-weight: 700; }
.hard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 14px; }
.hard-list { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.hard-list li > div { display: grid; }
.hard-list li { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.hard-stat { text-align: right; white-space: nowrap; color: var(--bad); }
.hard-stat small { display: block; color: var(--ink-3); }
@media (max-width: 560px) { .assign-left li { grid-template-columns: 1fr; gap: 4px; } }

/* Log in with Google, and the "or" line between ways to log in */
.btn-google { width: 100%; justify-content: center; gap: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-google:hover { background: var(--surface-2); }
.btn-google.btn-sm { width: auto; }
.btn-google svg { flex-shrink: 0; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: .85rem; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-sent { background: var(--brand-soft); border-radius: 12px; padding: 12px 14px; }

/* Math help */
#math-link::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='3'/%3E%3Cpath d='M7 8.5h4M9 6.5v4M14 8.5h4M7.5 14.5l3 3M10.5 14.5l-3 3M14 15h4M14 17.5h4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='3'/%3E%3Cpath d='M7 8.5h4M9 6.5v4M14 8.5h4M7.5 14.5l3 3M10.5 14.5l-3 3M14 15h4M14 17.5h4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.math-home { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.math-home > div { flex: 1; min-width: 200px; }
.math-home h2 { font-size: 1.2rem; }
.math-home-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.home-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.home-tool-card { position: relative; align-content: start; align-items: flex-start; min-height: 188px; padding: 22px; overflow: hidden; box-shadow: var(--shadow); transition: border-color .18s, box-shadow .18s, transform .18s; }
.home-tool-card::after { content: ''; position: absolute; right: -34px; bottom: -48px; width: 130px; height: 130px; border-radius: 50%; background: var(--brand-soft); opacity: .65; pointer-events: none; }
.home-tool-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 34%, var(--line)); box-shadow: var(--shadow-lg); }
.home-tool-card .math-home-icon { width: 46px; height: 46px; border-radius: 13px; }
.home-tool-card .home-tool-copy { flex: 1 1 calc(100% - 64px); min-width: 0; }
.home-tool-card .home-tool-copy p { margin-top: 5px; line-height: 1.45; }
.home-tool-actions { flex: 1 0 100%; align-self: flex-end; position: relative; z-index: 1; padding-top: 2px; }
@media (max-width: 760px) { .home-tools { grid-template-columns: 1fr; } .home-tool-card { min-height: 0; } }
@media (max-width: 460px) { .home-tool-card { padding: 18px; } .home-tool-actions .btn { flex: 1; } }
.math-page textarea#m-problem { font-size: 1.15rem; line-height: 1.5; }
.math-keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.math-key { min-width: 44px; height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.math-key:hover { border-color: var(--brand); color: var(--brand); }
.math-key:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; }
.math-examples .chip { font-size: .9rem; }
.math-problem { font-size: 1.3rem; overflow-wrap: anywhere; }
.math-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.math-step { position: relative; padding: 12px 14px 12px 52px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: grid; gap: 4px; counter-increment: step; }
.math-step::before { content: counter(step); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: .9rem; }
.math-step.new { border-color: var(--brand); }
@media (prefers-reduced-motion: no-preference) { .math-step.new { animation: math-in .25s ease-out; } }
@keyframes math-in { from { opacity: 0; transform: translateY(6px); } }
.math-work { font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.math-answer { display: grid; gap: 4px; padding: 16px 18px; border-radius: 14px; background: var(--good-soft, var(--brand-soft)); border: 2px solid var(--good, var(--brand)); }
.math-answer b { font-size: 1.5rem; overflow-wrap: anywhere; }
.math-graph { border: 1px solid var(--line, rgba(127,127,127,.22)); border-radius: 14px; padding: 10px 14px; }
.math-graph > summary { cursor: pointer; }
.math-graph-body { margin-top: 10px; }
.math-canvas { display: block; width: 100%; height: 300px; }
.math-msg { padding: 10px 14px; border-radius: 14px; max-width: 90%; overflow-wrap: anywhere; }
.math-msg.user { justify-self: end; background: var(--brand); color: var(--on-brand); }
.math-msg.assistant { justify-self: start; background: var(--surface-2); border: 1px solid var(--line); }
.math-msg p { margin: 0; }
.math-chat #mc-list { display: grid; }
.panel-inset { padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.math-lost-tip { display: grid; gap: 4px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.math-lost-tip .linklike { justify-self: start; }
.math-hint { padding: 12px 14px; border-radius: 12px; border: 2px dashed var(--brand); background: var(--brand-soft); display: grid; gap: 4px; }
.math-lost { justify-self: start; margin-top: 2px; }
.math-simpler { margin-top: 6px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border-left: 4px solid var(--brand); }
.math-simpler p, .math-simpler ul, .math-simpler ol { margin: 0 0 6px; }
.math-step.wrong { border-color: var(--bad); border-width: 2px; }
.math-mistake { display: grid; gap: 6px; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.math-mistake b svg { vertical-align: -3px; }
.math-mistake s { text-decoration-color: var(--bad); text-decoration-thickness: 2px; }
.math-mistake.good { border-color: var(--good); background: var(--good-soft); }
.math-mistake p { margin: 0; }
.math-words summary { cursor: pointer; }
.math-words dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; }
.math-words dt { font-weight: 800; }
.math-words dd { margin: 0; color: var(--ink-2); }
@media (max-width: 560px) { .math-words dl { grid-template-columns: 1fr; } .math-words dd { margin-bottom: 6px; } }
.math-concept ul { margin: 4px 0 0; padding-left: 20px; }
.math-example { padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.math-tabs { align-self: flex-start; }
.math-tabs .tab { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.math-checked { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--good); font-weight: 600; }
.math-mix { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.math-mix > div { flex: 1; min-width: 200px; }
.math-mix h2, .h-group { font-size: 1.15rem; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.topic-card { display: grid; gap: 6px; align-content: start; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; }
.topic-card:hover { border-color: var(--brand); }
@media (prefers-reduced-motion: no-preference) { .topic-card:hover { transform: translateY(-1px); } }
.topic-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topic-card .bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.topic-card .bar i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.lv-dots { display: inline-flex; gap: 3px; }
.lv-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--line-strong); }
.lv-dots i.on { background: var(--brand); border-color: var(--brand); }
.practice-q { font-size: 1.6rem; line-height: 1.4; }
.practice #pr-in { font-size: 1.2rem; }
.practice-steps summary { cursor: pointer; margin-bottom: 8px; }
.practice-score { font-family: var(--display); font-weight: 800; color: var(--brand); }
.practice-score b { font-size: 4rem; line-height: 1; }
.practice-score span { font-size: 1.6rem; color: var(--ink-3); }

/* AI loading */
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; flex-shrink: 0; }
.spinner.lg { width: 30px; height: 30px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.ai-loading { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 14px; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); margin-top: 12px; }
.ai-loading b { font-size: 1.02rem; }
.ai-loading .bar { margin-top: 6px; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--brand) 18%, var(--surface-2)); overflow: hidden; }
.ai-loading .bar i { display: block; height: 100%; width: 40%; background: var(--brand); border-radius: 99px; animation: ai-bar 1.4s ease-in-out infinite; }
@keyframes ai-bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .ai-loading .bar i { animation: none; width: 60%; } }

/* StudyPass AI: floating assistant button + chat panel */
.sp-ai-btn {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; border: none; border-radius: 999px;
  background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: .95rem; cursor: pointer;
  box-shadow: 0 6px 20px -6px rgba(0,0,0,.4); transition: transform .12s, box-shadow .12s;
}
.sp-ai-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -6px rgba(0,0,0,.45); }
.sp-ai-btn.on { transform: scale(.96); }
.sp-ai-panel {
  position: fixed; right: 16px; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); z-index: 61;
  width: min(380px, calc(100vw - 24px)); max-height: min(72vh, 620px); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 18px;
  box-shadow: 0 18px 50px -12px rgba(0,0,0,.55); overflow: hidden;
}
.sp-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line); }
.sp-ai-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sp-ai-msg { max-width: 88%; padding: 9px 13px; border-radius: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.sp-ai-msg.user { align-self: flex-end; background: var(--brand); color: var(--on-brand); }
.sp-ai-msg.bot { align-self: flex-start; background: var(--surface-2); }
.sp-ai-msg.bot p:first-child { margin-top: 0; } .sp-ai-msg.bot p:last-child { margin-bottom: 0; }
.sp-ai-hello { color: var(--ink-2); display: grid; gap: 12px; }
.sp-ai-starters { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-ai-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.sp-ai-form .input { flex: 1; }
.sp-ai-form .btn-primary { flex-shrink: 0; }
@media (max-width: 480px) {
  .sp-ai-btn span { display: none; } .sp-ai-btn { padding: 13px; }
  .sp-ai-panel { right: 8px; left: 8px; width: auto; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); max-height: 76vh; }
}
.sp-ai-form textarea.input { resize: none; min-height: 0; height: auto; max-height: 120px; overflow-y: auto; line-height: 1.4; }
.sp-ai-note { margin: 0; padding: 2px 12px 10px; font-size: .72rem; color: var(--ink-3); text-align: center; }
.sp-ai-msg.bot { display: flex; flex-direction: column; }
.sp-ai-copy { align-self: flex-end; margin-top: 8px; display: inline-flex; align-items: center; padding: 3px 7px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink-3); cursor: pointer; }
.sp-ai-copy:hover { color: var(--brand); border-color: var(--brand); }
.badge-adv { display: inline-flex; align-items: center; gap: 3px; background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent); }

/* Profile photo frames (a ring/glow around the avatar) + the picker in Settings */
.avatar.frame-coral, .avatar-img.frame-coral { box-shadow: 0 0 0 3px #f2542d; }
.avatar.frame-ocean, .avatar-img.frame-ocean { box-shadow: 0 0 0 3px #2f6df2; }
.avatar.frame-grape, .avatar-img.frame-grape { box-shadow: 0 0 0 3px #a855f7; }
.avatar.frame-forest, .avatar-img.frame-forest { box-shadow: 0 0 0 3px #14935f; }
.avatar.frame-gold, .avatar-img.frame-gold { box-shadow: 0 0 0 3px #f5b400; }
.avatar.frame-rose, .avatar-img.frame-rose { box-shadow: 0 0 0 3px #ec4899; }
.avatar.frame-glow, .avatar-img.frame-glow { box-shadow: 0 0 0 3px #f5b400, 0 0 11px 1px rgba(245,180,0,.6); }
.avatar.frame-neon, .avatar-img.frame-neon { box-shadow: 0 0 0 3px #22d3ee, 0 0 11px 1px rgba(34,211,238,.65); }
.frame-pick { background: none; border: 2px solid transparent; border-radius: 50%; padding: 5px; cursor: pointer; line-height: 0; transition: border-color .12s; }
.frame-pick:hover { border-color: var(--ink-3); }
.frame-pick.on { border-color: var(--brand); }

/* Avatar cropper (pick which part of the photo shows) */
.crop-wrap { display: grid; gap: 14px; justify-items: center; }
.crop-view { position: relative; width: 260px; height: 260px; overflow: hidden; border-radius: 14px; background: #000; touch-action: none; cursor: grab; user-select: none; }
.crop-view:active { cursor: grabbing; }
.crop-view img { position: absolute; top: 0; left: 0; max-width: none; -webkit-user-drag: none; user-select: none; }
.crop-mask { position: absolute; inset: 0; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.45); }
.crop-zoom { display: flex; align-items: center; gap: 12px; width: 260px; }
.crop-zoom input { flex: 1; }

/* "Add to Home Screen" banner */
.install-bar { background: var(--brand-soft); border-bottom: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); }
.install-in { max-width: 960px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.install-icon { color: var(--brand); flex-shrink: 0; display: inline-flex; }
.install-text { flex: 1; min-width: 0; font-size: .9rem; line-height: 1.4; color: var(--ink); }
.install-text b { font-weight: 700; }
.install-share { vertical-align: -3px; margin: 0 1px; }
.install-bar .btn { flex-shrink: 0; }
.install-x { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 5px; border-radius: 8px; flex-shrink: 0; display: inline-flex; }
.install-x:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
@media (max-width: 520px) { .install-in { flex-wrap: wrap; } .install-text { flex-basis: 100%; order: -1; } }

/* ---------- Listen mode ---------- */
.listen-card { display: flex; flex-direction: column; gap: 14px; padding: 24px; text-align: center; transition: box-shadow .2s, border-color .2s; }
.listen-card.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.listen-side .side { display: block; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.listen-side .txt { font-size: 1.25rem; line-height: 1.4; overflow-wrap: anywhere; }
.listen-card hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; }
.listen-nav { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.listen-nav .btn-lg { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- Weak spots ---------- */
.home-weak { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-weight: 600; color: var(--brand); text-decoration: none; }
.home-weak:hover { text-decoration: underline; }
.weak-sets { display: flex; flex-wrap: wrap; gap: 8px; }
.weak-set-chip b { margin-left: 4px; color: var(--brand); }
.weak-list { display: flex; flex-direction: column; gap: 8px; }
.weak-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.weak-card summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.weak-card summary::-webkit-details-marker { display: none; }
.weak-card .wc-term { font-weight: 600; overflow-wrap: anywhere; flex: 1; min-width: 0; }
.weak-card .wc-miss { flex-shrink: 0; font-size: .78rem; font-weight: 700; color: #c0392b; background: color-mix(in srgb, #c0392b 12%, transparent); padding: 2px 8px; border-radius: 999px; }
.weak-card[open] summary { border-bottom: 1px solid var(--line); }
.wc-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.wc-def { color: var(--ink-2); overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .listen-card { padding: 18px 16px; }
  .listen-side .txt { font-size: 1.12rem; }
  .listen-nav { gap: 10px; }
}

/* ---------- Flagged AI misuse (admin feed) ---------- */
.ai-item-flag { border-color: color-mix(in srgb, #c0392b 55%, var(--line)); background: color-mix(in srgb, #c0392b 6%, var(--surface)); }
.badge-flag { background: color-mix(in srgb, #c0392b 14%, transparent); color: #c0392b; display: inline-flex; align-items: center; gap: 4px; }
.badge-flag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------- Sofia's sparkle theme (opt-in, Sofia/admin only) ---------- */
html.sofia-fx { --fx: var(--sofia-fx, #fd9db8); }
/* A soft, living gradient wash behind everything */
html.sofia-fx body {
  background:
    radial-gradient(1100px 560px at 8% -12%, color-mix(in srgb, var(--fx) 24%, transparent), transparent 60%),
    radial-gradient(1000px 520px at 112% 8%, color-mix(in srgb, var(--fx) 16%, transparent), transparent 55%),
    var(--bg);
  /* No background-attachment:fixed — it janks on iOS Safari; the fixed ::before gives the steady wash. */
}
html.sofia-fx body::before {
  content: ""; position: fixed; inset: -25%; z-index: -2; pointer-events: none;
  background: radial-gradient(38% 38% at 50% 50%, color-mix(in srgb, var(--fx) 15%, transparent), transparent 70%);
  animation: sofiaDrift 20s ease-in-out infinite alternate;
}
@keyframes sofiaDrift { from { transform: translate(-6%, -4%) scale(1); } to { transform: translate(6%, 5%) scale(1.18); } }
/* Twinkling sparkles */
html.sofia-fx body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20% 30%, var(--fx), transparent),
    radial-gradient(2px 2px at 70% 18%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 42% 72%, var(--fx), transparent),
    radial-gradient(2px 2px at 86% 58%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 44%, var(--fx), transparent),
    radial-gradient(2px 2px at 14% 82%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 92% 30%, var(--fx), transparent);
  background-repeat: no-repeat;
  animation: sofiaTwinkle 4.5s ease-in-out infinite;
}
@keyframes sofiaTwinkle { 0%, 100% { opacity: .25; } 50% { opacity: .7; } }
/* Pink chat bubbles for her own messages. Always a LIGHT tint of her color so the dark text stays
   readable even if she picks a dark custom color. */
html.sofia-fx .chat-bubble.user {
  background: linear-gradient(135deg, color-mix(in srgb, var(--fx) 60%, #fff), color-mix(in srgb, var(--fx) 34%, #fff));
  color: #3a2230; box-shadow: 0 2px 12px color-mix(in srgb, var(--fx) 28%, transparent);
}
html.sofia-fx .chat-bubble.user a { color: #7a1f4a; }
/* An exclusive glowing avatar ring */
html.sofia-fx .avatar {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--fx) 92%, #fff), 0 0 10px color-mix(in srgb, var(--fx) 60%, transparent);
}
html.sofia-fx .topbar { background: color-mix(in srgb, var(--fx) 12%, var(--surface)); }
/* Respect reduce motion: keep the look, stop the movement */
html.sofia-fx.reduce-motion body::before, html.sofia-fx.reduce-motion body::after { animation: none; }
@media (prefers-reduced-motion: reduce) { html.sofia-fx body::before, html.sofia-fx body::after { animation: none; } }

/* ---------- A personal note from an admin (e.g. for Sofia) — now a little two-way thread ---------- */
.home-note { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); margin-bottom: 18px; }
.home-note-head { display: flex; align-items: center; gap: 10px; }
.home-note-head b { color: var(--brand); flex: 1; min-width: 0; }
.home-note-ic { flex-shrink: 0; color: var(--brand); display: inline-flex; }
.home-note-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.home-note-x { flex-shrink: 0; background: none; border: 0; cursor: pointer; color: var(--ink-3); padding: 6px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.home-note-x:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.home-note-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.home-note-thread, .note-thread-admin { display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }
.note-thread-admin { margin: 6px 0 12px; }
.note-msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; }
.note-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-msg.theirs { align-self: flex-start; background: color-mix(in srgb, var(--brand) 16%, var(--surface)); border-bottom-left-radius: 5px; }
.note-msg.mine { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.note-msg-who { display: block; font-size: .72rem; font-weight: 700; opacity: .75; margin-bottom: 2px; }
.home-note-reply { display: flex; gap: 8px; align-items: center; }
.home-note-reply .input { flex: 1; min-width: 0; }

/* ---------- Note popup (a little on-screen popup of an admin's note, auto-closes) ---------- */
.note-pop { position: fixed; top: calc(var(--header-h, 56px) + 12px); right: 16px; z-index: 60; max-width: min(340px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--brand) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--line));
  box-shadow: 0 12px 34px rgba(0,0,0,.22); opacity: 0; transform: translateY(-10px); transition: opacity .25s, transform .25s; }
.note-pop.in { opacity: 1; transform: translateY(0); }
.note-pop-ic { flex-shrink: 0; color: var(--brand); display: inline-flex; margin-top: 1px; }
.note-pop-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.note-pop-body { min-width: 0; flex: 1; }
.note-pop-body b { color: var(--brand); display: block; }
.note-pop-body p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.note-pop-x { flex-shrink: 0; background: none; border: 0; cursor: pointer; color: var(--ink-3); padding: 6px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.note-pop-x:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.note-pop-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
@media (max-width: 560px) {
  .note-pop { left: 12px; right: 12px; max-width: none; top: calc(var(--header-h, 56px) + 8px); padding: 13px 14px; }
  /* Comfortable tap targets for the close buttons on touch screens. */
  .note-pop-x, .home-note-x { min-width: 40px; min-height: 40px; margin: -4px -6px -4px 0; }
}

/* Photo a user sent the AI, shown in the admin AI activity feed */
.ai-photo { display: block; margin-top: 8px; max-width: 180px; max-height: 180px; width: auto; border-radius: 10px; border: 1px solid var(--line); }
@media (max-width: 560px) { .ai-photo { max-width: 100%; max-height: 240px; } }

/* ---------- Tools page (graph & analyze, calculator, formula finder) ---------- */
.g-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.g-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.g-stat b { display: block; font-size: 1.15rem; font-family: var(--display, inherit); overflow-wrap: anywhere; }
.g-stat span { color: var(--ink-3); font-size: .8rem; }
.calc-result { font-size: 1.25rem; font-weight: 700; font-family: var(--display, inherit); overflow-wrap: anywhere; min-width: 0; }
.formula-main { font-size: 1.5rem; font-weight: 700; text-align: center; padding: 10px; overflow-wrap: anywhere; font-family: var(--display, inherit); }

/* ===================== Phantom Chat (Persona 5-styled messenger) ===================== */
body.phantom-mode .topbar, body.phantom-mode .site-footer, body.phantom-mode .offline-bar,
body.phantom-mode .announce, body.phantom-mode .demo-bar { display: none !important; }
body.phantom-mode { background: #090909; }
body.phantom-mode .wrap { max-width: none; padding: 0; gap: 0; display: block; }
.p5-app { position: fixed; inset: 0 auto auto 0; width: 100%; height: var(--chat-window-height, 100dvh); display: flex; flex-direction: column; background: #0a0a0a; color: #fff; font-family: 'Figtree', system-ui, sans-serif; overflow: hidden; }
.p5-app::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, transparent 0 60px, rgba(227,6,19,.055) 60px 62px); pointer-events: none; z-index: 0; }
.p5-loading, .p5-empty, .p5-sayhi { color: #e30613; font-family: 'Anton', sans-serif; letter-spacing: 1px; text-align: center; margin: auto; padding: 30px; position: relative; z-index: 1; }
.p5-top { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 16px 22px; background: #e30613; color: #fff; clip-path: polygon(0 0, 100% 0, 100% 76%, 0 100%); z-index: 3; }
.p5-logo { font-size: 1.6rem; line-height: 1; }
.p5-wordmark { font-family: 'Anton', sans-serif; font-size: 1.75rem; letter-spacing: 2px; margin: 0; font-weight: 400; }
.p5-wordmark em { font-style: normal; -webkit-text-stroke: 2px #fff; color: #e30613; margin-left: 2px; }
.p5-convo-top { padding: 14px max(112px, calc((100vw - 980px) / 2 + 112px)) 14px max(16px, calc((100vw - 980px) / 2)); gap: 10px; background: #0c0c0c; clip-path: none; border-bottom: 4px solid #e30613; }
.p5-sayhi { color: #fff !important; text-shadow: 2px 2px 0 #000; }
.p5-name { font-family: 'Anton', sans-serif; font-size: clamp(1.05rem, 5.2vw, 1.5rem); letter-spacing: 1px; margin: 0; font-weight: 400; text-transform: uppercase; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p5-head-person { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.p5-presence { color: #aeb5c0; font-size: .64rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p5-presence.online { color: #56df8e; }
.p5-back { color: #fff; font-size: 1.5rem; text-decoration: none; line-height: 1; }
.p5-ava { display: inline-block; width: 46px; height: 46px; flex-shrink: 0; }
.p5-ava.sm { width: 40px; height: 40px; }
.p5-ava img.avatar, .p5-ava img { width: 100%; height: 100%; object-fit: cover; border: 2px solid #000; clip-path: polygon(12% 0, 100% 0, 88% 100%, 0 100%); background: #000; }
.p5-ava span.avatar { width: 100% !important; height: 100% !important; border-radius: 0 !important; display: flex; align-items: center; justify-content: center; font-family: 'Anton', sans-serif; border: 2px solid #000; clip-path: polygon(12% 0, 100% 0, 88% 100%, 0 100%); }
.p5-contacts { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 1; }
.p5-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #141414; color: #fff; text-decoration: none; border-left: 5px solid #e30613; clip-path: polygon(0 0, 100% 0, 97% 100%, 0 100%); transition: transform .08s; }
.p5-card:active { transform: scale(.98); }
.p5-card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.p5-card-body b { font-family: 'Anton', sans-serif; font-weight: 400; letter-spacing: .5px; font-size: 1.1rem; }
.p5-card-last { color: #9a9a9a; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p5-unread { background: #e30613; color: #fff; font-family: 'Anton', sans-serif; min-width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; clip-path: polygon(15% 0, 100% 0, 85% 100%, 0 100%); padding: 0 6px; }
.p5-exit { align-self: center; color: #e30613; font-family: 'Anton', sans-serif; letter-spacing: 2px; text-decoration: none; padding: 16px; position: relative; z-index: 1; }
.p5-msgs { flex: 1; overflow-y: auto; padding: 36px max(24px, calc((100vw - 980px) / 2)) 28px; display: flex; flex-direction: column; gap: 20px; position: relative; z-index: 1;
  background-color: #b10d0d;
  background-image: radial-gradient(circle at 7% 20%, #fff 0 3px, transparent 3.5px), radial-gradient(circle at 9.5% 24%, #fff 0 1.6px, transparent 2px), radial-gradient(circle at 93% 62%, #fff 0 2.5px, transparent 3px), radial-gradient(circle at 5% 72%, #fff 0 2px, transparent 2.5px), radial-gradient(circle at 90% 88%, #fff 0 1.8px, transparent 2.3px), linear-gradient(118deg, rgba(0,0,0,.2) 0 16%, transparent 16.2%); }
.p5-row { display: flex; flex-direction: column; width: min(760px, 86%); max-width: 86%; position: relative; z-index: 1; }
.p5-stage { flex: 1; min-height: 0; position: relative; display: flex; }
.p5-stage > .p5-msgs { flex: 1; min-width: 0; }
.p5-frame { position: absolute; inset: 0; z-index: 2; pointer-events: none; box-shadow: inset 0 0 0 4px #000, inset 0 0 0 11px #fff, inset 0 0 0 14px #000; }
.p5-spine { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
/* incoming: slanted duotone portrait + black bubble with white/black outline and a lightning tail */
.p5-row.theirs { flex-direction: row; align-items: center; gap: 4px; align-self: flex-start; }
.p5-col { display: flex; flex-direction: column; min-width: 0; position: relative; }
.p5-portrait { flex-shrink: 0; width: 74px; height: 56px; background: #fff; padding: 3px; transform: skewX(-10deg) rotate(-4deg); box-shadow: 0 0 0 2px #000, 4px 4px 0 #000; overflow: hidden; }
.p5-row.theirs:nth-child(2n) .p5-portrait { transform: skewX(-10deg) rotate(3deg); }
.p5-portrait-in { display: block; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(115deg, #f4ee27 0 58%, #d6cf18 58% 100%); }
.p5-portrait .avatar { width: 100% !important; height: 100% !important; border-radius: 0 !important; border: 0 !important; box-shadow: none !important; transform: skewX(10deg) scale(1.25); display: flex; align-items: center; justify-content: center; }
.p5-portrait img.avatar { object-fit: cover; filter: grayscale(1) contrast(1.5) brightness(1.05); mix-blend-mode: multiply; background: transparent; }
.p5-portrait span.avatar { background: transparent !important; color: #0c0c0c; font-family: 'Anton', sans-serif; font-size: 30px !important; }
.p5-bwrap { position: relative; margin-left: 15px; filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(2px 0 0 #000) drop-shadow(-2px 0 0 #000) drop-shadow(0 2px 0 #000) drop-shadow(0 -2px 0 #000) drop-shadow(5px 6px 0 rgba(0,0,0,.55)); }
.p5-bwrap::before { content: ''; position: absolute; left: -17px; top: 50%; width: 20px; height: 26px; margin-top: -13px; background: #0c0c0c; clip-path: polygon(100% 8%, 45% 30%, 62% 44%, 0 52%, 52% 62%, 34% 80%, 100% 92%); }
.p5-bubble { padding: 14px 20px; font-weight: 800; font-size: 1rem; line-height: 1.3; letter-spacing: .2px; white-space: pre-wrap; overflow-wrap: anywhere; background: #0c0c0c; color: #fff; clip-path: polygon(3% 0, 100% 0, 97% 100%, 0 100%); }
.p5-row.theirs:nth-child(2n) .p5-bwrap { transform: rotate(-1deg); }
.p5-row.theirs:nth-child(2n+1) .p5-bwrap { transform: rotate(.7deg); }
.p5-q { position: absolute; right: 2px; top: -27px; z-index: 2; font-family: 'Anton', sans-serif; font-size: 2.1rem; color: #fff; line-height: 1; transform: rotate(12deg); -webkit-text-stroke: 3px #000; paint-order: stroke fill; text-shadow: 3px 3px 0 #000; pointer-events: none; }
/* outgoing: white box with black edge + jagged tail, black text */
.p5-row.mine { align-self: flex-end; align-items: flex-end; margin-right: 14px; }
.p5-rwrap { position: relative; filter: drop-shadow(3px 0 0 #000) drop-shadow(-3px 0 0 #000) drop-shadow(0 3px 0 #000) drop-shadow(0 -3px 0 #000) drop-shadow(5px 6px 0 rgba(0,0,0,.45)); }
.p5-rwrap::after { content: ''; position: absolute; right: -16px; top: 50%; width: 20px; height: 24px; margin-top: -12px; background: #fff; clip-path: polygon(0 10%, 55% 32%, 40% 46%, 100% 52%, 46% 62%, 64% 80%, 0 90%); }
.p5-ribbon { padding: 14px 26px; background: #fff; color: #0c0c0c; font-weight: 800; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 100%); }
.p5-row.mine:nth-child(2n) .p5-rwrap { transform: rotate(.8deg); }
.p5-row.mine:nth-child(2n+1) .p5-rwrap { transform: rotate(-.6deg); }

/* the game's date stamp: big outlined M/D, weekday stamped across, time of day underneath */
.p5-datebadge { position: absolute; top: 4px; right: 6px; z-index: 5; width: 92px; height: 64px; pointer-events: none; transform: rotate(-6deg); font-family: 'Anton', sans-serif; }
.p5-date-md { position: absolute; top: -3px; left: 0; font-size: 2rem; line-height: 1; letter-spacing: -1px; color: #0c0c0c; -webkit-text-stroke: 6px #fff; paint-order: stroke fill; }
.p5-date-wd { position: absolute; top: 28px; left: 34px; font-size: .88rem; line-height: 1; letter-spacing: .5px; color: #0c0c0c; -webkit-text-stroke: 4px #fff; paint-order: stroke fill; transform: rotate(-12deg); }
.p5-date-tod { position: absolute; top: 47px; left: 2px; font-family: 'Figtree', sans-serif; font-weight: 800; font-style: italic; font-size: .78rem; line-height: 1; color: #fff; -webkit-text-stroke: 1.5px #0c0c0c; paint-order: stroke fill; text-shadow: 1px 1px 0 #e30613; transform: rotate(-12deg); white-space: nowrap; }
/* unread: the game's red "IM" speech-bubble icon with a little number badge */
.p5-imbadge { position: relative; flex-shrink: 0; width: 42px; height: 34px; margin: 6px 4px 0 0; background: #e30613; color: #fff; font-family: 'Anton', sans-serif; font-size: 1.05rem; letter-spacing: .5px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff; border-radius: 5px; box-shadow: 0 0 0 2px #000, 3px 3px 0 2px #000; transform: rotate(-6deg); }
.p5-imbadge::after { content: ''; position: absolute; bottom: -9px; left: 9px; width: 12px; height: 9px; background: #fff; clip-path: polygon(0 0, 100% 0, 15% 100%); }
.p5-imbadge-n { position: absolute; top: -11px; left: -11px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; background: #e30613; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #000; color: #fff; font-family: 'Figtree', sans-serif; font-weight: 800; font-size: .66rem; display: inline-flex; align-items: center; justify-content: center; }
.p5-stamp { font-size: .62rem; color: #fff; font-family: 'Anton', sans-serif; letter-spacing: 1px; margin: 7px 6px 0; text-shadow: 1px 1px 0 #000; }
.p5-read { font-size: .62rem; color: #fff; background: #000; font-family: 'Anton', sans-serif; letter-spacing: 2px; margin: 4px 2px 0; padding: 1px 8px; clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%); align-self: flex-end; }
.p5-actions { display: inline-flex; align-self: flex-end; gap: 5px; margin-top: 7px; }
.p5-actions button { border: 0; background: #111; color: #fff; padding: 4px 8px; font: 400 .65rem/1 'Anton', sans-serif; letter-spacing: 1px; cursor: pointer; clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%); }
.p5-actions button:last-child { background: #e30613; }
.p5-actions button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.p5-edited { align-self: flex-end; margin: 5px 4px -2px 0; color: #fff; font: 400 .58rem/1 'Anton', sans-serif; letter-spacing: 1px; text-shadow: 1px 1px 0 #000; }
.p5-img { max-width: min(220px, 62vw); max-height: 280px; display: block; cursor: zoom-in; clip-path: polygon(3% 0, 100% 0, 97% 100%, 0 100%); margin-bottom: 6px; }
.p5-video { width: min(360px, 68vw); max-height: 340px; display: block; background: #000; border: 3px solid #fff; box-shadow: 4px 4px 0 #000; margin-bottom: 8px; }
.p5-imtag { display: inline-flex; align-items: center; gap: 3px; background: #fff; color: #000; font-family: 'Anton', sans-serif; font-size: 1.35rem; padding: 0 9px 0 6px; height: 34px; transform: skewX(-10deg); box-shadow: 3px 3px 0 #e30613; flex-shrink: 0; }
.p5-imtag b { width: 7px; height: 22px; background: #e30613; display: inline-block; }
.p5-preview { padding: 8px 14px 0; position: relative; z-index: 2; }
.p5-typing { position: relative; z-index: 3; padding: 5px max(14px, calc((100vw - 980px) / 2)); background: #fff; color: #0c0c0c; border-top: 3px solid #0c0c0c; font-family: 'Anton', sans-serif; font-size: .75rem; letter-spacing: 1px; }
.p5-typing b { display: inline-flex; gap: 3px; margin-right: 7px; padding: 5px 9px; background: #0c0c0c; transform: skewX(-10deg); }
.p5-typing i { width: 6px; height: 6px; border-radius: 50%; background: #e30613; animation: dmTypingBounce 1s infinite ease-in-out; }
.p5-typing i:nth-child(2) { animation-delay: .14s; }
.p5-typing i:nth-child(3) { animation-delay: .28s; }
.p5-message-tools { display: flex; align-items: center; gap: 5px; min-height: 25px; margin-top: 5px; position: relative; z-index: 3; }
.p5-row.mine .p5-message-tools { justify-content: flex-end; }
.p5-heart { border: 2px solid #0c0c0c; min-width: 31px; height: 25px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; background: #fff; color: #777; font: inherit; font-family: 'Anton', sans-serif; cursor: pointer; transform: skewX(-9deg); box-shadow: 2px 2px 0 #0c0c0c; }
.p5-heart span { color: #e30613; font-family: sans-serif; font-size: 1rem; line-height: 1; }
.p5-heart b { font-size: .68rem; }
.p5-heart.has-heart, .p5-heart.on { background: #e30613; color: #fff; }
.p5-heart.has-heart span, .p5-heart.on span { color: #fff; }
.p5-heart:hover, .p5-heart:focus-visible { transform: skewX(-9deg) scale(1.06); outline: 2px solid #fff; outline-offset: 1px; }
.p5-prev { position: relative; display: inline-block; }
.p5-prev img { max-height: 80px; border: 2px solid #e30613; }
.p5-prev video { max-height: 120px; max-width: min(240px, 72vw); display: block; border: 2px solid #e30613; background: #000; }
.p5-prev-x { position: absolute; top: -10px; right: -10px; width: 24px; height: 24px; background: #e30613; color: #fff; border: 0; cursor: pointer; clip-path: polygon(15% 0, 100% 0, 85% 100%, 0 100%); }
.p5-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px max(12px, calc((100vw - 980px) / 2)) calc(10px + env(safe-area-inset-bottom)); background: #000; border-top: 3px solid #e30613; position: relative; z-index: 2; }
.p5-photo { flex-shrink: 0; width: 44px; height: 44px; background: #141414; color: #e30613; font-size: 1.7rem; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; clip-path: polygon(12% 0, 100% 0, 88% 100%, 0 100%); border: 2px solid #e30613; }
.p5-compose textarea { flex: 1; resize: none; max-height: 110px; background: #141414; color: #fff; border: 2px solid #333; padding: 10px 14px; font: inherit; font-weight: 600; }
.p5-compose textarea:focus { outline: none; border-color: #e30613; }
.p5-compose textarea::placeholder { color: #666; font-family: 'Anton', sans-serif; letter-spacing: 1px; }
.p5-send { flex-shrink: 0; width: 48px; height: 48px; background: #e30613; color: #fff; border: 0; font-size: 1.4rem; cursor: pointer; clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); }
.p5-send:active { transform: scale(.94); }
.p5-compose.sending { opacity: .7; pointer-events: none; }
@media (max-width: 700px) {
  .p5-convo-top { padding: 12px 92px 12px 12px; }
  .p5-msgs { padding: 30px 16px 22px; gap: 17px; }
  .p5-row { width: 92%; max-width: 92%; }
  .p5-portrait { width: 58px; height: 48px; }
  .p5-bubble, .p5-ribbon { padding: 12px 16px; }
  .p5-compose { padding: 8px 9px calc(8px + env(safe-area-inset-bottom)); }
}
.p5-denied { margin: auto; text-align: center; padding: 30px; position: relative; z-index: 1; }
.p5-denied-star { color: #e30613; font-size: 3rem; }
.p5-denied h1 { font-family: 'Anton', sans-serif; color: #e30613; letter-spacing: 3px; font-size: 2.4rem; margin: 6px 0; }
.p5-denied p { color: #aaa; }
.p5-btn { display: inline-block; margin-top: 16px; background: #e30613; color: #fff; font-family: 'Anton', sans-serif; letter-spacing: 2px; padding: 12px 26px; text-decoration: none; clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%); }

/* Kael + Sofia ending card. Somber and still; the saved history is left untouched. */
.p5-game-over { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; overflow: hidden; isolation: isolate; padding: 24px; background: #070809; color: #e9e9e9; }
.p5-game-over::before { content: ''; position: absolute; inset: 0; z-index: -2; opacity: .42; background: repeating-linear-gradient(105deg, transparent 0 52px, rgba(255,255,255,.025) 53px 54px), linear-gradient(180deg, #101114 0%, #070809 62%, #030303 100%); }
.p5-game-over::after { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at center, rgba(125,15,24,.13), transparent 48%); }
.p5-game-over-card { width: min(90vw, 620px); padding: clamp(28px, 6vw, 58px) 24px; text-align: center; border-top: 1px solid #64151b; border-bottom: 1px solid #64151b; background: rgba(7,8,9,.82); animation: p5SadFade 1.1s ease-out both; }
.p5-game-over-heart { position: relative; display: inline-block; margin-bottom: 24px; color: #8e1c25; font: 400 clamp(3rem, 9vw, 5rem)/1 serif; filter: grayscale(.2); }
.p5-game-over-heart::after { content: ''; position: absolute; left: 49%; top: 5%; width: 5px; height: 88%; background: #070809; transform: rotate(17deg); box-shadow: 5px 10px 0 #070809; }
.p5-game-over-card p { margin: 0 0 13px; color: #8f9299; font: 600 clamp(.72rem, 2vw, .9rem)/1 'Figtree', sans-serif; letter-spacing: .36em; }
.p5-game-over-card h2 { margin: 0; color: #d8d8d8; font: 400 clamp(3rem, 11vw, 6.6rem)/.95 'Anton', sans-serif; letter-spacing: .015em; text-shadow: 3px 4px 0 #26070a; }
.p5-game-over-sorry { display: block; margin-top: 25px; color: #a94950; font: 600 clamp(1rem, 3vw, 1.35rem)/1 'Figtree', sans-serif; letter-spacing: .24em; }
.p5-game-over-ended { display: block; margin-top: 13px; color: #656970; font: 600 clamp(.64rem, 1.7vw, .78rem)/1.4 'Figtree', sans-serif; letter-spacing: .15em; }
.p5-fresh { position: absolute; right: clamp(12px, 3vw, 34px); top: 50%; width: min(350px, 27vw); max-height: min(620px, 78vh); transform: translateY(-50%); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #333840; border-radius: 16px; background: rgba(17,19,23,.96); box-shadow: 0 20px 60px rgba(0,0,0,.45); text-align: left; }
.p5-fresh header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 15px; border-bottom: 1px solid #2d3036; }
.p5-fresh header div { display: flex; flex-direction: column; gap: 2px; }
.p5-fresh header b { font: 400 .92rem/1 'Anton', sans-serif; letter-spacing: .12em; color: #ddd; }
.p5-fresh header span { color: #737780; font-size: .7rem; }
.p5-fresh header i { color: #6f9b78; font: 700 .58rem/1 'Figtree', sans-serif; letter-spacing: .08em; font-style: normal; }
.p5-fresh-messages { min-height: 180px; max-height: 430px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding: 14px; }
.p5-fresh-empty { margin: auto; color: #666b73; font-size: .78rem; }
.p5-fresh-message { max-width: 86%; }
.p5-fresh-message.mine { align-self: flex-end; }
.p5-fresh-message.theirs { align-self: flex-start; }
.p5-fresh-message p { margin: 0; padding: 9px 11px; border-radius: 12px 12px 12px 3px; background: #292d34; color: #e6e6e6; font: 500 .86rem/1.35 'Figtree', sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.p5-fresh-message.mine p { border-radius: 12px 12px 3px 12px; background: #6d2027; }
.p5-fresh-message time { display: block; margin: 4px 3px 0; color: #666b73; font-size: .58rem; }
.p5-fresh-message.mine time { text-align: right; }
.p5-fresh-compose { display: flex; align-items: flex-end; gap: 7px; padding: 10px; border-top: 1px solid #2d3036; background: #0d0f12; }
.p5-fresh-compose textarea { min-width: 0; flex: 1; resize: none; max-height: 90px; padding: 9px 10px; border: 1px solid #343943; border-radius: 9px; outline: 0; background: #1b1e24; color: #eee; font: 500 .84rem/1.35 'Figtree', sans-serif; }
.p5-fresh-compose textarea:focus { border-color: #7d3339; }
.p5-fresh-compose button { flex: 0 0 auto; padding: 10px 9px; border: 0; border-radius: 8px; background: #712229; color: #fff; font: 700 .66rem/1 'Figtree', sans-serif; cursor: pointer; }
.p5-fresh-compose.sending { opacity: .65; pointer-events: none; }
@keyframes p5SadFade { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .p5-game-over-card { animation: none; } }
@media (max-width: 1280px) {
  .p5-game-over { align-content: start; overflow-y: auto; padding: 28px 14px; }
  .p5-game-over-card { width: min(94vw, 620px); padding: 25px 18px; }
  .p5-game-over-card h2 { font-size: clamp(2.7rem, 13vw, 5.2rem); }
  .p5-fresh { position: relative; right: auto; top: auto; width: min(94vw, 520px); max-height: 44vh; margin: 22px auto 0; transform: none; flex-shrink: 0; }
  .p5-fresh-messages { min-height: 120px; }
}

/* the new-message popup, restyled as a P5 notification while in Phantom Chat */
body.phantom-mode .note-pop { top: 84px; background: #0c0c0c; color: #fff; border: 3px solid #fff; border-radius: 0; box-shadow: 0 0 0 3px #000, 6px 6px 0 #e30613; transform: translateY(-10px) skewX(-4deg); }
body.phantom-mode .note-pop.in { transform: translateY(0) skewX(-4deg); }
body.phantom-mode .note-pop-body b { color: #e30613; font-family: 'Anton', sans-serif; font-weight: 400; letter-spacing: .5px; text-transform: uppercase; }
body.phantom-mode .note-pop-body p { color: #fff; font-weight: 700; }
body.phantom-mode .note-pop-ic, body.phantom-mode .note-pop-x { color: #fff; }

/* ---------- Admin: "See their account" (read-only) ---------- */
.adm-uv-row { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; text-decoration: none; color: inherit; min-width: 0; }
.adm-uv-row:hover { border-color: var(--brand); }
.adm-uv-row b { overflow-wrap: anywhere; }
button.adm-uv-row { text-align: left; font: inherit; cursor: pointer; width: 100%; }
.adm-transcript { display: flex; flex-direction: column; gap: 10px; }
.adm-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.adm-msg.them { align-self: flex-end; background: var(--brand-soft); }
.adm-msg.ai { align-self: flex-start; }
.adm-msg-who { font-size: .72rem; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.adm-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.adm-msg-img { max-width: min(260px, 70vw); max-height: 260px; border-radius: 10px; object-fit: cover; }
.adm-user-link { text-decoration: none; color: inherit; border-radius: 10px; }
.adm-user-link:hover b { color: var(--brand); text-decoration: underline; }
.chem-rule-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.chem-rule-grid article,.chem-memory-row>div{display:flex;flex-direction:column;gap:4px;padding:14px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2)}
.chem-rule-grid article span,.chem-memory-row p{margin:0;color:var(--muted);font-size:.9rem;line-height:1.45}
.chem-memory-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
@media(max-width:700px){.chem-rule-grid,.chem-memory-row{grid-template-columns:1fr}.chem-crash-course>.row{align-items:stretch!important}.chem-crash-course>.row .btn{width:100%}}
.chem-table-sheet{padding:12px}.chem-table-sheet>summary{cursor:pointer;list-style:none;display:flex;align-items:baseline;gap:8px}.chem-table-sheet>summary::-webkit-details-marker{display:none}.chem-table-sheet>summary:before{content:'▸';color:var(--brand);transition:transform .15s}.chem-table-sheet[open]>summary:before{transform:rotate(90deg)}
.chem-table-scroll{overflow-x:auto;margin-top:12px;padding:3px 2px 8px}.chem-table-grid{display:grid;grid-template-columns:24px repeat(18,52px);grid-template-rows:20px repeat(7,68px);gap:3px;min-width:1030px}.chem-group-no,.chem-period-no{display:grid;place-items:center;color:var(--ink-3);font-size:.72rem}.chem-el{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:0;padding:3px 2px;border:1px solid var(--line);border-radius:7px;background:var(--surface-2);line-height:1.05}.chem-el strong{font-size:1.1rem}.chem-el span{max-width:100%;overflow:hidden;text-overflow:ellipsis;font-size:.55rem}.chem-el small{font-size:.5rem;color:var(--ink-3)}.chem-el.liquid{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 13%,var(--surface-2))}.chem-el.gas{border-color:#f59e0b;background:color-mix(in srgb,#f59e0b 12%,var(--surface-2))}.chem-state-key{gap:14px;flex-wrap:wrap;margin-top:5px}
.chem-lewis-practice{display:grid;justify-items:center;gap:12px;padding:16px;border:1px solid var(--line);border-radius:16px;background:var(--surface-2)}
.chem-lewis-symbol{position:relative;display:grid;place-items:center;width:112px;height:112px;margin:12px;font-size:2.35rem;color:var(--ink);background:var(--surface);border:1px solid var(--line);border-radius:20px;box-shadow:var(--shadow-sm)}
.chem-lewis-symbol strong{line-height:1}.chem-lewis-dot{position:absolute;width:9px;height:9px;border-radius:50%;background:var(--brand)}
.chem-lewis-dot.top{top:10px}.chem-lewis-dot.right{right:10px}.chem-lewis-dot.bottom{bottom:10px}.chem-lewis-dot.left{left:10px}
.chem-lewis-dot.top.dot-1,.chem-lewis-dot.bottom.dot-3{left:calc(50% - 4px)}.chem-lewis-dot.right.dot-2,.chem-lewis-dot.left.dot-4{top:calc(50% - 4px)}
.chem-lewis-dot.top.dot-5{left:calc(50% + 10px)}.chem-lewis-dot.right.dot-6{top:calc(50% + 10px)}.chem-lewis-dot.bottom.dot-7{left:calc(50% + 10px)}.chem-lewis-dot.left.dot-8{top:calc(50% + 10px)}
#pr-result .chem-lewis-symbol{display:inline-grid;width:58px;height:58px;margin:0 8px;vertical-align:middle;font-size:1.35rem;border-radius:12px}#pr-result .chem-lewis-dot{width:6px;height:6px}#pr-result .chem-lewis-dot.top{top:5px}#pr-result .chem-lewis-dot.right{right:5px}#pr-result .chem-lewis-dot.bottom{bottom:5px}#pr-result .chem-lewis-dot.left{left:5px}
.chem-ai-note{padding:12px 14px;border:1px solid color-mix(in srgb,var(--brand) 35%,var(--line));border-radius:12px;background:color-mix(in srgb,var(--brand) 7%,var(--surface));line-height:1.5}
.chem-practice-page{width:min(1180px,100%);margin-inline:auto}.chem-practice-layout{display:grid;grid-template-columns:minmax(0,1fr) 220px;gap:16px;align-items:start}
.chem-practice-page .chem-table-scroll{padding-top:24px}
.chem-el.is-target{z-index:2;border-color:var(--brand);background:color-mix(in srgb,var(--brand) 24%,var(--surface));box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 28%,transparent);transform:scale(1.07)}
.chem-el.is-target:after{content:attr(data-target-label);position:absolute;top:-20px;padding:2px 5px;border-radius:5px;background:var(--brand);color:#fff;font-size:.48rem;font-weight:800;white-space:nowrap}
.chem-word-bank{position:sticky;top:82px;padding:16px;display:grid;gap:13px;max-height:calc(100vh - 100px);overflow:auto}.chem-word-bank h2{font-size:1.15rem}.chem-word-bank p{margin:0}.chem-word-bank details{display:grid;gap:8px}.chem-word-bank summary{cursor:pointer}.chem-word-list,.chem-roman-list{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}.chem-word-list span,.chem-roman-list span{padding:4px 7px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);font-size:.78rem}.chem-word-list span.is-needed{border-color:var(--brand);background:color-mix(in srgb,var(--brand) 13%,var(--surface));color:var(--brand);font-weight:800}
.chem-needed{display:grid;gap:8px;padding:12px;border:1px solid color-mix(in srgb,var(--brand) 42%,var(--line));border-radius:13px;background:color-mix(in srgb,var(--brand) 7%,var(--surface))}.chem-needed-head{display:flex;flex-direction:column;gap:5px}.chem-needed-row{display:grid;grid-template-columns:38px 1fr;gap:8px;align-items:center;padding:7px;border-radius:9px;background:var(--surface)}.chem-needed-row>strong{display:grid;place-items:center;min-height:34px;border:2px solid var(--brand);border-radius:8px;color:var(--brand);font-size:1.05rem}.chem-needed-row span{display:flex;min-width:0;flex-direction:column;gap:2px}.chem-needed-row small{color:var(--muted);line-height:1.25}
@media(max-width:900px){.chem-practice-layout{grid-template-columns:1fr}.chem-word-bank{position:static;max-height:none}.chem-word-bank details:not([open]) .chem-word-list{display:none}}

/* Sofia's quiet "which AI / what is new" note on the chat page */
.ai-note { margin: 4px 12px 0; font-size: .74rem; color: var(--ink-3); }
.ai-note-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-3); font: inherit; cursor: pointer; text-align: left; }
.ai-note-pill:hover { color: var(--ink-2); border-color: var(--line-strong); }
.ai-note-pill > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-note-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--a-sofia, var(--brand)); flex: none; }
.ai-note-dot[hidden] { display: none; }
.ai-note-chev { flex: none; transition: transform .15s; }
.ai-note.open .ai-note-chev { transform: rotate(180deg); }
.ai-note-body { margin-top: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-2); line-height: 1.45; }
.ai-note-body[hidden] { display: none; }
.ai-note-body ul { margin: 4px 0 6px; padding-left: 18px; }
@media (prefers-reduced-motion: reduce) { .ai-note-chev { transition: none; } }
@media (max-width: 520px) { .ai-note-pill { border-radius: 12px; } .ai-note-pill > span:nth-child(2) { white-space: normal; overflow: visible; } }
