/* ============================================================
   Atlas — 設計系統
   1. Reset        2. Tokens       3. Typography   4. Layout
   5. Navigation   6. Cards        7. Controls     8. Forms
   9. Modules      10. Utilities
   ============================================================ */

/* ── 1. Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
img, svg, video, canvas { display: block; max-width: 100%; }
/* 沒有明確指定尺寸的圖示，預設跟著字級走，不要撐滿容器 */
svg:not([width]) { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.17em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* ── 2. Tokens ────────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* 畫布與層級：Light 用「近白 canvas + 純白卡片」製造浮起感 */
  --bg:            #f5f5f7;
  --bg-tint:       #ffffff;
  --surface:       #ffffff;
  --surface-2:     #fafafc;
  --surface-sunk:  #eeeef2;
  --separator:     rgba(0, 0, 0, .08);
  --separator-strong: rgba(0, 0, 0, .14);

  --text:          #1d1d1f;
  --text-2:        #55555c;
  --text-3:        #8a8a90;
  --text-inverse:  #ffffff;

  --accent:        #2f6bff;
  --accent-ink:    #1d4fd8;
  --accent-soft:   rgba(47, 107, 255, .10);
  --accent-glow:   rgba(47, 107, 255, .22);

  --good:          #199a5b;
  --good-soft:     rgba(25, 154, 91, .12);
  --warn:          #c77b0a;
  --warn-soft:     rgba(199, 123, 10, .12);
  --bad:           #d1394b;
  --bad-soft:      rgba(209, 57, 75, .12);

  --shadow-sm:  0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --shadow-md:  0 2px 6px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 20px rgba(0,0,0,.08), 0 24px 56px rgba(0,0,0,.10);
  --shadow-key: 0 6px 20px var(--accent-glow);

  --chrome-bg:   rgba(255,255,255,.72);
  --chrome-line: rgba(0,0,0,.07);

  /* 尺度 */
  --r-xs: 8px;  --r-sm: 12px;  --r-md: 16px;  --r-lg: 22px;  --r-xl: 28px;  --r-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 56px; --sp-10: 72px;

  --tab-h: 58px;
  --maxw: 720px;
  --maxw-wide: 1180px;

  --ease: cubic-bezier(.32, .72, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
          "Helvetica Neue", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei",
          system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

:root[data-theme="dark"],
:root:not([data-theme="light"]) {
  /* 預留給 @media 覆寫，見下方 */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

/* Dark 不是把白翻黑：canvas 壓到純黑讓 OLED 省電且對比更乾淨，
   卡片用帶藍調的深灰浮起，分隔線改用「亮度」而非「暗度」。 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #000000;
    --bg-tint:       #0b0b0e;
    --surface:       #141418;
    --surface-2:     #1b1b21;
    --surface-sunk:  #0a0a0d;
    --separator:     rgba(255, 255, 255, .09);
    --separator-strong: rgba(255, 255, 255, .16);

    --text:          #f2f2f4;
    --text-2:        #a6a6ae;
    --text-3:        #6e6e78;
    --text-inverse:  #0b0b0e;

    --accent:        #5c93ff;
    --accent-ink:    #8fb4ff;
    --accent-soft:   rgba(92, 147, 255, .14);
    --accent-glow:   rgba(92, 147, 255, .26);

    --good:          #3ac97f;
    --good-soft:     rgba(58, 201, 127, .15);
    --warn:          #e6a13c;
    --warn-soft:     rgba(230, 161, 60, .15);
    --bad:           #ff6b7d;
    --bad-soft:      rgba(255, 107, 125, .15);

    --shadow-sm:  0 1px 2px rgba(0,0,0,.5);
    --shadow-md:  0 2px 8px rgba(0,0,0,.55), 0 12px 32px rgba(0,0,0,.4);
    --shadow-lg:  0 10px 28px rgba(0,0,0,.6), 0 30px 70px rgba(0,0,0,.5);
    --shadow-key: 0 6px 24px rgba(92,147,255,.28);

    --chrome-bg:   rgba(18,18,22,.74);
    --chrome-line: rgba(255,255,255,.08);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #000000;
  --bg-tint:       #0b0b0e;
  --surface:       #141418;
  --surface-2:     #1b1b21;
  --surface-sunk:  #0a0a0d;
  --separator:     rgba(255, 255, 255, .09);
  --separator-strong: rgba(255, 255, 255, .16);
  --text:          #f2f2f4;
  --text-2:        #a6a6ae;
  --text-3:        #6e6e78;
  --text-inverse:  #0b0b0e;
  --accent:        #5c93ff;
  --accent-ink:    #8fb4ff;
  --accent-soft:   rgba(92, 147, 255, .14);
  --accent-glow:   rgba(92, 147, 255, .26);
  --good:          #3ac97f;  --good-soft: rgba(58, 201, 127, .15);
  --warn:          #e6a13c;  --warn-soft: rgba(230, 161, 60, .15);
  --bad:           #ff6b7d;  --bad-soft:  rgba(255, 107, 125, .15);
  --shadow-sm:  0 1px 2px rgba(0,0,0,.5);
  --shadow-md:  0 2px 8px rgba(0,0,0,.55), 0 12px 32px rgba(0,0,0,.4);
  --shadow-lg:  0 10px 28px rgba(0,0,0,.6), 0 30px 70px rgba(0,0,0,.5);
  --shadow-key: 0 6px 24px rgba(92,147,255,.28);
  --chrome-bg:   rgba(18,18,22,.74);
  --chrome-line: rgba(255,255,255,.08);
}

/* 課程色票：11 色，使用者可自選。
   每個色相的亮度是逐一算出來的——取「白字對比仍 ≥ 4.6」的最亮值，
   所以色塊盡可能鮮豔，白字又一定讀得到。黃色帶（h 80–110）刻意避開，
   那個區間壓到夠深一定會變橄欖褐。 */
:root {
  --c-coral:#d9372f;  --c-orange:#ba5a00; --c-green:#008734; --c-emerald:#008469;
  --c-cyan:#00818c;   --c-blue:#0075d2;   --c-indigo:#6363eb; --c-violet:#9852d8;
  --c-pink:#c33ca0;   --c-rose:#d7325b;   --c-slate:#657689;
  /* 掌握度用的單色階（低 → 高），不是彩虹 */
  --seq-1:#96b9ee; --seq-2:#72a1e7; --seq-3:#5089dc;
  --seq-4:#2f70ce; --seq-5:#1159b8; --seq-6:#004498;
}
/* 深色模式：色塊沿用同一組（白字對比一樣過），但拿來當文字時要提亮 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-coral:#d5584d;  --c-orange:#cd6505; --c-green:#2b9f4a; --c-emerald:#019d7e;
    --c-cyan:#0098a4;   --c-blue:#2d88e2;   --c-indigo:#7278e4; --c-violet:#9d69d2;
    --c-pink:#c35aa4;   --c-rose:#d4556c;   --c-slate:#798898;
    --seq-1:#325384; --seq-2:#3a66a7; --seq-3:#447ac9;
    --seq-4:#518fe9; --seq-5:#69a5fe; --seq-6:#96c0fe;
  }
}
:root[data-theme="dark"] {
  --c-coral:#d5584d;  --c-orange:#cd6505; --c-green:#2b9f4a; --c-emerald:#019d7e;
  --c-cyan:#0098a4;   --c-blue:#2d88e2;   --c-indigo:#7278e4; --c-violet:#9d69d2;
  --c-pink:#c35aa4;   --c-rose:#d4556c;   --c-slate:#798898;
  --seq-1:#325384; --seq-2:#3a66a7; --seq-3:#447ac9;
  --seq-4:#518fe9; --seq-5:#69a5fe; --seq-6:#96c0fe;
}

/* --tint = 拿來當文字/邊框的色；--tint-solid = 實心色塊的底色（配白字） */
.c-coral  {--tint:var(--c-coral);  --tint-solid:#d9372f}
.c-orange {--tint:var(--c-orange); --tint-solid:#ba5a00}
.c-green  {--tint:var(--c-green);  --tint-solid:#008734}
.c-emerald{--tint:var(--c-emerald);--tint-solid:#008469}
.c-cyan   {--tint:var(--c-cyan);   --tint-solid:#00818c}
.c-blue   {--tint:var(--c-blue);   --tint-solid:#0075d2}
.c-indigo {--tint:var(--c-indigo); --tint-solid:#6363eb}
.c-violet {--tint:var(--c-violet); --tint-solid:#9852d8}
.c-pink   {--tint:var(--c-pink);   --tint-solid:#c33ca0}
.c-rose   {--tint:var(--c-rose);   --tint-solid:#d7325b}
.c-slate  {--tint:var(--c-slate);  --tint-solid:#657689}
/* 舊名稱對應，避免既有資料壞掉 */
.c-amber  {--tint:var(--c-orange); --tint-solid:#ba5a00}
.c-teal   {--tint:var(--c-emerald);--tint-solid:#008469}

/* ── 3. Typography ────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: .005em;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}

h1, h2, h3, h4 { line-height: 1.22; letter-spacing: -.02em; font-weight: 640; }
h1 { font-size: clamp(28px, 7vw, 38px); letter-spacing: -.032em; }
h2 { font-size: clamp(21px, 4.6vw, 26px); letter-spacing: -.024em; }
h3 { font-size: 17px; letter-spacing: -.012em; }

.display { font-size: clamp(32px, 9vw, 52px); font-weight: 680; letter-spacing: -.04em; line-height: 1.08; }
.lede    { font-size: 17px; color: var(--text-2); line-height: 1.6; }
.eyebrow {
  font-size: 12px; font-weight: 640; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3);
}
.meta    { font-size: 13px; color: var(--text-3); }
.numeral { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: .92em; }

/* 中英混排：英文與數字前後補一點視覺氣口 */
.mix :is(b, strong) { font-weight: 640; }

/* ── 4. Layout ────────────────────────────────────────────── */
.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + var(--sp-5));
}
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--sp-5);
}
.wrap-wide { max-width: var(--maxw-wide); }
.stack   > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-7); }
.row  { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.grow { flex: 1 1 auto; min-width: 0; }

section.block { margin-top: var(--sp-8); }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.section-head h2 { font-size: 20px; }

/* ── 5. Navigation ────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--chrome-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--ease);
}
.topbar.is-scrolled { border-bottom-color: var(--chrome-line); }
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); height: 52px;
  max-width: var(--maxw); margin-inline: auto; padding-inline: var(--sp-5);
}
.topbar-wide .topbar-inner { max-width: var(--maxw-wide); }
.topbar-title { font-size: 17px; font-weight: 640; letter-spacing: -.015em; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--chrome-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--chrome-line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: var(--tab-h); color: var(--text-3);
  font-size: 10.5px; font-weight: 560; letter-spacing: .01em;
  transition: color .2s var(--ease);
}
.tab svg { width: 23px; height: 23px; stroke-width: 1.7; }
.tab.is-active { color: var(--accent); }
.tab:active { opacity: .55; }

/* 平板／桌機：改成側邊欄 + 雙欄，而不是把手機畫面放大 */
@media (min-width: 900px) {
  :root { --tab-h: 0px; }
  .app { display: grid; grid-template-columns: 248px minmax(0, 1fr); padding-bottom: 0; }
  .tabbar {
    position: sticky; top: 0; left: auto; right: auto; bottom: auto;
    height: 100dvh; grid-auto-flow: row; grid-auto-columns: none;
    align-content: start; gap: 2px; padding: var(--sp-6) var(--sp-4);
    border-top: 0; border-right: 1px solid var(--chrome-line);
    background: var(--bg-tint); backdrop-filter: none;
  }
  .tab {
    flex-direction: row; justify-content: flex-start; gap: var(--sp-3);
    height: 42px; padding-inline: var(--sp-3); border-radius: var(--r-sm);
    font-size: 14.5px; font-weight: 520; letter-spacing: -.01em;
  }
  .tab svg { width: 20px; height: 20px; }
  .tab.is-active { background: var(--accent-soft); }
  .tabbar-brand {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 0 var(--sp-3) var(--sp-6); font-size: 19px; font-weight: 680;
    letter-spacing: -.03em;
  }
  .topbar { top: 0; }
  .topbar-inner, .wrap { max-width: 860px; }
  .wrap-wide, .topbar-wide .topbar-inner { max-width: var(--maxw-wide); }
}
@media (max-width: 899px) { .tabbar-brand { display: none; } }

/* ── 6. Cards ─────────────────────────────────────────────── */
.card {
  /* 卡片常常直接掛在 <a> / <button> 上，沒有這行的話會變成 inline 元素、寬度塌掉 */
  display: block;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-pad { padding: var(--sp-5); }
.card-lift { transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out); }
@media (hover: hover) {
  .card-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
}
.card-lift:active { transform: scale(.988); }

.card-quiet { background: var(--surface-2); box-shadow: none; }
.card-sunk  { background: var(--surface-sunk); border-color: transparent; box-shadow: none; }

/* 首頁主卡：今天的重點，視覺份量最重的一張 */
.hero {
  position: relative;
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 62%),
    var(--surface);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-md);
}

.divider { height: 1px; background: var(--separator); border: 0; }

.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--separator); }
.list-row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5); min-height: 56px;
  transition: background-color .2s var(--ease);
}
@media (hover: hover) { a.list-row:hover, button.list-row:hover { background: var(--surface-2); } }
.list-row:active { background: var(--surface-sunk); }
.list-row .chev { color: var(--text-3); flex: none; }

/* ── 7. Controls ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 44px; padding-inline: var(--sp-5);
  border-radius: var(--r-pill); font-size: 15.5px; font-weight: 600; letter-spacing: -.01em;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--separator);
  transition: transform .22s var(--ease), background-color .22s var(--ease), opacity .22s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(.965); }
.btn-primary {
  background: var(--accent); color: #fff; border-color: transparent;
  box-shadow: var(--shadow-key);
}
.btn-primary:disabled { opacity: .45; box-shadow: none; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-soft  { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn-sm { height: 34px; padding-inline: var(--sp-4); font-size: 14px; }
.btn-lg { height: 52px; padding-inline: var(--sp-6); font-size: 17px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: var(--r-pill); }
.btn-icon svg { width: 20px; height: 20px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding-inline: 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-sunk); color: var(--text-2);
  white-space: nowrap; flex: none;   /* 標籤不該被擠成兩三行 */
}
.pill-tint { background: color-mix(in srgb, var(--tint, var(--accent)) 14%, transparent); color: var(--tint, var(--accent)); }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad  { background: var(--bad-soft);  color: var(--bad); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tint, var(--accent)); flex: none; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-sunk); border-radius: var(--r-pill);
}
.seg button {
  height: 32px; padding-inline: var(--sp-4); border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 580; color: var(--text-2);
  transition: background-color .22s var(--ease), color .22s var(--ease);
}
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── 8. Forms ─────────────────────────────────────────────── */
.field { display: block; }
.field-label {
  display: block; font-size: 13px; font-weight: 600; color: var(--text-2);
  margin-bottom: 6px; letter-spacing: -.005em;
}
.input, .textarea, .select {
  width: 100%; padding: 11px var(--sp-4);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--separator-strong); border-radius: var(--r-sm);
  font-size: 16px; /* iOS 16px 以下會自動放大畫面 */
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.select { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238a8a90' stroke-width='1.6'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.field-hint { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.field-grid { display: grid; gap: var(--sp-4); }
@media (min-width: 560px) { .field-grid-2 { grid-template-columns: 1fr 1fr; } }

/* ── 9. Modules ───────────────────────────────────────────── */

/* 今日任務列 */
.task {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  transition: background-color .2s var(--ease), opacity .3s var(--ease);
}
.task + .task { border-top: 1px solid var(--separator); }
.task-mark {
  flex: none; width: 26px; height: 26px; margin-top: 2px; border-radius: 50%;
  border: 1.8px solid var(--separator-strong);
  display: grid; place-items: center; color: transparent;
  transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease);
}
.task-mark svg { width: 15px; height: 15px; stroke-width: 2.6; }
.task-body { flex: 1 1 auto; min-width: 0; }
.task-title { font-size: 16px; font-weight: 600; letter-spacing: -.012em; }
.task-sub { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.task-why { font-size: 12.5px; color: var(--text-3); margin-top: 6px; display: flex; gap: 5px; align-items: flex-start; }
.task-why svg { width: 13px; height: 13px; flex: none; margin-top: 3px; }
.task-min {
  flex: none; font-size: 13px; font-weight: 640; color: var(--text-3);
  font-variant-numeric: tabular-nums; padding-top: 3px;
}
.task.is-done { opacity: .5; }
.task.is-done .task-title { text-decoration: line-through; text-decoration-color: var(--text-3); }
.task.is-done .task-mark { background: var(--good); border-color: var(--good); color: #fff; }
.task.is-skipped { opacity: .4; }

.task-rail {
  width: 3px; border-radius: 3px; align-self: stretch; min-height: 34px;
  background: var(--tint, var(--accent)); opacity: .85; flex: none;
}

/* 掌握度量表（0 不會 → 5 可應用） */
.mastery { display: flex; gap: 3px; align-items: center; }
.mastery i {
  width: 16px; height: 5px; border-radius: 3px; background: var(--surface-sunk);
  display: block; transition: background-color .3s var(--ease);
}
.mastery i.on { background: var(--tint, var(--accent)); }
.mastery-lv0 { --tint: var(--bad); }
.mastery-lv1 { --tint: var(--bad); }
.mastery-lv2 { --tint: var(--warn); }
.mastery-lv3 { --tint: var(--accent); }
.mastery-lv4 { --tint: var(--good); }
.mastery-lv5 { --tint: var(--good); }

/* 進度環 */
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring-track { stroke: var(--surface-sunk); }
.ring-fill  { stroke: var(--tint, var(--accent)); stroke-linecap: round;
  transition: stroke-dashoffset .8s var(--ease-out); }
.ring-label { position: absolute; font-size: 13px; font-weight: 680; font-variant-numeric: tabular-nums; }

/* 進度條 */
.bar { height: 6px; border-radius: 3px; background: var(--surface-sunk); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--tint, var(--accent));
  transition: width .7s var(--ease-out); }

/* 空狀態 */
.empty {
  text-align: center; padding: var(--sp-8) var(--sp-5);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
}
.empty-art {
  width: 56px; height: 56px; border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: var(--sp-1);
}
.empty-art svg { width: 26px; height: 26px; stroke-width: 1.5; }
.empty h3 { font-size: 17px; }
.empty p { font-size: 14.5px; color: var(--text-2); max-width: 34ch; }

/* 課程卡 */
.course-card { position: relative; padding: var(--sp-5); }
.course-card::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--tint, var(--accent));
}
.course-name { font-size: 17px; font-weight: 640; letter-spacing: -.015em; }

/* AI 對話 */
.chat { display: flex; flex-direction: column; gap: var(--sp-5); padding-bottom: 96px; }
.msg { display: flex; gap: var(--sp-3); align-items: flex-start; }
.msg-user { flex-direction: row-reverse; }
.bubble {
  max-width: min(84%, 560px); padding: 11px var(--sp-4);
  border-radius: var(--r-lg); font-size: 15.5px; line-height: 1.62;
  overflow-wrap: anywhere;
}
.msg-user .bubble {
  background: var(--accent); color: #fff; border-bottom-right-radius: var(--r-xs);
}
.msg-ai .bubble {
  background: var(--surface); border: 1px solid var(--separator);
  border-bottom-left-radius: var(--r-xs); box-shadow: var(--shadow-sm); max-width: min(92%, 640px);
}
.bubble > * + * { margin-top: .7em; }
.bubble h1, .bubble h2, .bubble h3 { font-size: 16.5px; margin-top: 1.1em; }
.bubble ul, .bubble ol { padding-left: 1.35em; }
.bubble li + li { margin-top: .3em; }
.bubble pre {
  background: var(--surface-sunk); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm); overflow-x: auto; font-size: 13px; line-height: 1.55;
}
.bubble :not(pre) > code {
  background: var(--surface-sunk); padding: 1px 5px; border-radius: 5px; font-size: .9em;
}
.msg-avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--c-violet)));
  color: #fff; font-size: 12px; font-weight: 700; margin-top: 2px;
}

/* AI 產生的可操作卡片 */
.ai-card {
  border: 1px solid var(--separator); border-radius: var(--r-md);
  background: var(--surface-2); padding: var(--sp-4); margin-top: var(--sp-3);
}
.ai-card-head { display: flex; align-items: center; gap: var(--sp-2); font-size: 12px;
  font-weight: 640; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
  animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* 輸入列（文字 + 語音） */
.composer {
  position: sticky; bottom: 0; z-index: 30;
  padding: var(--sp-3) var(--sp-5) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  background: var(--chrome-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--chrome-line);
}
.composer-inner {
  display: flex; align-items: flex-end; gap: var(--sp-2);
  max-width: var(--maxw); margin-inline: auto;
}
.composer textarea {
  flex: 1 1 auto; max-height: 140px; min-height: 44px; padding: 11px var(--sp-4);
  border-radius: var(--r-lg); border: 1px solid var(--separator-strong);
  background: var(--surface); resize: none; font-size: 16px; line-height: 1.45;
}
.composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.mic {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2);
  border: 1px solid var(--separator-strong); color: var(--text-2);
  transition: all .25s var(--ease);
}
.mic svg { width: 20px; height: 20px; }
.mic.is-live { background: var(--bad); border-color: transparent; color: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); }
  70% { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.send { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--accent);
  color: #fff; display: grid; place-items: center; transition: all .25s var(--ease); }
.send svg { width: 19px; height: 19px; }
.send:disabled { opacity: .35; }

.voice-live {
  font-size: 14px; color: var(--text-2); padding: var(--sp-2) var(--sp-4) 0;
  max-width: var(--maxw); margin-inline: auto; min-height: 0;
}
.voice-live b { color: var(--text); font-weight: 560; }

/* 週成果格 */
.shelf { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

/* 課程地圖時間軸 */
.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before {
  content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px;
  background: var(--separator);
}
.tl-item { position: relative; padding-block: var(--sp-3); }
.tl-item::before {
  content: ''; position: absolute; left: calc(var(--sp-6) * -1 + 3px); top: 20px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--separator-strong);
}
.tl-item.is-taught::before { background: var(--good); border-color: var(--good); }
.tl-item.is-teaching::before { background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft); }

/* ── 10. Utilities ────────────────────────────────────────── */
.t2 { color: var(--text-2); } .t3 { color: var(--text-3); }
.tc { text-align: center; } .tr { text-align: right; }
.fs-13 { font-size: 13px; } .fs-14 { font-size: 14px; } .fs-15 { font-size: 15px; }
.fw-6 { font-weight: 640; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); } .mt-7 { margin-top: var(--sp-7); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x {
  display: flex; gap: var(--sp-3); overflow-x: auto; scroll-snap-type: x mandatory;
  margin-inline: calc(var(--sp-5) * -1); padding-inline: var(--sp-5);
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { scroll-snap-align: start; flex: none; }

.fade-in { animation: fadeIn .5s var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeIn .5s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* 數學式（KaTeX）在暗色下的可讀性 */
.katex { font-size: 1.02em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding-block: 4px; }

/* Toast */
.toast-host {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
  z-index: 100; display: flex; flex-direction: column; gap: var(--sp-2); align-items: center;
  pointer-events: none; width: max-content; max-width: calc(100vw - var(--sp-8));
}
.toast {
  background: var(--text); color: var(--bg-tint);
  padding: 10px var(--sp-5); border-radius: var(--r-pill);
  font-size: 14px; font-weight: 560; box-shadow: var(--shadow-lg);
  animation: toastIn .4s var(--ease-out) both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@media (min-width: 900px) { .toast-host { bottom: var(--sp-6); } }

/* 手機底部列只放五個主要分頁；專案與進度在桌機側欄與首頁入口 */
@media (max-width: 899px) { .tab-wide-only { display: none; } }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.brand-mark svg { width: 17px; height: 17px; }
.app-main { min-width: 0; }

/* ── AI 對話的附屬元件 ────────────────────────────────────── */
.tool-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); padding-left: 40px; }
.msg-ai .tool-strip { padding-left: 0; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 580; padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--good-soft); color: var(--good);
}
.tool-chip::before { content: '✓'; font-size: 11px; }
.tool-chip.is-running { background: var(--surface-sunk); color: var(--text-3); }
.tool-chip.is-running::before { content: '⋯'; }
.tool-chip.is-error { background: var(--bad-soft); color: var(--bad); }
.tool-chip.is-error::before { content: '!'; }

.thinking-note { color: var(--text-3); font-size: 14px; }
.thinking-note::after { content: ''; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

a.ai-card { display: block; transition: transform .25s var(--ease), border-color .25s var(--ease); }
@media (hover: hover) { a.ai-card:hover { transform: translateY(-1px); border-color: var(--accent); } }

.plan-strip { padding: var(--sp-4) var(--sp-5); }
.plan-strip-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding-block: 7px; font-size: 14.5px;
}
.plan-strip-row + .plan-strip-row { border-top: 1px solid var(--separator); }
.plan-strip-row.is-done { opacity: .45; text-decoration: line-through; }
.mic.is-off { opacity: .4; }

/* 對話頁的底部要讓出輸入列的高度 */
body:has(#composer) .app { padding-bottom: 0; }
#composer { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 900px) { #composer { bottom: 0; } }

/* 今日計畫頁：每個任務底下的微調工具 */
.task-wrap + .task-wrap { border-top: 1px solid var(--separator); }
.task-tools {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  padding: 0 var(--sp-5) var(--sp-4); margin-top: -6px;
}
.task-wrap .task + .task { border-top: 0; }
details > summary::-webkit-details-marker { display: none; }
details > summary { list-style: none; }

/* ── 圖表 ─────────────────────────────────────────────────── */
.stat-grid { display: grid; gap: var(--sp-3); grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-num {
  font-size: 30px; font-weight: 660; letter-spacing: -.03em; line-height: 1.1;
  margin-top: 6px;
}
.stat-unit { font-size: 14px; font-weight: 520; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }

.chart { margin: 0; }

/* 長條圖：細長條、資料端 4px 圓角、條間 2px 讓底色透出來 */
.bars {
  display: flex; align-items: flex-end; gap: 2px;
  height: 108px; margin-top: var(--sp-4);
  border-bottom: 1px solid var(--separator);
  padding-bottom: 1px;
}
.bar-col { position: relative; flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; }
.bar-fill {
  position: relative; width: 100%; background: var(--accent);
  border-radius: 4px 4px 0 0; min-height: 2px;
  transition: height .7s var(--ease-out);
}
.bar-fill.is-zero { background: var(--separator); border-radius: 2px; }
.bar-tag {
  position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 640; color: var(--text-2); white-space: nowrap;
}
.bars-axis {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--text-3); margin-top: 6px;
}

/* 橫條：標籤 + 條 + 數值，數值一律直接標，不靠顏色猜 */
.hbars { display: flex; flex-direction: column; gap: 10px; margin-top: var(--sp-4); }
.hbar-row { display: flex; align-items: center; gap: var(--sp-3); }
.hbar-label { flex: 0 0 92px; font-size: 13px; color: var(--text-2); }
.hbar-track { flex: 1 1 auto; height: 10px; border-radius: 5px; background: var(--surface-sunk); overflow: hidden; }
.hbar-track > i { display: block; height: 100%; border-radius: 5px; transition: width .7s var(--ease-out); }
.hbar-val { flex: 0 0 44px; text-align: right; font-size: 13px; font-weight: 620; color: var(--text-2); }
@media (min-width: 560px) { .hbar-label { flex-basis: 130px; font-size: 14px; } }

/* 「調整 ›」「全部 ›」這種次要連結：圖示縮小並禁止換行 */
a.meta {
  display: inline-flex; align-items: center; gap: 2px;
  white-space: nowrap; flex: none;
}
a.meta svg { width: 15px; height: 15px; stroke-width: 2; opacity: .6; }
.section-head h2 { min-width: 0; }

/* 任務列：標題最多兩行，原因一行就好，避免每列都很高 */
.task-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-why span {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.45;
}
.task-min { white-space: nowrap; }

/* ── 課表 ─────────────────────────────────────────────────
   參考 Schooly 的做法：實心色塊、白字、白底不畫網格，
   空堂就是留白。資訊只放三層：課名 / 教室 / 老師。 */
.class-time { display: none; }
.tt-wrap {
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: var(--sp-4) var(--sp-3) var(--sp-4) 0;
  overflow: hidden;
}
.tt-grid {
  display: grid;
  grid-template-columns: 38px repeat(5, minmax(0, 1fr));
  column-gap: 4px; row-gap: 4px;
}
@media (min-width: 560px) { .tt-grid { grid-template-columns: 50px repeat(5, minmax(0, 1fr)); column-gap: 6px; row-gap: 6px; } }

.tt-corner { grid-row: 1; grid-column: 1; }
.tt-dayhead {
  grid-row: 1; display: grid; place-items: center;
  height: 28px; font-size: 13px; font-weight: 640; color: var(--text-3);
  border-radius: var(--r-pill);
}
.tt-dayhead.is-today { background: var(--accent); color: #fff; }

/* 今天那一欄只用極淡的底色，不搶戲 */
.tt-todaycol {
  background: var(--accent-soft); border-radius: var(--r-md);
  margin: -3px; z-index: 0;
}

.tt-time {
  grid-column: 1; display: flex; flex-direction: column;
  align-items: flex-end; justify-content: center; padding-right: 6px; line-height: 1.1;
}
.tt-time b { font-size: 11px; font-weight: 700; color: var(--text-3); }
.tt-time span { font-size: 9.5px; color: var(--text-3); opacity: .7; font-variant-numeric: tabular-nums; }
.tt-time.is-lunch { opacity: .35; }

/* 空堂＝留白。只留一條極淡的基線讓視線對得齊 */
.tt-cell {
  min-height: 50px; z-index: 0;
  border-top: 1px solid var(--separator);
  opacity: .5;
}
.tt-cell.is-lunch { min-height: 18px; border-top-style: dashed; }
@media (min-width: 560px) { .tt-cell { min-height: 62px; } .tt-cell.is-lunch { min-height: 22px; } }

.tt-block {
  z-index: 1;
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  padding: 7px 8px; border-radius: 11px; overflow: hidden;
  background: var(--tint-solid); color: #fff;
  transition: transform .2s var(--ease), filter .2s var(--ease);
}
@media (hover: hover) { .tt-block:hover { filter: brightness(1.12); transform: translateY(-1px); } }
.tt-block:active { transform: scale(.97); }
.tt-name {
  font-size: 12px; font-weight: 680; line-height: 1.25; color: #fff;
  letter-spacing: -.012em; overflow-wrap: anywhere;
}
.tt-room, .tt-teacher {
  font-size: 10px; line-height: 1.25; color: rgba(255,255,255,.82);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tt-teacher { color: rgba(255,255,255,.66); }
@media (min-width: 560px) {
  .tt-name { font-size: 13.5px; }
  .tt-room, .tt-teacher { font-size: 11.5px; }
}

/* 課程資訊：官方大綱的配分、聯絡方式、Office hours */
.info-row { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: 14.5px; line-height: 1.6; }
.info-key { flex: 0 0 66px; color: var(--text-3); font-size: 13px; font-weight: 600; padding-top: 1px; }
.info-val { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.info-val.info-hot { font-weight: 600; color: var(--text); }
.model-pick { transition: border-color .2s var(--ease); border: 1px solid var(--separator); }
.model-pick.is-on { border-color: var(--accent); background: var(--accent-soft); }

/* ═══ 講堂 ════════════════════════════════════════════════════
   移植自《電子學白話講堂》的視覺語彙：白話用襯線、公式配「這式子在說什麼」、
   術語中英並陳、載子用藍紅區分。色票改綁 Atlas 的 token，深色模式才會正確。 */
.hall {
  --copper: #9c5527;  --copper-2: #8a4a20;  --copper-soft: rgba(156, 85, 39, .10);
  --electron: #3163b8; --electron-soft: rgba(49, 99, 184, .10);
  --hole: #b2434f;     --hole-soft: rgba(178, 67, 79, .10);
  --serif: Georgia, "Songti TC", "Noto Serif TC", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hall {
    --copper: #e28a54; --copper-2: #f0a272; --copper-soft: rgba(226, 138, 84, .14);
    --electron: #7da4ee; --electron-soft: rgba(125, 164, 238, .14);
    --hole: #e68b94;    --hole-soft: rgba(230, 139, 148, .14);
  }
}
:root[data-theme="dark"] .hall {
  --copper: #e28a54; --copper-2: #f0a272; --copper-soft: rgba(226, 138, 84, .14);
  --electron: #7da4ee; --electron-soft: rgba(125, 164, 238, .14);
  --hole: #e68b94;    --hole-soft: rgba(230, 139, 148, .14);
}

.hall .lbl {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-3);
  font-weight: 600; margin-bottom: 8px;
}
.hall-lead { font-size: 16px; line-height: 1.75; color: var(--text-2); max-width: 38em; }

/* 章節裡的一個段落 */
.hall-block { margin-top: var(--sp-8); }
.hall-block-head {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding-bottom: var(--sp-4); border-bottom: 1px solid var(--separator); margin-bottom: var(--sp-5);
}
.hall-block-head h2 { font-size: 21px; letter-spacing: -.022em; }
.hall-block.is-read .hall-block-head .task-mark { background: var(--good); border-color: var(--good); color: #fff; }
.hall-block.is-read { opacity: .62; }
.hall-body > * + * { margin-top: var(--sp-4); }
.hall-body p { font-size: 15.5px; line-height: 1.78; color: var(--text-2); max-width: 40em; }
.hall-body strong { color: var(--text); font-weight: 640; }
.hall-body ul, .hall-body ol { padding-left: 1.35em; color: var(--text-2); font-size: 15.5px; line-height: 1.8; }
.hall-body li + li { margin-top: 6px; }

/* 中英術語 */
.hall .term > i {
  font-style: normal; font-family: var(--font-mono); font-size: .8em;
  color: var(--copper); background: var(--copper-soft);
  padding: 1px 6px; border-radius: 5px; margin-left: 4px; letter-spacing: -.01em;
}

/* 白話比喻 */
.hall .eli5 {
  padding: 2px 0 2px 20px; border-left: 2px solid var(--copper); max-width: 37em;
}
.hall .eli5 .lbl { color: var(--copper); }
.hall .eli5 p {
  font-family: var(--serif); font-size: 17.5px; line-height: 1.72; color: var(--text);
  max-width: none;
}
.hall .eli5 p + p { margin-top: 10px; }

/* 公式 */
.hall .fx {
  background: var(--surface-2); border: 1px solid var(--separator);
  border-radius: var(--r-md); padding: 16px 18px; display: grid; gap: 11px; max-width: 40em;
}
.hall .fx-eq {
  font-family: var(--font-mono); font-size: 16px; color: var(--text);
  overflow-x: auto; line-height: 1.95; letter-spacing: -.01em;
}
.hall .fx-say {
  font-size: 13.5px; color: var(--text-2); display: flex; gap: 9px; align-items: flex-start;
  padding-top: 11px; border-top: 1px dashed var(--separator-strong);
}
.hall .fx-say b {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); flex: none; padding-top: 3px; font-weight: 600;
}
.hall .fx-note { font-size: 13.5px; color: var(--text-2); line-height: 1.7; }
.hall .fx-note em { font-style: normal; font-family: var(--font-mono); color: var(--text); }

/* 提醒 / 陷阱 */
.hall .warn {
  background: var(--copper-soft); border: 1px solid transparent;
  border-radius: var(--r-md); padding: 14px 16px; max-width: 40em;
}
.hall .warn p { color: var(--text); font-size: 14.5px; line-height: 1.72; margin: 0; }
.hall .warn p + p { margin-top: 8px; }
.hall .warn b { color: var(--copper-2); font-weight: 650; }

/* 考卷上會怎麼問 */
.hall .exam {
  background: var(--surface-2); border: 1px solid var(--separator);
  border-left: 3px solid var(--text-3);
  border-radius: var(--r-md); padding: 14px 16px; max-width: 40em;
}
.hall .exam .q {
  font-family: var(--font-mono); font-size: 13.5px; color: var(--text);
  line-height: 1.75; display: block; margin-bottom: 8px;
}
.hall .exam .a { font-size: 13.5px; color: var(--text-2); line-height: 1.72; display: block; }

/* 圖 */
.hall figure.dia {
  margin: 0; background: var(--surface-2); border: 1px solid var(--separator);
  border-radius: var(--r-md); overflow: hidden;
}
.hall figure.dia .dia-in { padding: 18px 16px 6px; overflow-x: auto; }
.hall figure.dia svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.hall figure.dia figcaption {
  font-size: 12.5px; color: var(--text-3); padding: 10px 16px 14px;
  line-height: 1.65; border-top: 1px solid var(--separator); margin-top: 12px;
}
.hall .dia-txt { fill: var(--text-2); font-family: var(--font-mono); font-size: 11px; }
.hall .dia-txt-b { fill: var(--text); font-family: var(--font); font-size: 12px; font-weight: 600; }
.hall .dia-line { stroke: var(--text-2); fill: none; stroke-width: 1.6; }
.hall .dia-thin { stroke: var(--separator-strong); fill: none; stroke-width: 1; }
.hall .c-stroke { stroke: var(--text-2); fill: none; }
.hall .c-fill { fill: var(--text-2); } .hall .c-txt { fill: var(--text-2); }
.hall .n-fill { fill: var(--electron); } .hall .n-txt { fill: var(--electron); }
.hall .p-fill { fill: var(--hole); }    .hall .p-txt { fill: var(--hole); }

/* 表格 */
.hall .tbl-wrap { overflow-x: auto; border: 1px solid var(--separator); border-radius: var(--r-md); }
.hall .tbl-wrap table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.hall .tbl-wrap th, .hall .tbl-wrap td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--separator);
  color: var(--text-2); line-height: 1.6;
}
.hall .tbl-wrap th { color: var(--text); font-weight: 640; background: var(--surface-2); white-space: nowrap; }
.hall .tbl-wrap tr:last-child td { border-bottom: 0; }

/* 使用說明 */
.hall .howto {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--separator); border-radius: var(--r-md); overflow: hidden;
}
.hall .howto-i { padding: 14px 16px; border-bottom: 1px solid var(--separator); }
.hall .howto-i h4 { font-size: 14px; margin-bottom: 4px; }
.hall .howto-i p { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
@media (min-width: 640px) {
  .hall .howto-i { border-bottom: 0; border-right: 1px solid var(--separator); }
  .hall .howto-i:last-child { border-right: 0; }
}

/* 詞彙表 / 講義索引 */
.hall .gl-en { font-family: var(--font-mono); font-size: 13.5px; color: var(--copper); }
.slide-row { display: flex; gap: var(--sp-3); align-items: flex-start; }
.slide-row + .slide-row { border-top: 1px solid var(--separator); padding-top: 12px; }
.slide-n {
  flex: 0 0 42px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  color: var(--text-3); padding-top: 2px;
}
/* 只看出席的課在課表上退到後面，讓要讀的五科跳出來 */
.tt-block.is-att { opacity: .58; }
.tt-block.is-att .tt-name { font-weight: 600; }
@media (hover: hover) { .tt-block.is-att:hover { opacity: 1; } }

/* 課程選色 */
.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--tint-solid); display: grid; place-items: center;
  color: transparent; border: 2px solid transparent;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.swatch svg { width: 15px; height: 15px; stroke-width: 3; }
.swatch.is-on { color: #fff; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--tint-solid); }
.swatch:active { transform: scale(.88); }
@media (hover: hover) { .swatch:hover { transform: scale(1.1); } }

/* 課程地圖的單元可以點進去看講解 */
.topic-link { display: block; }
.topic-chev { display: inline-flex; vertical-align: -.15em; color: var(--text-3); margin-left: 2px; }
.topic-chev svg { width: 14px; height: 14px; }
@media (hover: hover) { .topic-link:hover { color: var(--tint); } }

/* 長網址按鈕：允許換行，不要衝出卡片 */
.btn-url {
  height: auto; min-height: 44px; padding-block: 10px;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.4;
  font-size: 14px; letter-spacing: -.01em;
}

/* ── 學校行事曆 ───────────────────────────────────────────── */
.card.is-now { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.cal-row {
  display: flex; gap: var(--sp-4); align-items: flex-start;
  padding: var(--sp-4) var(--sp-5);
}
.cal-row + .cal-row { border-top: 1px solid var(--separator); }
.cal-row.is-today { background: var(--accent-soft); }
.cal-row.is-holiday .cal-dm { color: var(--bad); }
.cal-date { flex: 0 0 52px; display: flex; flex-direction: column; line-height: 1.25; }
.cal-dm { font-size: 14px; font-weight: 680; letter-spacing: -.01em; }
.cal-wd { font-size: 11px; color: var(--text-3); }
.cal-ev { font-size: 14px; line-height: 1.6; color: var(--text-2); }
.cal-ev + .cal-ev { margin-top: 4px; }
.cal-ev::before {
  content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-3); margin-right: 7px; vertical-align: .18em;
}
.cal-exam::before, .cal-ev.cal-exam::before { background: var(--bad); }
.cal-ev.cal-exam { color: var(--text); font-weight: 600; }
.cal-ev.cal-holiday::before { background: var(--good); }
.cal-ev.cal-deadline::before { background: var(--warn); }
.cal-ev.cal-start::before { background: var(--accent); }
.cal-exam {
  display: flex; align-items: center; gap: 7px; font-size: 14.5px;
  color: var(--tint); margin-bottom: 5px;
}
