/* Demia: Apple-native look from design/week-view.html + .superdesign/design-system.md */
:root {
  --win: #FFFFFF; --side: #F5F5F7; --sep: rgba(0,0,0,.08); --sep-strong: rgba(0,0,0,.12);
  --label: #1D1D1F; --label2: #6E6E73; --label3: #AEAEB2;
  --fill: rgba(0,0,0,.05); --fill2: rgba(0,0,0,.04); --fill3: rgba(0,0,0,.07);
  --accent: #0A84FF; --red: #FF3B30; --today-bg: rgba(255,59,48,.06); --today-bg-hover: rgba(255,59,48,.10); --today-line: rgba(255,59,48,.16);
  --office: rgba(0,0,0,.12); --office-hover: rgba(0,0,0,.28);
  --card: rgba(120,120,110,.08); --card-hover: rgba(120,120,110,.13); --card-line: rgba(0,0,0,.06);
  --c0: #0A84FF; --c1: #30B0C7; --c2: #AF52DE; --c3: #FF9500; --c4: #FF2D55; --c5: #34C759; --c6: #5856D6;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  --hour: 64px;
  --card-h: 44px;   /* every assignment card (sidebar + compact panel) uses this height */
  color-scheme: light;
}
/* Dark tokens: used when macOS is dark (unless Settings forces Light), or when Settings forces Dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --win: #1E1E1E; --side: #262626; --seg-on: #414145; --sep: rgba(255,255,255,.08); --sep-strong: rgba(255,255,255,.14);
    --label: #F5F5F7; --label2: #98989D; --label3: #636366;
    --fill: rgba(255,255,255,.07); --fill2: rgba(255,255,255,.05); --fill3: rgba(255,255,255,.10);
    --red: #FF453A; --today-bg: rgba(255,69,58,.10); --today-bg-hover: rgba(255,69,58,.15); --today-line: rgba(255,69,58,.24);
    --office: rgba(255,255,255,.16); --office-hover: rgba(255,255,255,.34);
    --card: rgba(255,255,255,.06); --card-hover: rgba(255,255,255,.10); --card-line: rgba(255,255,255,.07);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --win: #1E1E1E; --side: #262626; --seg-on: #414145; --sep: rgba(255,255,255,.08); --sep-strong: rgba(255,255,255,.14);
  --label: #F5F5F7; --label2: #98989D; --label3: #636366;
  --fill: rgba(255,255,255,.07); --fill2: rgba(255,255,255,.05); --fill3: rgba(255,255,255,.10);
  --red: #FF453A; --today-bg: rgba(255,69,58,.10); --today-bg-hover: rgba(255,69,58,.15); --today-line: rgba(255,69,58,.24);
  --office: rgba(255,255,255,.16); --office-hover: rgba(255,255,255,.34);
  --card: rgba(255,255,255,.06); --card-hover: rgba(255,255,255,.10); --card-line: rgba(255,255,255,.07);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
/* OLED black (Settings → Appearance → Special themes: OLED Black, saved per device as theme="oled", `data-oled` on <html>):
   the dark look with true black behind everything, so OLED screens switch those pixels off. Floating windows
   (settings, menus, assignment cards) sit a step above black so they don't vanish into the background. */
@media (prefers-color-scheme: dark) {
  :root[data-oled]:not([data-theme]) {
    --win: #000; --side: #000; --sep: rgba(255,255,255,.11); --sep-strong: rgba(255,255,255,.17); --raised: #121214; --modal-bg: #121214; --seg-on: #2a2a2e;
    --fill: rgba(255,255,255,.08); --card: rgba(255,255,255,.07); --card-line: rgba(255,255,255,.09);
  }
}
:root[data-oled][data-theme="dark"] {
  --win: #000; --side: #000; --sep: rgba(255,255,255,.11); --sep-strong: rgba(255,255,255,.17); --raised: #121214; --modal-bg: #121214; --seg-on: #2a2a2e;
  --fill: rgba(255,255,255,.08); --card: rgba(255,255,255,.07); --card-line: rgba(255,255,255,.09);
}
:root[data-oled] :is(.modal, .popover, .palette, .asg-card, .note-modal, .row-menu) { background: var(--raised, var(--win)); }
:root[data-oled] .modal-nav { background: #0a0a0c; }
:root[data-oled] .modal-nav .nav-row.active { background: rgba(255,255,255,.11); }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.4 var(--font); color: var(--label); background: var(--win); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 6px; }
.tnum { font-variant-numeric: tabular-nums; }
.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; }

/* ── Shell ── */
.app { display: grid; grid-template-columns: auto 1fr; height: 100vh; }
/* Home Screen app on an iPad or iPhone: keep everything clear of the status bar and the home bar (0 on a Mac). */
.app { height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
/* The window reaches the bottom edge; only what sits at the very bottom keeps clear of the home bar. */
.composer { margin-bottom: max(0px, calc(env(safe-area-inset-bottom) - 8px)); }
.sidebar .side-bottom { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
/* On Chats, hiding the sidebar shrinks its slot to nothing, so the chat widens to fill the window (like the
   Claude app). Elsewhere the slot stays 248px and shows the compact panel. The width animates; the panels
   inside keep a fixed 248px so their text doesn't squish while the slot closes. */
.sidebar { width: 248px; transition: width .32s cubic-bezier(.32,.72,0,1), border-color .32s; }
.app.collapsed[data-view="chats"] .sidebar { width: 0; border-right-color: transparent; }
.app.collapsed[data-view="chats"] .mini { visibility: hidden; }
.app.no-anim .sidebar { transition: none; }
/* The sidebar slot holds two layers: the compact panel (mini month + cards) underneath, and the full
   sidebar on top. Hiding the sidebar slides the top layer out to the left, uncovering the panel;
   showing it slides it back in over the panel. Nothing else moves. */
.sidebar { position: relative; background: var(--side); border-right: 1px solid var(--sep); min-width: 0; overflow: hidden; }
.mini { position: absolute; top: 0; bottom: 0; left: 0; width: 248px; display: flex; flex-direction: column; min-height: 0; }
.full { position: absolute; top: 0; bottom: 0; left: 0; width: 248px; z-index: 2; display: flex; flex-direction: column; background: var(--side);
  box-shadow: 6px 0 16px rgba(0,0,0,.07);   /* only visible while it slides over the panel */
  transition: transform .32s cubic-bezier(.32,.72,0,1), visibility 0s; }
.app.collapsed .full { transform: translateX(calc(-100% - 24px)); visibility: hidden;
  transition: transform .32s cubic-bezier(.32,.72,0,1), visibility 0s .32s; }
.app.no-anim .full { transition: none; }
@media (prefers-reduced-motion: reduce) { .sidebar, .full, .app.collapsed .full { transition: none; } }
.side-top { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 16px; }
.app-name { font-weight: 600; color: var(--label2); font-size: 12px; white-space: nowrap; }
.icon-btn { width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; border-radius: 6px; color: var(--label2); }
.icon-btn:hover:not(:disabled) { background: var(--fill); color: var(--label); }
.icon-btn:disabled { opacity: .45; cursor: default; }
.nav { padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-row { height: 28px; display: flex; align-items: center; gap: 8px; padding: 0 8px; border-radius: 6px; color: var(--label2); white-space: nowrap; }
.nav-row:hover { background: var(--fill2); }
.nav-row.active { background: var(--fill); color: var(--label); font-weight: 500; }
.side-fill { flex: 1; }
.side-bottom { padding: 8px 12px; border-top: 1px solid var(--sep); display: flex; align-items: center; gap: 8px; }
/* "D2L synced 12 min ago" next to the Settings button: quiet, and it says when something is stale */
.sync-line { min-width: 0; font-size: 11.5px; color: var(--label3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-line.stale { color: var(--orange, #c77700); }

/* Sidebar assignment cards: all the same size. Today = red, Upcoming = grey. */
.due { padding: 0 12px 14px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.due h2 { font-size: 12px; font-weight: 600; color: var(--label2); margin: 0 0 6px 4px; }
.due-list { display: flex; flex-direction: column; gap: 6px; }
.card { position: relative; width: 100%; height: var(--card-h); flex-shrink: 0; display: flex; align-items: center; gap: 9px; padding: 0 9px 0 13px; border-radius: 8px; text-align: left;
  overflow: hidden; background: var(--card); border: 1px solid var(--card-line); transition: background .15s, opacity .2s, transform .2s; }
/* Solid course-color strip on the left edge, so the class is clear at a glance. */
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cc); }
.card:hover { background: var(--card-hover); }
.card.today { background: var(--today-bg); border-color: var(--today-line); }
.card.today:hover { background: var(--today-bg-hover); }
.card .body { min-width: 0; flex: 1; }
.card .ttl { display: block; font-size: 12.5px; line-height: 1.25; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { display: block; font-size: 11px; line-height: 1.25; color: var(--label2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.today .meta, .card .count { color: var(--red); }
.card .count { font-size: 11px; font-weight: 600; flex-shrink: 0; }
.card.exam .meta b { color: var(--label); font-weight: 600; }
/* Check circle: a quiet ring, fills with the course color on hover or when done. */
.check { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; box-shadow: inset 0 0 0 1.5px var(--label3); transition: box-shadow .12s, background .12s; }
.check svg { width: 10px; height: 10px; stroke-width: 3; color: #fff; opacity: 0; }
.card:hover .check { box-shadow: inset 0 0 0 1.5px var(--cc); }
.check:hover, .check.done { background: var(--cc); box-shadow: none !important; }
.check:hover svg, .check.done svg { opacity: 1; }
.due-empty { color: var(--label3); font-size: 12px; padding: 0 4px; }
/* Streak line above Urgent: a flame (orange while a streak is going), the count, and the best run when it's higher. */
.streak { display: flex; align-items: center; gap: 7px; padding: 7px 8px; border-radius: 8px; background: var(--fill); font-size: 12px; color: var(--label2); line-height: 1.35; }
.streak svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--label3); }
.streak.on svg { color: #ff8a1f; fill: color-mix(in srgb, #ff8a1f 30%, transparent); }
.streak span { flex: 1; min-width: 0; }
.streak b { color: var(--label); font-weight: 700; font-variant-numeric: tabular-nums; }
.streak em { font-style: normal; color: var(--label3); white-space: nowrap; }

/* ── Main ── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { height: 40px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--sep); }
.toolbar h1 { font-size: 13px; font-weight: 600; margin: 0; }
.range { color: var(--label2); }
.pager { display: flex; align-items: center; gap: 2px; margin-left: 4px; }
.pager[hidden] { display: none; }
.today-btn { height: 22px; padding: 0 8px; border: 1px solid var(--sep-strong); border-radius: 5px; font-size: 12px; }
.today-btn:hover { background: var(--fill2); }
.view { flex: 1; min-height: 0; position: relative; }
.view > .page { position: absolute; inset: 0; display: flex; flex-direction: column; animation: enter .22s ease-out backwards;   /* backwards, not both: a held end state would stop the frosted-glass blur behind chats */ }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .view > .page { animation: none; } .app { transition: none; } }

/* ── Week ── */
.week { --cols: 1fr 1fr 1fr 1fr 1fr .62fr .62fr; display: flex; flex-direction: column; height: 100%; }
.week-head, .allday, .grid { display: grid; grid-template-columns: 52px var(--cols); }
.week-head { height: 32px; border-bottom: 1px solid var(--sep); }
.dh { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--label2); border-left: 1px solid var(--sep); }
.dh b { font-weight: 600; color: var(--label); }
.dh.today { color: var(--red); }
.dh.today b { background: var(--red); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.dh.weekend b { color: var(--label3); }
.allday { border-bottom: 1px solid var(--sep); min-height: 28px; }
.ad-label { font-size: 10px; color: var(--label3); text-align: right; padding: 7px 6px 0 0; }
.ad-day { border-left: 1px solid var(--sep); padding: 3px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chip { display: flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: 4px; background: var(--cc); color: #fff; font-size: 11px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip.done { background: transparent; color: var(--label3); text-decoration: line-through; font-weight: 500; padding-left: 2px; }
.scroller { flex: 1; overflow-y: auto; position: relative; }
.grid { position: relative; }
.hours { position: relative; }
.hour-label { position: absolute; right: 6px; font-size: 10px; color: var(--label3); transform: translateY(-6px); }
.col { position: relative; border-left: 1px solid var(--sep); background-image: linear-gradient(var(--sep) 1px, transparent 1px); background-size: 100% var(--hour); }
.col.weekend { background-color: color-mix(in srgb, var(--fill2) 40%, transparent); }
.col.today { background-color: color-mix(in srgb, var(--red) 3%, transparent); }
.block { position: absolute; left: 4px; right: 4px; border-radius: 6px; background: var(--cc); color: #fff; padding: 4px 7px; overflow: hidden; z-index: 2; cursor: default; }
.block.has-office { left: 9px; }
.block .code { font-size: 12px; font-weight: 600; line-height: 1.25; display: flex; gap: 6px; align-items: baseline; }
.block .code small { font-weight: 500; opacity: .85; font-size: 11px; }
.block .room { font-size: 11px; opacity: .85; }
.block.holiday { background: transparent; color: var(--label3); border: 1px dashed var(--sep-strong); }
.block.exam { box-shadow: inset 0 0 0 2px rgba(255,255,255,.55); }
.block .tag { font-size: 10px; font-weight: 700; background: rgba(255,255,255,.25); padding: 0 5px; border-radius: 3px; }
.inrow { display: flex; align-items: center; gap: 5px; margin-top: 2px; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.2); font-size: 11px; font-weight: 500; width: 100%; text-align: left; color: #fff; white-space: nowrap; overflow: hidden; }
.inrow span { overflow: hidden; text-overflow: ellipsis; }
.inrow:hover { background: rgba(255,255,255,.3); }
.inrow .ring { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.9); flex-shrink: 0; }
.inrow.done { text-decoration: line-through; opacity: .65; }
.inrow.done .ring { background: rgba(255,255,255,.9); }
.office { position: absolute; left: 2px; width: 4px; border-radius: 2px; background: var(--office); z-index: 1; cursor: pointer; transition: background .15s; }
.office:hover { background: var(--office-hover); }
.dueline { position: absolute; left: 4px; right: 4px; z-index: 3; }
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 5; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }

/* ── Popover ── */
.popover { position: fixed; z-index: 50; min-width: 220px; max-width: 300px; background: var(--win); border: 1px solid var(--sep-strong); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 10px 12px; font-size: 12px; }
.popover h3 { font-size: 13px; margin: 0 0 4px; display: flex; gap: 6px; align-items: center; }
.popover h3 i { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); }
.popover p { margin: 2px 0; color: var(--label2); }

/* ── Chats ── */
.chats { display: grid; grid-template-columns: 250px 1fr; height: 100%; }
.threads { border-right: 1px solid var(--sep); padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.thread-row { height: 30px; display: flex; align-items: center; gap: 8px; padding: 0 8px; border-radius: 6px; color: var(--label2); text-align: left; width: 100%; }
.thread-row:hover { background: var(--fill2); }
.thread-row.active { background: var(--fill); color: var(--label); font-weight: 500; }
.thread-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex-shrink: 0; }
.thread-row .tn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-row .sub { margin-left: auto; font-size: 11px; color: var(--label3); }
.convo { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.convo-head { padding: 10px 20px; border-bottom: 1px solid var(--sep); display: flex; align-items: baseline; gap: 8px; }
.convo-head h2 { font-size: 15px; margin: 0; }
.convo-head span { color: var(--label2); }
.convo-head button { margin-left: auto; font-size: 12px; color: var(--label2); }
.convo-head button:hover { color: var(--label); }
.messages { flex: 1; overflow-y: auto; padding: 20px; }
.messages-inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg-user { align-self: flex-end; background: var(--fill); padding: 8px 12px; border-radius: 14px; max-width: 80%; white-space: pre-wrap; font-size: 14px; }
.msg-bot { font-size: 14px; line-height: 1.55; }
.msg-bot .from { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--cc); margin-bottom: 4px; }
.msg-bot .from i { width: 7px; height: 7px; border-radius: 50%; background: var(--cc); }
.msg-bot .from:hover { text-decoration: underline; }
.msg-bot .via { font-size: 11px; color: var(--label3); margin-bottom: 4px; }
.msg-bot .tools { font-size: 12px; color: var(--label3); margin-bottom: 6px; }
.msg-bot .md > :first-child { margin-top: 0; } .msg-bot .md > :last-child { margin-bottom: 0; }
.msg-bot table { border-collapse: collapse; font-size: 13px; margin: 8px 0; display: block; overflow-x: auto; }
.msg-bot th, .msg-bot td { border: 1px solid var(--sep-strong); padding: 4px 8px; text-align: left; }
.msg-bot code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--fill2); padding: 1px 4px; border-radius: 4px; }
.msg-bot pre { background: var(--fill2); padding: 10px; border-radius: 8px; overflow-x: auto; }
.msg-bot pre code { background: none; padding: 0; }
.pending { color: var(--label3); font-size: 13px; }
.err { color: var(--red); font-size: 13px; }
.empty-thread { color: var(--label2); text-align: center; margin-top: 15vh; }
.empty-thread h3 { color: var(--label); font-size: 15px; margin: 0 0 4px; }
.composer { padding: 12px 20px 16px; }
.composer form { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--sep-strong); border-radius: 12px; padding: 6px 6px 6px 12px; background: var(--win); }
.composer form:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: none; color: var(--label); font: 14px/1.45 var(--font); padding: 5px 0; max-height: 200px; }
.send { height: 28px; padding: 0 12px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; }
.send:disabled { opacity: .4; cursor: default; }

/* Briefing card: shown when an assignment is opened into its course chat. */
.brief { max-width: 720px; margin: 0 auto 4px; width: 100%; border: 1px solid var(--sep-strong); border-left: 3px solid var(--cc); border-radius: 8px; padding: 12px 14px; }
.brief h3 { margin: 0; font-size: 15px; }
.brief .when { color: var(--label2); margin-top: 2px; }
.brief .when b { color: var(--red); font-weight: 600; }
.brief .notes { margin-top: 8px; font-size: 13px; color: var(--label2); }
.brief .notes p { margin: 4px 0; }
.brief .actions { display: flex; gap: 8px; margin-top: 10px; }
.btn { height: 26px; padding: 0 10px; white-space: nowrap; flex-shrink: 0; border-radius: 6px; border: 1px solid var(--sep-strong); font-size: 12px; font-weight: 500; }
.btn:hover { background: var(--fill2); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }

/* ── Calendar ── */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: 28px; grid-auto-rows: 1fr; height: 100%; }
.mdow { font-size: 11px; font-weight: 600; color: var(--label2); padding: 7px 8px 0; border-bottom: 1px solid var(--sep); }
.mcell { border-right: 1px solid var(--sep); border-bottom: 1px solid var(--sep); padding: 4px 4px 2px; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.mcell:nth-child(7n) { border-right: 0; }
.mcell .n { font-size: 12px; font-weight: 600; padding: 0 4px; height: 20px; display: flex; align-items: center; }
.mcell.other { color: var(--label3); }
.mcell.other .chip { opacity: .5; }
.mcell.today .n span { background: var(--red); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; margin-left: -4px; }
.mcell .chip { background: transparent; color: var(--label); font-weight: 500; padding: 0 4px; }
.mcell .chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--cc); flex-shrink: 0; }
.mcell .chip:hover { background: var(--fill2); }
.mcell .chip.exam { background: var(--cc); color: #fff; font-weight: 600; }
.mcell .chip.exam::before { background: #fff; }
.mcell .chip.done { color: var(--label3); text-decoration: line-through; }
.mcell .more { font-size: 11px; color: var(--label2); padding: 0 4px; }

/* ── Study timer: a small frosted pill that floats over every view while a timer runs ── */
.study-pill { position: fixed; right: 16px; bottom: 16px; z-index: 55; display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 32px));
  padding: 6px 6px 6px 12px; border-radius: 999px; border: 1px solid var(--sep-strong); background: color-mix(in srgb, var(--win) 90%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); box-shadow: 0 8px 28px rgba(0,0,0,.18); font-size: 12.5px; }
.study-pill[hidden] { display: none; }
.study-pill .sp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex: none; animation: spPulse 2s ease-in-out infinite; }
@keyframes spPulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .study-pill .sp-dot { animation: none; } }
.study-pill .sp-what { min-width: 0; display: flex; gap: 6px; color: var(--label); text-decoration: none; white-space: nowrap; overflow: hidden; }
.study-pill .sp-what span { color: var(--label2); overflow: hidden; text-overflow: ellipsis; }
.study-pill .sp-time { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--label); }
.study-pill .sp-stop { height: 26px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--fill); color: var(--label); font: 600 12px var(--font); cursor: pointer; }
.study-pill .sp-stop:hover { background: var(--fill3); }
@media (max-width: 700px) {
  .study-pill { left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom)); max-width: none; }
  .study-pill .sp-time { margin-left: auto; }
  .study-pill .sp-stop { height: 36px; padding: 0 16px; }
  body.has-study .main { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom)); }   /* content scrolls clear of the pill */
}
.card .study-go { display: none; width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; align-items: center; justify-content: center; color: var(--label2); }
.card .study-go svg { width: 12px; height: 12px; fill: currentColor; }
.card:hover .study-go, .card:focus-within .study-go { display: inline-flex; }
.card .study-go:hover { background: var(--fill); color: var(--cc); }
@media (hover: none) { .card:hover .study-go { display: none; } }
.cp-studied { color: var(--label2); }

/* ── D2L setup: the empty-account banner and the guided dialog ── */
.setup-banner { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 12px 12px 12px 14px; border-radius: 12px;
  border: 1px solid var(--sep-strong); background: var(--fill2); }
.setup-banner > div { flex: 1; min-width: 0; }
.setup-banner p { margin: 2px 0 0; font-size: 12.5px; color: var(--label2); }
.setup-dialog { width: min(520px, calc(100vw - 32px)); }
.su-steps { margin: 10px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.5; }
.su-steps li { margin-bottom: 12px; }
.su-steps p { margin: 6px 0 0; }
.su-steps .feed-add { margin-top: 6px; }
.su-done { margin-top: 4px; padding: 10px 12px; border-radius: 10px; background: var(--fill2); font-size: 13px; line-height: 1.45; }
.su-done p { margin: 4px 0 0; color: var(--label2); }
.su-classes { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 6px 0 8px; }
@media (max-width: 700px) {
  .su-steps { padding-left: 18px; }
  .su-steps .feed-add { flex-wrap: wrap; }
  .su-steps .feed-add input { flex-basis: 100%; height: 44px; font-size: 16px; }
  .setup-dialog .btn { min-height: 44px; padding: 0 16px; }
}

/* ── File viewer (hosted copies): the file in place, with Download / Print ── */
.viewer-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(0,0,0,.42); padding: 24px; }
.viewer-backdrop[hidden] { display: none; }
.viewer { width: min(1000px, 100%); height: min(92vh, 1200px); display: flex; flex-direction: column; background: var(--win);
  border: 1px solid var(--sep-strong); border-radius: 12px; box-shadow: 0 24px 70px rgba(0,0,0,.35); overflow: hidden; }
.viewer header { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--sep); }
.viewer header b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.viewer .v-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.viewer .v-body { flex: 1; min-height: 0; overflow: auto; background: var(--fill2); }
.viewer .v-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer .v-body img { display: block; max-width: 100%; margin: 0 auto; }
.viewer .v-note { margin: 0; padding: 10px 20px; font-size: 12.5px; color: var(--label2); background: var(--fill2); border-bottom: 1px solid var(--sep); }
.viewer .v-text { margin: 16px auto 24px; padding: 0 20px; max-width: 72ch; white-space: pre-wrap; font: 15px/1.65 var(--font); color: var(--label); }
.viewer #vClose { width: 32px; height: 32px; font-size: 18px; }
.viewer .v-body:has(.v-note) { background: var(--win); }
.print-frame { position: fixed; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none; }
@media (max-width: 700px) {
  .viewer-backdrop { padding: 0; }
  .viewer { height: 100dvh; border-radius: 0; border: 0; }
  .viewer header { padding-top: max(10px, env(safe-area-inset-top)); flex-wrap: wrap; }
  .viewer header b { flex-basis: 100%; }
  .viewer .v-newtab { display: none; }
}

/* ── Toast (finish / undo) ── */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 8px); opacity: 0; pointer-events: none; z-index: 60;
  background: var(--label); color: var(--win); padding: 7px 14px; border-radius: 8px; font-size: 12px; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: opacity .18s, transform .18s; white-space: nowrap; }
.toast span { opacity: .6; margin-left: 8px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ── Mini panel (collapsed sidebar) ── */
.mini-head { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; flex-shrink: 0; }
.mini-head b { font-size: 13px; font-weight: 600; }
.mini-head div { display: flex; }
.mini-head .icon-btn { width: 24px; height: 24px; }
.mini-month { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 10px 12px; row-gap: 2px; flex-shrink: 0; }
.mini-month .dw { font-size: 10.5px; font-weight: 500; color: var(--label2); text-align: center; height: 22px; line-height: 22px; }
.mini-week { display: contents; }
.mday { position: relative; height: 26px; display: grid; place-items: center; font-size: 12px; font-weight: 500; border-radius: 6px; font-variant-numeric: tabular-nums; }
.mday:hover { background: var(--fill2); }
.mday.other { color: var(--label3); }
.mday.inweek { background: var(--fill); border-radius: 0; }
.mday.inweek.first { border-radius: 6px 0 0 6px; } .mday.inweek.last { border-radius: 0 6px 6px 0; }
.mday.today span { background: var(--red); color: #fff; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.mday.has::after { content: ""; position: absolute; bottom: 2px; width: 3px; height: 3px; border-radius: 50%; background: var(--label3); }
.mday.today.has::after { display: none; }
.mini-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 12px; border-top: 1px solid var(--sep); overscroll-behavior: contain; }
.mini-group { display: flex; flex-direction: column; gap: 5px; }
.mini-group + .mini-group { margin-top: 4px; }
/* Day headers stay pinned while you scroll through that day's cards. */
.mini-group h3 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 4px 5px; background: var(--side);
  font-size: 11.5px; font-weight: 600; color: var(--label2); display: flex; justify-content: space-between; }
.mini-group h3 span { font-weight: 500; color: var(--label3); }
.mini-group.late h3 { color: var(--red); }

/* ── Term load heatmap (compact panel, Calendar view) ── */
.mini-month.heat { display: block; padding: 2px 14px 14px 12px; }
.heat-months, .heat-grid { display: grid; column-gap: 2px; }
.heat-months { font-size: 10px; color: var(--label3); height: 14px; margin-bottom: 2px; }
.heat-months span { white-space: nowrap; }
.heat-months span.on { color: var(--label); font-weight: 600; }
.heat-grid { grid-template-rows: repeat(7, auto); row-gap: 2px; }
.heat-grid > span { font-size: 9px; color: var(--label3); line-height: 1; align-self: center; grid-column: 1; }
.hc { aspect-ratio: 1; width: 100%; border-radius: 2.5px; transition: opacity .15s; }
.hc.l0, .heat-legend .l0 { background: var(--fill); }
.hc.l1, .heat-legend .l1 { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.hc.l2, .heat-legend .l2 { background: color-mix(in srgb, var(--accent) 50%, transparent); }
.hc.l3, .heat-legend .l3 { background: color-mix(in srgb, var(--accent) 75%, transparent); }
.hc.l4, .heat-legend .l4 { background: var(--accent); }
.hc.dim { opacity: .45; }               /* weeks outside the month shown in the big calendar */
.hc:hover { opacity: 1; outline: 1px solid var(--label2); outline-offset: 1px; }
/* Exams: a quiet marker, not an alarm. */
.hc.exam { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 55%, transparent); }
.hc.today { outline: 1.5px solid var(--label); outline-offset: 1px; opacity: 1; }
.heat-foot { display: flex; justify-content: space-between; margin-top: 10px; }
.heat-legend { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; color: var(--label3); }
.heat-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.heat-legend .exam-key { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 55%, transparent); background: var(--fill); }
.heat-busy { margin-top: 8px; font-size: 11.5px; color: var(--label2); }
.heat-busy b { color: var(--label); font-weight: 600; }

/* ── Segmented control (Settings, heatmap) ── */
.seg { display: inline-flex; background: var(--fill); border-radius: 7px; padding: 2px; gap: 2px; flex-shrink: 0; }
.seg button { padding: 3px 12px; border-radius: 5px; font-size: 12px; color: var(--label2); }
.seg button.on { background: var(--seg-on, var(--win)); color: var(--label); font-weight: 500; box-shadow: inset 0 0 0 1px var(--sep), 0 1px 2px rgba(0,0,0,.12); }
.seg.small button { padding: 2px 8px; font-size: 11px; }
.seg[hidden] { display: none; }
.icon-btn.active { background: var(--fill); color: var(--label); }

/* ── Settings window ── */
.srow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; }
.srow + .srow { border-top: 1px solid var(--sep); }
.srow.compact { padding: 9px 14px; }
.srow.stack { flex-direction: column; align-items: stretch; gap: 12px; }
.srow.stack .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; align-self: flex-start; }
.srow.stack .seg::-webkit-scrollbar { display: none; }
.srow.stack .seg button { flex-shrink: 0; white-space: nowrap; }
.slabel { display: flex; align-items: center; gap: 10px; min-width: 0; }
.slabel > div { min-width: 0; }
.slabel b { font-weight: 500; color: var(--label); }
.slabel p, .srow > p { margin: 3px 0 0; font-size: 12px; color: var(--label2); line-height: 1.45; }
.sdot { width: 10px; height: 10px; border-radius: 50%; background: var(--cc); flex-shrink: 0; }
.swatches { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sw { width: 18px; height: 18px; border-radius: 50%; background: var(--cc); }
.sw.on { box-shadow: 0 0 0 2px var(--modal-bg, var(--solid, var(--win))), 0 0 0 3.5px var(--cc); }
.swatches .auto { height: 26px; font-size: 12px; color: var(--label2); padding: 0 9px; border-radius: 6px; margin-left: 4px; border: 1px solid transparent; }
.swatches .auto:hover { background: var(--fill2); color: var(--label); }
.swatches .auto.on { background: var(--fill); color: var(--label); border-color: var(--sep); font-weight: 500; }
select { font: inherit; color: var(--label); background: var(--modal-bg, var(--win)); border: 1px solid var(--sep-strong); border-radius: 7px; padding: 0 10px; height: 30px; font-size: 12.5px; }
kbd { font: 11.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--label2); background: var(--fill); border: 1px solid var(--sep); border-radius: 5px; padding: 4px 7px; white-space: nowrap; flex-shrink: 0; }

/* `hidden` must win over display rules on buttons */
.icon-btn[hidden], .seg[hidden] { display: none; }

/* ── Settings window (floating, like the Claude app) ── */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.32); display: grid; place-items: center; animation: fadeIn .15s ease-out; }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(880px, calc(100vw - 48px)); height: min(660px, calc(100vh - 48px)); background: var(--modal-bg, var(--solid, var(--win))); border: 1px solid var(--sep-strong);
  border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; animation: popIn .18s cubic-bezier(.32,.72,0,1); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.97); } }
@media (prefers-reduced-motion: reduce) { .modal-backdrop, .modal { animation: none; } }
.modal-head { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 14px 0 20px; border-bottom: 1px solid var(--sep); }
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-back { margin-left: -6px; }
.modal-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 216px 1fr; }
.modal-nav { border-right: 1px solid var(--sep); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; background: var(--side); overflow-y: auto; }
.modal-nav .nav-row { width: 100%; height: 32px; padding: 0 10px; gap: 9px; border-radius: 7px; text-align: left; font-size: 13px; color: var(--label2); }
.modal-nav .nav-row svg { opacity: .82; }
.modal-nav .nav-row.active { background: var(--fill); color: var(--label); font-weight: 500; }
.modal-nav .nav-row.active svg { opacity: 1; }
.modal-nav .nav-chev { display: none; margin-left: auto; width: 14px; height: 14px; color: var(--label3); opacity: .75; }
.modal-content { overflow-y: auto; padding: 20px 26px 34px; }
.s-head { margin: 0 0 10px; }
.modal-content h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.s-lead { margin: 5px 0 0; font-size: 12.5px; color: var(--label2); line-height: 1.48; }
.s-group { border-top: 1px solid var(--sep); }
.s-group .srow:first-child { border-top: 0; }
.modal-content .sub-h { font-size: 12px; font-weight: 600; color: var(--label2); margin: 20px 0 8px; }
.modal-content .srow { padding: 14px 0; }
.modal-content .srow.compact { padding: 10px 0; }
.modal-content .srow + .srow { border-top: 1px solid var(--sep); }
.modal-content .btn { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.modal-content .seg { height: 30px; padding: 2px; border-radius: 7px; align-items: stretch; }
.modal-content .seg button { height: 100%; padding: 0 12px; font-size: 12.5px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; }
.s-state { padding: 12px 14px; border-radius: 8px; background: var(--fill2); border: 1px solid var(--sep); color: var(--label2); font-size: 12.5px; line-height: 1.45; margin: 4px 0 12px; }
.s-state.loading { color: var(--label3); }
.s-state.error { color: var(--red); background: var(--today-bg); border-color: var(--today-line); }
.muted { color: var(--label2); font-size: 12.5px; margin: 8px 0 14px; line-height: 1.48; }
.muted.small { font-size: 11.5px; margin: 6px 0 0; }
.feed { border: 1px solid var(--card-line); background: var(--card); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.feed-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.feed-top b { font-weight: 500; font-size: 13px; }
.feed-top p { margin: 3px 0 0; font-size: 12px; color: var(--label2); line-height: 1.4; }
.feed-actions { display: flex; gap: 6px; flex-shrink: 0; }
.feed details { margin-top: 8px; font-size: 12px; color: var(--label2); }
.feed summary { cursor: pointer; }
.feed ul { margin: 6px 0 0; padding-left: 18px; max-height: 160px; overflow-y: auto; }
.feed-add { display: flex; gap: 8px; margin-top: 12px; }
.feed-add input { flex: 1; min-width: 0; height: 32px; font: 12.5px var(--font); color: var(--label); background: var(--modal-bg, var(--win)); border: 1px solid var(--sep-strong); border-radius: 7px; padding: 0 10px; }
.feed-add input:focus { outline: none; border-color: var(--accent); }
.feed-add .btn { height: 32px; }
.feed-err { margin: 8px 0 0; font-size: 12px; }
.feed-err:empty { display: none; }
.modal-content .feed-held-heading { margin: 14px 0 4px; display: flex; align-items: center; gap: 6px; }
.feed-held-heading span { background: var(--fill); border-radius: 9px; padding: 1px 7px; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--label); }
.feed-held-lead { margin: 0 0 10px; }
.feed-held-empty { margin: 10px 0 0; }
.held-item { padding: 11px 0; }
.held-item + .held-item { border-top: 1px solid var(--sep); }
.held-item > b { display: block; font-size: 13px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.held-meta { display: flex; align-items: center; gap: 6px; margin: 4px 0 9px; color: var(--label2); font-size: 12px; font-variant-numeric: tabular-nums; }
.held-meta .sdot { width: 8px; height: 8px; }
.held-actions, .inbox-actions { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.held-pick, .lib-pick {
  min-width: 0; max-width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--sep-strong); border-radius: 7px;
  font: 12.5px var(--font); color: var(--label); background: var(--modal-bg, var(--solid, var(--win)));
}
.held-pick { width: min(260px, 100%); flex: 1 1 200px; }
.held-actions .btn:disabled, .inbox-actions:disabled { opacity: .48; cursor: default; }
.held-actions .btn:disabled:hover { background: transparent; }
a.btn { display: inline-flex; align-items: center; }
.inline-form { margin: 0; display: inline-flex; }
.srow-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.mcp-box { width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 11px; border-radius: 8px; background: var(--fill2); border: 1px solid var(--sep); }
.mcp-box[hidden] { display: none; }
.mcp-box code { flex: 1; min-width: 0; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--label); overflow-x: auto; white-space: nowrap; scrollbar-width: thin; user-select: all; }

/* ── Theme preview tiles (Settings → Appearance) ── */
.theme-grid { display: grid; gap: 10px; width: 100%; }
.theme-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.theme-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.theme-tile { display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 0; text-align: left; border-radius: 9px; }
.theme-tile:focus-visible { outline: none; }
.theme-shot { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; border: 1px solid var(--sep-strong);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.theme-tile:hover .theme-shot { border-color: var(--label3); transform: translateY(-1px); }
.theme-tile.on .theme-shot { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-tile:focus-visible .theme-shot { box-shadow: 0 0 0 2px var(--modal-bg, var(--solid, var(--win))), 0 0 0 4px var(--accent); }
.theme-name { font-size: 12px; font-weight: 500; color: var(--label2); text-align: center; line-height: 1.25; }
.theme-tile.on .theme-name { color: var(--label); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .theme-shot { transition: none; } .theme-tile:hover .theme-shot { transform: none; } }

/* Mini window inside each theme preview */
.ts-win { position: absolute; inset: 0; z-index: 2; display: grid; grid-template-columns: 28% 1fr; }
.ts-side { display: flex; flex-direction: column; gap: 3px; padding: 6px 5px; border-right: 1px solid var(--ts-sep); background: var(--ts-side); }
.ts-nav { display: block; height: 3px; width: 76%; border-radius: 2px; background: var(--ts-line); }
.ts-nav.on { width: 92%; background: var(--ts-accent); opacity: .92; }
.ts-card { display: block; margin-top: auto; height: 8px; border-radius: 2.5px; background: var(--ts-card); border-left: 2px solid var(--ts-accent); }
.ts-main { display: flex; flex-direction: column; gap: 5px; padding: 5px 6px; background: var(--ts-win); }
.ts-bar { display: flex; align-items: center; justify-content: space-between; height: 6px; padding-bottom: 3px; border-bottom: 1px solid var(--ts-sep); }
.ts-bar i { display: block; height: 2.5px; width: 26%; border-radius: 2px; background: var(--ts-line); }
.ts-bar i:last-child { width: 14%; background: var(--ts-accent); opacity: .82; }
.ts-cols { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(6, 1fr); gap: 3px 4px; padding-top: 2px; }
.ts-blk { display: block; border-radius: 3px; }
.ts-blk.b1 { background: var(--ts-c1, #0A84FF); grid-column: 1; grid-row: 1 / 5; }
.ts-blk.b2 { background: var(--ts-c2, #AF52DE); grid-column: 2; grid-row: 2 / 6; }
.ts-blk.b3 { background: var(--ts-c3, #34C759); grid-column: 3; grid-row: 1 / 4; }

/* Base themes */
.ts-light, .ts-half-l {
  --ts-win: #FFFFFF; --ts-side: #F5F5F7; --ts-sep: rgba(0,0,0,.09); --ts-line: rgba(29,29,31,.2);
  --ts-card: rgba(120,120,110,.13); --ts-accent: #0A84FF;
}
.ts-dark, .ts-half-r {
  --ts-win: #1E1E1E; --ts-side: #262626; --ts-sep: rgba(255,255,255,.1); --ts-line: rgba(245,245,247,.25);
  --ts-card: rgba(255,255,255,.09); --ts-accent: #0A84FF;
}
.ts-half { position: absolute; inset: 0; }
.ts-half-l { clip-path: inset(0 50% 0 0); }
.ts-half-r { clip-path: inset(0 0 0 50%); }
.ts-system::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; z-index: 3; background: rgba(128,128,128,.35); }
.ts-sunset .ts-half-l { --ts-win: #FFFDF9; --ts-side: #F7F1E8; --ts-accent: #FF9500; }
.ts-sunset .ts-half-r { --ts-win: #1A1822; --ts-side: #221F2D; --ts-accent: #FF8A5C; }
.ts-horizon { position: absolute; top: 0; bottom: 0; left: calc(50% - 1.5px); width: 3px; z-index: 3;
  background: linear-gradient(180deg, #ffb36b 0%, #f07b62 50%, #5b3a70 100%); }

/* Special themes: real tokens + art */
.ts-oled {
  background: #000000;
  --ts-win: #000000; --ts-side: #000000; --ts-sep: rgba(255,255,255,.16); --ts-line: rgba(245,245,247,.28);
  --ts-card: #121214; --ts-accent: #0A84FF;
}
.ts-sonoran {
  background: #1b1022 url(/themes/sonoran.svg) center bottom / cover no-repeat;
  --ts-win: rgba(30, 18, 34, .54); --ts-side: rgba(24, 13, 28, .32); --ts-sep: rgba(255, 214, 190, .18);
  --ts-line: rgba(252, 242, 234, .34); --ts-card: rgba(255, 228, 210, .12); --ts-accent: #FF8A5C;
  --ts-c1: #FF8A5C; --ts-c2: #c8665c; --ts-c3: #f09a62;
}
.ts-terminal {
  background: #030506;
  --ts-win: #05080a; --ts-side: #030506; --ts-sep: rgba(57, 255, 136, .26);
  --ts-line: rgba(111, 211, 143, .42); --ts-card: rgba(57, 255, 136, .08); --ts-accent: #39ff88;
}
.ts-terminal .ts-blk { background: rgba(57, 255, 136, .14); box-shadow: inset 0 0 0 1px #39ff88; border-radius: 1px; }
.ts-terminal .ts-blk.b2 { background: rgba(48, 176, 199, .16); box-shadow: inset 0 0 0 1px #30B0C7; }
.ts-terminal .ts-blk.b3 { background: rgba(255, 204, 51, .14); box-shadow: inset 0 0 0 1px #ffcc33; }
.ts-terminal .ts-nav, .ts-terminal .ts-card, .ts-terminal .ts-bar i { border-radius: 1px; }
.ts-terminal .ts-scan { position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.32) 0 1px, transparent 1px 3px); opacity: .5; }
.ts-pixel {
  background: linear-gradient(#59b7ff 0 32%, #7cc6ff 32% 58%, #a6d9ff 58% 78%, #cdeaff 78%);
  --ts-win: rgba(255, 255, 255, .64); --ts-side: rgba(255, 255, 255, .44); --ts-sep: rgba(29, 33, 64, .22);
  --ts-line: rgba(29, 33, 64, .34); --ts-card: rgba(255, 255, 255, .86); --ts-accent: #ff4f7b;
  --ts-c1: #ff4f7b; --ts-c2: #3b82f6; --ts-c3: #22c55e;
}
.ts-pixel .ts-sun { position: absolute; right: 9px; top: 8px; width: 10px; height: 10px; z-index: 1; background: #ffd23f; box-shadow: 0 0 0 2px rgba(255,210,63,.45); }
.ts-pixel .ts-land { position: absolute; left: 0; right: 0; bottom: 0; height: 48%; z-index: 1; background: url(/themes/pixel.svg) center bottom / cover no-repeat; image-rendering: pixelated; }
.ts-pixel .ts-xp { position: absolute; right: 6px; bottom: 5px; width: 28px; height: 4px; z-index: 3; background: #fff; border: 1px solid #1d2140;
  box-shadow: inset 18px 0 0 #22c55e; }
.ts-pixel .ts-blk, .ts-pixel .ts-nav, .ts-pixel .ts-card, .ts-pixel .ts-bar i { border-radius: 0; }
.ts-pixel .ts-blk { box-shadow: inset 0 1.5px 0 rgba(255,255,255,.35), inset 0 -2px 0 rgba(0,0,0,.25); }
.ts-nebula {
  background: #06051a;
  --ts-win: rgba(10, 8, 28, .38); --ts-side: rgba(8, 6, 24, .28); --ts-sep: rgba(200, 190, 255, .18);
  --ts-line: rgba(240, 237, 255, .32); --ts-card: rgba(200, 190, 255, .12); --ts-accent: #9d8cff;
  --ts-c1: #f1efe9; --ts-c2: rgba(241, 239, 233, .88); --ts-c3: #9d8cff;
}
.ts-nebula .ts-neb { position: absolute; inset: -10%; z-index: 1; filter: blur(8px);
  background: radial-gradient(45% 40% at 28% 35%, rgba(139,92,246,.85), transparent 72%),
    radial-gradient(40% 38% at 75% 60%, rgba(56,189,248,.65), transparent 72%),
    radial-gradient(35% 32% at 58% 24%, rgba(236,72,153,.6), transparent 72%); }
.ts-nebula .ts-stars { position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(1.2px 1.2px at 18% 22%, #fff, transparent), radial-gradient(1px 1px at 78% 26%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 62% 72%, #ffe9c7, transparent), radial-gradient(1px 1px at 36% 78%, #cfe0ff, transparent),
    radial-gradient(1.1px 1.1px at 86% 64%, #fff, transparent); }
.ts-cafe {
  background: #fbf6ee;
  --ts-win: #fbf6ee; --ts-side: #f2e8da; --ts-sep: rgba(90, 60, 40, .15);
  --ts-line: rgba(58, 46, 40, .24); --ts-card: rgba(120, 80, 50, .1); --ts-accent: #b8673a;
  --ts-c1: #b8673a; --ts-c2: #7a8f63; --ts-c3: #c98a55;
}
.ts-cafe .ts-side { background-image: radial-gradient(rgba(90, 60, 40, .26) 0.9px, transparent 1.1px); background-size: 6px 6px; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .theme-shot { border-radius: 0; }
:root[data-theme="terminal"]:not([data-intensity="low"]) .theme-shot { border-radius: 2px; }

/* ── Course page ── */
.course-page { height: 100%; overflow-y: auto; }
.cp-inner { max-width: 1040px; margin: 0 auto; padding: 24px 28px 48px; }
.cp-head { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--sep); }
.cp-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--cc); flex-shrink: 0; }
.cp-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.cp-head p { margin: 2px 0 0; color: var(--label2); }
.cp-actions { margin-left: auto; display: flex; gap: 8px; }
.cp-actions .btn, .pop-actions .btn { display: inline-flex; align-items: center; }
.cp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 36px; margin-top: 20px; }
.cp-grid h2 { font-size: 12px; font-weight: 600; color: var(--label2); margin: 22px 0 8px; display: flex; justify-content: space-between; }
.cp-grid h2:first-child { margin-top: 0; }
.cp-grid h2 span { font-weight: 500; color: var(--label3); }
.cp-cards { max-width: 520px; }
.cp-done { margin-top: 14px; font-size: 12.5px; color: var(--label2); }
.cp-done summary { cursor: pointer; }
.cp-done ul, .cp-qs { list-style: none; margin: 8px 0 0; padding: 0; }
.cp-done li, .cp-qs li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--sep); }
.cp-done li span, .cp-qs li span { color: var(--label3); flex-shrink: 0; }
.cp-qs a, .cp-done a { color: var(--label); }
.cp-qs a:hover, .cp-done a:hover { text-decoration: underline; }
.cp-md { font-size: 12.5px; color: var(--label2); line-height: 1.5; }
.cp-md ul { margin: 0; padding-left: 16px; }
.cp-md li { margin: 3px 0; }
.cp-md strong { color: var(--label); font-weight: 600; }
.cp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-tags span { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--fill); }
.cp-tags b { font-weight: 600; color: var(--cc); }
.convo-head h2 a:hover { text-decoration: underline; }
.brief-course { font-size: 12px; font-weight: 600; color: var(--cc); }
.brief-course:hover { text-decoration: underline; }
.pop-actions { display: flex; gap: 6px; margin-top: 8px; }
@media (max-width: 900px) { .cp-grid { grid-template-columns: 1fr; } }

/* Course page: class times, office hours and details, edited in place (mountCourseEdit in app.js). */
#cpEdit h2 { align-items: baseline; scroll-margin-top: 16px; }
#cpEdit h2:focus { outline: none; }
#cpEdit:first-child h2:first-child { margin-top: 0; }
.mt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mt-list:empty { display: none; }
.mt-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; width: 100%; padding: 8px 10px 8px 12px; text-align: left;
  border-radius: 9px; background: var(--fill2); border-left: 3px solid var(--cc); transition: background .12s; }
.mt-summary:hover { background: var(--fill); }
.mt-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mt-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 13px; color: var(--label); }
.mt-main b { font-weight: 600; }
.mt-time { font-variant-numeric: tabular-nums; color: var(--label2); }
.mt-sub { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 2px; font-size: 12px; color: var(--label2); min-width: 0; overflow-wrap: anywhere; }
.mt-sub:empty { display: none; }
.mt-type { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; color: var(--cc); background: color-mix(in srgb, var(--cc) 14%, transparent); }
.mt-chev { grid-column: 2; grid-row: 1 / span 2; width: 14px; height: 14px; fill: none; stroke: var(--label3); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mt-empty { margin: 0 0 8px; }
.mt-add { margin-top: 8px; display: inline-flex; align-items: center; gap: 5px; }
.mt-add span { font-size: 14px; line-height: 1; color: var(--accent); }
.mt-row.editing { padding: 12px; border-radius: 11px; background: var(--raised, var(--win)); border: 1px solid var(--sep-strong); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.mt-form, .ci-form { display: grid; gap: 10px; margin: 0; }
.mt-days { display: flex; gap: 4px; margin: 0; padding: 0; border: 0; min-width: 0; }
.day-chip { flex: 1 1 0; min-width: 0; height: 30px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--label2); background: var(--fill); transition: background .12s, color .12s; }
.day-chip:hover { background: var(--fill3); }
.day-chip.on { background: var(--cc, var(--accent)); color: #fff; }
.day-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mt-fields, .ci-form { grid-template-columns: 1fr 1fr; gap: 8px; }
.mt-fields { display: grid; }
.mt-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mt-field > span { font-size: 11px; font-weight: 500; color: var(--label2); }
.mt-field input, .mt-field select { width: 100%; min-width: 0; height: 30px; font: 12.5px var(--font); color: var(--label); background: var(--modal-bg, var(--win));
  border: 1px solid var(--sep-strong); border-radius: 7px; padding: 0 9px; }
.mt-field input[type=time], .mt-field input[type=date] { font-variant-numeric: tabular-nums; }
.mt-field input:focus, .mt-field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.mt-field input[aria-invalid=true] { border-color: var(--red); }
.mt-field.wide, .ci-form .wide { grid-column: 1 / -1; }
.mt-err { margin: 0; padding: 6px 10px; border-radius: 7px; font-size: 12px; color: var(--red); background: color-mix(in srgb, var(--red) 9%, transparent); }
.mt-err[hidden] { display: none; }
.mt-note { margin: 0; }
.mt-actions { display: flex; align-items: center; gap: 6px; }
.mt-actions .btn.subtle { margin-left: 0; color: var(--red); }
.mt-spacer { flex: 1; }
.ci-list { border-radius: 9px; background: var(--fill2); padding: 2px 12px; }
.ci-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 12.5px; border-top: 1px solid var(--sep); }
.ci-row:first-child { border-top: 0; }
.ci-row > span { color: var(--label2); flex-shrink: 0; }
.ci-row b { font-weight: 500; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.ci-row b.muted { font-weight: 400; color: var(--label3); margin: 0; font-size: inherit; }
.mt-sub .muted { margin: 0; font-size: inherit; }
.ci-form { padding: 12px; border-radius: 11px; background: var(--raised, var(--win)); border: 1px solid var(--sep-strong); }
.mt-add-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mt-add-row .mt-add { margin-top: 0; }
#cpEdit.drop .mt-list, #cpEdit.drop .mt-empty { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 9px; }
.ii-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; }
.ii-lead { margin: 0 0 10px; }
.ii-lead b { color: var(--label); font-weight: 500; }
.ii-body { overflow-y: auto; margin: 0 -4px; padding: 0 4px; display: flex; flex-direction: column; gap: 14px; }
.ii-course h3 { display: flex; align-items: baseline; gap: 7px; margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.ii-course h3 i { width: 9px; height: 9px; border-radius: 3px; background: var(--cc); align-self: center; }
.ii-course h3 span { font-weight: 400; color: var(--label2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ii-course ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ii-course li > label, .ii-course li { display: flex; align-items: center; gap: 10px; }
.ii-course li { padding: 7px 10px; border-radius: 8px; background: var(--fill2); }
.ii-course li > label { flex: 1; min-width: 0; flex-wrap: wrap; cursor: pointer; }
.ii-course input[type=checkbox] { accent-color: var(--cc, var(--accent)); width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
.ii-when { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--label2); }
.ii-when b { color: var(--label); font-weight: 600; margin-right: 4px; }
.ii-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--label2); min-width: 0; }
.ii-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 6px; font-size: 12px; color: var(--label2); }
.ii-mode label { display: inline-flex; align-items: center; gap: 5px; color: var(--label); cursor: pointer; }
.ii-unmatched h3 { color: var(--label2); }
.ii-un { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ii-sum { font-size: 12.5px; font-weight: 500; overflow-wrap: anywhere; }
.ii-unmatched select { flex-shrink: 0; max-width: 40%; }
.ii-dates, .ii-add { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 0 0 6px; cursor: pointer; }
.ii-term-group { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--sep); }
.ii-term-group:first-child { border-top: 0; padding-top: 0; }
.ii-term-group.off .ii-term-body, .ii-term-group.off .ii-note { opacity: .45; }
.ii-term-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ii-term-head b { font-size: 14px; font-weight: 600; }
.ii-term-head input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.ii-term-body { display: flex; flex-direction: column; gap: 12px; }
.ii-badge { margin-left: 8px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.ii-badge.new { color: var(--label2); background: var(--fill); }
.ii-note { margin: -4px 0 0 24px; }
.ii-desc { margin: 0 0 6px; font-size: 12px; color: var(--label2); }
.ii-desc summary { cursor: pointer; list-style-position: outside; }
.ii-desc summary label { display: inline-flex; align-items: center; gap: 6px; color: var(--label); }
.ii-desc p { margin: 4px 0 0; line-height: 1.45; max-height: 7.5em; overflow-y: auto; }
.ii-dialog .dialog-actions { position: sticky; bottom: 0; background: var(--win); padding-top: 8px; margin-top: 0; }
@media (max-width: 700px) {
  .ii-course li { padding: 10px 12px; }
  .ii-when, .ii-sum, .ii-dates, .ii-add, .ii-mode { font-size: 14px; }
  .ii-dialog .dialog-actions .btn { height: 38px; padding: 0 16px; font-size: 14px; }
}
.link-btn { font-size: 12px; font-weight: 500; color: var(--accent); padding: 0; }
.link-btn:hover { text-decoration: underline; }
@media (max-width: 700px) {
  .mt-summary { padding: 11px 12px 11px 14px; }
  .mt-main { font-size: 15px; }
  .mt-sub { font-size: 13px; }
  .day-chip { height: 38px; font-size: 14px; }
  .mt-field input, .mt-field select { height: 40px; }
  .mt-actions .btn, .mt-add { height: 38px; padding: 0 16px; font-size: 14px; }
  .ci-row { font-size: 14px; padding: 10px 0; }
  .link-btn { font-size: 14px; min-height: 32px; }
}

/* ── ⌘K palette ── */
.palette-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.18); display: flex; justify-content: center; align-items: flex-start; padding-top: 14vh; animation: fadeIn .12s ease-out; }
.palette-backdrop[hidden] { display: none; }
.palette { width: min(600px, calc(100vw - 32px)); background: var(--win); border: 1px solid var(--sep-strong); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; animation: popIn .15s cubic-bezier(.32,.72,0,1); }
.pal-search { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--sep); color: var(--label2); }
.pal-search input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: none; color: var(--label); font: 15px var(--font); }
.pal-list { max-height: min(380px, 58dvh); overflow-y: auto; padding: 6px; }
.pal-group { font-size: 11px; font-weight: 600; color: var(--label3); padding: 8px 10px 4px; }
.pal-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; text-align: left; cursor: pointer; }
.pal-item[aria-selected="true"] { background: var(--fill); }
.pal-item i { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex-shrink: 0; }
.pal-item i.none { background: transparent; }
.pal-label { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item.done .pal-label { color: var(--label3); text-decoration: line-through; }
.pal-sub { margin-left: auto; font-size: 12px; color: var(--label3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; flex-shrink: 0; }
.pal-foot { display: flex; justify-content: space-between; padding: 7px 14px; border-top: 1px solid var(--sep); font-size: 11px; color: var(--label3); }
.pal-foot > :last-child { margin-left: auto; }
.pal-status:not(:empty) { padding: 8px 14px; border-top: 1px solid var(--sep); }
@media (prefers-reduced-motion: reduce) { .palette-backdrop, .palette { animation: none; } }

.due-more { display: block; font-size: 11.5px; color: var(--label2); padding: 2px 4px 0; }
.due-more:hover { color: var(--label); }
#backBtn:disabled { opacity: .3; }

/* ── Files panel (right side of a chat) ── */
/* The files panel collapses like the left sidebar: its width animates to 0 (contents keep 270px, so they don't
   squish) and the conversation widens into the space. */
.chats { position: relative; grid-template-columns: 250px minmax(0, 1fr) auto; }
.files-panel { width: 320px; overflow: hidden; border-left: 1px solid var(--sep); min-height: 0; background: var(--side);
  transition: width .32s cubic-bezier(.32,.72,0,1), border-color .32s; }
.files-panel > * { width: 320px; }
/* Reading a practice set or briefing: the panel widens so the text has room. */
.files-panel.wide { width: min(440px, 34vw); }
.files-panel.wide > * { width: min(440px, 34vw); }
.files-panel { display: flex; flex-direction: column; }
.app.files-closed .files-panel { width: 0; border-left-color: transparent; }
.app.no-anim .files-panel { transition: none; }
@media (prefers-reduced-motion: reduce) { .files-panel { transition: none; } }
.fp-head b span { font-weight: 500; color: var(--label3); margin-left: 4px; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.toolbar-right [hidden] { display: none; }
.panel-tabs { display: flex; gap: 2px; }
.panel-tabs[hidden] { display: none; }
.app:not(.files-closed) .panel-tabs .icon-btn.on { background: var(--fill); color: var(--label); }
.fp-head { height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 14px; border-bottom: 1px solid var(--sep); }
.fp-head b { font-size: 13px; font-weight: 600; }
.fp-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.fp-row { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 8px; cursor: pointer; }
.fp-row:hover { background: var(--fill2); }
.fp-icon { width: 30px; height: 30px; border-radius: 6px; background: var(--fill); display: grid; place-items: center; flex-shrink: 0; color: var(--label2); }
.fp-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.fp-name { font-weight: 500; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-meta { font-size: 11px; color: var(--label3); }
.fp-status { font-size: 11px; color: var(--label3); }
.fp-status.ok { color: var(--label2); }
.fp-status.busy { color: var(--accent); }
.fp-reveal { position: absolute; right: 6px; top: 8px; width: 24px; height: 24px; border-radius: 5px; display: grid; place-items: center; color: var(--label2); opacity: 0; }
.fp-reveal svg { width: 13px; height: 13px; }
.fp-row:hover .fp-reveal { opacity: 1; }
.fp-reveal:hover { background: var(--fill); color: var(--label); }
.fp-empty { color: var(--label3); font-size: 12px; line-height: 1.5; padding: 10px 6px; }
.files-toggle { display: inline-flex; align-items: center; gap: 5px; margin-left: 12px !important; }
.files-toggle svg { width: 14px; height: 14px; }
.chats.files-open .files-toggle { color: var(--label); }
.composer .attach { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--label2); flex-shrink: 0; align-self: flex-end; }
.composer .attach:hover { background: var(--fill); color: var(--label); }
.composer form { padding-left: 6px; }
.msg-user.has-file { background: transparent; padding: 0; }
.msg-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--sep-strong); border-radius: 10px; background: var(--fill2); font-size: 13px; }
.msg-file svg { color: var(--label2); }
.drop-overlay { position: absolute; inset: 8px; z-index: 20; border: 2px dashed var(--accent); border-radius: 12px;
  background: color-mix(in srgb, var(--win) 85%, transparent); display: grid; place-items: center; pointer-events: none; }
.drop-overlay[hidden] { display: none; }
.drop-overlay div { font-size: 15px; font-weight: 600; text-align: center; }
.drop-overlay span { display: block; font-size: 12.5px; font-weight: 400; color: var(--label2); margin-top: 4px; }

/* ── Study blocks (planner) ── */
.study { position: absolute; left: 4px; right: 4px; z-index: 3; border-radius: 6px; padding: 4px 7px; overflow: hidden; cursor: pointer; font-size: 11px; }
.study.suggested { border: 1.5px dashed var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--win)); color: var(--label); }
.study.accepted { border: 1px solid color-mix(in srgb, var(--cc) 45%, transparent); border-left: 4px solid var(--cc);
  background: color-mix(in srgb, var(--cc) 14%, var(--win)); color: var(--label); }
.st-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.st-label { font-size: 10px; font-weight: 700; color: var(--accent); }
.study.accepted .st-label { color: var(--cc); }
.st-actions { display: flex; gap: 3px; }
.st-actions button { width: 18px; height: 18px; border-radius: 4px; font-size: 11px; line-height: 1; display: grid; place-items: center; background: var(--fill); color: var(--label2); }
.st-actions button:hover { background: var(--accent); color: #fff; }
.st-actions button[data-dismiss]:hover { background: var(--fill3); color: var(--label); }
.st-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.st-reason { color: var(--label2); margin-top: 2px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.study.tight .st-title { margin-top: 0; }
.plan-btn { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--sep-strong); color: var(--label); }
.plan-btn:hover:not(:disabled) { background: var(--fill2); }
.plan-btn svg { width: 13px; height: 13px; color: var(--accent); }
.plan-btn.busy svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .plan-btn.busy svg { animation: none; } }
.inmore { font-size: 10.5px; font-weight: 600; opacity: .85; margin-top: 2px; padding-left: 5px; }
.block { max-height: none; }

/* ── Remove dialog ── */
#removeModal { z-index: 95; }
.dialog { width: min(440px, calc(100vw - 32px)); background: var(--win); border: 1px solid var(--sep-strong); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 18px 20px 16px; animation: popIn .15s cubic-bezier(.32,.72,0,1); }
.dialog h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.chk { display: block; padding: 8px 0 8px 24px; position: relative; font-size: 13px; cursor: pointer; }
.chk input { position: absolute; left: 0; top: 10px; accent-color: var(--accent); }
.chk span { display: block; font-size: 11.5px; color: var(--label3); margin-top: 2px; line-height: 1.4; }
.rm-list { list-style: none; margin: 0 0 4px 24px; padding: 2px 0 2px 12px; border-left: 2px solid var(--sep); max-height: 220px; overflow: auto; }
.rm-list .chk { padding: 5px 0 5px 24px; }
.rm-list .chk input { top: 7px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.btn.danger { background: var(--red); color: #fff; border-color: transparent; }
.btn.danger:hover { filter: brightness(1.08); background: var(--red); }
.btn.danger-text { color: var(--red); }
/* Settings → Reminders on iPhone/iPad outside the Home Screen app: the steps to get there */
.ios-steps { margin: 4px 0 12px; padding: 12px 14px; border: 1px solid var(--sep-strong); border-radius: 10px; background: var(--fill2); font-size: 13px; line-height: 1.45; }
.ios-steps ol { margin: 8px 0 6px; padding-left: 20px; }
.ios-steps li { margin: 3px 0; }
.ios-steps p { margin: 0; color: var(--label2); font-size: 12.5px; }
/* Settings → Account: delete dialog fields and the storage meter */
.dialog .field { display: block; margin-top: 12px; font-size: 12.5px; color: var(--label2); }
.dialog .field input { display: block; width: 100%; margin-top: 5px; height: 32px; font: 13px var(--font); color: var(--label);
  background: var(--modal-bg, var(--win)); border: 1px solid var(--sep-strong); border-radius: 7px; padding: 0 10px; }
.dialog .field input:focus { outline: none; border-color: var(--accent); }
.dialog .err { margin: 10px 0 0; }
.dialog p.muted { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; }
.meter { width: 140px; height: 6px; border-radius: 3px; background: var(--fill3); overflow: hidden; flex: none; }
.meter i { display: block; height: 100%; min-width: 4px; background: var(--accent); border-radius: inherit; }
.btn.subtle { margin-left: auto; color: var(--label2); border-color: transparent; }
.btn.subtle:hover { color: var(--red); background: var(--fill2); }

/* ── Briefing "What I know" ── */
.brief-rubric { margin-top: 10px; border-top: 1px solid var(--sep); padding-top: 8px; font-size: 13px; }
.brief-rubric summary { cursor: pointer; font-weight: 600; }
.brief-rubric summary span { margin-left: 8px; font-weight: 400; color: var(--label2); font-variant-numeric: tabular-nums; }
.brief-rubric .rb-comment, .brief-rubric p { margin: 4px 0 0; color: var(--label2); white-space: pre-wrap; }
.brief-rubric .rb-note { color: var(--label); }
.rb-crit { margin-top: 10px; }
.rb-name { display: flex; justify-content: space-between; gap: 12px; }
.rb-name span { flex: none; color: var(--label2); font-variant-numeric: tabular-nums; }
.rb-crit ul { list-style: none; margin: 4px 0 0; padding: 0; }
.rb-crit li { padding: 4px 8px; border-left: 2px solid var(--sep); color: var(--label2); font-size: 12px; }
.rb-crit li b { display: block; font-weight: 600; color: var(--label); }
.rb-crit li span { white-space: pre-wrap; }
.rb-crit li.on { border-left-color: var(--cc); background: var(--fill3); }
.asg-card { width: min(680px, calc(100vw - 32px)); max-height: min(780px, calc(100dvh - 48px)); display: flex; flex-direction: column; overflow: hidden; background: var(--win);
  border: 1px solid var(--sep-strong); border-top: 3px solid var(--cc); border-radius: 12px; box-shadow: 0 24px 70px rgba(0,0,0,.35); animation: popIn .18s cubic-bezier(.32,.72,0,1); }
.asg-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px 0 20px; flex: none; }
.asg-card:focus { outline: none; }
.asg-head .brief-course { margin-right: auto; }
.asg-open { display: inline-flex; align-items: center; gap: 3px; height: 28px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--accent); }
.asg-open:hover { background: var(--fill); }
.asg-open svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.asg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 20px 16px; }
.asg-body h2 { margin: 0; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.asg-facts { margin: 12px 0 0; display: grid; gap: 4px; font-size: 13px; }
.asg-facts div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.asg-facts div[hidden] { display: none; }
.asg-facts dt { color: var(--label2); }
.asg-facts dd { margin: 0; }
.asg-facts .soon, .asg-facts .miss b { color: var(--red); font-weight: 600; }
.asg-section { margin-top: 14px; border-top: 1px solid var(--sep); padding-top: 10px; font-size: 13px; }
.asg-section h3 { margin: 0 0 4px; font-size: 13px; }
.asg-desc { color: var(--label2); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.asg-section .notes { color: var(--label2); }
.asg-actions { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--sep); }
.asg-actions #removeBtn { margin-left: auto; }
.chat-tag { display: flex; align-items: center; gap: 8px; max-width: 720px; margin: 0 auto 6px; padding: 5px 6px 5px 10px; font-size: 12px; border: 1px solid var(--sep-strong); border-left: 3px solid var(--cc); border-radius: 7px; }
.chat-tag[hidden] { display: none; }
.tag-label { flex: none; color: var(--label2); }
.tag-name { flex: 1; min-width: 0; text-align: left; font-weight: 600; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-name:hover { text-decoration: underline; }
.tag-start { flex: none; color: var(--accent); }
.tag-x { flex: none; width: 20px; height: 20px; border-radius: 4px; color: var(--label2); }
.tag-x:hover { background: var(--fill); color: var(--label); }
.chat-note { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--label3); font-size: 11px; }
.chat-note::before, .chat-note::after { content: ""; flex: 1; border-top: 1px solid var(--sep); }
.ask-opus { margin-top: 8px; padding: 5px 10px; border: 1px solid var(--sep-strong); border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--accent); }
.ask-opus:hover { background: var(--fill); }
.msg-bot:not(:last-child) .ask-opus { display: none; }
.known { margin-top: 10px; }
.known details { border-top: 1px solid var(--sep); padding-top: 8px; }
.known summary { cursor: pointer; font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; list-style: none; }
.known summary::-webkit-details-marker { display: none; }
.known summary::before { content: "›"; display: inline-block; transition: transform .15s; color: var(--label3); }
.known details[open] summary::before { transform: rotate(90deg); }
.known summary span { font-weight: 400; font-size: 11.5px; color: var(--label3); }
.known summary a { color: var(--label2); text-decoration: underline; text-underline-offset: 2px; }
.known-body { font-size: 13px; color: var(--label2); max-height: 360px; overflow-y: auto; margin-top: 6px; }
.known-body h2 { font-size: 12.5px; color: var(--label); margin: 12px 0 4px; }
.known-body ul { margin: 2px 0; padding-left: 18px; }
.known-body li { margin: 2px 0; }
.known-empty { font-size: 12.5px; color: var(--label3); margin: 0; padding-top: 8px; border-top: 1px solid var(--sep); }
.known-empty b { color: var(--label2); font-weight: 600; }

.model-tag { font-weight: 600; color: var(--label2); }
.model-tag.opus { color: var(--c2); }
.model-tag.haiku { color: var(--c1); }

.msg-user.has-file { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.fp-status.err { color: var(--red); }

.fp-retry { margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--accent); padding: 0 6px; border-radius: 4px; }
.fp-retry:hover { background: var(--fill); }
.fp-retry:disabled { color: var(--label3); }

.fp-connect { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 8px 14px; border-bottom: 1px solid var(--sep); font-size: 11px; color: var(--label3); }
.fp-link { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--accent); padding: 3px 7px; border-radius: 5px; flex-shrink: 0; }
.fp-link svg { width: 13px; height: 13px; }
.fp-link:hover:not(:disabled) { background: var(--fill); }
.fp-link:disabled { color: var(--label3); }

.fp-head-actions { display: flex; align-items: center; gap: 2px; }
.fp-reread { font-size: 11px; color: var(--label2); padding: 3px 7px; border-radius: 5px; }
.fp-reread:hover { background: var(--fill); color: var(--label); }

.fp-group { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--label2); padding: 10px 8px 3px; }
.fp-group span { color: var(--label3); font-weight: 500; }
.fp-group:first-child { padding-top: 2px; }
.fp-exam { font-weight: 600; color: var(--c1); }

.practice { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 9px 10px; border-radius: 8px; background: var(--fill2); font-size: 12.5px; color: var(--label2); }
.practice svg { color: var(--cc); flex-shrink: 0; }
.practice span { flex: 1; }
.practice b { color: var(--label); }
.practice .btn { display: inline-flex; align-items: center; flex-shrink: 0; }
.btn.subtle-link { border-color: transparent; color: var(--label2); }

/* Unread D2L updates */
.thread-row .dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: auto; }
.thread-row.unread .dot { display: block; }
.thread-row.unread { color: var(--label); font-weight: 600; }
.nav-row.has-unread::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: auto; }

.sub-h { font-size: 12px; font-weight: 600; color: var(--label2); margin: 18px 0 4px; }
.muted-inline { color: var(--label3); font-size: 11.5px; }

/* ── Library ── */
.library { position: relative; display: flex; flex-direction: column; height: 100%; }
.lib-bar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--sep); }
.lib-search { margin-left: auto; width: 240px; font: 12.5px var(--font); color: var(--label); background: var(--fill2); border: 1px solid var(--sep); border-radius: 7px; padding: 5px 10px; }
.lib-search:focus { outline: none; border-color: var(--accent); }
.cp-search { width: 100%; margin: 0 0 8px; }
.file-search-panel { margin-bottom: 16px; }
.file-search-status { color: var(--label2); font-size: 12px; }
.file-search-list { margin-top: 6px; border: 1px solid var(--sep); border-radius: 9px; background: var(--fill2); }
.file-hit, .pal-item.file-hit { display: grid; width: 100%; gap: 3px; padding: 9px 11px; text-align: left; overflow-wrap: anywhere; }
.file-search-list .file-hit + .file-hit { border-top: 1px solid var(--sep); }
.file-search-list .file-hit:first-child { border-radius: 8px 8px 0 0; }
.file-search-list .file-hit:last-child { border-radius: 0 0 8px 8px; }
.file-search-list .file-hit:only-child { border-radius: 8px; }
.file-search-list .file-hit:is(:hover, [aria-selected="true"]) { background: var(--fill); }
.file-hit-name { font-size: 13.5px; font-weight: 600; }
.file-hit-meta { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--label2); }
.file-hit-line { font-size: 12.5px; color: var(--label2); }
.file-hit-line mark { background: var(--fill3); color: var(--label); border-radius: 2px; font-weight: 700; }
.lib-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.lib-chips .chip { width: auto; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--fill2); color: var(--label2); font-weight: 500; font-size: 12px; }
.lib-chips .chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cc, var(--label3)); }
.lib-chips .chip.on { background: var(--fill3); color: var(--label); font-weight: 600; }
.lib-chips .chip.graph-groups { justify-content: center; width: 24px; padding: 0; flex: none; margin: 0 -16px 0 6px; background: transparent; color: var(--label3); }
.lib-chips .chip.graph-groups:hover, .lib-chips .chip.graph-groups[aria-expanded="true"] { background: transparent; color: var(--label); }
.lib-chips .chip.graph-groups.on { background: transparent; color: var(--accent); }
.lib-chips .graph-groups::before { display: none; }
.graph-groups svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.graph-menu { position: fixed; z-index: 70; width: 220px; padding: 5px; background: var(--win); border: 1px solid var(--sep-strong); border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.28); font-size: 12px; }
.graph-menu hr { border: 0; border-top: 1px solid var(--sep); margin: 4px 0; }
.gm-title { padding: 3px 7px; font-size: 11px; color: var(--label3); }
.gm-row { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border-radius: 5px; cursor: pointer; }
.gm-row:hover { background: var(--fill); }
.gm-row b { font-weight: 600; }
.gm-row span { margin-left: auto; color: var(--label3); font-variant-numeric: tabular-nums; }
.lib-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px 40px; }
.lib-inbox { border: 1.5px dashed var(--sep-strong); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.lib-inbox-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.lib-inbox-head > b { font-size: 14px; }
.lib-inbox-head span { font-size: 12px; color: var(--label2); }
.lib-empty { font-size: 12px; color: var(--label3); padding: 4px 0; }
.lib-term { font-size: 13px; font-weight: 700; margin: 22px 0 6px; color: var(--label2); }
.lib-course { margin-bottom: 14px; }
.lib-course h3 { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; margin: 10px 0 4px; }
.lib-course h3 i { width: 9px; height: 9px; border-radius: 50%; background: var(--cc); align-self: center; }
.lib-course h3 span { font-weight: 400; color: var(--label2); font-size: 12.5px; }
.lib-course h3 em { font-style: normal; color: var(--label3); font-size: 11.5px; margin-left: auto; }
.lib-row { position: relative; display: grid; grid-template-columns: 30px minmax(0, 2.2fr) minmax(0, 1.2fr) 120px 110px 28px; gap: 10px; align-items: center;
  padding: 5px 6px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.lib-row.inbox { grid-template-columns: 30px minmax(0, 1fr); align-items: start; gap: 10px; padding: 10px 6px; border-radius: 0; cursor: default; }
.lib-row.inbox + .lib-row.inbox { border-top: 1px solid var(--sep); }
.lib-row.inbox:hover { background: transparent; }
.lib-row.inbox .fp-icon { margin-top: 1px; }
.inbox-main { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.inbox-file { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.lib-row.inbox .lib-name { white-space: normal; overflow-wrap: anywhere; font-weight: 500; }
.lib-row.inbox .lib-status { font-size: 12px; color: var(--label2); }
.lib-row.inbox .lib-status.reading { color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.lib-row.inbox .lib-status.reading::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: inboxPulse 1.4s ease-in-out infinite; }
@keyframes inboxPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .lib-row.inbox .lib-status.reading::before { animation: none; } }
.lib-row.inbox .lib-status.error { color: var(--red); font-weight: 500; }
.inbox-chip.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  border-color: color-mix(in srgb, var(--cc) 42%, var(--sep-strong));
  background: color-mix(in srgb, var(--cc) 11%, var(--fill2));
  transition: background .12s, border-color .12s;
}
.inbox-chip.btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cc) 20%, var(--fill2));
  border-color: color-mix(in srgb, var(--cc) 62%, var(--sep-strong));
}
.inbox-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex-shrink: 0; }
.inbox-err { margin: 0; font-size: 12px; }
.inbox-err:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .inbox-chip.btn { transition: none; } }
.lib-row:hover { background: var(--fill2); }
.lib-row .fp-icon { width: 26px; height: 26px; }
.lib-details { display: contents; }
.lib-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-kind, .lib-meta { color: var(--label3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-status { font-size: 11.5px; color: var(--label3); }
.lib-status.reading { color: var(--accent); }
.lib-status.error { color: var(--red); }
.lib-row .fp-reveal { position: static; opacity: 0; }
.lib-row:hover .fp-reveal { opacity: 1; }
.graph-wrap { position: relative; height: 100%; min-height: 420px; margin: -16px -24px -40px; }
.graph-wrap canvas { display: block; cursor: grab; }
.graph-tip { position: absolute; pointer-events: none; background: var(--win); border: 1px solid var(--sep-strong); border-radius: 6px; padding: 4px 8px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.15); white-space: nowrap; }
.graph-legend { position: absolute; left: 16px; bottom: 14px; display: flex; gap: 12px; font-size: 11px; color: var(--label3); }
.graph-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.lg-sum, .lg-map { background: var(--label2); } .lg-map { width: 11px !important; height: 11px !important; }
.lg-concept { border: 2px solid var(--label2); background: transparent; } .lg-other { background: var(--label3); opacity: .6; }
.graph-help { position: absolute; right: 16px; bottom: 14px; font-size: 11px; color: var(--label3); }

/* Pasted screenshots: thumbnails waiting above the message box, and in sent messages. */
.paste-tray { max-width: 720px; margin: 0 auto 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.tray-img { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--sep-strong); background: var(--fill2); }
.tray-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-img button { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 14px; line-height: 1; opacity: 0; transition: opacity .15s; }
.tray-img:hover button, .tray-img button:focus-visible { opacity: 1; }
.msg-user.has-images { background: transparent; padding: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-images { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg-images img { display: block; max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--sep-strong); }
.msg-user.has-images .msg-text { background: var(--fill); padding: 8px 12px; border-radius: 14px; }
.srow-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Grades overview */
.grade-overview { height: 100%; overflow-y: auto; }
.grade-overview .cp-inner { max-width: 1040px; }
.grade-term { font-size: 13px; margin: 0 0 12px; }
.grade-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.grade-stats[hidden], .grade-err-box[hidden] { display: none; }
.grade-stat {
  display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--card-line);
}
.grade-stat > span { font-size: 11.5px; font-weight: 600; color: var(--label2); }
.grade-stat > b { font-size: 20px; font-weight: 700; letter-spacing: -.015em; color: var(--label); line-height: 1.2; }
.grade-stat > b small { font-size: 14px; font-weight: 500; color: var(--label2); }
.grade-stat > em { font-style: normal; font-size: 11.5px; color: var(--label3); }
.grade-err-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.grade-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 760px) { .grade-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grade-course {
  display: flex; flex-direction: column; gap: 12px; padding: 15px 16px 14px; border-radius: 11px;
  background: var(--card); border: 1px solid var(--card-line); color: var(--label);
  transition: background .14s, border-color .14s;
}
.grade-course:hover { background: var(--card-hover); border-color: var(--sep-strong); }
.grade-course.is-empty { background: transparent; border-style: dashed; border-color: var(--sep-strong); }
.grade-course.is-empty:hover { background: var(--fill2); }
.grade-course-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.grade-course .sdot { width: 10px; height: 10px; }
.grade-course-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.grade-course-info b { font-size: 14px; font-weight: 600; line-height: 1.25; }
.grade-course-info > span { color: var(--label2); font-size: 12.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grade-course-score { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.grade-course-score strong { font-size: 21px; font-weight: 700; letter-spacing: -.015em; }
.grade-course-score em {
  font-style: normal; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: color-mix(in srgb, var(--cc) 16%, transparent); color: var(--label);
}
.grade-none { font-size: 12px; font-weight: 500; color: var(--label3); padding: 2px 8px; border-radius: 999px; background: var(--fill); }
.grade-none.err { color: var(--red); background: var(--today-bg); }
.grade-chev { width: 15px; height: 15px; color: var(--label3); transition: transform .14s, color .14s; }
.grade-course:hover .grade-chev { color: var(--label2); transform: translateX(2px); }
.grade-scale-wrap { display: block; }
.grade-bar { position: relative; display: block; height: 7px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.grade-bar s { display: block; height: 100%; background: var(--cc); border-radius: 4px; text-decoration: none; }
.grade-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: color-mix(in srgb, var(--win) 65%, var(--sep-strong)); opacity: .75; pointer-events: none; }
.grade-course.is-empty .grade-bar { opacity: .55; }
.grade-course-meta {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--label2); padding-top: 8px; border-top: 1px solid var(--sep);
}
.grade-course-meta > span:last-child { color: var(--label3); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .grade-course, .grade-chev { transition: none; }
  .grade-course:hover .grade-chev { transform: none; }
}
#courseGrades { scroll-margin-top: 12px; }

/* Grades card (course page) */
.grades { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.grade-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.grade-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.grade-big b { font-size: 18px; margin-left: 8px; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--cc) 16%, transparent); vertical-align: 6px; }
.grade-cats { display: flex; flex-direction: column; gap: 7px; }
.gcat { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 84px; align-items: center; gap: 10px; font-size: 13px; }
.gcat span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcat i { font-style: normal; color: var(--label3); margin-left: 4px; font-size: 12px; }
.gcat em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; }
.gcat.none em { color: var(--label3); font-size: 12px; }
.gbar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.gbar s { display: block; height: 100%; background: var(--cc); border-radius: 3px; text-decoration: none; }
.grade-needs { font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; padding: 10px 12px; border-radius: 10px; background: var(--fill2); }
.grade-needs > b { font-weight: 600; }
.grade-needs span b { margin-right: 3px; }
/* Weights from D2L: the two questions D2L can't answer (drops, letter scale). Open and bold until answered. */
.grade-setup { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--fill2); }
.grade-setup summary { cursor: pointer; color: var(--label2); }
.grade-setup.todo summary { color: var(--label); font-weight: 600; }
.grade-setup p { margin: 6px 0 0; }
.gs-rows { display: grid; gap: 6px; margin-top: 10px; }
.gs-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gs-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-row i { font-style: normal; color: var(--label3); font-size: 12px; margin-left: 4px; }
.gs-row em { font-style: normal; color: var(--label2); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.grade-setup input { width: 56px; height: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--sep-strong); background: var(--win); color: var(--label); font: 13px var(--font); text-align: right; font-variant-numeric: tabular-nums; }
.grade-setup input:focus { outline: none; border-color: var(--accent); }
.gs-scale { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--sep); }
.gs-scale span { flex: 1 1 100%; color: var(--label2); }
.gs-scale label { display: inline-flex; align-items: center; gap: 6px; }
.gs-scale input { width: 46px; }
.gs-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
@media (max-width: 700px) { .grade-setup input { height: 36px; font-size: 16px; } .gs-actions .btn { height: 34px; padding: 0 16px; font-size: 14px; } }
.grade-items summary { cursor: pointer; font-size: 13px; color: var(--label2); }
.grade-items table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.grade-items td { padding: 6px 4px; border-top: 1px solid var(--sep); vertical-align: top; }
.grade-items td:nth-child(n+2) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grade-items tr.lost td:last-child { color: var(--red); }
.grade-items tr.pending-row td { color: var(--label3); }
.grade-items .fb { font-size: 12px; color: var(--label2); margin-top: 2px; }
.grade-items .rubric { margin-top: 4px; font-size: 12px; }
.grade-items .rubric summary { font-size: 12px; color: var(--accent); }
.rubric .rb-comment { margin: 6px 0 0; color: var(--label2); white-space: pre-wrap; }
.rubric .rb-row { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--sep); }
.rubric .rb-head b { display: block; overflow-wrap: normal; }
.rubric .rb-head span { display: block; color: var(--label2); font-variant-numeric: tabular-nums; }
.rubric p { margin: 2px 0 0; color: var(--label2); white-space: pre-wrap; }
.rubric .rb-note { color: var(--label); }
.grade-drop { display: block; padding: 12px; border: 1px dashed var(--sep-strong); border-radius: 10px; font-size: 13px; color: var(--label2); cursor: pointer; text-align: center; }
.grade-drop:hover, .grade-drop.over { border-color: var(--cc); color: var(--label); background: var(--fill2); }
.grade-drop b { color: var(--label); font-weight: 600; }
.grade-d2l { display: block; margin-top: 6px; font-size: 12px; text-align: center; color: var(--accent); text-decoration: none; }
.grade-d2l:hover { text-decoration: underline; }

/* Side panel: Coming up / Grades / reading a practice set */
.fp-head-actions .grade-meta { font-size: 11px; color: var(--label3); }
.up-list .due-list { display: flex; flex-direction: column; gap: 6px; }
.up-list .fp-group { margin-top: 6px; }
.up-sub { margin: -2px 0 4px 10px; }
.up-link { font-size: 12px; font-weight: 500; color: var(--accent); padding: 2px 6px; border-radius: 5px; }
.up-link:hover { background: var(--fill); }
.up-block { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 8px; border-left: 3px solid var(--accent); background: var(--fill2); font-size: 12px; }
.up-block.suggested { border-left-style: dashed; }
.up-block b { font-weight: 600; font-variant-numeric: tabular-nums; }
.up-block em { font-style: normal; color: var(--label3); font-size: 11px; }
.up-doc { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; font-size: 12.5px; text-align: left; }
.up-doc:hover { background: var(--fill2); }
.up-doc svg { width: 15px; height: 15px; color: var(--label2); flex-shrink: 0; }
.doc-title { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-title .icon-btn { width: 24px; height: 24px; flex-shrink: 0; }
.doc-body { flex: 1; overflow-y: auto; padding: 12px 16px 24px; font-size: 13.5px; line-height: 1.55; }
.doc-body h1 { font-size: 18px; } .doc-body h2 { font-size: 15px; margin-top: 18px; } .doc-body h3 { font-size: 14px; }
.doc-body details.callout { margin: 8px 0 12px; padding: 6px 10px; border-radius: 8px; background: var(--fill2); border-left: 3px solid var(--label3); }
.doc-body details.callout.success { border-left-color: #34C759; }
.doc-body details.callout summary { cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--label2); }
.files-panel .grades { padding: 4px 6px; }
.files-panel .grade-big { font-size: 28px; }
.files-panel .gcat { grid-template-columns: minmax(0, 1fr) 44px auto; font-size: 12px; }
.gcat em { white-space: nowrap; }
.grade-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; font-size: 13px; color: var(--label); text-decoration: none; }
.grade-row:hover { background: var(--fill2); }
.grade-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); }
.grade-row span { flex: 1; font-weight: 500; }
.grade-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.grade-row em { font-style: normal; font-weight: 400; color: var(--label3); font-size: 12px; }
.grade-pending { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 10px; background: var(--fill2); }
.grade-pending[hidden] { display: none; }
.gp-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.gp-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grade-items td:first-child { overflow-wrap: anywhere; }
.files-panel .fp-list { overflow-x: hidden; }
.gcat small { grid-column: 1 / -1; margin-top: -4px; font-size: 11px; color: var(--label3); }
.grade-items .st { font-size: 11px; margin-top: 1px; }
.grade-items tr.st-missing .st { color: var(--red); }
.grade-items tr.st-dropped td, .grade-items tr.st-auto-drop td { color: var(--label3); }
.grade-items tr.st-dropped td:nth-child(n+2), .grade-items tr.st-auto-drop td:nth-child(n+2) { text-decoration: line-through; }
.grade-items tr.st-dropped .st, .grade-items tr.st-auto-drop .st { text-decoration: none; color: var(--label2); }
.grade-items tr.st-pending td { color: var(--label3); }
.gdrops { grid-column: 1 / -1; margin-top: -3px; font-size: 11px; color: var(--label2); display: flex; flex-wrap: wrap; gap: 2px 8px; }
.gdrops b { font-weight: 600; }
.gdrops span { text-decoration: line-through; text-decoration-color: var(--label3); }
.gdrops i { font-style: normal; color: var(--label3); }
.gcat small.gmiss { color: var(--red); }
.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; margin-right: 4px; }
.badge.drop { background: var(--fill); color: var(--label2); }
.badge.miss { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.grade-items tr.st-missing .st { color: var(--label2); }
.up-sub.loop { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.round { display: flex; align-items: baseline; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.round b { font-variant-numeric: tabular-nums; }
.up-link.subtle { color: var(--label3); font-weight: 400; }
/* Study blocks can be dragged (move) and resized (bottom edge). */
.study { touch-action: none; user-select: none; }
.study .st-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.study:hover .st-resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; margin-left: -9px; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--label) 30%, transparent); }
.study.dragging { cursor: grabbing; z-index: 6; box-shadow: 0 6px 18px rgba(0,0,0,.18); opacity: .95; transition: none; }

/* Settings → Usage */
.ustats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 8px; }
.ustats div { padding: 10px 12px; border-radius: 10px; background: var(--fill2); display: flex; flex-direction: column; gap: 2px; }
.ustats b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ustats span { font-size: 11px; color: var(--label2); }
.uchart { width: 100%; height: 120px; margin: 10px 0 4px; display: block; background: var(--fill2); border-radius: 8px; }
.ulegend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--label2); margin-bottom: 4px; }
.ulegend i, .urow i { display: inline-block; }
.ulegend i { width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.urow { display: grid; grid-template-columns: 140px 1fr 64px 52px; align-items: center; gap: 10px; padding: 6px 2px; font-size: 13px; border-top: 1px solid var(--sep); }
.urow .uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.urow em { text-align: right; font-style: normal; color: var(--label3); font-size: 12px; font-variant-numeric: tabular-nums; }
.ubar { height: 8px; }
.ustack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; min-width: 2px; }
.ustack i { height: 100%; }

/* ── Phone (≤ 700px): tab bar instead of the sidebar, Today screen, 3-day week, chats list → conversation ── */
.tabbar, .phone-only { display: none; }
@media (max-width: 700px) {
  html, body { height: 100%; }
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; height: 100dvh; padding-top: env(safe-area-inset-top); padding-bottom: 0; }   /* the tab bar covers the bottom */
  .sidebar { display: none; }
  .main { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .phone-only { display: grid; }
  #toggleSidebar, .plan-btn { display: none !important; }
  .toolbar { height: 46px; gap: 6px; padding: 0 8px 0 4px; }
  .toolbar h1 { font-size: 17px; }
  .toolbar .range { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .icon-btn { width: 36px; height: 36px; }
  .icon-btn svg { width: 19px; height: 19px; }
  /* Tab bar, frosted like iOS */
  .tabbar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--win) 82%, transparent); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
    border-top: 1px solid var(--sep); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 500; color: var(--label3); }
  .tabbar a svg { width: 23px; height: 23px; }
  .tabbar a.active { color: var(--accent); }

  /* Today */
  .today-page { height: 100%; overflow-y: auto; padding: 12px 14px 24px; -webkit-overflow-scrolling: touch; }
  .today-page .due { padding: 0; overflow: visible; }
  .today-page .due h2 { font-size: 13px; }
  .tp-classes { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; }
  .tp-class { flex-shrink: 0; display: flex; flex-direction: column; gap: 1px; padding: 8px 12px 8px 14px; border-radius: 10px; background: var(--fill2);
    border-left: 4px solid var(--cc); font-size: 12px; color: var(--label2); position: relative; }
  .tp-class i { display: none; }
  .tp-class b { color: var(--label); font-size: 14px; }
  .tp-class.past { opacity: .5; }
  .tp-h { font-size: 13px; color: var(--label2); margin: 18px 0 6px; }
  .tp-all { border-top: 0; padding: 0; overflow: visible; }
  .card { min-height: 52px; }

  /* Week: 3 days */
  .week { --cols: 1fr 1fr 1fr; }
  .week-head, .allday, .grid { grid-template-columns: 40px var(--cols); }
  .hours div { font-size: 10px; }
  .study .st-actions button { width: 26px; height: 26px; }
  /* Narrow day columns: the dashed outline already says "suggested", so the label gives its room to ✓ and ✕. */
  .study.suggested .st-label { display: none; }
  .study.suggested .st-top { justify-content: flex-end; }
  /* "No class" on its own line instead of wrapping word by word beside the class code. */
  .block.holiday .code { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .block.holiday .code small { display: block; }

  /* Calendar month */
  .month { font-size: 11px; }

  /* Chats: the list, or one conversation */
  .chats, .chats.list-only { grid-template-columns: minmax(0, 1fr) !important; }
  .chats:not(.list-only) .threads { display: none; }
  .chats.list-only .threads { border-right: 0; padding: 8px 12px; }
  .chats.list-only .thread-row { padding: 14px 12px; font-size: 16px; border-radius: 10px; }
  .convo-head { padding: 8px 14px; }
  .convo-head span, .convo-head h2 { display: none; }
  .convo-head { justify-content: flex-end; }
  .messages { padding: 14px 12px; }
  .msg-user { max-width: 88%; font-size: 15px; }
  .composer { padding: 8px 10px 10px; }
  /* The right panel becomes a sheet that slides over the conversation */
  .files-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 10; width: 100%; border-left: 0; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
  .files-panel > *, .files-panel.wide, .files-panel.wide > * { width: 100vw; }
  .app.files-closed .files-panel { width: 0; box-shadow: none; }
  .files-panel .fp-list { padding: 8px 12px 20px; }

  /* Course page, library */
  .cp-inner { padding: 16px 14px 32px !important; }
  .grade-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .grade-stats .grade-stat:nth-child(2) { grid-column: 1 / -1; order: -1; }
  .grade-stat { padding: 10px 12px; }
  .grade-stat > b { font-size: 18px; }
  .grade-course { padding: 13px 14px; gap: 10px; }
  .grade-course-top { gap: 8px; }
  .grade-course-score strong { font-size: 19px; }
  .cp-head { flex-wrap: wrap; gap: 10px; }
  .cp-actions { width: 100%; }
  .lib-body { padding: 12px 14px 32px; }
  .lib-search { width: min(240px, 100%); min-width: 0; }
  .lib-row { grid-template-columns: 26px minmax(0, 1fr) auto; gap: 2px 8px; }
  .lib-row.inbox { grid-template-columns: 26px minmax(0, 1fr); gap: 8px; padding: 12px 2px; }
  .lib-row .lib-name { grid-column: 2 / -1; white-space: normal; overflow-wrap: anywhere; }
  .lib-row.inbox .lib-name { grid-column: auto; }
  .lib-row .lib-details { display: flex; flex-wrap: wrap; gap: 0 5px; grid-column: 2 / -1; }
  .lib-details .lib-date, .lib-details > :empty, .lib-row .fp-reveal { display: none; }
  .lib-details .lib-kind:not(:empty) + .lib-meta::before, .lib-details .lib-status:not(:empty)::before { content: "· "; }
  .inbox-actions { margin-top: 2px; gap: 8px; }
  .inbox-chip.btn { height: auto; min-height: 44px; padding: 0 14px; font-size: 14px; }
  .inbox-actions .lib-pick { height: auto; min-height: 44px; flex: 1 1 160px; }

  /* Settings: full screen iOS-style list / detail drill-down */
  .modal-backdrop { padding: 0; }
  .modal { width: 100vw; height: 100dvh; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .modal-head { height: 50px; padding: 0 12px 0 16px; }
  .modal-body { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .modal:not(.phone-detail) .modal-content { display: none; }
  .modal.phone-detail .modal-nav { display: none; }
  .modal-nav { flex-direction: column; overflow-y: auto; border-right: 0; border-bottom: 0; padding: 8px 12px calc(24px + env(safe-area-inset-bottom)); gap: 2px; background: var(--modal-bg, var(--solid, var(--win))); }
  .modal-nav .nav-row { width: 100%; height: 46px; padding: 0 12px; gap: 12px; font-size: 15px; border-radius: 10px; color: var(--label); }
  .modal-nav .nav-row svg { width: 18px; height: 18px; color: var(--label2); }
  .modal-nav .nav-row.active svg { color: var(--label); }
  .modal-nav .nav-chev { display: block; }
  .modal-content { padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }
  .modal.phone-detail .s-head h3 { display: none; }
  .modal.phone-detail .s-head:not(:has(.s-lead)) { display: none; }
  .modal-content .btn, .modal-content .seg, .modal-content select { height: 34px; font-size: 13px; }
  .modal-content .held-actions { gap: 8px; }
  .modal-content .held-actions .held-pick { width: 100%; flex: 1 1 100%; height: auto; min-height: 44px; }
  .modal-content .held-actions .btn { flex: 1 1 auto; height: auto; min-height: 44px; font-size: 14px; }
  .feed-add input { height: 38px; font-size: 16px; }
  .feed-add .btn { height: 38px; }
  .theme-grid.cols-4, .theme-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .srow, .srow-head { flex-wrap: wrap; }
  .ustats { grid-template-columns: 1fr 1fr; }
  .urow { grid-template-columns: 96px 1fr 56px; }
  .urow em { display: none; }
  .toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .popover { max-width: calc(100vw - 24px); }
}
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.md .katex { font-size: 1.05em; }

/* Chat list: ⋯ menu (rename, pin) */
.thread-row { position: relative; }
.thread-row .pin { margin-left: auto; display: flex; color: var(--label3); }
.thread-row .pin svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.thread-row .dot + .pin { margin-left: 4px; }
.row-more { display: none; width: 22px; height: 22px; margin: 0 -4px 0 auto; border-radius: 5px; align-items: center; justify-content: center; color: var(--label2); flex-shrink: 0; }
.row-more svg { width: 15px; height: 15px; fill: currentColor; }
.row-more:hover { background: var(--fill); }
.thread-row:hover .row-more { display: flex; }
.thread-row:hover .pin, .thread-row:hover .dot { display: none; }
.pin-sep { border: 0; border-top: 1px solid var(--sep); margin: 4px 8px; }
.tn-edit { flex: 1; min-width: 0; font: inherit; color: var(--label); background: var(--win); border: 1px solid var(--accent); border-radius: 4px; padding: 2px 5px; outline: none; }
.row-menu { position: fixed; z-index: 60; min-width: 180px; padding: 5px; background: var(--win); border: 1px solid var(--sep-strong); border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0,0,0,.22); display: flex; flex-direction: column; }
.row-menu button { display: flex; align-items: center; justify-content: space-between; text-align: left; padding: 6px 9px; border-radius: 5px; font-size: 13px; color: var(--label); }
.row-menu button:hover { background: var(--accent); color: #fff; }
.row-menu button:hover kbd { color: rgba(255,255,255,.8); }
.row-menu kbd { font: inherit; font-size: 12px; color: var(--label3); background: none; border: 0; padding: 0; }
.row-menu hr { border: 0; border-top: 1px solid var(--sep); margin: 4px 6px; }
@media (max-width: 700px) {
  .chats.list-only .row-more { display: flex; width: 32px; height: 32px; }
  .chats.list-only .thread-row .pin { margin-left: auto; }
  .chats.list-only .thread-row .pin + .row-more, .chats.list-only .thread-row .dot + .row-more { margin-left: 6px; }
  .chats.list-only .thread-row:not(.unread):not(.pinned) .row-more { margin-left: auto; }   /* line the ⋯ up on the right */
  .row-menu button { padding: 11px 12px; font-size: 16px; }
  .row-menu kbd { display: none; }
}

/* Grades: "if you get X on Exam 3, you need Y on the final" */
.whatif { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.whatif th { text-align: left; font-weight: 500; color: var(--label2); padding: 4px 6px; border-bottom: 1px solid var(--sep); }
.whatif td { padding: 4px 6px; border-bottom: 1px solid var(--sep); }
.whatif tr:last-child td { border-bottom: 0; }
.whatif td.out { color: var(--label3); }
.whatif th[rowspan] { vertical-align: bottom; width: 34%; }
.whatif th[colspan] { border-bottom: 0; padding-bottom: 0; }
.whatif th.gl { font-weight: 600; color: var(--label); }
.whatif td.ok { color: var(--green, #34c759); }
.gw-note { flex-basis: 100%; color: var(--label3); font-size: 11.5px; }

/* Coming up: finished assignments, collapsed at the bottom */
.up-finished > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: flex-start; gap: 6px; }
.up-finished > summary::-webkit-details-marker { display: none; }
.up-finished > summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 14px; line-height: 1; }
.up-finished[open] > summary::before { transform: rotate(90deg); }
.card.finished .ttl { color: var(--label2); text-decoration: line-through; text-decoration-color: var(--label3); }
.card.finished { opacity: .8; }

.confirm-date { color: var(--warn, #c77700); font-weight: 600; }
.done-on { color: var(--muted, #8a8a8e); }
.card-score { font-weight: 600; color: var(--label); font-variant-numeric: tabular-nums; }
.card-score.miss, .brief-score.miss b { color: var(--red); }
.brief-score { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: 13px; }
.brief-score span { color: var(--label2); }
.brief-score b { font-variant-numeric: tabular-nums; }

/* ── Sonoran theme: the app as frosted glass over a Tucson desert at dusk (web/themes/sonoran.svg) ── */
:root[data-theme="sonoran"] {
  --win: rgba(30, 18, 34, .58); --side: rgba(24, 13, 28, .30); --solid: #26172c; --seg-on: #66404b;
  --sep: rgba(255, 214, 190, .10); --sep-strong: rgba(255, 214, 190, .17);
  --label: #FCF2EA; --label2: #D2B9B2; --label3: #94798A;
  --fill: rgba(255, 210, 180, .09); --fill2: rgba(255, 210, 180, .06); --fill3: rgba(255, 210, 180, .12);
  --accent: #FF8A5C; --red: #FF6A5A; --today-bg: rgba(255, 120, 90, .13); --today-bg-hover: rgba(255, 120, 90, .19); --today-line: rgba(255, 120, 90, .30);
  --office: rgba(255, 214, 190, .18); --office-hover: rgba(255, 214, 190, .36);
  --card: rgba(255, 228, 210, .07); --card-hover: rgba(255, 228, 210, .12); --card-line: rgba(255, 214, 190, .09);
  color-scheme: dark;
}
:root[data-theme="sonoran"] body { background: #1b1022 url(/themes/sonoran.svg) center bottom / cover no-repeat fixed; }
/* Glass: the sidebar shows the most desert, the main area a little, so text stays easy to read. */
:root[data-theme="sonoran"] .sidebar { background: var(--side); -webkit-backdrop-filter: blur(3px) saturate(1.2); backdrop-filter: blur(3px) saturate(1.2); }
:root[data-theme="sonoran"] .full { background: transparent; }
/* The compact panel sits under the sidebar; with see-through glass it would show through, so it hides until needed. */
:root[data-theme="sonoran"] .app:not(.collapsed) .mini { opacity: 0; }
:root[data-theme="sonoran"] .mini { transition: opacity .2s; }
:root[data-theme="sonoran"] .main { background: var(--win); -webkit-backdrop-filter: blur(26px) saturate(1.2); backdrop-filter: blur(26px) saturate(1.2); }
/* Windows that float above everything stay solid. */
:root[data-theme="sonoran"] :is(.modal, .popover, .palette, .asg-card, .note-modal, .row-menu, .toast) { background: var(--solid); }

:root[data-theme="sonoran"] .mini-group h3 { background: rgba(28, 16, 32, .94); }

/* ── Fun themes (Settings → Appearance → Fun themes) ──────────────────────────────────────────────────────────────
   Art sits in #themeArt: background layers under the app (z-index 0), small widgets above it (z-index 40+).
   Each theme reacts to data-daypart, --progress (this week's work finished, 0–1) and data-crunch="exam". */
#themeArt { display: contents; }
#themeArt > * { position: fixed; pointer-events: none; }
:root:is([data-theme="terminal"], [data-theme="pixel"], [data-theme="nebula"], [data-theme="cafe"]) .app { position: relative; z-index: 1; }
@media (max-width: 700px) { .ta-status, .ta-xp, .ta-cup { display: none; } }
@media (prefers-reduced-motion: reduce) { #themeArt *, #themeArt *::before, #themeArt *::after { animation: none !important; } }

/* ── Terminal: all in. Green phosphor on black, monospace everywhere, scanlines, a status line. ── */
:root[data-theme="terminal"] {
  --win: #05080a; --side: #030506; --solid: #071012; --seg-on: #18352b;
  --sep: rgba(57, 255, 136, .14); --sep-strong: rgba(57, 255, 136, .26);
  --label: #c9ffd9; --label2: #6fd38f; --label3: #3a7a51;
  --fill: rgba(57, 255, 136, .08); --fill2: rgba(57, 255, 136, .05); --fill3: rgba(57, 255, 136, .13);
  --accent: #39ff88; --red: #ff5f56; --today-bg: rgba(57, 255, 136, .07); --today-bg-hover: rgba(57, 255, 136, .12); --today-line: rgba(57, 255, 136, .32);
  --office: rgba(57, 255, 136, .22); --office-hover: rgba(57, 255, 136, .42);
  --card: rgba(57, 255, 136, .035); --card-hover: rgba(57, 255, 136, .08); --card-line: rgba(57, 255, 136, .24);
  color-scheme: dark;
}
:root[data-theme="terminal"]:not([data-intensity="low"]) { --font: "SF Mono", ui-monospace, Menlo, monospace; }   /* low keeps the system font */
:root[data-theme="terminal"][data-crunch="exam"] { --accent: #ffcc33; --today-line: rgba(255, 204, 51, .38); }   /* amber alert before exams */
:root[data-theme="terminal"] body { background: #030506; }
:root[data-theme="terminal"][data-intensity="high"] body { text-shadow: 0 0 5px rgba(57, 255, 136, .28); }
:root[data-theme="terminal"]:not([data-intensity="low"]) :is(.card, .block, .btn, .composer, .nav-row, .thread-row, .icon-btn, .seg, .seg button, .modal, .asg-card, .note-modal, .notes-pin, .note-row, .cp-note, .note-chip, .asg-guide-row, .asg-note-row, .popover, .study) { border-radius: 2px; }
:root[data-theme="terminal"]:not([data-intensity="low"]) .block:not(.holiday) { background: color-mix(in srgb, var(--cc) 16%, #030506); box-shadow: inset 0 0 0 1px var(--cc); }
:root[data-theme="terminal"]:not([data-intensity="low"]) .block:not(.holiday) * { color: color-mix(in srgb, var(--cc) 55%, #e8fff0); }
:root[data-theme="terminal"]:not([data-intensity="low"]) .app-name::before { content: "~/"; color: var(--accent); }
:root[data-theme="terminal"]:not([data-intensity="low"]) .nav-row.active::before { content: ">"; color: var(--accent); margin-right: -2px; }
.ta-scan { display: none; inset: 0; z-index: 60; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .28) 0 1px, transparent 1px 3px); opacity: .45; }
.ta-scan::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .45)); }   /* CRT edges */
.ta-status { right: 14px; bottom: 10px; z-index: 61; font: 11px/1 var(--font); color: var(--label2); background: rgba(3, 5, 6, .9);
  border: 1px solid var(--sep-strong); padding: 5px 9px; white-space: nowrap; }
.ta-status span { color: var(--accent); }
.ta-status em { font-style: normal; color: #ffcc33; margin-left: 6px; }
.ta-status i { font-style: normal; color: var(--accent); animation: ta-blink 1.1s steps(1) infinite; margin-left: 4px; }
@keyframes ta-blink { 50% { opacity: 0; } }

/* ── Pixel Quest: noticeable. 8-bit hills, a sky that follows your day, drifting clouds, rain before exams, an XP bar. ── */
:root[data-theme="pixel"] {
  --win: rgba(255, 255, 255, .82); --side: rgba(255, 255, 255, .55); --solid: #ffffff; --seg-on: #fff;
  --sep: rgba(29, 33, 64, .14); --sep-strong: rgba(29, 33, 64, .26);
  --label: #1d2140; --label2: #4b5179; --label3: #59618a;
  --fill: rgba(29, 33, 64, .07); --fill2: rgba(29, 33, 64, .05); --fill3: rgba(29, 33, 64, .1);
  --accent: #ff4f7b; --red: #e8364f; --today-bg: rgba(255, 79, 123, .1); --today-bg-hover: rgba(255, 79, 123, .16); --today-line: rgba(255, 79, 123, .35);
  --card: rgba(255, 255, 255, .78); --card-hover: #ffffff; --card-line: rgba(29, 33, 64, .3);
  --sky: linear-gradient(#59b7ff 0 30%, #7cc6ff 30% 55%, #a6d9ff 55% 75%, #cdeaff 75%);
  color-scheme: light;
}
:root[data-theme="pixel"][data-daypart="morning"] { --sky: linear-gradient(#7fb2ff 0 30%, #a9c8ff 30% 55%, #ffc9a8 55% 75%, #ffe1b8 75%); }
:root[data-theme="pixel"]:is([data-daypart="dusk"], [data-daypart="night"]) {
  --win: rgba(18, 20, 48, .82); --side: rgba(16, 18, 44, .55); --solid: #171a3d; --seg-on: #3c3c71;
  --sep: rgba(230, 234, 255, .12); --sep-strong: rgba(230, 234, 255, .22);
  --label: #eef0ff; --label2: #b4b9e6; --label3: #6d72a3;
  --fill: rgba(230, 234, 255, .08); --fill2: rgba(230, 234, 255, .05); --fill3: rgba(230, 234, 255, .12);
  --accent: #ffd23f; --today-bg: rgba(255, 210, 63, .1); --today-bg-hover: rgba(255, 210, 63, .16); --today-line: rgba(255, 210, 63, .35);
  --card: rgba(30, 33, 72, .8); --card-hover: rgba(40, 44, 92, .9); --card-line: rgba(230, 234, 255, .22);
  color-scheme: dark;
}
:root[data-theme="pixel"][data-daypart="dusk"] { --sky: linear-gradient(#2b2a6b 0 30%, #5a3d8a 30% 55%, #c25e7a 55% 75%, #ff9a6b 75%); }
:root[data-theme="pixel"][data-daypart="night"] { --sky: linear-gradient(#0d1033 0 30%, #141846 30% 55%, #1c2257 55% 75%, #26306b 75%); }
:root[data-theme="pixel"] body { background: var(--sky); }
:root[data-theme="pixel"][data-crunch="exam"]:not([data-daypart="night"]) { --sky: linear-gradient(#6d7c93 0 30%, #8492a8 30% 55%, #9aa7ba 55% 75%, #b3bdcb 75%); }   /* overcast before exams */
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.card, .btn, .composer, .modal, .asg-card, .note-modal, .notes-pin, .note-row, .cp-note, .note-chip, .asg-guide-row, .asg-note-row, .popover, .study, .nav-row, .thread-row, .seg, .seg button, .icon-btn) { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .card { border-width: 2px; box-shadow: 3px 3px 0 rgba(0, 0, 0, .22); }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.due h2, .toolbar h1, .app-name, .mini-group h3) { font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; letter-spacing: .08em; }
.ta-land { left: 0; right: 0; bottom: 0; height: 42vh; z-index: 0; background: url(/themes/pixel.svg) center bottom / cover no-repeat; image-rendering: pixelated; }
:root[data-daypart="night"] .ta-land { filter: brightness(.45) saturate(.7) hue-rotate(15deg); }
:root[data-daypart="dusk"] .ta-land { filter: brightness(.7) saturate(.9); }
.ta-sun { right: 12vw; top: 14vh; width: 48px; height: 48px; z-index: 0; background: #ffd23f;
  box-shadow: 0 0 0 6px rgba(255, 210, 63, .4), 0 0 0 12px rgba(255, 210, 63, .18); }
:root[data-daypart="dusk"] .ta-sun { top: 46vh; background: #ff8a5c; box-shadow: 0 0 0 6px rgba(255, 138, 92, .4), 0 0 0 12px rgba(255, 138, 92, .18); }
:root[data-daypart="night"] .ta-sun { background: #f4f1de; box-shadow: inset -14px 0 0 #0d1033, 0 0 0 6px rgba(244, 241, 222, .12); }   /* the moon */
:root[data-theme="pixel"] .ta-stars { inset: 0 0 45% 0; z-index: 0; opacity: 0; transition: opacity 1s; }
:root[data-theme="pixel"][data-daypart="night"] .ta-stars { opacity: .9; background:
  linear-gradient(#fff 0 0) 8% 12% / 3px 3px no-repeat, linear-gradient(#fff 0 0) 22% 30% / 3px 3px no-repeat, linear-gradient(#fff 0 0) 37% 8% / 3px 3px no-repeat,
  linear-gradient(#fff 0 0) 51% 40% / 3px 3px no-repeat, linear-gradient(#fff 0 0) 63% 18% / 3px 3px no-repeat, linear-gradient(#fff 0 0) 78% 34% / 3px 3px no-repeat,
  linear-gradient(#fff 0 0) 91% 10% / 3px 3px no-repeat, linear-gradient(#fff 0 0) 30% 55% / 3px 3px no-repeat, linear-gradient(#fff 0 0) 70% 60% / 3px 3px no-repeat;
  animation: ta-twinkle 3s steps(2) infinite; }
.ta-cloud { z-index: 0; width: 8px; height: 8px; background: transparent; animation: ta-drift linear infinite;
  box-shadow: 16px 0 #fff, 24px 0 #fff, 32px 0 #fff, 8px 8px #fff, 16px 8px #fff, 24px 8px #fff, 32px 8px #fff, 40px 8px #fff, 48px 8px #fff,
    0 16px #fff, 8px 16px #fff, 16px 16px #fff, 24px 16px #fff, 32px 16px #fff, 40px 16px #fff, 48px 16px #fff, 56px 16px #fff,
    8px 24px #e6f0ff, 16px 24px #e6f0ff, 24px 24px #e6f0ff, 32px 24px #e6f0ff, 40px 24px #e6f0ff, 48px 24px #e6f0ff; }
.ta-cloud.c1 { top: 10vh; animation-duration: 140s; animation-delay: -30s; }
.ta-cloud.c2 { top: 22vh; animation-duration: 190s; animation-delay: -120s; transform: scale(1.5); }
.ta-cloud.c3 { top: 5vh; animation-duration: 160s; animation-delay: -80s; }
:root[data-daypart="night"] .ta-cloud { opacity: .18; }
:root[data-daypart="dusk"] .ta-cloud { opacity: .3; }
@keyframes ta-drift { from { left: -80px; } to { left: 105vw; } }
@keyframes ta-twinkle { 50% { opacity: .5; } }
.ta-rain { inset: 0; z-index: 0; display: none; }
:root[data-theme="pixel"][data-crunch="exam"] .ta-rain { display: block;   /* stormy before exams */
  background-image: repeating-linear-gradient(90deg, transparent 0 26px, rgba(90, 130, 210, .8) 26px 29px), repeating-linear-gradient(90deg, transparent 0 13px, rgba(90, 130, 210, .55) 13px 15px, transparent 15px 26px);
  -webkit-mask-image: repeating-linear-gradient(180deg, #000 0 10px, transparent 10px 34px); mask-image: repeating-linear-gradient(180deg, #000 0 10px, transparent 10px 34px);
  animation: ta-rain .6s linear infinite; }
@keyframes ta-rain { to { -webkit-mask-position: 0 34px; mask-position: 0 34px; } }
.ta-xp { right: 16px; bottom: 14px; z-index: 41; width: 170px; height: 18px; border: 2px solid var(--label); background: var(--solid);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .25); font: 700 10px/14px ui-monospace, Menlo, monospace; }
.ta-xp span { position: absolute; inset: 0 auto 0 0; width: calc(var(--progress) * 100%); background: repeating-linear-gradient(90deg, #4ade80 0 6px, #22c55e 6px 8px); transition: width .6s steps(8); }
.ta-xp b { position: relative; display: block; text-align: center; color: var(--label); letter-spacing: .06em; }

/* ── Nebula: noticeable. Drifting space clouds, stars that light up as you finish work, redder before exams. ── */
:root[data-theme="nebula"] {
  --win: rgba(10, 8, 28, .40); --side: rgba(8, 6, 24, .30); --solid: #14112e;
  --sep: rgba(200, 190, 255, .12); --sep-strong: rgba(200, 190, 255, .2);
  --label: #f0edff; --label2: #b9b2e3; --label3: #77709f;
  --fill: rgba(200, 190, 255, .09); --fill2: rgba(200, 190, 255, .06); --fill3: rgba(200, 190, 255, .13);
  --accent: #9d8cff; --red: #ff6b8b; --today-bg: rgba(157, 140, 255, .12); --today-bg-hover: rgba(157, 140, 255, .18); --today-line: rgba(157, 140, 255, .35);
  --card: rgba(200, 190, 255, .07); --card-hover: rgba(200, 190, 255, .12); --card-line: rgba(200, 190, 255, .12);
  color-scheme: dark;
}
:root[data-theme="nebula"] body { background: #06051a; }

:root[data-theme="nebula"] .main { background: var(--win); }
:root[data-theme="nebula"] :is(.modal, .popover, .palette, .asg-card, .note-modal, .row-menu, .toast) { background: var(--solid); }
.ta-nebula { inset: -25%; z-index: 0; filter: blur(30px); transition: filter 2s;
  background: radial-gradient(38% 32% at 28% 32%, rgba(139, 92, 246, .85), transparent 70%), radial-gradient(34% 30% at 72% 58%, rgba(56, 189, 248, .6), transparent 70%),
    radial-gradient(28% 26% at 56% 24%, rgba(236, 72, 153, .6), transparent 70%), radial-gradient(44% 38% at 18% 78%, rgba(79, 70, 229, .45), transparent 70%),
    radial-gradient(30% 28% at 84% 18%, rgba(45, 212, 191, .25), transparent 70%);
  animation: ta-nebula 80s ease-in-out infinite alternate; }
:root[data-crunch="exam"] .ta-nebula { filter: blur(30px) hue-rotate(75deg) saturate(1.3); }   /* turns red-orange before exams */
@keyframes ta-nebula { 0% { transform: translate(0, 0) rotate(0) scale(1); } 50% { transform: translate(3%, -2%) rotate(4deg) scale(1.05); } 100% { transform: translate(-3%, 2%) rotate(-3deg) scale(1); } }
.ta-stars.s1, .ta-stars.s2 { inset: 0; z-index: 0; }
.ta-stars.s1 { background-image: radial-gradient(2px 2px at 20px 30px, #fff, transparent), radial-gradient(1.6px 1.6px at 120px 80px, #fff, transparent),
    radial-gradient(2px 2px at 200px 160px, #fff, transparent), radial-gradient(1.4px 1.4px at 60px 210px, #dfe6ff, transparent);
  background-size: 260px 260px; opacity: .9; animation: ta-twinkle 6s ease-in-out infinite; }
.ta-stars.s2 { background-image: radial-gradient(2.4px 2.4px at 40px 60px, #fff, transparent), radial-gradient(1.8px 1.8px at 170px 20px, #ffe9c7, transparent),
    radial-gradient(2.6px 2.6px at 300px 230px, #fff, transparent), radial-gradient(1.8px 1.8px at 90px 300px, #cfe0ff, transparent);
  background-size: 380px 380px; opacity: calc(.1 + var(--progress) * .9); animation: ta-twinkle 9s ease-in-out infinite -3s; }   /* more stars as you finish */

/* ── Study Café: just a hint. Warm paper and a dot-grid notebook; lamp light after dark; a cup that fills as you finish. ── */
:root[data-theme="cafe"] {
  --win: #fbf6ee; --side: #f2e8da; --solid: #fbf6ee; --seg-on: #fffaf3;
  --sep: rgba(90, 60, 40, .12); --sep-strong: rgba(90, 60, 40, .2);
  --label: #3a2e28; --label2: #7a6658; --label3: #b09d8e;
  --fill: rgba(90, 60, 40, .07); --fill2: rgba(90, 60, 40, .05); --fill3: rgba(90, 60, 40, .1);
  --accent: #b8673a; --red: #c9472f; --today-bg: rgba(201, 71, 47, .07); --today-bg-hover: rgba(201, 71, 47, .11); --today-line: rgba(201, 71, 47, .2);
  --card: rgba(120, 80, 50, .055); --card-hover: rgba(120, 80, 50, .09); --card-line: rgba(90, 60, 40, .1);
  --coffee: #6b4226; --cup: #7a6658;
  color-scheme: light;
}
:root[data-theme="cafe"]:is([data-daypart="dusk"], [data-daypart="night"]) {   /* lamp light */
  --win: #241c17; --side: #1d1612; --solid: #2a211b; --seg-on: #4d392e;
  --sep: rgba(255, 220, 180, .1); --sep-strong: rgba(255, 220, 180, .17);
  --label: #f3e7da; --label2: #c4ad9a; --label3: #7f6c5d;
  --fill: rgba(255, 220, 180, .08); --fill2: rgba(255, 220, 180, .05); --fill3: rgba(255, 220, 180, .11);
  --accent: #e8955a; --red: #ff7a5c; --today-bg: rgba(232, 149, 90, .1); --today-bg-hover: rgba(232, 149, 90, .15); --today-line: rgba(232, 149, 90, .28);
  --card: rgba(255, 220, 180, .05); --card-hover: rgba(255, 220, 180, .09); --card-line: rgba(255, 220, 180, .09);
  --coffee: #c98a55; --cup: #c4ad9a;
  color-scheme: dark;
}
:root[data-theme="cafe"] .sidebar { background-color: var(--side); background-image: radial-gradient(var(--sep-strong) 1px, transparent 1.4px); background-size: 14px 14px; }
:root[data-theme="cafe"] body { background: var(--win); }
.ta-lamp { left: 0; top: 0; width: 70vw; height: 70vh; z-index: 2; opacity: 0; transition: opacity 2s;
  background: radial-gradient(closest-side at 18% 12%, rgba(255, 190, 120, .16), transparent); }
:root[data-theme="cafe"]:is([data-daypart="dusk"], [data-daypart="night"]) .ta-lamp { opacity: 1; }
.ta-cup { left: 204px; bottom: 9px; z-index: 41; width: 30px; height: 30px; pointer-events: auto; }
:root:has(.app.collapsed[data-view="chats"]) .ta-cup { display: none; }   /* sidebar hidden on Chats */
.ta-cup svg { width: 30px; height: 30px; overflow: visible; }
.ta-cup .cup { fill: none; stroke: var(--cup); stroke-width: 1.8; }
.ta-cup .coffee { fill: var(--coffee); transform-box: fill-box; transform-origin: bottom; transform: scaleY(var(--progress)); transition: transform 1s; }
.ta-cup .steam { fill: none; stroke: var(--cup); stroke-width: 1.4; opacity: .55; animation: ta-steam 3.5s ease-in-out infinite; }
@keyframes ta-steam { 0%, 100% { opacity: .15; transform: translateY(1px); } 50% { opacity: .6; transform: translateY(-1px); } }
/* See-through themes: the compact panel under the sidebar would show through the glass, so it hides until needed. */
:root:is([data-theme="pixel"], [data-theme="nebula"]) .full { background: transparent; }
:root:is([data-theme="pixel"], [data-theme="nebula"]) .sidebar { background: var(--side); }
:root:is([data-theme="pixel"], [data-theme="nebula"]) .app:not(.collapsed) .mini { opacity: 0; }
:root:is([data-theme="pixel"], [data-theme="nebula"]) .mini { transition: opacity .2s; }
:root:is([data-theme="pixel"], [data-theme="nebula"]) .mini-group h3 { background: var(--solid); }
:root[data-theme="pixel"] .main { background: color-mix(in srgb, var(--solid) 50%, transparent); }
:root[data-theme="pixel"][data-crunch="exam"]:not([data-daypart="night"]) .ta-sun { opacity: .25; }   /* the sun hides behind the storm */

/* Pixel Quest cards: stepped 4px corners, a console-button bevel (light top edge, dark bottom edge), blocky headings. */
:root[data-theme="pixel"]:not([data-intensity="low"]) {
  --px-corners: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
  --px-small: polygon(0 2px, 2px 2px, 2px 0, calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px),
    calc(100% - 2px) 100%, 2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px));
}
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.block:not(.holiday), .chip:not(.done), .card, .study) { border-radius: 0; clip-path: var(--px-corners); }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.block:not(.holiday), .chip:not(.done)) {
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .28), inset 0 -4px 0 rgba(0, 0, 0, .28), inset 3px 0 0 rgba(255, 255, 255, .12), inset -3px 0 0 rgba(0, 0, 0, .14); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .block.exam { box-shadow: inset 0 0 0 3px #ffd23f, inset 0 -6px 0 rgba(0, 0, 0, .28); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .card { border: 0; box-shadow: inset 0 0 0 2px var(--card-line), inset 0 -4px 0 rgba(0, 0, 0, .16); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .card::before { width: 6px; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .card .check { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .study { box-shadow: none; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .inrow { border-radius: 0; clip-path: var(--px-small); background: rgba(0, 0, 0, .2); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .15); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .inrow:hover { background: rgba(0, 0, 0, .3); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .inrow .ring { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .block .tag, :root[data-theme="pixel"]:not([data-intensity="low"]) .block .now { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.block .code, .chip, .card .ttl, .st-label) { font-family: ui-monospace, Menlo, monospace; letter-spacing: .02em; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .block:not(.holiday) .code { text-transform: uppercase; text-shadow: 2px 2px 0 rgba(0, 0, 0, .3); }

/* ── Intensity (Settings → Appearance → Intensity): high = all in, medium = noticeable, low = just a hint ── */
/* Terminal: high adds scanlines, CRT edges and glowing text; low is only the palette (system font, filled blocks, no status line). */
:root[data-theme="terminal"][data-intensity="high"] .ta-scan { display: block; }
:root[data-theme="terminal"][data-intensity="low"] .ta-status { display: none; }
/* Pixel Quest: frost the high-intensity workspace so small text holds up over the moving sky. */
:root[data-theme="pixel"][data-intensity="high"] .main { background: color-mix(in srgb, var(--solid) 72%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
:root[data-theme="pixel"][data-intensity="high"] { --font: ui-monospace, Menlo, monospace; }
:root[data-theme="pixel"][data-intensity="high"] .ta-cloud.c2 { transform: scale(2.2); }
:root[data-theme="pixel"][data-intensity="low"] .main { background: var(--solid); }
:root[data-theme="pixel"][data-intensity="low"] .sidebar { background: color-mix(in srgb, var(--solid) 78%, transparent); }
:root[data-theme="pixel"][data-intensity="low"] :is(.ta-cloud, .ta-rain, .ta-stars) { display: none; }
/* Nebula: high = almost clear glass and a brighter nebula; low = mostly solid panels with a glow at the edges. */
:root[data-theme="nebula"][data-intensity="high"] { --win: rgba(8, 6, 24, .2); --side: rgba(6, 4, 20, .14); --card: rgba(20, 16, 50, .78); --card-hover: rgba(30, 24, 70, .85); }
:root[data-theme="nebula"][data-intensity="high"] .ta-nebula { filter: blur(24px) brightness(1.25) saturate(1.2); }
:root[data-theme="nebula"][data-intensity="high"][data-crunch="exam"] .ta-nebula { filter: blur(24px) brightness(1.25) hue-rotate(75deg) saturate(1.4); }
:root[data-theme="nebula"][data-intensity="low"] { --win: rgba(12, 10, 32, .86); --side: rgba(10, 8, 28, .7); }
/* Sonoran: keep the desert visible, with more frost under the crowded sidebar. */
:root[data-theme="sonoran"][data-intensity="high"] { --win: rgba(30, 18, 34, .34); --side: rgba(24, 13, 28, .56); }
:root[data-theme="sonoran"][data-intensity="high"] .main { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
:root[data-theme="sonoran"][data-intensity="high"] .sidebar { -webkit-backdrop-filter: blur(13px) saturate(1.2); backdrop-filter: blur(13px) saturate(1.2); }
:root[data-theme="sonoran"][data-intensity="low"] { --win: rgba(30, 18, 34, .86); --side: rgba(24, 13, 28, .62); }
:root[data-theme="sonoran"][data-intensity="low"] .sidebar { -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
/* Study Café: low = warm paper only; medium adds serif headings and a faint dot grid on the page; high adds a stronger notebook grid,
   serif type throughout and a brighter lamp. */
:root[data-theme="cafe"]:not([data-intensity="low"]) :is(.toolbar h1, .due h2, .mini-group h3, .app-name, .chat-head h2, .asg-card h2, .note-modal h2, .notes-pin-title, .modal h3) {
  font-family: "New York", "Iowan Old Style", Georgia, serif; letter-spacing: 0; }
:root[data-theme="cafe"][data-intensity="medium"] .main { background-image: radial-gradient(var(--sep) 1px, transparent 1.4px); background-size: 14px 14px; }
:root[data-theme="cafe"][data-intensity="high"] { --font: "New York", "Iowan Old Style", Georgia, serif; }
:root[data-theme="cafe"][data-intensity="high"] .main { background-image: linear-gradient(var(--sep) 1px, transparent 1px), linear-gradient(90deg, var(--sep) 1px, transparent 1px);
  background-size: 22px 22px; }
:root[data-theme="cafe"][data-intensity="high"] .ta-lamp { background: radial-gradient(closest-side at 18% 12%, rgba(255, 190, 120, .28), transparent); }
:root[data-theme="cafe"][data-intensity="high"] .ta-cup { transform: scale(1.3); transform-origin: bottom left; }
:root[data-theme="cafe"][data-intensity="low"] .sidebar { background-image: none; }

/* Nebula on High: your week as constellations (see constellations() in app.js). Finished work = a lit star; a class with
   everything done draws its lines; the whole week done makes every star shimmer. Exams are the big four-point stars. */
.ta-const { display: none; inset: 0; width: 100vw; height: 100vh; z-index: 0; }
:root[data-theme="nebula"][data-intensity="high"] .ta-const { display: block; }
:root[data-theme="nebula"][data-intensity="high"] .ta-stars.s2 { display: none; }   /* the real stars replace the progress layer */
.ta-const .cg { opacity: 0; transition: opacity 1.5s; }
.ta-const .cg.lit { opacity: .8; }
/* Assignment stars: one bright white four-point star with a soft haze around it (see constellations()). */
.ta-const .cs { opacity: 0; stroke: none; }
.ta-const .cs .csp { fill: #fff; }
.ta-const .cs.lit { opacity: 1; animation: ta-ignite 1.6s ease-out, ta-star 5s ease-in-out 1.6s infinite; }

.ta-const .cl { stroke: rgba(220, 225, 255, .6); stroke-width: 1.6; stroke-dasharray: var(--len); stroke-dashoffset: var(--len); opacity: 0; }
.ta-const .cl.on { opacity: 1; stroke-dashoffset: 0; animation: ta-draw 2.4s ease-out both; }
.ta-const .cstars.all .cs.lit { animation: ta-ignite 1.6s ease-out, ta-shimmer 2.2s ease-in-out 1.6s 3, ta-star 5s ease-in-out 8.2s infinite; }
@keyframes ta-ignite { 0% { opacity: 0; } 40% { opacity: 1; } 60% { opacity: .6; } 100% { opacity: 1; } }
@keyframes ta-star { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }
@keyframes ta-shimmer { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ta-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
/* "no class" moves to its own line in narrow columns instead of wrapping word by word (any width, any theme). */
.block.holiday .code { flex-wrap: wrap; white-space: nowrap; row-gap: 0; }
.ta-const .cname { fill: #e6e8ff; stroke: none; font: 200 7.5px/1 "Avenir Next", "Helvetica Neue", sans-serif; letter-spacing: .22em; text-transform: uppercase; text-anchor: middle; transition: opacity 1.5s; }
/* Phones: the list fills the screen, so Nebula High's cards go solid and the sky shows in the gaps between them. */
@media (max-width: 700px) {
  :root[data-theme="nebula"][data-intensity="high"] { --card: #17132f; --card-hover: #201a40; }
  :root[data-theme="nebula"][data-intensity="high"] .card.today { background: color-mix(in srgb, var(--red) 14%, #17132f); }
  .ta-const .cname { font-size: 6.5px; }
}

/* ── Theme fonts (Medium and High) ────────────────────────────────────────────────────────────────────────────────
   Medium changes headings, labels and the sidebars; High changes all text except long reading (chat answers,
   descriptions, what you type). Terminal uses SF Mono and Study Café New York (both set above). */
@font-face { font-family: "Silkscreen"; src: url(/fonts/silkscreen.ttf) format("truetype"); font-display: swap; }
:root[data-theme="pixel"] { --theme-font: "Silkscreen", ui-monospace, Menlo, monospace; }
@font-face { font-family: "Space Grotesk"; src: url(/fonts/space-grotesk.ttf) format("truetype"); font-weight: 300 700; font-display: swap; }
:root[data-theme="nebula"] { --theme-font: "Space Grotesk", "Avenir Next", system-ui, sans-serif; }
:root[data-theme="sonoran"] { --theme-font: Rockwell, "Rockwell Nova", "American Typewriter", Georgia, serif; }
:root:is([data-theme="pixel"], [data-theme="nebula"], [data-theme="sonoran"]):not([data-intensity="low"])
  :is(.app-name, .nav-row, .thread-row, .due h2, .mini-group h3, .mini-head b, .toolbar h1, .fp-head b, .fp-group, .card .ttl,
      .block .code, .chip, .st-label, .modal h3, .modal-nav .nav-row, .asg-card h2, .note-modal h2, .notes-pin-title, .side-top, .panel-tabs, .tab-bar, .tabbar a,
      .mini-month, .mini-month *, .week-head, .week-head *, .hour-label, .mcell .n, .mcell .more, .cal-head, .heat, .heat *) {
  font-family: var(--theme-font); }
:root:is([data-theme="pixel"], [data-theme="nebula"], [data-theme="sonoran"])[data-intensity="high"] { --font: var(--theme-font); }
:root:is([data-theme="pixel"], [data-theme="nebula"], [data-theme="sonoran"])[data-intensity="high"] :is(.md, .md *, textarea, input, .asg-desc, .asg-desc *) {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
/* Silkscreen is a pixel font with big capitals: a little smaller so labels still fit. */
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.nav-row, .thread-row, .card .ttl, .block .code, .chip, .due h2, .app-name) { font-size: .92em; letter-spacing: .02em; }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.due h2, .mini-group h3, .app-name) { text-transform: uppercase; }
/* Pixel Quest is the one theme where Claude's answers use the theme font too (Chris asked). Silkscreen runs large, so
   the size drops and the lines open up to stay readable; code stays monospaced. */
:root[data-theme="pixel"]:not([data-intensity="low"]) .msg-bot .md :not(code, pre, pre *, .katex, .katex *) {
  font-family: var(--theme-font); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .msg-bot .md { font-family: var(--theme-font); font-size: 12px; line-height: 1.9; letter-spacing: .03em; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .msg-bot .md :is(strong, b, h1, h2, h3, h4) { font-weight: 400; color: var(--accent); }
/* Pixel Quest High: truly everything is pixel type, including what you type, search boxes and the XP label. */
:root[data-theme="pixel"][data-intensity="high"] :is(textarea, input, .ta-xp b, .mcp-box code) { font-family: var(--theme-font); letter-spacing: .03em; }
:root[data-theme="pixel"][data-intensity="high"] :is(textarea, input)::placeholder { font-family: var(--theme-font); }
:root[data-theme="pixel"][data-intensity="high"] .composer textarea { font-size: 12px; line-height: 1.8; }
/* Pixel Quest message box: a chunky 2px frame with stepped corners (no rounding), pixel type in it, a square beveled
   Send button and a square paperclip button, like the cards. */
:root[data-theme="pixel"]:not([data-intensity="low"]) .composer form {
  border: 0; border-radius: 0; clip-path: var(--px-corners);
  box-shadow: inset 0 0 0 2px var(--sep-strong), inset 0 -4px 0 rgba(0, 0, 0, .25); padding-bottom: 8px; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .composer form:focus-within { box-shadow: inset 0 0 0 2px var(--accent), inset 0 -4px 0 rgba(0, 0, 0, .25); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .composer textarea { font-family: var(--theme-font); font-size: 12px; line-height: 1.8; letter-spacing: .03em; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .composer textarea::placeholder { font-family: var(--theme-font); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .send {
  border-radius: 0; clip-path: var(--px-small); font-family: var(--theme-font); font-weight: 400; font-size: 11px;
  letter-spacing: .06em; text-transform: uppercase; color: #1a1033;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(0, 0, 0, .3); padding: 0 12px 2px; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .send:active:not(:disabled) { box-shadow: inset 0 3px 0 rgba(0, 0, 0, .3); padding: 2px 12px 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .composer .attach { border-radius: 0; clip-path: var(--px-small); }
/* Pixel Quest toolbar: the week range and Today use the pixel font on Medium too (like the WEEK title), and Today is a
   square button with stepped corners and a 2px frame, like Send. */
:root[data-theme="pixel"]:not([data-intensity="low"]) .toolbar .range { font-family: var(--theme-font); font-size: 12px; letter-spacing: .04em; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .today-btn {
  border: 0; border-radius: 0; clip-path: var(--px-small); height: 24px; padding: 0 10px 1px;
  font-family: var(--theme-font); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  box-shadow: inset 0 0 0 2px var(--sep-strong), inset 0 -3px 0 rgba(0, 0, 0, .25); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .today-btn:active { box-shadow: inset 0 0 0 2px var(--sep-strong), inset 0 3px 0 rgba(0, 0, 0, .25); padding: 1px 10px 0; }
/* Pixel Quest windows (Settings, assignment cards) are solid so text behind never shows through; Usage bars are blocky:
   square chart columns with no outline, and the per-chat bars become segmented health-bar strips like the XP bar. */
:root[data-theme="pixel"]:not([data-intensity="low"]) .modal { background: var(--solid); }

/* Pixel Quest (Medium/High): course colour swatches and dots are pixel-art circles (2px cells); the selected ring is stepped too. */
:root[data-theme="pixel"]:not([data-intensity="low"]) .sw { position: relative; border-radius: 0; background: none; box-shadow: none; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .sw::before { content: ""; position: absolute; inset: 0; background: var(--cc); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'%3E%3Crect x='3' y='0' width='1' height='1'/%3E%3Crect x='4' y='0' width='1' height='1'/%3E%3Crect x='5' y='0' width='1' height='1'/%3E%3Crect x='1' y='1' width='1' height='1'/%3E%3Crect x='2' y='1' width='1' height='1'/%3E%3Crect x='3' y='1' width='1' height='1'/%3E%3Crect x='4' y='1' width='1' height='1'/%3E%3Crect x='5' y='1' width='1' height='1'/%3E%3Crect x='6' y='1' width='1' height='1'/%3E%3Crect x='7' y='1' width='1' height='1'/%3E%3Crect x='1' y='2' width='1' height='1'/%3E%3Crect x='2' y='2' width='1' height='1'/%3E%3Crect x='3' y='2' width='1' height='1'/%3E%3Crect x='4' y='2' width='1' height='1'/%3E%3Crect x='5' y='2' width='1' height='1'/%3E%3Crect x='6' y='2' width='1' height='1'/%3E%3Crect x='7' y='2' width='1' height='1'/%3E%3Crect x='0' y='3' width='1' height='1'/%3E%3Crect x='1' y='3' width='1' height='1'/%3E%3Crect x='2' y='3' width='1' height='1'/%3E%3Crect x='3' y='3' width='1' height='1'/%3E%3Crect x='4' y='3' width='1' height='1'/%3E%3Crect x='5' y='3' width='1' height='1'/%3E%3Crect x='6' y='3' width='1' height='1'/%3E%3Crect x='7' y='3' width='1' height='1'/%3E%3Crect x='8' y='3' width='1' height='1'/%3E%3Crect x='0' y='4' width='1' height='1'/%3E%3Crect x='1' y='4' width='1' height='1'/%3E%3Crect x='2' y='4' width='1' height='1'/%3E%3Crect x='3' y='4' width='1' height='1'/%3E%3Crect x='4' y='4' width='1' height='1'/%3E%3Crect x='5' y='4' width='1' height='1'/%3E%3Crect x='6' y='4' width='1' height='1'/%3E%3Crect x='7' y='4' width='1' height='1'/%3E%3Crect x='8' y='4' width='1' height='1'/%3E%3Crect x='0' y='5' width='1' height='1'/%3E%3Crect x='1' y='5' width='1' height='1'/%3E%3Crect x='2' y='5' width='1' height='1'/%3E%3Crect x='3' y='5' width='1' height='1'/%3E%3Crect x='4' y='5' width='1' height='1'/%3E%3Crect x='5' y='5' width='1' height='1'/%3E%3Crect x='6' y='5' width='1' height='1'/%3E%3Crect x='7' y='5' width='1' height='1'/%3E%3Crect x='8' y='5' width='1' height='1'/%3E%3Crect x='1' y='6' width='1' height='1'/%3E%3Crect x='2' y='6' width='1' height='1'/%3E%3Crect x='3' y='6' width='1' height='1'/%3E%3Crect x='4' y='6' width='1' height='1'/%3E%3Crect x='5' y='6' width='1' height='1'/%3E%3Crect x='6' y='6' width='1' height='1'/%3E%3Crect x='7' y='6' width='1' height='1'/%3E%3Crect x='1' y='7' width='1' height='1'/%3E%3Crect x='2' y='7' width='1' height='1'/%3E%3Crect x='3' y='7' width='1' height='1'/%3E%3Crect x='4' y='7' width='1' height='1'/%3E%3Crect x='5' y='7' width='1' height='1'/%3E%3Crect x='6' y='7' width='1' height='1'/%3E%3Crect x='7' y='7' width='1' height='1'/%3E%3Crect x='3' y='8' width='1' height='1'/%3E%3Crect x='4' y='8' width='1' height='1'/%3E%3Crect x='5' y='8' width='1' height='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'%3E%3Crect x='3' y='0' width='1' height='1'/%3E%3Crect x='4' y='0' width='1' height='1'/%3E%3Crect x='5' y='0' width='1' height='1'/%3E%3Crect x='1' y='1' width='1' height='1'/%3E%3Crect x='2' y='1' width='1' height='1'/%3E%3Crect x='3' y='1' width='1' height='1'/%3E%3Crect x='4' y='1' width='1' height='1'/%3E%3Crect x='5' y='1' width='1' height='1'/%3E%3Crect x='6' y='1' width='1' height='1'/%3E%3Crect x='7' y='1' width='1' height='1'/%3E%3Crect x='1' y='2' width='1' height='1'/%3E%3Crect x='2' y='2' width='1' height='1'/%3E%3Crect x='3' y='2' width='1' height='1'/%3E%3Crect x='4' y='2' width='1' height='1'/%3E%3Crect x='5' y='2' width='1' height='1'/%3E%3Crect x='6' y='2' width='1' height='1'/%3E%3Crect x='7' y='2' width='1' height='1'/%3E%3Crect x='0' y='3' width='1' height='1'/%3E%3Crect x='1' y='3' width='1' height='1'/%3E%3Crect x='2' y='3' width='1' height='1'/%3E%3Crect x='3' y='3' width='1' height='1'/%3E%3Crect x='4' y='3' width='1' height='1'/%3E%3Crect x='5' y='3' width='1' height='1'/%3E%3Crect x='6' y='3' width='1' height='1'/%3E%3Crect x='7' y='3' width='1' height='1'/%3E%3Crect x='8' y='3' width='1' height='1'/%3E%3Crect x='0' y='4' width='1' height='1'/%3E%3Crect x='1' y='4' width='1' height='1'/%3E%3Crect x='2' y='4' width='1' height='1'/%3E%3Crect x='3' y='4' width='1' height='1'/%3E%3Crect x='4' y='4' width='1' height='1'/%3E%3Crect x='5' y='4' width='1' height='1'/%3E%3Crect x='6' y='4' width='1' height='1'/%3E%3Crect x='7' y='4' width='1' height='1'/%3E%3Crect x='8' y='4' width='1' height='1'/%3E%3Crect x='0' y='5' width='1' height='1'/%3E%3Crect x='1' y='5' width='1' height='1'/%3E%3Crect x='2' y='5' width='1' height='1'/%3E%3Crect x='3' y='5' width='1' height='1'/%3E%3Crect x='4' y='5' width='1' height='1'/%3E%3Crect x='5' y='5' width='1' height='1'/%3E%3Crect x='6' y='5' width='1' height='1'/%3E%3Crect x='7' y='5' width='1' height='1'/%3E%3Crect x='8' y='5' width='1' height='1'/%3E%3Crect x='1' y='6' width='1' height='1'/%3E%3Crect x='2' y='6' width='1' height='1'/%3E%3Crect x='3' y='6' width='1' height='1'/%3E%3Crect x='4' y='6' width='1' height='1'/%3E%3Crect x='5' y='6' width='1' height='1'/%3E%3Crect x='6' y='6' width='1' height='1'/%3E%3Crect x='7' y='6' width='1' height='1'/%3E%3Crect x='1' y='7' width='1' height='1'/%3E%3Crect x='2' y='7' width='1' height='1'/%3E%3Crect x='3' y='7' width='1' height='1'/%3E%3Crect x='4' y='7' width='1' height='1'/%3E%3Crect x='5' y='7' width='1' height='1'/%3E%3Crect x='6' y='7' width='1' height='1'/%3E%3Crect x='7' y='7' width='1' height='1'/%3E%3Crect x='3' y='8' width='1' height='1'/%3E%3Crect x='4' y='8' width='1' height='1'/%3E%3Crect x='5' y='8' width='1' height='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .sw.on::after { content: ""; position: absolute; inset: -4px; background: var(--cc); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13' shape-rendering='crispEdges'%3E%3Crect x='4' y='0' width='1' height='1'/%3E%3Crect x='5' y='0' width='1' height='1'/%3E%3Crect x='6' y='0' width='1' height='1'/%3E%3Crect x='7' y='0' width='1' height='1'/%3E%3Crect x='8' y='0' width='1' height='1'/%3E%3Crect x='2' y='1' width='1' height='1'/%3E%3Crect x='3' y='1' width='1' height='1'/%3E%3Crect x='4' y='1' width='1' height='1'/%3E%3Crect x='8' y='1' width='1' height='1'/%3E%3Crect x='9' y='1' width='1' height='1'/%3E%3Crect x='10' y='1' width='1' height='1'/%3E%3Crect x='1' y='2' width='1' height='1'/%3E%3Crect x='2' y='2' width='1' height='1'/%3E%3Crect x='10' y='2' width='1' height='1'/%3E%3Crect x='11' y='2' width='1' height='1'/%3E%3Crect x='1' y='3' width='1' height='1'/%3E%3Crect x='11' y='3' width='1' height='1'/%3E%3Crect x='0' y='4' width='1' height='1'/%3E%3Crect x='1' y='4' width='1' height='1'/%3E%3Crect x='11' y='4' width='1' height='1'/%3E%3Crect x='12' y='4' width='1' height='1'/%3E%3Crect x='0' y='5' width='1' height='1'/%3E%3Crect x='12' y='5' width='1' height='1'/%3E%3Crect x='0' y='6' width='1' height='1'/%3E%3Crect x='12' y='6' width='1' height='1'/%3E%3Crect x='0' y='7' width='1' height='1'/%3E%3Crect x='12' y='7' width='1' height='1'/%3E%3Crect x='0' y='8' width='1' height='1'/%3E%3Crect x='1' y='8' width='1' height='1'/%3E%3Crect x='11' y='8' width='1' height='1'/%3E%3Crect x='12' y='8' width='1' height='1'/%3E%3Crect x='1' y='9' width='1' height='1'/%3E%3Crect x='11' y='9' width='1' height='1'/%3E%3Crect x='1' y='10' width='1' height='1'/%3E%3Crect x='2' y='10' width='1' height='1'/%3E%3Crect x='10' y='10' width='1' height='1'/%3E%3Crect x='11' y='10' width='1' height='1'/%3E%3Crect x='2' y='11' width='1' height='1'/%3E%3Crect x='3' y='11' width='1' height='1'/%3E%3Crect x='4' y='11' width='1' height='1'/%3E%3Crect x='8' y='11' width='1' height='1'/%3E%3Crect x='9' y='11' width='1' height='1'/%3E%3Crect x='10' y='11' width='1' height='1'/%3E%3Crect x='4' y='12' width='1' height='1'/%3E%3Crect x='5' y='12' width='1' height='1'/%3E%3Crect x='6' y='12' width='1' height='1'/%3E%3Crect x='7' y='12' width='1' height='1'/%3E%3Crect x='8' y='12' width='1' height='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13' shape-rendering='crispEdges'%3E%3Crect x='4' y='0' width='1' height='1'/%3E%3Crect x='5' y='0' width='1' height='1'/%3E%3Crect x='6' y='0' width='1' height='1'/%3E%3Crect x='7' y='0' width='1' height='1'/%3E%3Crect x='8' y='0' width='1' height='1'/%3E%3Crect x='2' y='1' width='1' height='1'/%3E%3Crect x='3' y='1' width='1' height='1'/%3E%3Crect x='4' y='1' width='1' height='1'/%3E%3Crect x='8' y='1' width='1' height='1'/%3E%3Crect x='9' y='1' width='1' height='1'/%3E%3Crect x='10' y='1' width='1' height='1'/%3E%3Crect x='1' y='2' width='1' height='1'/%3E%3Crect x='2' y='2' width='1' height='1'/%3E%3Crect x='10' y='2' width='1' height='1'/%3E%3Crect x='11' y='2' width='1' height='1'/%3E%3Crect x='1' y='3' width='1' height='1'/%3E%3Crect x='11' y='3' width='1' height='1'/%3E%3Crect x='0' y='4' width='1' height='1'/%3E%3Crect x='1' y='4' width='1' height='1'/%3E%3Crect x='11' y='4' width='1' height='1'/%3E%3Crect x='12' y='4' width='1' height='1'/%3E%3Crect x='0' y='5' width='1' height='1'/%3E%3Crect x='12' y='5' width='1' height='1'/%3E%3Crect x='0' y='6' width='1' height='1'/%3E%3Crect x='12' y='6' width='1' height='1'/%3E%3Crect x='0' y='7' width='1' height='1'/%3E%3Crect x='12' y='7' width='1' height='1'/%3E%3Crect x='0' y='8' width='1' height='1'/%3E%3Crect x='1' y='8' width='1' height='1'/%3E%3Crect x='11' y='8' width='1' height='1'/%3E%3Crect x='12' y='8' width='1' height='1'/%3E%3Crect x='1' y='9' width='1' height='1'/%3E%3Crect x='11' y='9' width='1' height='1'/%3E%3Crect x='1' y='10' width='1' height='1'/%3E%3Crect x='2' y='10' width='1' height='1'/%3E%3Crect x='10' y='10' width='1' height='1'/%3E%3Crect x='11' y='10' width='1' height='1'/%3E%3Crect x='2' y='11' width='1' height='1'/%3E%3Crect x='3' y='11' width='1' height='1'/%3E%3Crect x='4' y='11' width='1' height='1'/%3E%3Crect x='8' y='11' width='1' height='1'/%3E%3Crect x='9' y='11' width='1' height='1'/%3E%3Crect x='10' y='11' width='1' height='1'/%3E%3Crect x='4' y='12' width='1' height='1'/%3E%3Crect x='5' y='12' width='1' height='1'/%3E%3Crect x='6' y='12' width='1' height='1'/%3E%3Crect x='7' y='12' width='1' height='1'/%3E%3Crect x='8' y='12' width='1' height='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .sdot { border-radius: 0; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 5' shape-rendering='crispEdges'%3E%3Crect x='1' y='0' width='1' height='1'/%3E%3Crect x='2' y='0' width='1' height='1'/%3E%3Crect x='3' y='0' width='1' height='1'/%3E%3Crect x='0' y='1' width='1' height='1'/%3E%3Crect x='1' y='1' width='1' height='1'/%3E%3Crect x='2' y='1' width='1' height='1'/%3E%3Crect x='3' y='1' width='1' height='1'/%3E%3Crect x='4' y='1' width='1' height='1'/%3E%3Crect x='0' y='2' width='1' height='1'/%3E%3Crect x='1' y='2' width='1' height='1'/%3E%3Crect x='2' y='2' width='1' height='1'/%3E%3Crect x='3' y='2' width='1' height='1'/%3E%3Crect x='4' y='2' width='1' height='1'/%3E%3Crect x='0' y='3' width='1' height='1'/%3E%3Crect x='1' y='3' width='1' height='1'/%3E%3Crect x='2' y='3' width='1' height='1'/%3E%3Crect x='3' y='3' width='1' height='1'/%3E%3Crect x='4' y='3' width='1' height='1'/%3E%3Crect x='1' y='4' width='1' height='1'/%3E%3Crect x='2' y='4' width='1' height='1'/%3E%3Crect x='3' y='4' width='1' height='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 5' shape-rendering='crispEdges'%3E%3Crect x='1' y='0' width='1' height='1'/%3E%3Crect x='2' y='0' width='1' height='1'/%3E%3Crect x='3' y='0' width='1' height='1'/%3E%3Crect x='0' y='1' width='1' height='1'/%3E%3Crect x='1' y='1' width='1' height='1'/%3E%3Crect x='2' y='1' width='1' height='1'/%3E%3Crect x='3' y='1' width='1' height='1'/%3E%3Crect x='4' y='1' width='1' height='1'/%3E%3Crect x='0' y='2' width='1' height='1'/%3E%3Crect x='1' y='2' width='1' height='1'/%3E%3Crect x='2' y='2' width='1' height='1'/%3E%3Crect x='3' y='2' width='1' height='1'/%3E%3Crect x='4' y='2' width='1' height='1'/%3E%3Crect x='0' y='3' width='1' height='1'/%3E%3Crect x='1' y='3' width='1' height='1'/%3E%3Crect x='2' y='3' width='1' height='1'/%3E%3Crect x='3' y='3' width='1' height='1'/%3E%3Crect x='4' y='3' width='1' height='1'/%3E%3Crect x='1' y='4' width='1' height='1'/%3E%3Crect x='2' y='4' width='1' height='1'/%3E%3Crect x='3' y='4' width='1' height='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .swatches .auto { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.asg-card, .note-modal) { background: var(--solid); }
/* Assignment descriptions and briefings in the card read like Claude's answers: pixel type at 12px with open lines,
   a shade brighter than the usual grey so the small pixel letters stay readable. */
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.asg-desc, .asg-desc *, .asg-card .md, .asg-card .md :not(code, pre, pre *, .katex, .katex *)) {
  font-family: var(--theme-font); }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.asg-desc, .asg-card .md) { font-size: 12px; line-height: 1.9; letter-spacing: .03em; color: var(--label); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .asg-card .md :is(strong, b, h1, h2, h3, h4) { font-weight: 400; color: var(--accent); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .uchart { border-radius: 0; clip-path: var(--px-small); shape-rendering: crispEdges; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .uchart rect { stroke: none; rx: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .ubar { height: 12px; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .ustack { height: 12px; border-radius: 0; position: relative;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .25); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .ustack::after { content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 6px, rgba(0, 0, 0, .35) 6px 8px); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .ulegend i { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .ustats > div { border-radius: 0; clip-path: var(--px-corners); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .streak { border-radius: 0; clip-path: var(--px-small); font-family: var(--theme-font); font-size: 11px; letter-spacing: .03em; }

/* ── Sidebars, chat list and files panel follow the theme ── */
/* Pixel Quest: square rows, a beveled "selected" button, chunky panel edges. */
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.nav-row, .thread-row, .fp-row) { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.nav-row.active, .thread-row.active) {
  background: var(--card); box-shadow: inset 0 0 0 2px var(--card-line), inset 0 -3px 0 rgba(0, 0, 0, .2), 3px 3px 0 rgba(0, 0, 0, .2); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .sidebar { border-right: 3px solid rgba(0, 0, 0, .28); }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.threads, .files-panel) { border-color: rgba(0, 0, 0, .28); border-width: 3px; background: color-mix(in srgb, var(--solid) 45%, transparent); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .fp-head { border-bottom: 3px solid rgba(0, 0, 0, .2); }
/* Space: the selected row glows like a lit console button. */
:root[data-theme="nebula"]:not([data-intensity="low"]) :is(.nav-row.active, .thread-row.active) {
  background: rgba(157, 140, 255, .16); box-shadow: inset 2px 0 0 var(--accent), 0 0 18px -6px var(--accent); }
:root[data-theme="nebula"]:not([data-intensity="low"]) :is(.sidebar, .threads, .files-panel) { border-color: rgba(160, 150, 255, .16); }
:root[data-theme="nebula"]:not([data-intensity="low"]) :is(.threads, .files-panel) { background: color-mix(in srgb, #0a0820 45%, transparent); }
/* Sonoran: warm sunset highlight on the selected row. */
:root[data-theme="sonoran"]:not([data-intensity="low"]) :is(.nav-row.active, .thread-row.active) {
  background: linear-gradient(90deg, rgba(255, 138, 92, .24), rgba(255, 138, 92, .06)); box-shadow: inset 2px 0 0 var(--accent); }
:root[data-theme="sonoran"]:not([data-intensity="low"]) :is(.threads, .files-panel) { background: color-mix(in srgb, #1d1022 40%, transparent); }
/* Study Café: the selected row is a paper tab. */
:root[data-theme="cafe"]:not([data-intensity="low"]) :is(.nav-row.active, .thread-row.active) { background: var(--win); box-shadow: 0 1px 2px rgba(60, 35, 20, .14), inset 0 0 0 1px var(--sep); }
:root[data-theme="cafe"]:not([data-intensity="low"]) :is(.threads, .files-panel) { background-image: radial-gradient(var(--sep) 1px, transparent 1.4px); background-size: 14px 14px; }
/* Terminal: panels share the console look. */
:root[data-theme="terminal"]:not([data-intensity="low"]) :is(.thread-row.active) { background: var(--fill); box-shadow: inset 2px 0 0 var(--accent); }
:root[data-theme="terminal"]:not([data-intensity="low"]) .thread-row.active::before { content: ">"; color: var(--accent); margin-right: -2px; }

/* ── Space cards: like a printed star chart. Hairline rules, small-cap serif titles, a tiny ✦ in the class color,
   quiet and inky (Medium and High). ── */
:root[data-theme="nebula"]:not([data-intensity="low"]) .card { border: 0; border-bottom: 1px solid rgba(225, 220, 255, .22); border-radius: 0; box-shadow: none; padding-left: 24px; background: rgba(6, 6, 20, .55); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card::before { content: "✦"; width: auto; height: auto; top: 50%; bottom: auto; left: 8px; transform: translateY(-50%); background: none; box-shadow: none; color: var(--cc); font-size: 10px; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card .ttl { font-family: "Iowan Old Style", Georgia, serif; font-variant: small-caps; letter-spacing: .05em; font-weight: 600; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card .meta { font-family: "Iowan Old Style", Georgia, serif; font-style: italic; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) { border-radius: 0; background: rgba(6, 6, 20, .5); box-shadow: inset 0 0 0 1px rgba(225, 220, 255, .28); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) .code { color: color-mix(in srgb, var(--cc) 55%, #fff); font-family: "Iowan Old Style", Georgia, serif; font-variant: small-caps; letter-spacing: .06em; font-size: 13px; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) .code::before { content: "✦ "; color: var(--cc); font-size: 9px; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) :is(.room, .tag, .now) { color: rgba(225, 220, 255, .7); font-family: "Iowan Old Style", Georgia, serif; font-style: italic; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .inrow { background: none; border-radius: 0; border-bottom: 1px solid rgba(225, 220, 255, .14); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .ad-day .chip:not(.done) { border-radius: 0; background: rgba(6, 6, 20, .6); box-shadow: inset 0 -1px 0 var(--cc); color: color-mix(in srgb, var(--cc) 55%, #fff); font-family: "Iowan Old Style", Georgia, serif; font-variant: small-caps; }


/* Preview only: Fable 5.2 "Flight deck" proposal, shown when data-space-cards="f" is set while comparing. */
/* ── Space cards, option F: "Flight deck" ─────────────────────────────────────────────────────────────────────────
   Reference: Apollo and Shuttle cockpit panels and the crew's cue-card checklists. Matte plates with squared corners,
   engraved-style uppercase Futura nomenclature (the typeface NASA actually used on those panels), a solid color band
   for the system (here: the class), square checklist boxes, and the countdown in a small mission-timer window that
   turns into a lit caution annunciator on the day something is due. Flat fills and hairlines only.
   Applies on Medium and High, like the other Space card rules (Low stays plain). ── */

/* Sidebar assignment card: a panel plate */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card {
  padding: 0 7px 0 14px; gap: 9px;
  border: 1px solid rgba(225, 220, 255, .16); border-radius: 2px; box-shadow: none;
  background: color-mix(in srgb, color-mix(in srgb, var(--cc, var(--accent)) 8%, #0c0b1f) 88%, transparent);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card:hover {
  background: color-mix(in srgb, color-mix(in srgb, var(--cc, var(--accent)) 15%, #0c0b1f) 92%, transparent);
  border-color: rgba(225, 220, 255, .28);
}
/* The class color band, full height, like the banding that groups a panel's switches */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card::before {
  content: ""; left: 0; top: 0; bottom: 0; width: 5px; height: auto; transform: none;
  background: var(--cc, var(--accent)); box-shadow: none; color: transparent; font-size: 0;
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card.today {
  background: color-mix(in srgb, color-mix(in srgb, var(--red) 10%, #0c0b1f) 90%, transparent);
  border-color: color-mix(in srgb, var(--red) 50%, transparent);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card.today:hover {
  background: color-mix(in srgb, color-mix(in srgb, var(--red) 16%, #0c0b1f) 94%, transparent);
}

/* Checklist box: square, as on a cue card */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card .check {
  border-radius: 2px; box-shadow: inset 0 0 0 1.5px rgba(225, 220, 255, .5);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card:hover .check {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--cc, var(--accent)) 60%, #fff);
}

/* Nomenclature: uppercase Futura title, monospaced data line under it */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card .ttl {
  font-family: Futura, "Avenir Next", "Helvetica Neue", sans-serif; font-variant: normal; font-style: normal;
  font-size: 11px; font-weight: 500; line-height: 1.3; letter-spacing: .06em; text-transform: uppercase; color: var(--label);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card .meta {
  font-family: "SF Mono", ui-monospace, Menlo, monospace; font-style: normal; font-variant: normal;
  font-size: 10.5px; line-height: 1.3; letter-spacing: 0; margin-top: 2px; color: var(--label2);
  font-variant-numeric: tabular-nums;
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card.today .meta { color: var(--label2); }

/* Countdown: a mission-timer window. On the due day it is a lit annunciator (solid, no glow). */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card .count {
  font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 10.5px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
  padding: 4px 5px; border-radius: 1px; background: #05040f; color: var(--label);
  box-shadow: inset 0 0 0 1px rgba(225, 220, 255, .22);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .card.today .count {
  background: var(--red); color: #16040b; box-shadow: none;
}

/* Week view class block: the same plate, class color as band and flat tint */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) {
  padding: 4px 6px 4px 7px; border-radius: 2px;
  border: 1px solid color-mix(in srgb, var(--cc, var(--accent)) 45%, rgba(225, 220, 255, .12));
  border-left: 4px solid var(--cc, var(--accent));
  background: color-mix(in srgb, var(--cc, var(--accent)) 20%, #0c0b1f); box-shadow: none; color: var(--label);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block.exam:not(.holiday) {
  box-shadow: inset 0 0 0 1px rgba(240, 237, 255, .7);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .code {
  font-family: Futura, "Avenir Next", "Helvetica Neue", sans-serif; font-variant: normal;
  font-size: 11px; font-weight: 500; line-height: 1.3; letter-spacing: .07em; text-transform: uppercase; color: #fff;
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .code::before { content: none; }
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .code small {
  font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 10px; font-weight: 500; letter-spacing: 0;
  text-transform: none; opacity: 1; color: color-mix(in srgb, var(--cc, var(--accent)) 35%, #fff);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .room {
  font-family: "SF Mono", ui-monospace, Menlo, monospace; font-style: normal; font-size: 10px; letter-spacing: 0;
  opacity: 1; color: color-mix(in srgb, var(--cc, var(--accent)) 35%, #fff);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .tag {
  font-family: Futura, "Avenir Next", "Helvetica Neue", sans-serif; font-style: normal; font-size: 9px; font-weight: 500;
  letter-spacing: .08em; padding: 1px 4px 0; border-radius: 1px; background: #fff; color: #0c0b1f;
}
/* Item rows inside a block: checklist lines separated by a hairline */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .inrow {
  margin-top: 3px; padding: 3px 0 0; border-radius: 0; border: 0;
  border-top: 1px solid color-mix(in srgb, var(--cc, var(--accent)) 45%, transparent);
  background: none; color: var(--label); font-size: 11px; font-weight: 500;
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .inrow:hover { background: none; color: #fff; }
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .inrow .ring {
  border-radius: 1px; border: 1.5px solid rgba(240, 237, 255, .8);
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .block:not(.holiday) .inrow:hover .ring { border-color: #fff; }

/* Due chip (week view top row): a small label plate with the class band */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .ad-day .chip:not(.done) {
  padding: 0 5px 0 6px; border-radius: 1px; border: 0; border-left: 3px solid var(--cc, var(--accent));
  background: color-mix(in srgb, var(--cc, var(--accent)) 22%, #0c0b1f);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cc, var(--accent)) 40%, transparent);
  color: #fff; font-family: Futura, "Avenir Next", "Helvetica Neue", sans-serif; font-variant: normal;
  font-size: 10px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase;
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .ad-day .chip:not(.done):hover {
  background: color-mix(in srgb, var(--cc, var(--accent)) 32%, #0c0b1f);
}

/* Other chips (month cells, library filters) keep their own shapes; only the Star atlas serif/underline is cleared
   and the labels pick up the same Futura nomenclature. */
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) :is(.mcell, .lib-chips) .chip:not(.done) {
  border-radius: 2px; box-shadow: none; background: transparent; color: var(--label);
  font-family: Futura, "Avenir Next", "Helvetica Neue", sans-serif; font-variant: normal;
}
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .mcell .chip:not(.done):hover { background: var(--fill2); }
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .mcell .chip.exam:not(.done) { background: color-mix(in srgb, var(--cc, var(--accent)) 30%, #0c0b1f); color: #fff; box-shadow: inset 3px 0 0 var(--cc, var(--accent)); }
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .lib-chips .chip:not(.done):not(.graph-groups) { background: var(--fill2); color: var(--label2); }
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .lib-chips .chip.on:not(.done):not(.graph-groups) { background: var(--fill3); color: var(--label); }
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .lib-chips .chip.graph-groups { color: var(--label3); }
:root[data-theme="nebula"][data-space-cards="f"]:not([data-intensity="low"]) .lib-chips .chip.graph-groups.on { color: var(--accent); }

/* ── Space: a true black void (2026-11-25). No nebula clouds; pure black everywhere so the stars and your
   constellations are the only light. Panels are see-through to the same black, so stars show behind them. ── */
:root[data-theme="nebula"][data-intensity] {
  --win: rgba(0, 0, 0, 0); --side: rgba(0, 0, 0, 0); --solid: #0b0b0d; --seg-on: #33314b;
  --sep: rgba(255, 255, 255, .09); --sep-strong: rgba(255, 255, 255, .16);
  --label: #f4f4f6; --label2: #a3a3ad; --label3: #5f5f69;
  --fill: rgba(255, 255, 255, .07); --fill2: rgba(255, 255, 255, .045); --fill3: rgba(255, 255, 255, .1);
  --card: rgba(0, 0, 0, .7); --card-hover: rgba(18, 18, 22, .9); --card-line: rgba(255, 255, 255, .1);
  --accent: #b9b4ff; --today-bg: rgba(255, 90, 80, .1); --today-bg-hover: rgba(255, 90, 80, .15); --today-line: rgba(255, 90, 80, .3);
}
:root[data-theme="nebula"], :root[data-theme="nebula"] body { background: #000; }
:root[data-theme="nebula"] .ta-nebula { display: none; }
:root[data-theme="nebula"] .main { background: transparent; }
:root[data-theme="nebula"] :is(.threads, .files-panel) { background: transparent; }
:root[data-theme="nebula"] .mini-group h3 { background: rgba(0, 0, 0, .68); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
@media (max-width: 700px) { :root[data-theme="nebula"] .tabbar { background: rgba(17, 17, 23, .86); } }
:root[data-theme="nebula"] .ta-stars.s1 { opacity: 1; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card { background: rgba(0, 0, 0, .78); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) { background: #000; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .ad-day .chip:not(.done) { background: #000; }
/* Before an exam the void isn't red-tinted any more; the stars warm slightly instead. */
:root[data-theme="nebula"][data-crunch="exam"] .ta-stars { filter: sepia(.6) saturate(2) hue-rotate(-20deg); }
@media (max-width: 700px) { :root[data-theme="nebula"][data-intensity="high"] { --card: #050506; --card-hover: #111114; } }

/* Space cards: soft white, rounded, on the black (2026-11-25). Class color stays in the ✦ and the class code. */
:root[data-theme="nebula"]:not([data-intensity="low"]) .card {
  background: #f1efe9; border: 0; border-radius: 10px; box-shadow: 0 1px 0 rgba(255, 255, 255, .06); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card:hover { background: #fbfaf7; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card.today { background: #f6e9e6; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card::before { color: color-mix(in srgb, var(--cc) 80%, #000); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card .ttl { color: #1d1c22; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card .meta { color: #66636e; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card.today .meta, :root[data-theme="nebula"]:not([data-intensity="low"]) .card .count { color: #c43a2c; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card.exam .meta b { color: #1d1c22; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card .check { box-shadow: inset 0 0 0 1.5px #a9a6b0; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) { background: #f1efe9; border-radius: 10px; box-shadow: none; color: #1d1c22; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) .code { color: color-mix(in srgb, var(--cc) 75%, #000); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) :is(.room, .now, .tag) { color: #66636e; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) .inrow { color: #1d1c22; border-bottom-color: rgba(0, 0, 0, .1); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) .inrow .ring { border-color: #8d8a95; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) .inrow.done .ring { background: #8d8a95; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .ad-day .chip:not(.done) { background: #f1efe9; border-radius: 6px; box-shadow: none; color: color-mix(in srgb, var(--cc) 75%, #000); }

/* Space with Space Grotesk (2026-11-25): the cards drop the old star-chart serif for the theme font too. */
:root[data-theme="nebula"]:not([data-intensity="low"]) :is(.card .ttl, .card .meta, .block:not(.holiday) .code, .block:not(.holiday) .room, .ad-day .chip) {
  font-family: var(--theme-font); font-variant: normal; font-style: normal; letter-spacing: 0; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .card .ttl { font-weight: 600; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .block:not(.holiday) .code { font-weight: 700; font-size: 12.5px; }
/* Your week as stars and constellations at Medium and High (not just High). */
:root[data-theme="nebula"]:not([data-intensity="low"]) .ta-const { display: block; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .ta-stars.s2 { display: none; }


/* Space on High: cards and class blocks drift slowly, each on its own rhythm, like objects in zero gravity.
   A couple of pixels at most so times stay readable; hovering holds a card still; off with reduced motion. */
@keyframes ta-float {
  0%   { transform: translate(0, 0) rotate(0deg); }
  25%  { transform: translate(.6px, -1.8px) rotate(.25deg); }
  50%  { transform: translate(-.4px, -2.6px) rotate(-.15deg); }
  75%  { transform: translate(-.8px, -1px) rotate(.2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block:not(.holiday), :where(.ad-day) .chip:not(.done)) {
  animation: ta-float 8s ease-in-out infinite; will-change: transform;
  box-shadow: 0 14px 28px -18px rgba(255, 255, 255, .14); }
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block, :where(.ad-day) .chip):nth-child(2n) { animation-duration: 10s; animation-delay: -3s; }
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block, :where(.ad-day) .chip):nth-child(3n) { animation-duration: 11.5s; animation-delay: -6s; animation-direction: reverse; }
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block, :where(.ad-day) .chip):nth-child(5n) { animation-duration: 9s; animation-delay: -8s; }
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block:not(.holiday), :where(.ad-day) .chip:not(.done)):hover { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { :root[data-theme="nebula"] :is(.card, .block, :where(.ad-day) .chip) { animation: none !important; } }

/* Space on High: the floating cards become 3D slabs. A solid bottom edge for thickness, light from above
   (brighter top, darker bottom, a bright top rim), and they tilt in perspective as they drift. */
@keyframes ta-float3d {
  0%   { transform: perspective(700px) rotateX(0deg) rotateY(0deg) translateY(0); }
  25%  { transform: perspective(700px) rotateX(calc(5.5deg * var(--slab-tilt, 1))) rotateY(calc(-4deg * var(--slab-tilt, 1))) translateY(-2px); }
  50%  { transform: perspective(700px) rotateX(calc(-3deg * var(--slab-tilt, 1))) rotateY(calc(4.5deg * var(--slab-tilt, 1))) translateY(-3.5px); }
  75%  { transform: perspective(700px) rotateX(calc(4deg * var(--slab-tilt, 1))) rotateY(calc(2.5deg * var(--slab-tilt, 1))) translateY(-1.5px); }
  100% { transform: perspective(700px) rotateX(0deg) rotateY(0deg) translateY(0); }
}
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block:not(.holiday), :where(.ad-day) .chip:not(.done)) {
  animation-name: ta-float3d; transform-origin: 50% 60%;
  background: linear-gradient(180deg, #fdfcf9 0%, #efece5 55%, #e2ded5 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 rgba(0, 0, 0, .06),
    0 4px 0 #a8a398, 0 5px 0 #7d786e, 0 16px 26px -12px rgba(255, 255, 255, .16); }
:root[data-theme="nebula"][data-intensity="high"] .card:hover { background: linear-gradient(180deg, #ffffff 0%, #f5f2ec 55%, #e9e5dd 100%); }
:root[data-theme="nebula"][data-intensity="high"] .card.today {
  background: linear-gradient(180deg, #fff4f1 0%, #f6e5e1 55%, #ead6d1 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95), 0 4px 0 #c49a92, 0 5px 0 #946c64, 0 16px 26px -12px rgba(255, 150, 130, .18); }
:root[data-theme="nebula"][data-intensity="high"] .ad-day .chip:not(.done) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 2px 0 #a8a398, 0 3px 0 #7d786e; }
/* Room for the slab edge under each card. */
:root[data-theme="nebula"][data-intensity="high"] .due-list { gap: 10px; }
/* Space on High: flat faces (no brighter top), keeping the slab edge and the tilt. */
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block:not(.holiday), :where(.ad-day) .chip:not(.done)) { background: #f1efe9;
  box-shadow: 0 4px 0 #a8a398, 0 5px 0 #7d786e, 0 16px 26px -12px rgba(255, 255, 255, .16); }
:root[data-theme="nebula"][data-intensity="high"] .card:hover { background: #f7f5f0; }
:root[data-theme="nebula"][data-intensity="high"] .card.today { background: #f6e9e6; box-shadow: 0 4px 0 #c49a92, 0 5px 0 #946c64, 0 16px 26px -12px rgba(255, 150, 130, .18); }
:root[data-theme="nebula"][data-intensity="high"] .ad-day .chip:not(.done) { box-shadow: 0 2px 0 #a8a398, 0 3px 0 #7d786e; }
/* Space on High: the light-from-above shading is back, with a softer top (2026-11-25). */
:root[data-theme="nebula"][data-intensity="high"] :is(.card, .block:not(.holiday), :where(.ad-day) .chip:not(.done)) {
  background: linear-gradient(180deg, #f3f1eb 0%, #ebe8e0 55%, #e0dcd3 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -1px 0 rgba(0, 0, 0, .06),
    0 4px 0 #a8a398, 0 5px 0 #7d786e, 0 16px 26px -12px rgba(255, 255, 255, .16); }
:root[data-theme="nebula"][data-intensity="high"] .card:hover { background: linear-gradient(180deg, #f8f6f1 0%, #f0ede6 55%, #e6e2da 100%); }
:root[data-theme="nebula"][data-intensity="high"] .card.today {
  background: linear-gradient(180deg, #f8ece9 0%, #f2e1dd 55%, #e8d4cf 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 4px 0 #c49a92, 0 5px 0 #946c64, 0 16px 26px -12px rgba(255, 150, 130, .18); }
:root[data-theme="nebula"][data-intensity="high"] .ad-day .chip:not(.done) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 #a8a398, 0 3px 0 #7d786e; }

@media (max-width: 700px) { :root[data-theme="nebula"][data-intensity="high"] .today-page .card { --slab-tilt: .35; } }

/* Space: one nebula per class in its color, sized by its file count, behind its constellation (Medium and High). */
.ta-clouds { display: none; inset: 0; z-index: 0; overflow: hidden; }
:root[data-theme="nebula"]:not([data-intensity="low"]) .ta-clouds { display: block; }
.ta-clouds i { position: absolute; display: block; }
.ta-clouds svg { width: 100%; height: 100%; display: block; }
:root[data-theme="nebula"][data-intensity="high"] .ta-clouds i { animation: ta-cloud 60s ease-in-out infinite alternate; will-change: transform; }
@keyframes ta-cloud { from { transform: scale(1) rotate(0deg); } to { transform: translate(-1.5%, 1%) scale(1.12) rotate(11deg); } }
/* High: the sky feels alive (turned up a notch 2026-11-26). The whole sky (nebulae and constellations together, so they stay lined up) turns and
   drifts very slowly; each nebula also breathes and wanders on its own clock; constellation lines and names shimmer. */
:root[data-theme="nebula"][data-intensity="high"] :is(.ta-clouds, .ta-const) { animation: ta-sky 100s ease-in-out infinite alternate; transform-origin: 50% 60%; }
@keyframes ta-sky { from { transform: translate(0, 0) rotate(0deg); } to { transform: translate(-22px, -13px) rotate(1.2deg); } }
:root[data-theme="nebula"][data-intensity="high"] .ta-clouds i { animation: ta-cloud 46s ease-in-out infinite alternate, ta-breathe 11s ease-in-out infinite alternate; }
:root[data-theme="nebula"][data-intensity="high"] .ta-clouds i:nth-child(2n) { animation-duration: 58s, 14s; animation-delay: -20s, -6s; animation-name: ta-cloud2, ta-breathe; }
:root[data-theme="nebula"][data-intensity="high"] .ta-clouds i:nth-child(3n) { animation-duration: 68s, 9s; animation-delay: -45s, -3s; }
@keyframes ta-cloud2 { from { transform: translate(0, 0) scale(1.04) rotate(0deg); } to { transform: translate(3.5%, -3%) scale(.96) rotate(-10deg); } }
@keyframes ta-breathe { from { opacity: .74; } to { opacity: 1; } }
:root[data-theme="nebula"][data-intensity="high"] .ta-const .cl.on { animation: ta-draw 2.4s ease-out both, ta-line 7s ease-in-out 2.4s infinite alternate; }
@keyframes ta-line { from { opacity: 1; } to { opacity: .45; } }
:root[data-theme="nebula"][data-intensity="high"] .ta-const .cnames { animation: ta-line 15s ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) { :root[data-theme="nebula"] :is(.ta-clouds, .ta-clouds i, .ta-const, .ta-const .cnames, .ta-const .cl.on) { animation: none !important; } }

/* Space on High: shooting stars, tumbling asteroids and satellites (added by skyEvents() in app.js). */
#themeArt > .ta-event { z-index: 0; pointer-events: none; }
.ta-shoot { height: 1.6px; transform-origin: 0 50%; transform: rotate(var(--a));
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .9) 85%, #fff); border-radius: 2px;
  animation: ta-shoot var(--d) ease-out forwards; }
@keyframes ta-shoot { 0% { opacity: 0; clip-path: inset(0 100% 0 0); translate: 0 0; } 15% { opacity: 1; }
  70% { opacity: 1; clip-path: inset(0 0 0 0); } 100% { opacity: 0; clip-path: inset(0 0 0 60%); translate: 60px 30px; } }
.ta-rock { left: 0; animation: ta-drift-x var(--d) linear forwards; }
.ta-rock svg { width: 100%; height: 100%; animation: ta-tumble var(--d) linear forwards; }
.ta-sat { left: 0; width: 4px; height: 4px; animation: ta-drift-x var(--d) linear forwards; }
.ta-sat i { display: block; width: 3px; height: 3px; border-radius: 50%; background: #fff; animation: ta-blink-sat 1.6s steps(1) infinite; }
@keyframes ta-drift-x { from { transform: translate(var(--from), 0); } to { transform: translate(var(--to), var(--rise)); } }
@keyframes ta-tumble { to { transform: rotate(var(--spin)); } }
@keyframes ta-blink-sat { 0%, 100% { opacity: .9; } 50% { opacity: .15; } 55% { opacity: 1; } }
/* A background star flaring up (starFlares() in app.js): soft glow plus four light spikes, swelling then settling. */
.ta-flare { width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); opacity: 0;
  background: radial-gradient(circle, #fff 0 6%, rgba(var(--c), .7) 10%, rgba(var(--c), .18) 32%, transparent 62%);
  animation: ta-flare var(--d) ease-in-out forwards; }
.ta-flare::before, .ta-flare::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(var(--c), .9) 50%, transparent) center / 100% 1.2px no-repeat,
    linear-gradient(transparent, rgba(var(--c), .9) 50%, transparent) center / 1.2px 100% no-repeat; }
.ta-flare::after { transform: rotate(45deg) scale(.5); opacity: .6; }
@keyframes ta-flare { 0% { opacity: 0; transform: scale(.2); } 35% { opacity: 1; transform: scale(1); } 55% { opacity: .85; transform: scale(.9); } 100% { opacity: 0; transform: scale(.25); } }
@media (prefers-reduced-motion: reduce) { .ta-event { display: none; } }
/* The app draws icon outlines on every <svg>; the sky art has none. */
.ta-clouds svg *, .ta-rock svg * { stroke: none; }

/* Space on High: you're looking at the sky through a spaceship window. A pane of glass sits over the sky art and under
   the app: a cool tint, darker thick-glass edges, two soft reflections that slide slowly as the ship moves, a few faint
   smudges and a thin lit rim. Everything is a gradient, so it costs almost nothing to draw. */
.ta-glass { display: none; inset: 0; z-index: 0; }
:root[data-theme="nebula"][data-intensity="high"] .ta-glass { display: block;
  box-shadow: inset 0 0 0 1px rgba(190, 215, 255, .14), inset 0 0 0 7px rgba(150, 180, 230, .035), inset 0 0 160px rgba(90, 140, 255, .13);
  background:
    radial-gradient(120% 95% at 50% 50%, transparent 55%, rgba(18, 34, 66, .55) 100%),
    radial-gradient(18% 12% at 22% 78%, rgba(220, 230, 255, .05), transparent 70%),
    radial-gradient(10% 7% at 81% 30%, rgba(220, 230, 255, .04), transparent 70%),
    linear-gradient(rgba(110, 150, 255, .04), rgba(110, 150, 255, .04)); }
:root[data-theme="nebula"][data-intensity="high"] .ta-glass::before { content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(118deg, transparent 22%, rgba(225, 235, 255, .11) 30%, rgba(225, 235, 255, .04) 37%, transparent 39%,
    transparent 45%, rgba(225, 235, 255, .07) 47%, transparent 50%);
  background-size: 200% 100%; animation: ta-glint 48s ease-in-out infinite alternate; }
@keyframes ta-glint { from { background-position: 0% 0; } to { background-position: 60% 0; } }
/* The pane is square and fills the window, corners included (it was rounded at 28px, which left the corners outside it
   untinted: notches next to the sidebar, inside the window's own rounded corners). */

/* Space: the chat screen sits behind frosted glass so long answers are easy to read. The sky still shows through as
   soft colour, but stars and nebula detail are blurred out. Medium frosts a little, High a lot (the window glass is
   clear elsewhere). The chat list and files panel get a lighter frost. */
:root[data-theme="nebula"]:not([data-intensity="low"]) .chats .convo {
  background: rgba(8, 10, 22, .58);
  -webkit-backdrop-filter: blur(18px) saturate(1.15); backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: inset 1px 0 0 rgba(200, 215, 255, .08);
}
:root[data-theme="nebula"][data-intensity="high"] .chats .convo {
  background: linear-gradient(160deg, rgba(150, 175, 230, .07), transparent 40%), rgba(8, 10, 22, .64);
  -webkit-backdrop-filter: blur(28px) saturate(1.2); backdrop-filter: blur(28px) saturate(1.2);
}
:root[data-theme="nebula"]:not([data-intensity="low"]) .chats :is(.threads, .files-panel) {
  background: rgba(8, 10, 22, .4);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
:root[data-theme="nebula"]:not([data-intensity="low"]) .chats .msg-user { background: rgba(255, 255, 255, .1); }

/* Pixel: the same frosted glass behind the chat, tinted with the theme's own panel colour so it follows the time of day
   (light by day, deep blue at dusk and night). Clouds, sun and stars blur into soft colour behind long answers.
   Medium frosts a little, High a lot; the chat list and files panel get a lighter frost. Low is already solid. */
:root[data-theme="pixel"]:not([data-intensity="low"]) .chats .convo {
  background: color-mix(in srgb, var(--solid) 55%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.1); backdrop-filter: blur(16px) saturate(1.1);
}
:root[data-theme="pixel"][data-intensity="high"] .chats .convo {
  background: color-mix(in srgb, var(--solid) 50%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.15); backdrop-filter: blur(24px) saturate(1.15);
}
:root[data-theme="pixel"]:not([data-intensity="low"]) .chats :is(.threads, .files-panel) {
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
/* No Claude or Codex CLI on this server (the hosted test server, <html data-ai="off">): no Chats tab, no new-class button
   (it starts a chat), no "Open chat" or "Help me start this" buttons, no Plan study time / Re-plan, no practice sets and
   no reading grades from screenshots; the phone tab bar drops to five tabs. (Settings drops AI and Usage, and course
   pages drop Trouble spots, in app.js.) */
:root[data-ai="off"] :is(.nav-row[data-view="chats"], #tabbar a[data-view="chats"], #newClass, #asgChat, #briefMe, a.btn[href^="#chats/"],
  #planBtn, #practiceRow, .grade-drop, .grade-pending) { display: none; }
:root[data-ai="off"] .grade-d2l { text-align: left; }
@media (max-width: 700px) {
  :root[data-ai="off"] .tabbar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  /* iOS zooms on focus when a control's font is smaller. */
  :is(input, select, textarea) { font-size: 16px !important; }
}

/* ── Notes & guides (Library → Notes, course page, assignment card, reader) ── */
.notes-empty { color: var(--label2); font-size: 13px; padding: 24px 2px; }
.notes-pin { display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
  padding: 13px 16px 13px 18px; margin-bottom: 18px; border-radius: 10px; background: var(--card);
  border: 1px solid var(--sep-strong); border-left: 3px solid var(--accent); transition: background .15s, border-color .15s; }
.notes-pin:hover { background: var(--card-hover); }
.notes-pin-kicker { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: .01em; }
.notes-pin-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; color: var(--label); overflow-wrap: anywhere; }
.notes-pin-meta { font-size: 12px; color: var(--label2); margin-top: 2px; }
.notes-list { display: flex; flex-direction: column; gap: 2px; }
.note-row { display: flex; align-items: baseline; gap: 9px; width: 100%; padding: 7px 8px; border-radius: 7px; text-align: left; font-size: 13px; transition: background .12s; }
.note-row:hover { background: var(--fill2); }
.note-row.is-guide { background: color-mix(in srgb, var(--cc) 6%, transparent); }
.note-row.is-guide:hover { background: color-mix(in srgb, var(--cc) 11%, transparent); }
.note-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cc); flex-shrink: 0; transform: translateY(-1px); }
.note-title { flex: 1; min-width: 0; font-weight: 500; line-height: 1.35; color: var(--label); overflow-wrap: anywhere; }
.note-row.is-guide .note-title { font-weight: 600; }
.note-meta { display: inline-flex; align-items: baseline; gap: 10px; flex-shrink: 0; margin-left: 8px; font-size: 11.5px; color: var(--label2); white-space: nowrap; }
.note-kind { color: var(--label2); }

/* Course page right column: Notes & guides */
#cpNotes[hidden], #asgNotes[hidden] { display: none; }
.cp-notes { display: flex; flex-direction: column; gap: 5px; }
.cp-note { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 7px 10px; border-radius: 7px; text-align: left; background: var(--fill2); transition: background .12s; }
.cp-note:hover { background: var(--fill); }
.cp-note.is-guide { border-left: 3px solid var(--cc); padding-left: 9px; background: color-mix(in srgb, var(--cc) 8%, var(--fill2)); }
.cp-note.is-guide:hover { background: color-mix(in srgb, var(--cc) 13%, var(--fill2)); }
.cp-note-title { font-size: 12.5px; font-weight: 500; line-height: 1.35; color: var(--label); overflow-wrap: anywhere; }
.cp-note.is-guide .cp-note-title { font-weight: 600; }
.cp-note-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--label2); }

/* Assignment card: Notes & guides under Description/Rubric */
.asg-notes-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.asg-guide-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 12px; border-radius: 8px;
  background: color-mix(in srgb, var(--cc) 9%, var(--fill2)); border-left: 3px solid var(--cc); cursor: pointer; transition: background .12s; }
.asg-guide-row:hover { background: color-mix(in srgb, var(--cc) 14%, var(--fill2)); }
.asg-guide-info { flex: 1; min-width: 0; }
.asg-guide-title { font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--label); overflow-wrap: anywhere; }
.asg-guide-meta { font-size: 11.5px; color: var(--label2); margin-top: 1px; }
.asg-note-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 7px; text-align: left;
  background: var(--fill2); font-size: 12.5px; transition: background .12s; }
.asg-note-row:hover { background: var(--fill); }
.asg-note-title { flex: 1; min-width: 0; font-weight: 500; line-height: 1.35; color: var(--label); overflow-wrap: anywhere; }
.asg-note-meta { flex-shrink: 0; font-size: 11.5px; color: var(--label2); white-space: nowrap; }

/* Reader modal (and full-height sheet on phones) */
#noteModal { z-index: 86; }
.note-modal { width: min(740px, calc(100vw - 32px)); max-height: min(820px, calc(100dvh - 48px)); display: flex; flex-direction: column; overflow: hidden;
  background: var(--win); border: 1px solid var(--sep-strong); border-top: 3px solid var(--cc); border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.35); animation: popIn .18s cubic-bezier(.32,.72,0,1); }
.note-modal:focus { outline: none; }
.note-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--sep); flex: none; }
.note-scope { font-size: 12px; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.note-head-meta { font-size: 12px; color: var(--label2); margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px 28px; -webkit-overflow-scrolling: touch; }
.note-body h2#noteTitle { margin: 0 0 12px; font-size: 20px; line-height: 1.28; overflow-wrap: anywhere; }
.note-meta-chips { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--sep); }
.note-chip-group { display: flex; align-items: flex-start; gap: 8px; }
.note-chip-label { font-size: 11px; font-weight: 600; color: var(--label3); width: 46px; flex-shrink: 0; padding-top: 4px; }
.note-chips { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; flex: 1; }
.note-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 3px 9px; border-radius: 999px; background: var(--fill); font-size: 11.5px; color: var(--label2); line-height: 1.3; }
.note-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--cc); flex-shrink: 0; }
.note-chip.link { color: var(--label); cursor: pointer; }
.note-chip.link:hover { background: var(--fill3); }
.note-md { font-size: 14px; line-height: 1.6; color: var(--label); overflow-wrap: break-word; }
.note-md > :first-child { margin-top: 0; } .note-md > :last-child { margin-bottom: 0; }
.note-md h1 { font-size: 18px; margin: 18px 0 6px; } .note-md h2 { font-size: 15.5px; margin: 16px 0 6px; } .note-md h3 { font-size: 14px; margin: 14px 0 4px; }
.note-md p { margin: 8px 0; } .note-md ul, .note-md ol { margin: 6px 0; padding-left: 20px; } .note-md li { margin: 3px 0; }
.note-md blockquote { margin: 10px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--sep-strong); color: var(--label2); }
.note-md code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--fill2); padding: 1px 4px; border-radius: 4px; }
.note-md pre { background: var(--fill2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.note-md pre code { background: none; padding: 0; }
.note-md table { border-collapse: collapse; font-size: 13px; margin: 10px 0; display: block; overflow-x: auto; }
.note-md th, .note-md td { border: 1px solid var(--sep-strong); padding: 5px 9px; text-align: left; }
.note-versions { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--sep); }
.note-versions summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--label2); list-style: none; display: flex; align-items: center; gap: 6px; }
.note-versions summary::-webkit-details-marker { display: none; }
.note-versions summary::before { content: "›"; display: inline-block; transition: transform .15s; color: var(--label3); font-size: 14px; line-height: 1; }
.note-versions[open] summary::before { transform: rotate(90deg); }
.nv-body { margin-top: 10px; display: flex; flex-direction: column; gap: 14px; }
.nv-item { padding: 12px 14px; border-radius: 8px; background: var(--fill2); border: 1px solid var(--sep); }
.nv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--sep); font-size: 12px; }
.nv-head b { font-weight: 600; color: var(--label); overflow-wrap: anywhere; } .nv-head span { color: var(--label2); flex-shrink: 0; }

/* Frosted glass & theme polish: keep notes legible over animated skies and desert scenes, while High feels alive. */
:root[data-theme="nebula"]:not([data-intensity="low"]) .notes-pin {
  background: rgba(10, 12, 26, .68); -webkit-backdrop-filter: blur(20px) saturate(1.2); backdrop-filter: blur(20px) saturate(1.2);
  border-color: rgba(210, 220, 255, .2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .notes-pin:hover { background: rgba(16, 19, 38, .78); border-color: rgba(210, 220, 255, .32); }
:root[data-theme="nebula"]:not([data-intensity="low"]) :is(.lib-notes-group, .cp-notes) {
  padding: 10px 12px; border-radius: 10px; background: rgba(8, 10, 22, .6);
  -webkit-backdrop-filter: blur(18px) saturate(1.15); backdrop-filter: blur(18px) saturate(1.15);
  border: 1px solid rgba(200, 215, 255, .12); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .lib-notes-group h3 { margin-top: 2px; }
:root[data-theme="nebula"][data-intensity="high"] :is(.lib-notes-group, .cp-notes) {
  background: linear-gradient(160deg, rgba(150, 175, 230, .07), transparent 42%), rgba(8, 10, 22, .66);
  -webkit-backdrop-filter: blur(24px) saturate(1.2); backdrop-filter: blur(24px) saturate(1.2); }
:root[data-theme="nebula"][data-intensity="high"] .notes-pin {
  background: linear-gradient(150deg, rgba(185, 180, 255, .12), transparent 48%), rgba(10, 12, 26, .72);
  -webkit-backdrop-filter: blur(24px) saturate(1.25); backdrop-filter: blur(24px) saturate(1.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 12px 28px -16px rgba(185, 180, 255, .28); }
:root[data-theme="nebula"] :is(.note-meta, .note-chip-label) { color: var(--label2); }

:root[data-theme="sonoran"]:not([data-intensity="low"]) .notes-pin {
  background: rgba(34, 20, 38, .66); -webkit-backdrop-filter: blur(16px) saturate(1.15); backdrop-filter: blur(16px) saturate(1.15); }
:root[data-theme="sonoran"]:not([data-intensity="low"]) .notes-pin:hover { background: rgba(44, 26, 48, .76); }
:root[data-theme="sonoran"]:not([data-intensity="low"]) :is(.lib-notes-group, .cp-notes) {
  padding: 10px 12px; border-radius: 10px; background: rgba(28, 16, 32, .56);
  -webkit-backdrop-filter: blur(14px) saturate(1.15); backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--sep); }
:root[data-theme="sonoran"]:not([data-intensity="low"]) .lib-notes-group h3 { margin-top: 2px; }
:root[data-theme="sonoran"][data-intensity="high"] :is(.lib-notes-group, .cp-notes) { background: rgba(28, 16, 32, .66); }
:root[data-theme="sonoran"] :is(.note-meta, .note-chip-label) { color: var(--label2); }

:root[data-theme="pixel"]:not([data-intensity="low"]) .notes-pin {
  border: 0; border-left: 6px solid var(--accent); clip-path: var(--px-corners); background: var(--card);
  box-shadow: inset 0 0 0 2px var(--card-line), inset 0 -4px 0 rgba(0, 0, 0, .16); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .notes-pin:hover { background: var(--card-hover); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .lib-notes-group {
  padding: 10px 12px; background: color-mix(in srgb, var(--solid) 72%, transparent); border: 2px solid var(--sep-strong); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .lib-notes-group h3 { margin-top: 2px; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .note-dot { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .cp-note { background: var(--card); border: 2px solid var(--sep-strong); }
:root[data-theme="pixel"]:not([data-intensity="low"]) .cp-note.is-guide { border-left: 4px solid var(--cc); }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.note-meta, .note-chip-label) { color: var(--label2); }
:root[data-theme="pixel"][data-intensity="high"] :is(.notes-pin-title, .note-title, .cp-note-title) { letter-spacing: .02em; }

/* Special-theme polish for Grades overview, Inbox class picker and Held feed items */
:root[data-oled] :is(.held-pick, .lib-pick) { background: var(--raised, #121214); }
:root[data-theme="sonoran"]:not([data-intensity="low"]) :is(.grade-stat, .grade-course:not(.is-empty), .lib-inbox) {
  background: rgba(34, 20, 38, .62); -webkit-backdrop-filter: blur(14px) saturate(1.15); backdrop-filter: blur(14px) saturate(1.15);
}
:root[data-theme="sonoran"]:not([data-intensity="low"]) .grade-course:not(.is-empty):hover { background: rgba(44, 26, 48, .74); }
:root[data-theme="sonoran"]:not([data-intensity="low"]) .grade-course.is-empty { background: rgba(28, 16, 32, .34); }
:root[data-theme="nebula"]:not([data-intensity="low"]) :is(.grade-stat, .grade-course:not(.is-empty), .lib-inbox) {
  background: rgba(10, 12, 26, .66); -webkit-backdrop-filter: blur(18px) saturate(1.15); backdrop-filter: blur(18px) saturate(1.15);
  border-color: rgba(200, 215, 255, .14);
}
:root[data-theme="nebula"]:not([data-intensity="low"]) .grade-course:not(.is-empty):hover { background: rgba(16, 19, 38, .78); }
:root[data-theme="nebula"]:not([data-intensity="low"]) .grade-course.is-empty { background: rgba(10, 12, 26, .36); }
:root[data-theme="cafe"]:not([data-intensity="low"]) :is(.grade-course-info b, .grade-stat > b) {
  font-family: "New York", "Iowan Old Style", Georgia, serif; letter-spacing: 0;
}
:root[data-theme="terminal"]:not([data-intensity="low"]) :is(.grade-stat, .grade-course, .grade-course-score em, .grade-none, .grade-bar, .grade-bar s, .inbox-chip.btn, .held-pick, .lib-pick) {
  border-radius: 2px;
}
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.grade-stat, .grade-course, .grade-course-score em, .grade-none, .grade-bar, .grade-bar s, .inbox-chip.btn, .held-pick, .lib-pick) {
  border-radius: 0;
}
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.grade-stat, .grade-course:not(.is-empty)) {
  background: var(--card); border: 2px solid var(--sep-strong);
}
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.grade-course .sdot, .inbox-chip i, .held-meta .sdot) { border-radius: 0; }

/* ── Base theme glass · Medium chrome ── */
:root:is(:not([data-theme]), [data-theme="light"], [data-theme="dark"]):is([data-intensity="medium"], [data-intensity="high"]) {
  --glass-page: light-dark(#edf0f4, #191a1c);
  --glass-light: light-dark(#fff, #3d4148);
  --glass-reflection: light-dark(#cdd6e1, #242a32);
  --glass-position: 45% 0%;
  --glass-backdrop: radial-gradient(ellipse at var(--glass-position), var(--glass-light), transparent 68%),
    radial-gradient(ellipse at 85% 100%, var(--glass-reflection), transparent 63%);
  --glass-panel-light: none;
  --glass-chrome: light-dark(rgb(248 250 253 / .63), rgb(34 36 40 / .68));
  --glass-floating: light-dark(rgb(251 252 254 / .87), rgb(36 38 42 / .87));
  --glass-content: color-mix(in srgb, var(--win) 97%, transparent);
  --glass-edge: light-dark(rgb(255 255 255 / .85), rgb(255 255 255 / .15));
  --glass-rim: inset 0 1px 0 var(--glass-edge);
  --glass-blur: blur(16px);
  --label3: light-dark(#65686f, #a1a3a9);
  /* Glass is a shade darker than the flat sidebar, so secondary text steps down to keep 4.5:1 on Light. */
  --label2: light-dark(#5f6066, #98989d);
}
:root:is(:not([data-theme]), [data-theme="light"], [data-theme="dark"]):is([data-intensity="medium"], [data-intensity="high"]) body {
  background: var(--glass-backdrop) var(--glass-page);
}
:root[data-oled]:is([data-intensity="medium"], [data-intensity="high"]) {
  --glass-page: #000;
  --glass-chrome: rgb(9 10 12 / .65);
  --glass-floating: rgb(19 20 23 / .90);
  --glass-light: #202328;
  --glass-reflection: #0c1118;
  --glass-panel-light: var(--glass-backdrop);
}
:root[data-oled]:is([data-intensity="medium"], [data-intensity="high"]) body { background: #000; }

:root:is(:not([data-theme]), [data-theme="light"], [data-theme="dark"]):is([data-intensity="medium"], [data-intensity="high"]) {
  & :is(.sidebar, .toolbar, .tabbar, .convo-head, .lib-bar, .fp-head) {
    background: var(--glass-panel-light) var(--glass-chrome);
    box-shadow: var(--glass-rim);
  }
  & :is(.sidebar, .toolbar, .tabbar, .modal, .dialog, .palette, .note-modal) {
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
  }
  & .full { background: transparent; }
  & .app:not(.collapsed) .mini { visibility: hidden; }
  & .mini-group h3 { background: var(--side); }
  & .view { background: var(--glass-content); }
  & :is(.modal, .dialog, .palette, .note-modal, .popover, .row-menu, .toast) {
    background: var(--glass-panel-light) var(--glass-floating);
    box-shadow: var(--glass-rim), 0 16px 48px light-dark(rgb(22 29 43 / .22), rgb(0 0 0 / .45));
  }
  & .modal-nav { background: color-mix(in srgb, var(--side) 46%, transparent); }
  /* Dense text sits on a near-solid backing: Settings and dialog bodies, and the red due-today text. */
  & .modal-content { background-color: var(--glass-content); }
  & :is(.card.today .meta, .card .count) { color: light-dark(#9f2721, #ff9a91); }
}

/* ── Base theme glass · High panels and cards ── */
:root:is(:not([data-theme]), [data-theme="light"], [data-theme="dark"])[data-intensity="high"] {
  --glass-light: light-dark(#fff, #555a63);
  --glass-reflection: light-dark(#bdc8d6, #303741);
  --glass-chrome: light-dark(rgb(241 245 251 / .49), rgb(31 34 39 / .56));
  --glass-floating: light-dark(rgb(248 250 253 / .79), rgb(31 33 37 / .83));
  --glass-content: color-mix(in srgb, var(--win) 93%, transparent);
  --glass-card: light-dark(rgb(251 252 255 / .90), rgb(35 37 41 / .87));
  --glass-sheen: linear-gradient(145deg, light-dark(rgb(255 255 255 / .68), rgb(255 255 255 / .12)), transparent 48%);
  --glass-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='128' height='128'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.065'/%3E%3C/svg%3E");
  --glass-rim: inset 0 1px 0 var(--glass-edge), inset 1px 0 0 light-dark(rgb(255 255 255 / .64), rgb(255 255 255 / .09));
  --glass-blur: blur(20px);

  &[data-daypart="morning"] { --glass-position: 17% 0%; }
  &[data-daypart="afternoon"] { --glass-position: 62% 0%; }
  &[data-daypart="dusk"] { --glass-position: 88% 9%; }
  &[data-daypart="night"] { --glass-position: 34% 0%; --glass-light: light-dark(#f6f8fb, #464a52); }

  & :is(.sidebar, .toolbar, .tabbar, .modal, .dialog, .palette, .note-modal, .popover, .row-menu, .convo-head, .lib-bar, .fp-head) {
    background-image: var(--glass-grain), var(--glass-sheen), var(--glass-panel-light);
  }
  & .view {
    background-image: linear-gradient(var(--glass-content), var(--glass-content)), var(--glass-panel-light);
    background-color: transparent;
    box-shadow: var(--glass-rim);
  }
  & :is(.modal-content, .asg-card, .note-body) { background-color: var(--glass-content); }
  & .asg-card { background-color: color-mix(in srgb, var(--raised, var(--win)) 96%, transparent); }
  & :is(.card, .grade-course, .grade-needs, .grade-setup, .grade-pending, .notes-pin, .lib-notes-group, .cp-notes) {
    background-color: var(--glass-card);
    background-image: var(--glass-grain), var(--glass-sheen);
    box-shadow: var(--glass-rim);
  }
  & .grade-course { border-radius: 8px; }
  & :is(.card, .grade-course, .notes-pin):hover { background-color: color-mix(in srgb, var(--glass-card) 90%, var(--label)); }
  & .card.today { background-color: color-mix(in srgb, var(--glass-card) 88%, var(--red)); }
  & .card.today:hover { background-color: color-mix(in srgb, var(--glass-card) 84%, var(--red)); }
  & :is(.block:not(.holiday), .week .chip:not(.done)) {
    background-color: color-mix(in srgb, var(--cc) 57%, #16181c);
    background-image: var(--glass-grain), linear-gradient(145deg, rgb(255 255 255 / .10), transparent 55%);
  }
  & .block .inrow { background: rgb(0 0 0 / .16); }
  & .block .inrow:hover { background: rgb(0 0 0 / .28); }
  & .block:not(.exam, .holiday), & .week .chip:not(.done) { box-shadow: inset 0 1px 0 rgb(255 255 255 / .23); }
}
:root[data-oled][data-intensity="high"] {
  --glass-light: #393d44;
  --glass-reflection: #121923;
  --glass-chrome: rgb(5 6 8 / .52);
  --glass-floating: rgb(12 13 16 / .78);
  --glass-card: rgb(22 24 28 / .91);
  &[data-daypart="night"] { --glass-light: #2d3035; }
}

/* Appearance previews use the same level as the app. */
:root:is([data-intensity="medium"], [data-intensity="high"]) :is(.ts-light, .ts-dark, .ts-oled, .ts-half) .ts-side {
  background: linear-gradient(145deg, color-mix(in srgb, var(--ts-side) 76%, #b4bfd0), var(--ts-side));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .36);
}
:root[data-intensity="high"] :is(.ts-light, .ts-dark, .ts-oled, .ts-half) .ts-main {
  background: linear-gradient(145deg, color-mix(in srgb, var(--ts-win) 80%, #b4bfd0), var(--ts-win));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .36);
}

/* The phone tab bar has frost in the original Low design, too. Reduce Transparency makes it solid there.
   theme init (index.html, applyTheme) sets data-reduce-transparency; no CSS media query, so Safari reads every glass rule. */
:root[data-reduce-transparency] .tabbar { background: var(--win); -webkit-backdrop-filter: none; backdrop-filter: none; }

@media (max-width: 700px) {
  .lib-bar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .lib-search { flex: 1 1 100%; width: 100%; margin-left: 0; }
  .lib-search { min-height: 36px; }
  .file-hit { min-height: 44px; }
  .note-row { flex-wrap: wrap; row-gap: 2px; padding: 9px 8px; }
  .note-row .note-meta { flex-basis: 100%; margin-left: 16px; font-size: 12px; }
  .asg-note-row { flex-direction: column; gap: 2px; }
  .note-modal { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; border-top: 3px solid var(--cc); padding-top: env(safe-area-inset-top); }
  .note-head { padding: 10px 10px 10px 16px; }
  .note-body { padding: 14px 16px calc(28px + env(safe-area-inset-bottom)); }
  .note-md { font-size: 15px; }
}

/* Settings → Connect AI: numbered steps for the picked assistant. */
.ai-steps { margin: 2px 0 0; padding-left: 20px; color: var(--label2); font-size: 13px; line-height: 1.55; }
.ai-steps li + li { margin-top: 4px; }
.ai-steps b { color: var(--label); font-weight: 600; }

/* ── Class file search UI ─────────────────────────────────────────────────── */
.lib-search:focus, .lib-search:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.cp-title { min-width: 0; }
.cp-title h1, .cp-title p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-actions { align-items: center; flex-wrap: wrap; }
.cp-search { width: 220px; margin: 0; flex-shrink: 0; }
.cp-file-search { margin: 14px 0 0; }
.file-search-panel[hidden], .file-search-list[hidden] { display: none; }
.file-search-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--label2); font-size: 12px; line-height: 1.4; }
.file-search-status[data-state="loading"]::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: fileSearchPulse 1.2s ease-in-out infinite; flex-shrink: 0;
}
.file-search-status[data-state="error"] { color: var(--red); }
.file-search-retry {
  font-size: 12px; font-weight: 600; color: var(--accent); padding: 1px 6px; border-radius: 5px;
}
.file-search-retry:hover { background: var(--fill); }
@keyframes fileSearchPulse { 0%, 100% { opacity: 1; } 50% { opacity: .28; } }
@media (prefers-reduced-motion: reduce) { .file-search-status[data-state="loading"]::before { animation: none; } }

.file-search-list {
  margin-top: 6px; border: 1px solid var(--sep-strong); border-radius: 10px;
  background: var(--fill2); overflow: hidden;
}
.file-hit, .pal-item.file-hit {
  display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; gap: 3px;
  padding: 9px 12px; text-align: left; cursor: pointer;
}
.file-search-list .file-hit { border-radius: 0; }
.file-search-list .file-hit + .file-hit { border-top: 1px solid var(--sep); }
.file-search-list .file-hit:hover { background: var(--fill); }
.file-search-list .file-hit[aria-selected="true"],
.pal-item.file-hit[aria-selected="true"] {
  background: var(--fill);
  box-shadow: inset 2px 0 0 var(--accent);
}
.file-hit-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.file-hit-name {
  min-width: 0; flex: 1; font-size: 13.5px; font-weight: 600; color: var(--label);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-hit-chip {
  flex-shrink: 0; font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 7px; border-radius: 999px;
  background: var(--fill3); color: var(--label2); border: 1px solid var(--sep);
}
.file-hit-meta {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: 11.5px; color: var(--label2);
}
.file-hit-meta .sdot { width: 8px; height: 8px; flex-shrink: 0; }
.file-hit-course { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-hit-term {
  flex-shrink: 0; font-size: 10.5px; font-weight: 500; line-height: 1.2;
  padding: 1px 6px; border-radius: 999px;
  background: var(--fill); color: var(--label2); border: 1px solid var(--sep);
}
.file-hit-line {
  min-width: 0; font-size: 12.5px; line-height: 1.4; color: var(--label2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.file-hit-line mark {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--label); padding: 0 2.5px; border-radius: 3px; font-weight: 600;
}
.pal-list[hidden] + .pal-status:not(:empty) { border-top: 0; }
.pal-search:focus-within { border-bottom-color: color-mix(in srgb, var(--accent) 45%, var(--sep)); }

/* Earlier-term switch dialog */
#termSwitchModal { z-index: 95; }
.term-switch-copy { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--label2); overflow-wrap: anywhere; }
.term-switch-copy b { color: var(--label); font-weight: 600; }

/* Dark, OLED & special theme polish for file search */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .file-hit-line mark { background: color-mix(in srgb, var(--accent) 28%, transparent); }
}
:root[data-theme="dark"] .file-hit-line mark { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:root[data-oled] .file-search-list { background: var(--raised, #121214); border-color: var(--sep-strong); }
:root[data-oled] .file-hit-chip { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .14); color: var(--label); }
:root[data-oled] .file-hit-line mark { background: color-mix(in srgb, var(--accent) 30%, transparent); }
:root[data-oled] .term-switch-dialog { background: var(--raised, #121214); }

:root[data-theme="nebula"]:not([data-intensity="low"]) .file-search-list {
  background: rgba(10, 12, 26, .72);
  -webkit-backdrop-filter: blur(16px) saturate(1.15); backdrop-filter: blur(16px) saturate(1.15);
  border-color: rgba(200, 215, 255, .16);
}
:root[data-theme="nebula"] .file-hit-chip {
  background: rgba(200, 190, 255, .12); border-color: rgba(200, 190, 255, .2); color: var(--label);
}
:root[data-theme="nebula"] .file-hit-line mark {
  background: rgba(157, 140, 255, .30); color: #f6f4ff;
}
:root[data-theme="nebula"] .term-switch-dialog,
:root[data-theme="sonoran"] .term-switch-dialog { background: var(--solid); }
:root[data-theme="sonoran"]:not([data-intensity="low"]) .file-search-list {
  background: rgba(34, 20, 38, .66);
  -webkit-backdrop-filter: blur(14px) saturate(1.15); backdrop-filter: blur(14px) saturate(1.15);
}
:root[data-theme="sonoran"] .file-hit-line mark { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:root[data-theme="cafe"] .file-search-list { background: color-mix(in srgb, var(--side) 72%, var(--win)); }
:root[data-theme="cafe"] .file-hit-chip { background: color-mix(in srgb, var(--accent) 10%, var(--side)); border-color: var(--sep-strong); }
:root[data-theme="cafe"] .file-hit-line mark { background: color-mix(in srgb, var(--accent) 22%, transparent); }
:root[data-theme="terminal"]:not([data-intensity="low"]) :is(.file-search-list, .file-hit-chip, .file-hit-term, .file-hit-line mark) { border-radius: 2px; }
:root[data-theme="pixel"]:not([data-intensity="low"]) :is(.file-search-list, .file-hit-chip, .file-hit-term, .file-hit-line mark, .file-hit-meta .sdot) { border-radius: 0; }
:root[data-theme="pixel"]:not([data-intensity="low"]) .file-search-list { background: var(--card); border: 2px solid var(--sep-strong); }

@media (max-width: 900px) {
  .cp-search { width: 200px; }
}
@media (max-width: 700px) {
  .cp-search { flex: 1 1 100%; width: 100%; min-height: 38px; }
  .lib-search { min-height: 38px; }
  .file-hit, .pal-item.file-hit { min-height: 44px; padding: 10px 12px; }
  .palette-backdrop { padding-top: max(16px, env(safe-area-inset-top)); }
}
@media (pointer: coarse) {
  .lib-search, .cp-search, .pal-search input { font-size: 16px !important; }
}

/* ── Settings: time zone and key resets (renderSettingsContent → tzRows, d2lKeyRow, mcpResetRow) ── */
.tz-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.tz-form input { flex: 1 1 220px; min-width: 0; height: 30px; font: 12.5px var(--font); color: var(--label); background: var(--modal-bg, var(--win)); border: 1px solid var(--sep-strong); border-radius: 7px; padding: 0 10px; }
.tz-form input:focus { outline: none; border-color: var(--accent); }
.tz-form .btn { height: 30px; }
#tzErr { margin: -4px 0 8px; font-size: 12px; }
#tzErr:empty { display: none; }
.tz-note { margin: -4px 0 12px; }
.tz-note b, .slabel p code { color: var(--label); font-weight: 500; }
.slabel p code { font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.tz-hint { position: fixed; right: 20px; bottom: 20px; z-index: 59; width: min(340px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 12px;
  background: var(--modal-bg, var(--solid, var(--win))); color: var(--label); border: 1px solid var(--sep); box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 12.5px; line-height: 1.45; }
.tz-hint p { margin: 0 0 10px; color: var(--label2); }
.tz-hint b { color: var(--label); font-weight: 500; }
.tz-hint-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 700px) {
  .tz-form input { height: 38px; font-size: 16px; flex-basis: 100%; }
  .tz-form .btn { flex: 1 1 auto; height: 38px; }
  .tz-hint { left: 16px; right: 16px; width: auto; bottom: calc(68px + env(safe-area-inset-bottom)); }
  .tz-hint .btn { height: 36px; font-size: 13px; }
}
