/* ==========================================================================
   STA261 schedule styles

   1. Fonts (bundled in /fonts, only downloaded when a theme uses them)
   2. Theme tokens: colours, fonts, shapes. Every theme sets the same list.
   3. Components (in the "base" layer so theme decorations always win)
   4. Theme decorations (@scope, so a theme preview inside another theme
      only gets its own decorations)
   ========================================================================== */

/* ---------- 1. Fonts ---------- */

@font-face {
  font-family: "Fredoka Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url("/fonts/fredoka-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Nunito Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("/fonts/nunito-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Patrick Hand";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  size-adjust: 112%;
  src: url("/fonts/patrick-hand-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Grotesk Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url("/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Quicksand Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url("/fonts/quicksand-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("/fonts/press-start-2p-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "VT323";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  size-adjust: 128%;
  src: url("/fonts/vt323-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- 2. Theme tokens ---------- */

/* Clean (default). Also resets every token on any themed element, so a theme
   preview never inherits colours from the page's theme. */
:root,
[data-theme] {
  color-scheme: light;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-body);
  --display-weight: 680;

  --bg: #f5f6f8;
  --page-bg: var(--bg);
  --surface: #ffffff;
  --solid-surface: var(--surface);
  --surface-2: #eef0f3;
  --input-bg: var(--bg);
  --text: #14171c;
  --muted: #5b6471;
  --faint: #8a929d;
  --border: #e1e5ea;
  --accent: #2f5bea;
  --accent-hover: #2449c4;
  --accent-text: #ffffff;
  --danger: #c4302b;

  --header-bg: color-mix(in srgb, var(--bg) 88%, transparent);
  --code-bg: var(--text);
  --code-text: var(--bg);
  --tile-bg: var(--surface-2);
  --chip-on-bg: var(--text);
  --chip-on-text: var(--bg);
  --toast-bg: var(--text);
  --toast-text: var(--bg);
  --backdrop: rgb(10 12 16 / 0.45);
  --wheel-line: rgb(255 255 255 / 0.7);

  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  --shadow-lg: 0 20px 50px rgb(16 24 40 / 0.18);
  --btn-shadow: none;
  --radius: 14px;
  --radius-sm: 9px;
  --btn-radius: var(--radius-sm);
  --pill-radius: 999px;
  --bw: 1px;

  --t-assignment: #2f5bea;
  --t-quiz: #0f8a7e;
  --t-test: #c26a06;
  --t-exam: #c4302b;
  --t-activity: #7a4ae0;
  --t-other: #5f6b7a;
  --t-presentation: #b0306f;

  /* Little symbol shown before each type label ("none" = no symbol). */
  --i-assignment: none;
  --i-quiz: none;
  --i-test: none;
  --i-exam: none;
  --i-activity: none;
  --i-other: none;
  --i-presentation: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]),
  [data-theme="clean"] {
    color-scheme: dark;
    --bg: #0e1014;
    --surface: #171a20;
    --surface-2: #20242c;
    --text: #e9ecf1;
    --muted: #a3abb7;
    --faint: #737c88;
    --border: #2a2f38;
    --accent: #6d8dff;
    --accent-hover: #8aa3ff;
    --accent-text: #0b1020;
    --danger: #ff7b72;
    --backdrop: rgb(0 0 0 / 0.6);
    --wheel-line: rgb(0 0 0 / 0.35);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 20px 50px rgb(0 0 0 / 0.55);
    --t-assignment: #7d9bff;
    --t-quiz: #3cc9b7;
    --t-test: #f0a347;
    --t-exam: #ff7b72;
    --t-activity: #b394ff;
    --t-other: #9aa6b5;
    --t-presentation: #f27bb6;
  }
}

/* Bubblegum: kawaii pastels, cocoa outlines, sparkles. */
[data-theme="bubblegum"] {
  color-scheme: light;
  --font-body: "Nunito Variable", system-ui, sans-serif;
  --font-display: "Fredoka Variable", "Nunito Variable", system-ui, sans-serif;
  --display-weight: 600;
  --bg: #fff4f9;
  --page-bg:
    radial-gradient(circle at 8% 0%, #ffd6ea 0, transparent 42%) fixed,
    radial-gradient(circle at 96% 22%, #e6dbff 0, transparent 38%) fixed,
    radial-gradient(circle at 40% 105%, #d3f4ea 0, transparent 45%) fixed,
    radial-gradient(#f6c3da 1.3px, transparent 1.5px) 0 0 / 22px 22px,
    #fff4f9;
  --surface: #ffffff;
  --solid-surface: #ffffff;
  --surface-2: #fff0f7;
  --input-bg: #fffafd;
  --text: #4a2b3d;
  --muted: #86587a;
  --faint: #b48da0;
  --border: #f6cfe0;
  --accent: #ff63a5;
  --accent-hover: #f24b94;
  --accent-text: #ffffff;
  --danger: #dc3b66;
  --header-bg: rgb(255 244 249 / 0.82);
  --code-bg: linear-gradient(135deg, #ff8cc0, #b08cff);
  --code-text: #ffffff;
  --tile-bg: #fff0f7;
  --chip-on-bg: #ff63a5;
  --chip-on-text: #ffffff;
  --toast-bg: #4a2b3d;
  --toast-text: #ffffff;
  --backdrop: rgb(74 43 61 / 0.35);
  --wheel-line: #ffffff;
  --shadow: 0 4px 0 #f6cfe0;
  --shadow-lg: 0 24px 60px rgb(255 99 165 / 0.25);
  --btn-shadow: 0 3px 0 #f2c3d8;
  --radius: 22px;
  --radius-sm: 14px;
  --btn-radius: 999px;
  --bw: 2px;
  --t-assignment: #f04f97;
  --t-quiz: #22a595;
  --t-test: #ea7d2c;
  --t-exam: #dc3b66;
  --t-activity: #8f64e3;
  --t-other: #9a7389;
  --t-presentation: #2a8fd6;
  --i-assignment: "📝";
  --i-quiz: "✏️";
  --i-test: "🧪";
  --i-exam: "🎓";
  --i-activity: "📚";
  --i-other: "📌";
  --i-presentation: "🎤";
}

/* Notebook: sticky notes and washi tape on graph paper. */
[data-theme="notebook"] {
  color-scheme: light;
  --font-body: "Nunito Variable", system-ui, sans-serif;
  --font-display: "Patrick Hand", "Comic Sans MS", cursive;
  --display-weight: 400;
  --bg: #fbf8ef;
  --page-bg:
    linear-gradient(#dfe8f5 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, #dfe8f5 1px, transparent 1px) 0 0 / 26px 26px,
    #fbf8ef;
  --surface: #fffdf6;
  --solid-surface: #fffdf6;
  --surface-2: #f2eddd;
  --input-bg: #ffffff;
  --text: #2b2a35;
  --muted: #5a5866;
  --faint: #868391;
  --border: #d8d0b8;
  --accent: #2b5fd9;
  --accent-hover: #1f4bb5;
  --accent-text: #ffffff;
  --danger: #cf3029;
  --header-bg: rgb(251 248 239 / 0.92);
  --code-bg: #2b5fd9;
  --code-text: #ffffff;
  --tile-bg: rgb(255 255 255 / 0.65);
  --chip-on-bg: #2b2a35;
  --chip-on-text: #fffdf6;
  --toast-bg: #2b2a35;
  --toast-text: #fffdf6;
  --backdrop: rgb(43 42 53 / 0.4);
  --wheel-line: #2b2a35;
  --shadow: 1px 2px 0 rgb(0 0 0 / 0.05), 0 12px 18px -12px rgb(80 60 10 / 0.45);
  --shadow-lg: 0 18px 40px rgb(80 60 10 / 0.25);
  --radius: 4px;
  --radius-sm: 6px;
  --bw: 1.5px;
  --t-assignment: #c99700;
  --t-quiz: #1c8f63;
  --t-test: #e06b10;
  --t-exam: #cf3029;
  --t-activity: #6f4fd0;
  --t-other: #6f7787;
  --t-presentation: #c0407a;
}

/* Pop: neo-brutalism. Thick outlines, hard shadows, loud colours. */
[data-theme="pop"] {
  color-scheme: light;
  --font-body: "Space Grotesk Variable", system-ui, sans-serif;
  --font-display: "Space Grotesk Variable", system-ui, sans-serif;
  --display-weight: 700;
  --bg: #fff3d1;
  --page-bg: radial-gradient(rgb(17 17 17 / 0.14) 1.3px, transparent 1.5px) 0 0 / 20px 20px, #fff3d1;
  --surface: #ffffff;
  --solid-surface: #ffffff;
  --surface-2: #fff3d1;
  --input-bg: #ffffff;
  --text: #111111;
  --muted: #3a3a3a;
  --faint: #555555;
  --border: #111111;
  --accent: #ff5ca8;
  --accent-hover: #ff3d95;
  --accent-text: #111111;
  --danger: #d61f1f;
  --header-bg: #ffd23f;
  --code-bg: #111111;
  --code-text: #ffd23f;
  --tile-bg: #ffd23f;
  --chip-on-bg: #111111;
  --chip-on-text: #ffffff;
  --toast-bg: #111111;
  --toast-text: #ffd23f;
  --backdrop: rgb(17 17 17 / 0.5);
  --wheel-line: #111111;
  --shadow: 4px 4px 0 #111111;
  --shadow-lg: 8px 8px 0 #111111;
  --btn-shadow: 3px 3px 0 #111111;
  --radius: 12px;
  --radius-sm: 10px;
  --bw: 2.5px;
  --t-assignment: #5b86ff;
  --t-quiz: #00c9a7;
  --t-test: #ffa41b;
  --t-exam: #ff5252;
  --t-activity: #a86bff;
  --t-other: #b4b4b4;
  --t-presentation: #ff7ac8;
}

/* Galaxy: dreamy night sky with twinkling stars. */
[data-theme="galaxy"] {
  color-scheme: dark;
  --font-body: "Quicksand Variable", system-ui, sans-serif;
  --font-display: "Quicksand Variable", system-ui, sans-serif;
  --display-weight: 700;
  --bg: #0b0a24;
  --page-bg:
    radial-gradient(1px 1px at 25px 35px, #ffffffcc 50%, transparent 55%) 0 0 / 160px 160px,
    radial-gradient(1.5px 1.5px at 110px 80px, #ffffff 50%, transparent 55%) 0 0 / 160px 160px,
    radial-gradient(1px 1px at 70px 140px, #d7c8ffcc 50%, transparent 55%) 0 0 / 160px 160px,
    radial-gradient(1.2px 1.2px at 150px 15px, #ffd6f5 50%, transparent 55%) 0 0 / 160px 160px,
    radial-gradient(ellipse at 10% -5%, #3b1d7a 0, transparent 55%) fixed,
    radial-gradient(ellipse at 105% 55%, #5a1b6b 0, transparent 50%) fixed,
    radial-gradient(ellipse at 30% 110%, #13306b 0, transparent 50%) fixed,
    linear-gradient(180deg, #120c35, #0a0820) fixed;
  --surface: rgb(255 255 255 / 0.06);
  --solid-surface: #1b1645;
  --surface-2: rgb(255 255 255 / 0.09);
  --input-bg: rgb(255 255 255 / 0.06);
  --text: #f2eeff;
  --muted: #c0b7e3;
  --faint: #918ab9;
  --border: rgb(255 255 255 / 0.14);
  --accent: #c48bff;
  --accent-hover: #d7adff;
  --accent-text: #1a0b35;
  --danger: #ff8fa3;
  --header-bg: rgb(11 10 36 / 0.6);
  --code-bg: linear-gradient(135deg, #c48bff, #7dd3fc);
  --code-text: #140b30;
  --tile-bg: rgb(255 255 255 / 0.08);
  --chip-on-bg: #c48bff;
  --chip-on-text: #1a0b35;
  --toast-bg: #f2eeff;
  --toast-text: #1a0b35;
  --backdrop: rgb(5 4 20 / 0.6);
  --wheel-line: #1b1645;
  --shadow: 0 10px 30px -12px rgb(0 0 0 / 0.7);
  --shadow-lg: 0 30px 70px rgb(0 0 0 / 0.6);
  --radius: 18px;
  --radius-sm: 12px;
  --t-assignment: #7dd3fc;
  --t-quiz: #5eead4;
  --t-test: #fcd34d;
  --t-exam: #fb7185;
  --t-activity: #c4b5fd;
  --t-other: #a5b4cb;
  --t-presentation: #f9a8d4;
  --i-assignment: "✦";
  --i-quiz: "✧";
  --i-test: "☄";
  --i-exam: "★";
  --i-activity: "☾";
  --i-other: "•";
  --i-presentation: "✺";
}

/* Arcade: retro pixel game with neon glow. */
[data-theme="arcade"] {
  color-scheme: dark;
  --font-body: "VT323", ui-monospace, monospace;
  --font-display: "Press Start 2P", ui-monospace, monospace;
  --display-weight: 400;
  --bg: #0b0118;
  --page-bg:
    linear-gradient(rgb(57 255 20 / 0.06) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgb(57 255 20 / 0.06) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(ellipse at 50% -10%, #2a0a52 0, transparent 60%) fixed,
    #0b0118;
  --surface: #13042a;
  --solid-surface: #13042a;
  --surface-2: #1e0a3d;
  --input-bg: #0b0118;
  --text: #f3efff;
  --muted: #bcaaeb;
  --faint: #9381c4;
  --border: #3b2170;
  --accent: #39ff14;
  --accent-hover: #7bff5e;
  --accent-text: #0b0118;
  --danger: #ff4d6a;
  --header-bg: rgb(11 1 24 / 0.92);
  --code-bg: #ff2fd6;
  --code-text: #0b0118;
  --tile-bg: #0b0118;
  --chip-on-bg: #39ff14;
  --chip-on-text: #0b0118;
  --toast-bg: #39ff14;
  --toast-text: #0b0118;
  --backdrop: rgb(0 0 0 / 0.7);
  --wheel-line: #0b0118;
  --shadow: 4px 4px 0 #000000;
  --shadow-lg: 8px 8px 0 #000000;
  --btn-shadow: 3px 3px 0 #000000;
  --radius: 0px;
  --radius-sm: 0px;
  --pill-radius: 0px;
  --bw: 2px;
  --t-assignment: #00e5ff;
  --t-quiz: #39ff14;
  --t-test: #ffe600;
  --t-exam: #ff4d6a;
  --t-activity: #ff2fd6;
  --t-other: #a28cff;
  --t-presentation: #ff8c1a;
  --i-assignment: "►";
  --i-quiz: "?";
  --i-test: "!";
  --i-exam: "★";
  --i-activity: "♪";
  --i-other: "■";
  --i-presentation: "▲";
}

/* ===== Cute themes ===== */

/* Strawberry Milk: pink gingham picnic with sweets. */
[data-theme="strawberry"] {
  color-scheme: light;
  --font-body: "Nunito Variable", system-ui, sans-serif;
  --font-display: "Fredoka Variable", "Nunito Variable", system-ui, sans-serif;
  --display-weight: 600;
  --bg: #fff7f8;
  --page-bg:
    repeating-linear-gradient(0deg, rgb(255 110 140 / 0.1) 0 16px, transparent 16px 32px),
    repeating-linear-gradient(90deg, rgb(255 110 140 / 0.1) 0 16px, transparent 16px 32px),
    #fff7f8;
  --surface: #ffffff;
  --solid-surface: #ffffff;
  --surface-2: #ffeef2;
  --input-bg: #fffafb;
  --text: #5a2132;
  --muted: #8b4459;
  --faint: #b9808f;
  --border: #ffc9d6;
  --accent: #e8335f;
  --accent-hover: #d02550;
  --accent-text: #ffffff;
  --danger: #c81f3a;
  --header-bg: rgb(255 247 248 / 0.9);
  --code-bg: #e8335f;
  --code-text: #ffffff;
  --tile-bg: #ffeef2;
  --chip-on-bg: #e8335f;
  --chip-on-text: #ffffff;
  --toast-bg: #5a2132;
  --toast-text: #ffffff;
  --backdrop: rgb(90 33 50 / 0.35);
  --wheel-line: #ffffff;
  --shadow: 0 4px 0 #ffd3de;
  --shadow-lg: 0 24px 60px rgb(232 51 95 / 0.22);
  --btn-shadow: 0 3px 0 #ffd3de;
  --radius: 20px;
  --radius-sm: 14px;
  --btn-radius: 999px;
  --bw: 2px;
  --t-assignment: #e8335f;
  --t-quiz: #f0619a;
  --t-test: #ec7a4f;
  --t-exam: #b3134f;
  --t-activity: #a95ad1;
  --t-other: #a1717f;
  --t-presentation: #2f9e8f;
  --i-assignment: "🍓";
  --i-quiz: "🍒";
  --i-test: "🧁";
  --i-exam: "🎂";
  --i-activity: "🍰";
  --i-other: "🍬";
  --i-presentation: "🎤";
}

/* Sakura: soft cherry blossoms with drifting petals. */
[data-theme="sakura"] {
  color-scheme: light;
  --font-body: "Quicksand Variable", system-ui, sans-serif;
  --font-display: "Quicksand Variable", system-ui, sans-serif;
  --display-weight: 700;
  --bg: #fff8fa;
  --page-bg: linear-gradient(180deg, #ffeef4, #fffafc 45%, #f6efff) fixed;
  --surface: #ffffff;
  --solid-surface: #ffffff;
  --surface-2: #fdeef4;
  --input-bg: #fffcfd;
  --text: #4b2c3f;
  --muted: #845670;
  --faint: #b48ea3;
  --border: #f4d3e1;
  --accent: #dc5f90;
  --accent-hover: #c94b7c;
  --accent-text: #ffffff;
  --danger: #c4325a;
  --header-bg: rgb(255 244 248 / 0.85);
  --code-bg: linear-gradient(135deg, #f7a5c6, #dc5f90);
  --code-text: #ffffff;
  --tile-bg: #fdeef4;
  --chip-on-bg: #dc5f90;
  --chip-on-text: #ffffff;
  --toast-bg: #4b2c3f;
  --toast-text: #ffffff;
  --backdrop: rgb(75 44 63 / 0.35);
  --wheel-line: #ffffff;
  --shadow: 0 6px 18px -8px rgb(220 95 144 / 0.35);
  --shadow-lg: 0 24px 60px rgb(220 95 144 / 0.25);
  --radius: 18px;
  --radius-sm: 12px;
  --btn-radius: 999px;
  --bw: 1.5px;
  --t-assignment: #dc5f90;
  --t-quiz: #5f9fc4;
  --t-test: #d4913f;
  --t-exam: #c4325a;
  --t-activity: #9474cf;
  --t-other: #9c8090;
  --t-presentation: #3f9e86;
  --i-assignment: "🌸";
  --i-quiz: "🌷";
  --i-test: "🍡";
  --i-exam: "🏮";
  --i-activity: "🎐";
  --i-other: "🌼";
  --i-presentation: "🎤";
}

/* Matcha: cosy green tea café in sage and cream. */
[data-theme="matcha"] {
  color-scheme: light;
  --font-body: "Nunito Variable", system-ui, sans-serif;
  --font-display: "Fredoka Variable", "Nunito Variable", system-ui, sans-serif;
  --display-weight: 600;
  --bg: #f4f1e6;
  --page-bg: radial-gradient(rgb(107 142 78 / 0.14) 1.2px, transparent 1.4px) 0 0 / 20px 20px, linear-gradient(180deg, #eaf1dc, #f7f3e8) fixed;
  --surface: #fffdf7;
  --solid-surface: #fffdf7;
  --surface-2: #eef3e2;
  --input-bg: #fffef9;
  --text: #2f3a26;
  --muted: #5a664e;
  --faint: #879279;
  --border: #d6e0c2;
  --accent: #5f8f41;
  --accent-hover: #4c7633;
  --accent-text: #ffffff;
  --danger: #b84a32;
  --header-bg: rgb(244 241 230 / 0.9);
  --code-bg: #5f8f41;
  --code-text: #fffdf7;
  --tile-bg: #eef3e2;
  --chip-on-bg: #2f3a26;
  --chip-on-text: #fffdf7;
  --toast-bg: #2f3a26;
  --toast-text: #fffdf7;
  --backdrop: rgb(47 58 38 / 0.35);
  --wheel-line: #fffdf7;
  --shadow: 0 2px 0 #dfe7cf, 0 10px 20px -14px rgb(47 58 38 / 0.35);
  --shadow-lg: 0 24px 60px rgb(47 58 38 / 0.22);
  --radius: 16px;
  --radius-sm: 12px;
  --btn-radius: 999px;
  --bw: 1.5px;
  --t-assignment: #5f8f41;
  --t-quiz: #3f8f89;
  --t-test: #c08734;
  --t-exam: #b84a32;
  --t-activity: #7f69b0;
  --t-other: #807f68;
  --t-presentation: #c0507f;
  --i-assignment: "🍵";
  --i-quiz: "🍃";
  --i-test: "🌿";
  --i-exam: "🎋";
  --i-activity: "🌱";
  --i-other: "🍡";
  --i-presentation: "🎤";
}

/* Cotton Candy: pastel pink-and-blue sky with fluffy clouds. */
[data-theme="cottoncandy"] {
  color-scheme: light;
  --font-body: "Quicksand Variable", system-ui, sans-serif;
  --font-display: "Fredoka Variable", "Quicksand Variable", system-ui, sans-serif;
  --display-weight: 600;
  --bg: #fdf2fb;
  --page-bg:
    radial-gradient(circle at 9% 16%, rgb(255 255 255 / 0.9) 0 34px, transparent 35px) fixed,
    radial-gradient(circle at 13% 12%, rgb(255 255 255 / 0.9) 0 40px, transparent 41px) fixed,
    radial-gradient(circle at 17% 16%, rgb(255 255 255 / 0.9) 0 30px, transparent 31px) fixed,
    radial-gradient(circle at 84% 34%, rgb(255 255 255 / 0.85) 0 30px, transparent 31px) fixed,
    radial-gradient(circle at 88% 30%, rgb(255 255 255 / 0.85) 0 38px, transparent 39px) fixed,
    radial-gradient(circle at 92% 34%, rgb(255 255 255 / 0.85) 0 26px, transparent 27px) fixed,
    radial-gradient(circle at 30% 88%, rgb(255 255 255 / 0.8) 0 28px, transparent 29px) fixed,
    radial-gradient(circle at 34% 84%, rgb(255 255 255 / 0.8) 0 36px, transparent 37px) fixed,
    linear-gradient(160deg, #ffd1ec 0%, #e8d6ff 48%, #c9ecff 100%) fixed;
  --surface: rgb(255 255 255 / 0.8);
  --solid-surface: #ffffff;
  --surface-2: rgb(255 255 255 / 0.65);
  --input-bg: #ffffff;
  --text: #46305f;
  --muted: #73608f;
  --faint: #a090b8;
  --border: #ecdcf6;
  --accent: #f75fae;
  --accent-hover: #e84a9b;
  --accent-text: #ffffff;
  --danger: #d93d68;
  --header-bg: rgb(255 240 250 / 0.7);
  --code-bg: linear-gradient(135deg, #ff9ad0, #9ad5ff);
  --code-text: #ffffff;
  --tile-bg: rgb(255 255 255 / 0.85);
  --chip-on-bg: #f75fae;
  --chip-on-text: #ffffff;
  --toast-bg: #46305f;
  --toast-text: #ffffff;
  --backdrop: rgb(70 48 95 / 0.3);
  --wheel-line: #ffffff;
  --shadow: 0 10px 30px -14px rgb(150 100 200 / 0.45);
  --shadow-lg: 0 30px 70px rgb(150 100 200 / 0.35);
  --radius: 24px;
  --radius-sm: 16px;
  --btn-radius: 999px;
  --bw: 2px;
  --t-assignment: #f75fae;
  --t-quiz: #4aa9e6;
  --t-test: #ec9a33;
  --t-exam: #d93d68;
  --t-activity: #9470ea;
  --t-other: #8f80ab;
  --t-presentation: #2fb39a;
  --i-assignment: "🍭";
  --i-quiz: "🎈";
  --i-test: "🌈";
  --i-exam: "🦄";
  --i-activity: "☁️";
  --i-other: "⭐";
  --i-presentation: "🎤";
}

/* Teddy: warm latte browns, polka dots and little bear ears. */
[data-theme="teddy"] {
  color-scheme: light;
  --font-body: "Nunito Variable", system-ui, sans-serif;
  --font-display: "Fredoka Variable", "Nunito Variable", system-ui, sans-serif;
  --display-weight: 600;
  --bg: #f8efe4;
  --page-bg:
    radial-gradient(rgb(176 122 78 / 0.14) 3px, transparent 3.5px) 0 0 / 34px 34px,
    radial-gradient(rgb(176 122 78 / 0.1) 3px, transparent 3.5px) 17px 17px / 34px 34px,
    #f8efe4;
  --surface: #fffaf3;
  --solid-surface: #fffaf3;
  --surface-2: #f3e4d2;
  --input-bg: #fffdf9;
  --text: #4a3222;
  --muted: #7a5b45;
  --faint: #a48771;
  --border: #e8d3bd;
  --accent: #a9653a;
  --accent-hover: #8f522b;
  --accent-text: #ffffff;
  --danger: #b93d33;
  --header-bg: rgb(248 239 228 / 0.92);
  --code-bg: #8a5a3a;
  --code-text: #fff7ec;
  --tile-bg: #e7bd8f;
  --chip-on-bg: #4a3222;
  --chip-on-text: #fffaf3;
  --toast-bg: #4a3222;
  --toast-text: #fffaf3;
  --backdrop: rgb(74 50 34 / 0.35);
  --wheel-line: #fffaf3;
  --shadow: 0 4px 0 #ead6c0;
  --shadow-lg: 0 24px 60px rgb(74 50 34 / 0.22);
  --btn-shadow: 0 3px 0 #e2c9ad;
  --radius: 20px;
  --radius-sm: 14px;
  --btn-radius: 999px;
  --bw: 2px;
  --t-assignment: #a9653a;
  --t-quiz: #5f8f5a;
  --t-test: #cf8a2e;
  --t-exam: #b93d33;
  --t-activity: #82649f;
  --t-other: #968070;
  --t-presentation: #c05a87;
  --i-assignment: "🧸";
  --i-quiz: "🍪";
  --i-test: "🍯";
  --i-exam: "🐻";
  --i-activity: "🧺";
  --i-other: "🐾";
  --i-presentation: "🎤";
}

/* Mermaid: shimmery ocean pastels with bubbles and shells. */
[data-theme="mermaid"] {
  color-scheme: light;
  --font-body: "Quicksand Variable", system-ui, sans-serif;
  --font-display: "Fredoka Variable", "Quicksand Variable", system-ui, sans-serif;
  --display-weight: 600;
  --bg: #eefafc;
  --page-bg:
    radial-gradient(circle at 22px 22px, transparent 7px, rgb(255 255 255 / 0.75) 8px, transparent 9.5px) 0 0 / 110px 110px,
    radial-gradient(circle at 75px 80px, rgb(255 255 255 / 0.7) 0 3px, transparent 4px) 0 0 / 110px 110px,
    radial-gradient(circle at 60px 30px, transparent 4px, rgb(255 255 255 / 0.6) 5px, transparent 6px) 0 0 / 170px 170px,
    linear-gradient(160deg, #c6f1f4 0%, #d8e3ff 40%, #efdcff 70%, #ffe0ee 100%) fixed;
  --surface: rgb(255 255 255 / 0.85);
  --solid-surface: #ffffff;
  --surface-2: rgb(232 248 251 / 0.9);
  --input-bg: #ffffff;
  --text: #22405a;
  --muted: #4b6a84;
  --faint: #7f9ab0;
  --border: #cbe7f0;
  --accent: #1fa6b6;
  --accent-hover: #178d9b;
  --accent-text: #ffffff;
  --danger: #d94a70;
  --header-bg: rgb(238 250 252 / 0.75);
  --code-bg: linear-gradient(135deg, #7ee8fa, #c8a2ff, #ffb3d9);
  --code-text: #22405a;
  --tile-bg: rgb(255 255 255 / 0.85);
  --chip-on-bg: #22405a;
  --chip-on-text: #ffffff;
  --toast-bg: #22405a;
  --toast-text: #ffffff;
  --backdrop: rgb(34 64 90 / 0.3);
  --wheel-line: #ffffff;
  --shadow: 0 10px 28px -14px rgb(47 120 160 / 0.45);
  --shadow-lg: 0 30px 70px rgb(47 120 160 / 0.3);
  --radius: 22px;
  --radius-sm: 14px;
  --btn-radius: 999px;
  --bw: 2px;
  --t-assignment: #1fa6b6;
  --t-quiz: #6b7ceb;
  --t-test: #e99a4c;
  --t-exam: #d94a70;
  --t-activity: #a66de2;
  --t-other: #7494aa;
  --t-presentation: #3fb37f;
  --i-assignment: "🐚";
  --i-quiz: "🐠";
  --i-test: "🌊";
  --i-exam: "🦀";
  --i-activity: "🐬";
  --i-other: "⭐";
  --i-presentation: "🎤";
}

/* Midnight Kitty: cute dark mode with pink glow and cat ears. */
[data-theme="kitty"] {
  color-scheme: dark;
  --font-body: "Quicksand Variable", system-ui, sans-serif;
  --font-display: "Fredoka Variable", "Quicksand Variable", system-ui, sans-serif;
  --display-weight: 600;
  --bg: #1c1326;
  --page-bg:
    radial-gradient(1.5px 1.5px at 20px 30px, #ff9ad8 50%, transparent 55%) 0 0 / 140px 140px,
    radial-gradient(1px 1px at 90px 100px, #c9b2ff 50%, transparent 55%) 0 0 / 140px 140px,
    radial-gradient(ellipse at 85% -10%, #4a2257 0, transparent 55%) fixed,
    #1c1326;
  --surface: #281a36;
  --solid-surface: #281a36;
  --surface-2: #34234a;
  --input-bg: #20162d;
  --text: #fbeefe;
  --muted: #d4b9df;
  --faint: #a58db4;
  --border: #44315c;
  --accent: #ff8ad8;
  --accent-hover: #ffa9e3;
  --accent-text: #2a0f2a;
  --danger: #ff7a92;
  --header-bg: rgb(28 19 38 / 0.85);
  --code-bg: #ff8ad8;
  --code-text: #2a0f2a;
  --tile-bg: #34234a;
  --chip-on-bg: #ff8ad8;
  --chip-on-text: #2a0f2a;
  --toast-bg: #ff8ad8;
  --toast-text: #2a0f2a;
  --backdrop: rgb(10 5 15 / 0.65);
  --wheel-line: #1c1326;
  --shadow: 0 8px 24px -12px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 30px 70px rgb(0 0 0 / 0.55);
  --radius: 18px;
  --radius-sm: 12px;
  --btn-radius: 999px;
  --t-assignment: #ff8ad8;
  --t-quiz: #7ee0d0;
  --t-test: #ffd27a;
  --t-exam: #ff7a92;
  --t-activity: #b9a1ff;
  --t-other: #b8a6c6;
  --t-presentation: #8fd3ff;
  --i-assignment: "🐾";
  --i-quiz: "😺";
  --i-test: "🙀";
  --i-exam: "👑";
  --i-activity: "🌙";
  --i-other: "🎀";
  --i-presentation: "🎤";
}

@keyframes petal-fall {
  to {
    background-position: 180px 180px, -240px 240px, 300px 300px;
  }
}

@keyframes twinkle {
  from {
    opacity: 0.25;
  }
  to {
    opacity: 1;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    scale: 0.6;
  }
}

/* ---------- 3. Components ---------- */

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

  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    margin: 0;
    min-height: 100dvh;
    background: var(--page-bg);
    color: var(--text);
    font: 15px/1.5 var(--font-body);
    font-synthesis: none;
    font-variant-numeric: tabular-nums;
  }

  [hidden] {
    display: none !important;
  }

  a {
    color: var(--accent);
  }

  h1,
  h2,
  h3,
  h4,
  p {
    margin: 0;
  }

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

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
  }

  .icon .dot {
    fill: currentColor;
    stroke: none;
  }

  [data-type="assignment"] { --type: var(--t-assignment); --icon: var(--i-assignment); }
  [data-type="quiz"] { --type: var(--t-quiz); --icon: var(--i-quiz); }
  [data-type="test"] { --type: var(--t-test); --icon: var(--i-test); }
  [data-type="exam"] { --type: var(--t-exam); --icon: var(--i-exam); }
  [data-type="presentation"] { --type: var(--t-presentation); --icon: var(--i-presentation); }
  [data-type="activity"] { --type: var(--t-activity); --icon: var(--i-activity); }
  [data-type="other"] { --type: var(--t-other); --icon: var(--i-other); }

  /* Header */

  .top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--header-bg);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: var(--bw) solid var(--border);
  }

  .top-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
  }

  .code {
    flex: none;
    font-family: var(--font-display);
    font-weight: 750;
    font-size: 13px;
    letter-spacing: 0.02em;
    padding: 7px 9px;
    border-radius: 10px;
    background: var(--code-bg);
    color: var(--code-text);
  }

  .brand-text {
    min-width: 0;
  }

  .brand h1 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: var(--display-weight);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .term {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
  }

  .badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    border: var(--bw) solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
  }

  /* Buttons */

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 13px;
    border-radius: var(--btn-radius);
    border: var(--bw) solid var(--border);
    background: var(--solid-surface);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: var(--btn-shadow);
    transition: background 0.12s, border-color 0.12s, translate 0.12s, box-shadow 0.12s;
  }

  .btn:hover {
    background: var(--surface-2);
  }

  .btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
  }

  .btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }

  .btn.danger {
    color: var(--danger);
  }

  .btn.small {
    height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }

  .btn.big {
    height: 46px;
    padding: 0 24px;
    font-size: 17px;
  }

  .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }

  .icon-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
  }

  .icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  .avatar {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 12px;
    font-weight: 700;
  }

  /* Menus */

  .menu {
    position: relative;
  }

  .menu-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 230px;
    padding: 6px;
    background: var(--solid-surface);
    border: var(--bw) solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 30;
  }

  .menu-list.align-right,
  .actions > .menu:last-child .menu-list {
    left: auto;
    right: 0;
  }

  .menu-list > a,
  .menu-list > button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
  }

  .menu-list > a:hover,
  .menu-list > button:hover {
    background: var(--surface-2);
  }

  .menu-note {
    padding: 6px 10px 8px;
    font-size: 13px;
    color: var(--muted);
    border-bottom: var(--bw) solid var(--border);
    margin-bottom: 4px;
  }

  /* Main */

  main {
    max-width: 860px;
    margin: 0 auto;
    padding: 18px 16px 40px;
  }

  .view-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 18px;
    border: var(--bw) solid var(--border);
    border-radius: calc(var(--btn-radius) + 4px);
    background: var(--surface-2);
  }

  .view-tabs button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--btn-radius);
    background: transparent;
    color: var(--muted);
    font-weight: 650;
    cursor: pointer;
  }

  .view-tabs .tab-link {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 16px;
    border-radius: var(--btn-radius);
    color: var(--muted);
    font-weight: 650;
    text-decoration: none;
  }

  .view-tabs .tab-link:hover {
    color: var(--text);
  }

  .view-tabs button[aria-selected="true"] {
    background: var(--solid-surface);
    color: var(--text);
    box-shadow: var(--shadow);
  }

  .next-up {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 16px;
    align-items: center;
    padding: 18px 20px;
    margin-bottom: 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: var(--bw) solid var(--border);
    border-left: 5px solid var(--type, var(--accent));
    box-shadow: var(--shadow);
  }

  .next-up .label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }

  .next-up .label::before,
  .pill::before {
    content: var(--icon);
    margin-right: 0.35em;
  }

  .next-up .title {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: var(--display-weight);
    line-height: 1.25;
  }

  .next-up .title .tbc {
    margin-left: 8px;
    font-size: 12px;
    vertical-align: 3px;
  }

  .next-up .when {
    color: var(--muted);
  }

  .next-up .countdown {
    grid-column: 2;
    grid-row: 1 / span 3;
    text-align: right;
  }

  .next-up .countdown strong {
    display: block;
    font-family: var(--font-display);
    font-size: 28px;
    line-height: 1.1;
    font-weight: var(--display-weight);
    color: var(--type, var(--accent));
  }

  .next-up .countdown span {
    font-size: 13px;
    color: var(--muted);
  }

  .next-up .more {
    font-size: 13px;
    color: var(--muted);
  }

  .toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
  }

  .chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  .chip {
    height: 32px;
    padding: 0 12px;
    border-radius: var(--pill-radius);
    border: var(--bw) solid var(--border);
    background: var(--solid-surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .chip:hover {
    color: var(--text);
  }

  .chip[aria-pressed="true"] {
    background: var(--chip-on-bg);
    border-color: var(--chip-on-bg);
    color: var(--chip-on-text);
  }

  .switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
  }

  .switch input {
    appearance: none;
    width: 34px;
    height: 20px;
    margin: 0;
    border-radius: var(--pill-radius);
    background: var(--border);
    position: relative;
    cursor: pointer;
    transition: background 0.15s;
  }

  .switch input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: var(--pill-radius);
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    transition: transform 0.15s;
  }

  .switch input:checked {
    background: var(--accent);
  }

  .switch input:checked::after {
    transform: translateX(14px);
  }

  /* Timeline */

  .week {
    margin-top: 24px;
  }

  .week-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 4px 10px;
  }

  .week-head h2 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: var(--display-weight);
  }

  .week-head .range,
  .week-head .term-week {
    font-size: 13px;
    color: var(--muted);
  }

  .week-head .term-week {
    margin-left: auto;
  }

  .week.current .week-head h2 {
    color: var(--accent);
  }

  .divider {
    margin: 34px 4px 0;
    padding-top: 14px;
    border-top: var(--bw) dashed var(--border);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }

  .items {
    display: grid;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .item {
    --type: var(--t-other);
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 14px;
    padding: 12px 14px;
    background: var(--surface);
    border: var(--bw) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
  }

  .item::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--type);
  }

  .item.past {
    opacity: 0.62;
  }

  .date-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    align-self: start;
    padding: 6px 0 7px;
    border-radius: calc(var(--radius) * 0.7);
    background: var(--tile-bg);
    line-height: 1.1;
  }

  .date-tile .dow {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }

  .date-tile .day {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: var(--display-weight);
  }

  .date-tile .mon {
    font-size: 11px;
    color: var(--muted);
  }

  .item.today .date-tile {
    background: var(--accent);
    color: var(--accent-text);
  }

  .item.today .date-tile .dow,
  .item.today .date-tile .mon {
    color: inherit;
    opacity: 0.85;
  }

  .item-body {
    display: block;
    min-width: 0;
  }

  .tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 2px;
  }

  .pill {
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--pill-radius);
    color: var(--type);
    background: color-mix(in srgb, var(--type) 13%, transparent);
  }

  .tbc {
    font-size: 11.5px;
    font-weight: 650;
    padding: 1px 7px;
    border-radius: var(--pill-radius);
    border: 1px dashed var(--faint);
    color: var(--muted);
  }

  .rel {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
  }

  .rel.soon {
    color: var(--danger);
  }

  .item-title {
    display: block;
    font-family: var(--font-display);
    font-size: 16.5px;
    font-weight: var(--display-weight);
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .item .sub {
    display: block;
    font-size: 13.5px;
    color: var(--muted);
  }

  .item .details {
    margin-top: 4px;
    font-size: 13.5px;
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  .item .link {
    display: inline-block;
    margin-top: 4px;
    font-size: 13.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
  }

  .item .by {
    margin-top: 6px;
    font-size: 12px;
    color: var(--faint);
  }

  .edit-btn {
    align-self: start;
    height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }

  .empty,
  .loading {
    margin-top: 26px;
    padding: 32px 20px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: var(--bw) dashed var(--border);
    border-radius: var(--radius);
  }

  .empty strong {
    display: block;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: var(--display-weight);
    margin-bottom: 4px;
  }

  .empty .btn {
    margin-top: 14px;
  }

  .foot {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px 40px;
    font-size: 12.5px;
    color: var(--faint);
  }

  /* Groups */

  .section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
  }

  .section-head h2 {
    margin-right: auto;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: var(--display-weight);
  }

  .section-note {
    margin: -6px 0 16px;
    font-size: 13.5px;
    color: var(--muted);
  }

  .set-card {
    position: relative;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface);
    border: var(--bw) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .set-title {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: var(--display-weight);
    overflow-wrap: anywhere;
  }

  .set-meta {
    font-size: 13px;
    color: var(--muted);
  }

  .set-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
  }

  .name-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
  }

  .name-chip {
    padding: 3px 10px;
    border: var(--bw) solid var(--border);
    border-radius: var(--pill-radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
  }

  button.name-chip {
    cursor: pointer;
  }

  button.name-chip:hover {
    border-color: var(--accent);
  }

  .name-chip.out {
    text-decoration: line-through;
    opacity: 0.55;
  }

  .group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
    margin-top: 12px;
  }

  .group-box {
    position: relative;
    padding: 10px 12px 12px;
    border: var(--bw) solid var(--border);
    border-top: 4px solid var(--type);
    border-radius: calc(var(--radius) * 0.8);
    background: var(--surface-2);
  }

  .group-box h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: var(--display-weight);
    color: var(--type);
  }

  .group-box ul {
    display: grid;
    gap: 4px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
  }

  .member {
    display: block;
    width: 100%;
    padding: 4px 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--solid-surface);
    color: var(--text);
    font-size: 14px;
    text-align: left;
    overflow-wrap: anywhere;
  }

  button.member {
    cursor: pointer;
  }

  button.member:hover {
    outline: 2px solid color-mix(in srgb, var(--type) 55%, transparent);
  }

  .member.me {
    font-weight: 750;
  }

  .pick-btn {
    height: 26px;
    padding: 0 8px;
    font-size: 12px;
  }

  .late {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--muted);
  }

  .set-history,
  .pick-list {
    display: grid;
    gap: 4px;
    margin: 12px 0 0;
    padding: 10px 0 0;
    border-top: var(--bw) dashed var(--border);
    list-style: none;
    font-size: 13px;
    color: var(--muted);
  }

  .pick-list {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .set-card {
    scroll-margin-top: 84px;
  }

  .set-history-wrap {
    margin-top: 10px;
  }

  .set-history-wrap summary {
    width: fit-content;
    cursor: pointer;
  }

  .item .group-link {
    display: block;
    width: fit-content;
    text-decoration: none;
  }

  .item .group-link:hover {
    text-decoration: underline;
  }

  .pick-list li strong {
    color: var(--text);
  }

  /* Wheels */

  .spin-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
  }

  .wheel-wrap {
    position: relative;
    width: min(100%, 340px);
    aspect-ratio: 1;
    margin: 6px auto 0;
  }

  .wheel {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 8px 18px rgb(0 0 0 / 0.18));
  }

  .wheel .spinner {
    transform-origin: 0 0;
  }

  .wheel .slice {
    stroke: var(--wheel-line);
    stroke-width: 0.012;
  }

  .wheel .s0 { fill: var(--t-assignment); }
  .wheel .s1 { fill: var(--t-quiz); }
  .wheel .s2 { fill: var(--t-test); }
  .wheel .s3 { fill: var(--t-activity); }
  .wheel .s4 { fill: var(--t-exam); }
  .wheel .s5 { fill: var(--accent); }

  .wheel .label {
    fill: #ffffff;
    stroke: rgb(0 0 0 / 0.45);
    stroke-width: 0.018;
    paint-order: stroke;
    font-family: var(--font-body);
    font-weight: 700;
  }

  .wheel .rim {
    fill: none;
    stroke: var(--wheel-line);
    stroke-width: 0.03;
  }

  .wheel .hub {
    fill: var(--solid-surface);
    stroke: var(--wheel-line);
    stroke-width: 0.02;
  }

  .wheel .empty-wheel {
    fill: var(--surface-2);
    stroke: var(--border);
    stroke-width: 0.02;
  }

  .wheel-pointer {
    position: absolute;
    top: -8px;
    left: 50%;
    z-index: 2;
    width: 0;
    height: 0;
    translate: -50% 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 28px solid var(--text);
    filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.3));
  }

  .landed {
    min-height: 40px;
    margin-top: 12px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: var(--display-weight);
  }

  .landed small {
    display: block;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
  }

  .landed.big {
    font-size: 30px;
    color: var(--accent);
    animation: pop-in 0.35s ease-out;
  }

  .deal-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    max-height: 52dvh;
    overflow-y: auto;
  }

  .deal-groups .group-box ul li {
    animation: pop-in 0.35s ease-out;
  }

  .spin-controls {
    display: grid;
    gap: 2px;
  }

  .spin-controls .row2 {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 10px;
  }

  .seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 12px;
    border-radius: calc(var(--radius-sm) + 3px);
    background: var(--surface-2);
  }

  .seg button {
    height: 32px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
  }

  .seg button[aria-pressed="true"] {
    background: var(--solid-surface);
    color: var(--text);
    box-shadow: var(--shadow);
  }

  .spin-summary {
    margin: 4px 0 12px;
    font-size: 13.5px;
    color: var(--muted);
  }

  /* Dialogs */

  dialog {
    width: min(480px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 20px;
    border: var(--bw) solid var(--border);
    border-radius: max(var(--radius), 4px);
    background: var(--solid-surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
  }

  dialog.wide {
    width: min(660px, calc(100vw - 24px));
  }

  dialog.wider {
    width: min(820px, calc(100vw - 24px));
  }

  dialog::backdrop {
    background: var(--backdrop);
  }

  .dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -4px -6px 12px 0;
  }

  .dialog-head h2 {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: var(--display-weight);
  }

  form label,
  .field {
    display: grid;
    gap: 5px;
    margin-bottom: 12px;
    font-size: 13.5px;
    font-weight: 600;
  }

  input:not([type="checkbox"]),
  select,
  textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 11px;
    border: var(--bw) solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    font-weight: 400;
    font-size: 15px;
  }

  textarea {
    resize: vertical;
  }

  input:focus,
  select:focus,
  textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
    outline-offset: 0;
    border-color: var(--accent);
  }

  form .row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 10px;
  }

  form .row label {
    margin-bottom: 4px;
  }

  form label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
  }

  form label.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
  }

  .hint {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--muted);
  }

  p.hint {
    margin: 0 0 12px;
  }

  .form-error {
    color: var(--danger);
    font-size: 13.5px;
    font-weight: 600;
  }

  .form-error:not(:empty) {
    margin-bottom: 10px;
  }

  .meta-line {
    font-size: 12.5px;
    color: var(--faint);
  }

  .meta-line:not(:empty) {
    margin-bottom: 10px;
  }

  .dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
  }

  .spacer {
    flex: 1;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 16px;
    background: var(--surface-2);
    border-radius: calc(var(--radius-sm) + 3px);
  }

  .tabs button {
    height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
  }

  .tabs button[aria-selected="true"] {
    background: var(--solid-surface);
    color: var(--text);
    box-shadow: var(--shadow);
  }

  .move-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .move-options .btn {
    justify-content: center;
  }

  /* Recent changes */

  .activity {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 2px;
    max-height: 65dvh;
    overflow-y: auto;
  }

  .activity li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
  }

  .activity li:last-child {
    border-bottom: 0;
  }

  .activity .what {
    font-size: 14px;
  }

  .activity .changes {
    grid-column: 1;
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
  }

  .activity .ago {
    grid-column: 1;
    font-size: 12px;
    color: var(--faint);
  }

  .activity .restore {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    height: 30px;
    font-size: 13px;
  }

  /* Theme picker */

  .theme-intro {
    margin: -4px 0 14px;
    font-size: 13.5px;
    color: var(--muted);
  }

  .theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    max-height: min(64dvh, 620px);
    overflow-y: auto;
    padding: 4px;
    margin: 0 -4px 12px;
  }

  .theme-choice {
    display: grid;
    gap: 2px;
    align-content: start;
    padding: 8px 8px 12px;
    border: 2px solid var(--border);
    border-radius: 16px;
    background: var(--solid-surface);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, translate 0.15s;
  }

  .theme-choice:hover {
    translate: 0 -2px;
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  }

  .theme-choice[aria-pressed="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  }

  .theme-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 4px 0;
    font-weight: 700;
  }

  .theme-choice[aria-pressed="true"] .theme-name::after {
    content: "✓ On";
    font-size: 12px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
  }

  .theme-desc {
    padding: 0 4px;
    font-size: 13px;
    color: var(--muted);
  }

  .theme-preview {
    display: block;
    height: 150px;
    overflow: hidden;
    border-radius: 11px;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
    position: relative;
  }

  .theme-preview .tp-zoom {
    display: block;
    zoom: 0.66;
    padding: 14px;
  }

  .theme-preview .tp-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
  }

  .theme-preview .tp-name {
    font-family: var(--font-display);
    font-weight: var(--display-weight);
    font-size: 17px;
  }

  .theme-preview .items {
    gap: 12px;
  }

  /* Toast and celebrations */

  .toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--toast-bg);
    color: var(--toast-text);
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
  }

  .toast-action {
    margin-left: 12px;
    padding: 2px 10px;
    border: 1px solid currentColor;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
  }

  .burst {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 60;
    overflow: hidden;
  }

  .burst span {
    position: absolute;
    line-height: 1;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  /* Small screens */

  @media (max-width: 640px) {
    .spin-layout {
      grid-template-columns: 1fr;
    }

    .wheel-wrap {
      width: min(100%, 300px);
    }
  }

  @media (max-width: 600px) {
    .hide-sm {
      display: none;
    }

    .view-tabs {
      display: flex;
      width: 100%;
    }

    .view-tabs button,
    .view-tabs .tab-link {
      flex: 1;
      justify-content: center;
      padding: 0 6px;
      white-space: nowrap;
      font-size: 14px;
    }

    .brand h1 {
      font-size: 15px;
    }

    .actions {
      gap: 6px;
    }

    .actions .btn {
      padding: 0 10px;
    }

    .next-up {
      grid-template-columns: 1fr;
    }

    .next-up .countdown {
      grid-column: 1;
      grid-row: auto;
      text-align: left;
      display: flex;
      align-items: baseline;
      gap: 8px;
      margin-top: 6px;
    }

    .next-up .countdown strong {
      display: inline;
      font-size: 23px;
    }

    .item {
      grid-template-columns: 46px 1fr;
      gap: 12px;
    }

    .edit-btn {
      grid-column: 2;
      justify-self: start;
    }

    form .row {
      grid-template-columns: 1fr 1fr;
    }

    form .row label:first-child {
      grid-column: 1 / -1;
    }

    .week-head .term-week {
      margin-left: 0;
      width: 100%;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- 4. Theme decorations ---------- */

@scope ([data-theme="bubblegum"]) to ([data-theme]) {
  .brand h1::after {
    content: " ♡";
    color: var(--accent);
  }

  .code {
    border-radius: 14px;
    box-shadow: 0 3px 0 #e9b3cf;
  }

  .btn.primary {
    box-shadow: 0 3px 0 #d23d82;
  }

  .btn:active {
    translate: 0 2px;
    box-shadow: none;
  }

  .item,
  .next-up,
  .set-card {
    border-color: color-mix(in srgb, var(--type, var(--accent)) 28%, #ffffff);
    box-shadow: 0 5px 0 color-mix(in srgb, var(--type, var(--accent)) 24%, #ffffff);
  }

  .item {
    transition: translate 0.2s, rotate 0.2s;
  }

  .item:hover {
    translate: 0 -3px;
    rotate: -0.4deg;
  }

  .item::before {
    display: none;
  }

  .date-tile {
    border-radius: 16px;
    background: color-mix(in srgb, var(--type) 13%, #ffffff);
    color: color-mix(in srgb, var(--type) 80%, #4a2b3d);
  }

  .item.today .date-tile {
    background: var(--accent);
    color: #ffffff;
  }

  .pill {
    color: color-mix(in srgb, var(--type) 70%, #4a2b3d);
    background: color-mix(in srgb, var(--type) 15%, #ffffff);
  }

  .next-up {
    background: linear-gradient(135deg, #ffe0ef 0%, #efe4ff 60%, #dcf6ee 100%);
    border-left-width: var(--bw);
  }

  .next-up::after {
    content: "✦ ✧ ✦";
    position: absolute;
    right: 20px;
    bottom: 12px;
    font-size: 12px;
    letter-spacing: 4px;
    color: #ff9cc8;
  }

  .next-up .countdown strong {
    background: linear-gradient(90deg, #ff63a5, #8f64e3);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .week.current .week-head h2::after {
    content: " ✨";
  }

  .chip[aria-pressed="true"] {
    box-shadow: 0 3px 0 #d23d82;
  }

  .group-box {
    border-top-width: var(--bw);
    background: color-mix(in srgb, var(--type) 9%, #ffffff);
  }

  .section-head h2::after {
    content: " 🎀";
  }
}

@scope ([data-theme="notebook"]) to ([data-theme]) {
  [data-type="assignment"] { --note: #fff09c; }
  [data-type="quiz"] { --note: #c9f0dc; }
  [data-type="test"] { --note: #ffdcb5; }
  [data-type="exam"] { --note: #ffcfcf; }
  [data-type="activity"] { --note: #e4d9ff; }
  [data-type="presentation"] { --note: #ffd3e6; }
  [data-type="other"] { --note: #eceef3; }

  .brand h1 {
    font-size: 23px;
  }

  .code {
    rotate: -3deg;
    border-radius: 3px;
    box-shadow: 1px 2px 0 rgb(0 0 0 / 0.15);
  }

  .btn {
    border-color: var(--text);
  }

  .btn.primary {
    border-color: var(--accent);
  }

  .chip {
    border-color: var(--text);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 400;
  }

  .items {
    gap: 18px;
    padding-top: 6px;
  }

  .item,
  .group-box {
    overflow: visible;
    border: 0;
    border-radius: 2px;
    background: var(--note, var(--surface));
    box-shadow: var(--shadow);
  }

  .item::before {
    display: none;
  }

  /* Washi tape */
  .item::after,
  .group-box::after {
    content: "";
    position: absolute;
    top: -9px;
    left: 50%;
    width: 92px;
    height: 20px;
    translate: -50% 0;
    rotate: -2deg;
    background: repeating-linear-gradient(
      45deg,
      rgb(255 255 255 / 0.65) 0 6px,
      color-mix(in srgb, var(--type) 30%, rgb(255 255 255 / 0.55)) 6px 12px
    );
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
  }

  .group-box::after {
    width: 60px;
  }

  .items > .item:nth-child(odd),
  .group-box:nth-child(odd) {
    rotate: -0.6deg;
  }

  .items > .item:nth-child(even),
  .group-box:nth-child(even) {
    rotate: 0.5deg;
  }

  .items > .item:nth-child(3n)::after {
    left: 24%;
    rotate: 3deg;
  }

  .item.past {
    opacity: 0.7;
  }

  .item-title {
    font-size: 21px;
    line-height: 1.15;
  }

  .date-tile {
    border: 1.5px solid rgb(0 0 0 / 0.12);
    border-radius: 4px;
  }

  /* Today is circled in red pen. */
  .item.today .date-tile {
    background: rgb(255 255 255 / 0.7);
    color: var(--danger);
    border: 2px solid var(--danger);
    border-radius: 50%;
  }

  .pill {
    padding: 0;
    border-radius: 0;
    background: none;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 400;
    text-decoration: underline wavy var(--type) 1.5px;
    text-underline-offset: 4px;
  }

  .tbc {
    border-color: var(--muted);
  }

  /* Highlighter on headings */
  .week-head h2,
  .section-head h2 {
    font-size: 23px;
    padding: 0 4px;
    background: linear-gradient(transparent 58%, #fff19a 58%);
  }

  .week.current .week-head h2 {
    color: var(--text);
    background: linear-gradient(transparent 58%, #ffc2dc 58%);
  }

  .group-box h4 {
    color: var(--text);
    font-size: 19px;
  }

  .member {
    background: rgb(255 255 255 / 0.6);
  }

  /* Lined paper with a red margin */
  .next-up,
  .set-card {
    border: 0;
    background:
      linear-gradient(90deg, transparent 40px, #f4a3a3 40px 42px, transparent 42px),
      repeating-linear-gradient(#fffdf6 0 25px, #d9e5f5 25px 26px);
  }

  .next-up {
    padding-left: 60px;
    rotate: -0.4deg;
  }

  .set-card {
    padding-left: 58px;
  }

  .set-title {
    font-size: 25px;
  }

  .next-up .title {
    font-size: 27px;
  }

  .next-up .countdown strong {
    color: var(--danger);
    font-size: 36px;
  }

  .empty strong {
    font-size: 22px;
  }

  .landed {
    font-size: 28px;
  }
}

@scope ([data-theme="pop"]) to ([data-theme]) {
  .code {
    border: 2px solid #111111;
    box-shadow: 2px 2px 0 #111111;
    rotate: -2deg;
  }

  .btn:hover {
    translate: -1px -1px;
    box-shadow: 4px 4px 0 #111111;
    background: var(--surface);
  }

  .btn.primary:hover {
    background: var(--accent-hover);
  }

  .btn:active {
    translate: 3px 3px;
    box-shadow: 0 0 0 #111111;
  }

  .badge {
    background: #ffffff;
    color: #111111;
  }

  .chip,
  .view-tabs {
    border: 2px solid #111111;
    color: #111111;
    font-weight: 700;
  }

  .chip[aria-pressed="true"] {
    background: #111111;
    color: #ffffff;
    box-shadow: 3px 3px 0 var(--accent);
  }

  .view-tabs {
    background: #ffffff;
    box-shadow: 3px 3px 0 #111111;
  }

  .view-tabs button[aria-selected="true"],
  .seg button[aria-pressed="true"] {
    background: #111111;
    color: #ffd23f;
    box-shadow: none;
  }

  .item {
    transition: translate 0.12s, box-shadow 0.12s;
  }

  .item:hover {
    translate: -2px -2px;
    box-shadow: 6px 6px 0 #111111;
  }

  .item::before {
    display: none;
  }

  .date-tile {
    border: 2px solid #111111;
    border-radius: 8px;
    background: var(--type);
    color: #111111;
  }

  .date-tile .dow,
  .date-tile .mon {
    color: #111111;
  }

  .item.today .date-tile {
    background: #111111;
    color: #ffd23f;
  }

  .pill {
    border: 2px solid #111111;
    border-radius: 6px;
    background: var(--type);
    color: #111111;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .tbc {
    border: 2px dashed #111111;
    color: #111111;
  }

  .rel {
    color: #111111;
  }

  .rel.soon {
    padding: 0 6px;
    border: 2px solid #111111;
    border-radius: 6px;
    background: #ff5252;
    color: #ffffff;
  }

  .next-up {
    border-left-width: var(--bw);
    background: var(--type, #ffd23f);
    box-shadow: 6px 6px 0 #111111;
  }

  .next-up .label,
  .next-up .when,
  .next-up .more,
  .next-up .countdown span,
  .next-up .countdown strong {
    color: #111111;
  }

  .next-up .countdown strong {
    font-size: 34px;
  }

  .week-head h2,
  .section-head h2 {
    padding: 2px 10px;
    border-radius: 6px;
    background: #111111;
    color: #ffffff;
    rotate: -1deg;
  }

  .week.current .week-head h2 {
    border: 2px solid #111111;
    background: var(--accent);
    color: #111111;
  }

  .group-box {
    border: 2.5px solid #111111;
    background: var(--type);
    box-shadow: 3px 3px 0 #111111;
  }

  .group-box h4 {
    color: #111111;
  }

  .member {
    border: 2px solid #111111;
  }

  .switch input {
    border: 2px solid #111111;
  }

  .tabs button[aria-selected="true"] {
    border: 2px solid #111111;
    box-shadow: 2px 2px 0 #111111;
  }

  .wheel {
    filter: drop-shadow(5px 5px 0 #111111);
  }

  .toast {
    border: 2.5px solid #ffd23f;
  }
}

@scope ([data-theme="galaxy"]) to ([data-theme]) {
  /* A second layer of stars that slowly twinkles. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(1.6px 1.6px at 30px 60px, #ffffff 50%, transparent 55%) 0 0 / 190px 190px,
      radial-gradient(1.4px 1.4px at 140px 120px, #ffd6f5 50%, transparent 55%) 0 0 / 250px 250px,
      radial-gradient(1.8px 1.8px at 200px 30px, #c9e8ff 50%, transparent 55%) 0 0 / 310px 310px;
    animation: twinkle 3.2s ease-in-out infinite alternate;
  }

  .brand h1 {
    background: linear-gradient(90deg, #f2eeff, #c48bff 60%, #7dd3fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .btn {
    background: rgb(255 255 255 / 0.06);
  }

  .btn:hover {
    background: rgb(255 255 255 / 0.12);
  }

  .btn.primary {
    border-color: transparent;
    background: linear-gradient(135deg, #c48bff, #8fb8ff);
    box-shadow: 0 0 22px rgb(196 139 255 / 0.35);
  }

  .chip {
    background: rgb(255 255 255 / 0.05);
  }

  .chip[aria-pressed="true"] {
    background: var(--chip-on-bg);
    color: var(--chip-on-text);
  }

  .item,
  .next-up,
  .set-card {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .item::before {
    box-shadow: 0 0 14px 1px var(--type);
  }

  .pill {
    background: color-mix(in srgb, var(--type) 14%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--type) 45%, transparent);
  }

  .item.today .date-tile {
    background: linear-gradient(135deg, #c48bff, #7dd3fc);
    color: #140b30;
  }

  .next-up {
    background: linear-gradient(135deg, rgb(196 139 255 / 0.22), rgb(125 211 252 / 0.1));
  }

  .next-up .countdown strong,
  .landed.big {
    text-shadow: 0 0 22px color-mix(in srgb, var(--type, var(--accent)) 70%, transparent);
  }

  .week.current .week-head h2 {
    text-shadow: 0 0 14px rgb(196 139 255 / 0.7);
  }

  .group-box {
    box-shadow: 0 -6px 18px -10px var(--type);
  }

  .wheel {
    filter: drop-shadow(0 0 22px rgb(196 139 255 / 0.45));
  }

  .wheel .label {
    fill: #140b30;
    stroke: rgb(255 255 255 / 0.35);
  }
}

@scope ([data-theme="arcade"]) to ([data-theme]) {
  /* CRT scanlines */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, rgb(0 0 0 / 0.22) 0 1px, transparent 1px 3px);
  }

  .brand h1 {
    font-size: 12px;
    line-height: 1.8;
    color: var(--accent);
    text-shadow: 0 0 8px rgb(57 255 20 / 0.6);
  }

  .code {
    font-size: 10px;
    padding: 9px 8px;
    box-shadow: 3px 3px 0 #000000;
  }

  .btn,
  .chip,
  .tabs button,
  .view-tabs button,
  .view-tabs .tab-link,
  .seg button,
  .badge {
    font-family: var(--font-display);
    font-size: 9px;
    text-transform: uppercase;
  }

  .btn:active {
    translate: 3px 3px;
    box-shadow: none;
  }

  .item,
  .group-box {
    border: 2px solid var(--type);
    box-shadow: 0 0 0 2px #000000, 0 0 16px color-mix(in srgb, var(--type) 35%, transparent);
  }

  .item::before {
    display: none;
  }

  .date-tile {
    border: 2px solid var(--type);
    color: var(--type);
  }

  .date-tile .day {
    margin: 5px 0 3px;
    font-size: 14px;
  }

  .item.today .date-tile {
    background: var(--type);
    color: #0b0118;
  }

  .pill {
    padding: 4px 6px;
    border: 2px solid var(--type);
    background: transparent;
    font-family: var(--font-display);
    font-size: 8px;
    font-weight: 400;
  }

  .item-title,
  .member {
    font-family: var(--font-body);
    font-size: 21px;
    line-height: 1.1;
  }

  .week-head h2,
  .group-box h4,
  .set-title,
  .section-head h2 {
    font-size: 11px;
    line-height: 1.8;
  }

  .section-head h2 {
    font-size: 14px;
    color: var(--accent);
  }

  .next-up {
    border: 2px solid var(--type, var(--accent));
    box-shadow: 0 0 0 2px #000000, 0 0 26px color-mix(in srgb, var(--type, var(--accent)) 40%, transparent);
  }

  .next-up .label {
    font-family: var(--font-display);
    font-size: 9px;
    color: var(--type);
  }

  .next-up .title {
    font-size: 14px;
    line-height: 1.7;
  }

  .next-up .countdown strong {
    font-size: 20px;
    text-shadow: 0 0 12px color-mix(in srgb, var(--type) 70%, transparent);
  }

  .next-up .countdown strong::after,
  .landed.big::after {
    content: "_";
    animation: blink 1s steps(1) infinite;
  }

  .landed {
    font-size: 14px;
    line-height: 1.8;
  }

  .landed.big {
    font-size: 18px;
  }

  .dialog-head h2 {
    font-size: 13px;
    line-height: 1.7;
  }

  .empty strong {
    font-size: 12px;
    line-height: 1.8;
  }

  .wheel {
    filter: drop-shadow(0 0 18px rgb(57 255 20 / 0.35));
  }

  .wheel .label {
    fill: #0b0118;
    stroke: none;
  }

  .wheel-pointer {
    border-top-color: var(--accent);
  }
}


/* ----- Cute theme decorations ----- */

/* Shared by the soft cute themes: no side bar, tinted date tiles and pills, gentle hover. */
@scope ([data-theme="strawberry"], [data-theme="sakura"], [data-theme="matcha"], [data-theme="cottoncandy"], [data-theme="teddy"], [data-theme="mermaid"]) to ([data-theme]) {
  .item::before {
    display: none;
  }

  .item {
    transition: translate 0.2s, rotate 0.2s;
  }

  .item:hover {
    translate: 0 -3px;
  }

  .pill {
    background: color-mix(in srgb, var(--type) 15%, #ffffff);
    color: color-mix(in srgb, var(--type) 72%, var(--text));
  }

  .btn:active {
    translate: 0 2px;
    box-shadow: none;
  }
}

@scope ([data-theme="strawberry"]) to ([data-theme]) {
  .brand h1::after {
    content: " 🍓";
  }

  /* Stitched edges, like a picnic blanket. */
  .item,
  .next-up,
  .set-card,
  .group-box {
    border-style: dashed;
  }

  .item {
    border-color: color-mix(in srgb, var(--type) 40%, #ffffff);
  }

  .date-tile {
    background: color-mix(in srgb, var(--type) 13%, #ffffff);
    color: color-mix(in srgb, var(--type) 80%, var(--text));
  }

  .item.today .date-tile {
    background: var(--accent);
    color: #ffffff;
  }

  .next-up {
    border-left-style: dashed;
    border-left-width: var(--bw);
    background:
      repeating-linear-gradient(0deg, rgb(255 110 140 / 0.12) 0 10px, transparent 10px 20px),
      repeating-linear-gradient(90deg, rgb(255 110 140 / 0.12) 0 10px, transparent 10px 20px),
      #ffffff;
  }

  .week.current .week-head h2::after {
    content: " 🍓";
  }

  .btn.primary {
    box-shadow: 0 3px 0 #b81f46;
  }
}

@scope ([data-theme="sakura"]) to ([data-theme]) {
  /* Petals drifting down the page. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(ellipse 7px 4px at 40px 50px, #ffb7cf 60%, transparent 64%) 0 0 / 180px 180px,
      radial-gradient(ellipse 5px 3px at 120px 150px, #ffcade 60%, transparent 64%) 0 0 / 240px 240px,
      radial-gradient(ellipse 6px 4px at 200px 60px, #f9a9c6 60%, transparent 64%) 0 0 / 300px 300px;
    animation: petal-fall 22s linear infinite;
  }

  .brand h1::after {
    content: " 🌸";
  }

  .item {
    border-color: color-mix(in srgb, var(--type) 25%, #ffffff);
  }

  .date-tile {
    background: color-mix(in srgb, var(--type) 12%, #ffffff);
    color: color-mix(in srgb, var(--type) 80%, var(--text));
  }

  .item.today .date-tile {
    background: var(--accent);
    color: #ffffff;
  }

  .next-up {
    border-left-width: var(--bw);
    background: linear-gradient(135deg, #ffe6ef, #ffffff 60%);
  }

  .next-up::after {
    content: "🌸";
    position: absolute;
    right: 14px;
    bottom: 6px;
    font-size: 26px;
    opacity: 0.35;
    rotate: 18deg;
  }

  .week.current .week-head h2::after {
    content: " 🌸";
  }
}

@scope ([data-theme="matcha"]) to ([data-theme]) {
  .brand h1::after {
    content: " 🍵";
  }

  .item {
    border-left: 5px solid var(--type);
  }

  .date-tile {
    background: color-mix(in srgb, var(--type) 12%, #fffdf7);
    color: color-mix(in srgb, var(--type) 80%, var(--text));
  }

  .item.today .date-tile {
    background: var(--accent);
    color: #ffffff;
  }

  .next-up {
    background: linear-gradient(135deg, #e3eecf, #fffdf7 65%);
  }

  .next-up::after {
    content: "🍃";
    position: absolute;
    right: 16px;
    bottom: 8px;
    font-size: 22px;
    opacity: 0.5;
  }

  .week.current .week-head h2::after {
    content: " 🍃";
  }
}

@scope ([data-theme="cottoncandy"]) to ([data-theme]) {
  .brand h1 {
    background: linear-gradient(90deg, #f75fae, #9470ea 55%, #4aa9e6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .item,
  .next-up,
  .set-card {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .date-tile {
    background: linear-gradient(160deg, color-mix(in srgb, var(--type) 18%, #ffffff), #ffffff);
    color: color-mix(in srgb, var(--type) 80%, var(--text));
  }

  .item.today .date-tile {
    background: linear-gradient(135deg, #ff9ad0, #9ad5ff);
    color: #ffffff;
  }

  .next-up {
    border-left-width: var(--bw);
    background: linear-gradient(135deg, rgb(255 214 238 / 0.9), rgb(205 236 255 / 0.9));
  }

  .next-up .countdown strong {
    background: linear-gradient(90deg, #f75fae, #4aa9e6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .week.current .week-head h2::after {
    content: " 🌈";
  }
}

@scope ([data-theme="teddy"]) to ([data-theme]) {
  .brand h1::after {
    content: " 🧸";
  }

  .item {
    border-color: #ecd9c4;
  }

  /* Each date tile is a little bear face with round ears. */
  .date-tile {
    position: relative;
    margin-top: 6px;
    border-radius: 18px;
    background: var(--tile-bg);
    color: #4a3222;
  }

  .date-tile::before,
  .date-tile::after {
    content: "";
    position: absolute;
    top: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: inherit;
    box-shadow: inset 0 0 0 4px var(--tile-bg), inset 0 0 0 10px #f6dcc0;
  }

  .date-tile::before {
    left: 1px;
  }

  .date-tile::after {
    right: 1px;
  }

  .date-tile .dow,
  .date-tile .mon {
    color: #6b4a32;
  }

  .item.today .date-tile {
    --tile-bg: var(--accent);
    color: #ffffff;
  }

  .item.today .date-tile .dow,
  .item.today .date-tile .mon {
    color: #ffffff;
  }

  .next-up {
    border-left-width: var(--bw);
    background: linear-gradient(135deg, #f6e1c8, #fffaf3 65%);
  }

  .next-up::after {
    content: "🐾";
    position: absolute;
    right: 16px;
    bottom: 8px;
    font-size: 20px;
    opacity: 0.45;
  }

  .week.current .week-head h2::after {
    content: " 🐾";
  }

  .btn.primary {
    box-shadow: 0 3px 0 #7a4524;
  }
}

@scope ([data-theme="mermaid"]) to ([data-theme]) {
  .brand h1 {
    background: linear-gradient(90deg, #1fa6b6, #a66de2 60%, #e86aa6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  /* Iridescent, shell-like edges */
  .item,
  .next-up,
  .set-card {
    border: 2px solid transparent;
    background:
      linear-gradient(rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.9)) padding-box,
      linear-gradient(135deg, #7ee8fa, #c8a2ff 50%, #ffb3d9) border-box;
  }

  .date-tile {
    background: linear-gradient(160deg, color-mix(in srgb, var(--type) 18%, #ffffff), #ffffff);
    color: color-mix(in srgb, var(--type) 80%, var(--text));
  }

  .item.today .date-tile {
    background: linear-gradient(135deg, #7ee8fa, #c8a2ff);
    color: #22405a;
  }

  .next-up .countdown strong {
    background: linear-gradient(90deg, #1fa6b6, #a66de2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .next-up::after {
    content: "🐚";
    position: absolute;
    right: 16px;
    bottom: 8px;
    font-size: 20px;
    opacity: 0.55;
  }

  .week.current .week-head h2::after {
    content: " 🐚";
  }
}

@scope ([data-theme="kitty"]) to ([data-theme]) {
  .brand h1 {
    color: #ffd0ef;
    text-shadow: 0 0 14px rgb(255 138 216 / 0.55);
  }

  .brand h1::after {
    content: " 🐱";
  }

  .item::before {
    box-shadow: 0 0 12px 1px var(--type);
  }

  /* Each date tile gets pointy cat ears. */
  .date-tile {
    position: relative;
    margin-top: 6px;
  }

  .date-tile::before,
  .date-tile::after {
    content: "";
    position: absolute;
    top: -8px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 11px solid var(--tile-bg);
  }

  .date-tile::before {
    left: 6px;
  }

  .date-tile::after {
    right: 6px;
  }

  .item.today .date-tile::before,
  .item.today .date-tile::after {
    border-bottom-color: var(--accent);
  }

  .pill {
    background: color-mix(in srgb, var(--type) 16%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--type) 45%, transparent);
  }

  .next-up {
    background: linear-gradient(135deg, rgb(255 138 216 / 0.16), rgb(185 161 255 / 0.08));
    box-shadow: 0 0 0 1px rgb(255 138 216 / 0.25), 0 0 30px -8px rgb(255 138 216 / 0.45);
  }

  .next-up .countdown strong {
    text-shadow: 0 0 18px color-mix(in srgb, var(--type, var(--accent)) 70%, transparent);
  }

  .btn.primary {
    box-shadow: 0 0 18px rgb(255 138 216 / 0.35);
  }

  .week.current .week-head h2::after {
    content: " 🐾";
  }
}

/* ----- Theme picker sections ----- */
@layer base {
  .theme-section {
    grid-column: 1 / -1;
    margin: 8px 2px -2px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .theme-section:first-child {
    margin-top: 0;
  }
}

/* ----- Admin page ----- */
@layer base {
  .top-inner.wide,
  .admin-main {
    max-width: 1120px;
  }

  .admin-main {
    margin: 0 auto;
    padding: 18px 16px 48px;
    display: grid;
    gap: 18px;
  }

  .tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
  }

  .tile {
    padding: 14px 16px;
    background: var(--surface);
    border: var(--bw) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .tile.budget {
    grid-column: span 2;
  }

  .tile-label {
    font-size: 13px;
    color: var(--muted);
  }

  .tile-value {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: var(--display-weight);
    line-height: 1.25;
  }

  .tile-note {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--faint);
  }

  .meter {
    height: 8px;
    margin-top: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
    overflow: hidden;
  }

  .meter-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
  }

  .budget.warning .meter-fill {
    background: #d97706;
  }

  .budget.danger .meter-fill {
    background: var(--danger);
  }

  .panel {
    padding: 16px;
    background: var(--surface);
    border: var(--bw) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
  }

  .panel-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 12px;
  }

  .panel-head h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: var(--display-weight);
  }

  .panel-head input[type="search"] {
    width: min(280px, 100%);
    margin-left: auto;
  }

  .chart {
    position: relative;
    min-height: 220px;
  }

  .chart svg {
    display: block;
    max-width: 100%;
    overflow: visible;
  }

  .chart .grid {
    stroke: var(--border);
    stroke-width: 1;
  }

  .chart .axis {
    fill: var(--muted);
    font-size: 11.5px;
    font-family: var(--font-body);
  }

  .chart .value {
    fill: var(--text);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-body);
  }

  .chart .bar {
    fill: var(--accent);
    transition: opacity 0.15s;
  }

  .chart .hit {
    fill: transparent;
    cursor: pointer;
    outline: none;
  }

  .chart .hit.on {
    fill: color-mix(in srgb, var(--text) 6%, transparent);
  }

  .chart-tip {
    position: absolute;
    z-index: 2;
    display: grid;
    gap: 1px;
    padding: 6px 10px;
    translate: -50% 0;
    border: var(--bw) solid var(--border);
    border-radius: 8px;
    background: var(--solid-surface);
    color: var(--text);
    font-size: 12.5px;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
  }

  .chart-empty {
    position: absolute;
    inset: 40% 0 auto;
    text-align: center;
    color: var(--muted);
  }

  .table-view {
    margin-top: 10px;
  }

  .table-view summary {
    width: fit-content;
    cursor: pointer;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
  }

  table.data th,
  table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
  }

  table.data th {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
  }

  table.data .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  table.data td.low {
    color: var(--danger);
    font-weight: 700;
  }

  table.data tr.off td {
    opacity: 0.55;
  }

  table.users {
    min-width: 760px;
  }

  .row-actions > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tag {
    display: inline-block;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--muted);
  }

  .tag.ok {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
    color: var(--text);
  }

  .allow-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
  }

  .allow-list li {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px 4px 3px 12px;
    border: var(--bw) solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 13.5px;
  }

  .allow-list .icon-btn {
    width: 26px;
    height: 26px;
    font-size: 18px;
  }

  @media (max-width: 600px) {
    .tile.budget {
      grid-column: auto;
    }
  }
}

/* ----- Study bot (chat page) ----- */
@layer base {
  label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
  }

  label.check input {
    width: 18px;
    height: 18px;
    min-height: 0;
    accent-color: var(--accent);
  }

  .seg button[aria-checked="true"] {
    background: var(--solid-surface);
    color: var(--text);
    box-shadow: var(--shadow);
  }

  .chat-page {
    overflow: hidden;
  }

  .chat-app {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    height: 100dvh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(300px, 86vw);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--solid-surface);
    border-right: var(--bw) solid var(--border);
    translate: -105% 0;
    transition: translate 0.2s ease;
  }

  .side-open .sidebar {
    translate: 0 0;
    box-shadow: var(--shadow-lg);
  }

  .side-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: var(--backdrop);
  }

  .side-head {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .side-head .code {
    text-decoration: none;
  }

  .side-title {
    flex: 1;
    font-family: var(--font-display);
    font-weight: var(--display-weight);
  }

  .new-chat {
    justify-content: center;
  }

  .chat-list {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 2px;
    margin: 0 -4px;
    overflow-y: auto;
  }

  .side-empty {
    padding: 8px;
  }

  .chat-row {
    display: flex;
    align-items: center;
    border-radius: var(--radius-sm);
  }

  .chat-row.on,
  .chat-row:hover {
    background: var(--surface-2);
  }

  .chat-row .icon-btn {
    flex: none;
    width: 30px;
    height: 30px;
    font-size: 14px;
    opacity: 0.55;
  }

  .chat-row:hover .icon-btn,
  .chat-row.on .icon-btn {
    opacity: 1;
  }

  .chat-open {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
  }

  .chat-name {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
  }

  .side-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    padding-top: 10px;
    border-top: var(--bw) solid var(--border);
    font-size: 13px;
  }

  .side-foot a {
    color: var(--muted);
    text-decoration: none;
  }

  .side-foot a:hover {
    color: var(--text);
  }

  .chat-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100dvh;
  }

  .chat-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: var(--bw) solid var(--border);
    background: var(--header-bg);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
  }

  .chat-top h1 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: var(--display-weight);
  }

  .mode-toggle {
    flex: none;
    margin: 0;
    padding: 3px;
  }

  .mode-toggle button {
    height: 30px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .credit-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 6px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    color: var(--muted);
  }

  .credit-bar #credit-text {
    color: var(--text);
    font-weight: 600;
  }

  .credit-bar .meter {
    flex: 1;
    min-width: 60px;
    max-width: 200px;
    height: 6px;
    margin: 0;
  }

  .meter-fill[data-level="warn"] {
    background: #d97706;
  }

  .meter-fill[data-level="low"] {
    background: var(--danger);
  }

  .smart-count {
    white-space: nowrap;
  }

  .banners:empty {
    display: none;
  }

  .banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 8px 12px 0;
    padding: 6px 6px 6px 12px;
    border: 1px solid color-mix(in srgb, #d97706 45%, var(--border));
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, #d97706 14%, var(--surface));
    font-size: 14px;
    font-weight: 600;
  }

  .banner.danger {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
    background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  }

  .banner .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }

  .messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 12px 10px;
  }

  .messages > * {
    width: 100%;
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
  }

  .msg.user {
    display: flex;
    justify-content: flex-end;
  }

  .msg.user .bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px 18px 4px 18px;
    background: var(--accent);
    color: var(--accent-text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .msg.assistant {
    padding: 12px 14px;
    background: var(--surface);
    border: var(--bw) solid var(--border);
    border-radius: 18px 18px 18px 4px;
    box-shadow: var(--shadow);
  }

  .alt-label {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
  }

  .md {
    line-height: 1.6;
    overflow-wrap: anywhere;
  }

  .md > :first-child {
    margin-top: 0;
  }

  .md > :last-child {
    margin-bottom: 0;
  }

  .md p,
  .md ul,
  .md ol,
  .md pre,
  .md table,
  .md blockquote {
    margin: 0 0 0.7em;
  }

  .md ul,
  .md ol {
    padding-left: 1.4em;
  }

  .md h1,
  .md h2,
  .md h3,
  .md h4 {
    margin: 0.9em 0 0.4em;
    font-family: var(--font-display);
    font-size: 1.05em;
    font-weight: var(--display-weight);
  }

  .md code {
    padding: 1px 4px;
    border-radius: 4px;
    background: var(--surface-2);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
  }

  .md pre {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    overflow-x: auto;
  }

  .md pre code {
    padding: 0;
    background: none;
  }

  .md table {
    display: block;
    border-collapse: collapse;
    overflow-x: auto;
  }

  .md th,
  .md td {
    padding: 4px 10px;
    border: 1px solid var(--border);
  }

  .md blockquote {
    padding-left: 10px;
    border-left: 3px solid var(--border);
    color: var(--muted);
  }

  .md .katex-display {
    margin: 0.6em 0;
    padding: 2px 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .md .katex {
    font-size: 1.08em;
  }

  .msg-note {
    margin-top: 6px;
    font-size: 13px;
    font-style: italic;
    color: var(--muted);
  }

  .msg-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--faint);
  }

  .msg-error {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--danger) 12%, var(--surface));
    font-size: 14px;
  }

  .typing {
    display: inline-flex;
    gap: 4px;
    padding: 6px 0;
  }

  .typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: blink 1.2s infinite;
  }

  .typing i:nth-child(2) {
    animation-delay: 0.2s;
  }

  .typing i:nth-child(3) {
    animation-delay: 0.4s;
  }

  .welcome {
    margin: auto;
    padding: 24px 8px;
    text-align: center;
  }

  .welcome-title {
    margin-bottom: 6px;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: var(--display-weight);
  }

  .examples {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin-top: 16px;
  }

  .examples .example {
    height: auto;
    min-height: 36px;
    padding: 8px 14px;
    white-space: normal;
    text-align: left;
  }

  .gate {
    margin: auto;
    max-width: 440px;
  }

  .composer {
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: var(--bw) solid var(--border);
    background: var(--header-bg);
  }

  .composer > * {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
  }

  .composer-box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
  }

  .composer textarea {
    flex: 1;
    min-height: 46px;
    max-height: 180px;
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 16px;
    resize: none;
  }

  .send-btn {
    height: 46px;
    padding: 0 18px;
  }

  .send-btn.danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #ffffff;
  }

  .composer-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--faint);
  }

  .composer-hint:not(:empty) {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--danger);
  }

  .nudge {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 13px;
    color: var(--muted);
  }

  .rules-intro {
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.55;
  }

  .rules-list {
    display: grid;
    gap: 6px;
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
    font-size: 14.5px;
  }

  .rules-agree {
    margin: 12px 0;
    font-weight: 700;
  }

  .smart-skip {
    margin: 12px 0;
  }

  @media (min-width: 900px) {
    .chat-app {
      grid-template-columns: 280px minmax(0, 1fr);
    }

    .sidebar {
      position: static;
      width: auto;
      translate: none;
      transition: none;
    }

    .menu-btn,
    .side-close,
    .side-backdrop {
      display: none !important;
    }
  }

  @media (max-width: 480px) {
    .chat-top {
      gap: 6px;
      padding: 8px;
    }

    .mode-toggle button {
      padding: 0 8px;
      font-size: 12.5px;
    }
  }
}
