/* 新培學習平台 — 橙色主調（配合 B logo 嘅播放徽章，同新培網站「報名」掣一樣）
   --brand      橙色填色（按鈕、播放掣、進度條）；上面用 --on-brand 字色
   --brand-dark 深橙色，用喺白底上嘅文字／連結（對比度夠 4.5:1） */
:root {
  --brand: #C94B09;
  --brand-hover: #A03D08;
  --on-brand: #FFFFFF;
  --brand-dark: #A03D08;
  --brand-soft: #FFF3EB;
  --brand-tint: #FFE4D1;
  --navy: #0B1F3A;
  --ink: #101828;
  --muted: #667085;
  --line: #E4E7EC;
  --line-soft: #F2F4F7;
  --bg: #FAF9F7;
  --surface: #FFFFFF;
  --surface-2: #F7F7F5;
  --green: #12B76A;
  --red: #D92D20;
  --red-soft: #FEF3F2;
  --gold: #B54708;
  --gold-soft: #FFFAEB;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #FF7A33; --brand-hover: #FF9A5C; --on-brand: #1F0D02; --brand-dark: #FF9A5C; --brand-soft: #2A1A10; --brand-tint: #3D2414;
    --navy: #E6ECF5; --ink: #EEF0F3; --muted: #98A2B3; --line: #2E3440; --line-soft: #232831;
    --bg: #12151B; --surface: #1A1E26; --surface-2: #20252E; --red-soft: #3A1714; --gold: #FDB022;
    --gold-soft: #33260B; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #FF7A33; --brand-hover: #FF9A5C; --on-brand: #1F0D02; --brand-dark: #FF9A5C; --brand-soft: #2A1A10; --brand-tint: #3D2414;
  --navy: #E6ECF5; --ink: #EEF0F3; --muted: #98A2B3; --line: #2E3440; --line-soft: #232831;
  --bg: #12151B; --surface: #1A1E26; --surface-2: #20252E; --red-soft: #3A1714; --gold: #FDB022;
  --gold-soft: #33260B; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang HK", "Microsoft JhengHei", "Noto Sans TC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); line-height: 1.3; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .4em 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }
.ic { flex: none; vertical-align: middle; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink); font-weight: 500;
}
.side-nav a:hover { background: var(--line-soft); text-decoration: none; }
.side-nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.side-user { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.side-user small { display: block; color: var(--muted); }
.content { flex: 1; min-width: 0; }
.main { max-width: 860px; margin: 0 auto; padding: 28px 24px 60px; }
.topbar, .tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; position: sticky; top: 0; z-index: 20; height: 54px; padding: 0 16px;
    padding-top: env(safe-area-inset-top); background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .main { padding: 14px 16px calc(84px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: var(--surface);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px;
    color: var(--muted); font-size: .72rem;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--brand-dark); }
  h1 { font-size: 1.3rem; }
}

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.page-head { margin-bottom: 16px; }
.page-head.row { display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.page-head p { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--line-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #B42318; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .88rem; border-radius: 9px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-weight: 600; font-size: .9rem; color: var(--navy); }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 16px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 12px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-error { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: 9px; font-size: .9rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; color: #fff; font-weight: 700; font-size: 1rem;
}
.avatar.sm { width: 30px; height: 30px; font-size: .8rem; }
.badge {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 99px; font-size: .74rem;
  font-weight: 600; background: var(--line-soft); color: var(--muted); vertical-align: middle; white-space: nowrap;
}
.badge-teacher { background: var(--brand-soft); color: var(--brand-dark); }
.badge-lock { background: var(--red-soft); color: var(--red); }
.badge-warn { background: var(--gold-soft); color: var(--gold); }
.badge-ok { background: #ECFDF3; color: #027A48; }
.tag { display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-dark); font-size: .78rem; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 14px; cursor: pointer;
  font-size: .88rem; font-weight: 500;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: var(--surface); }
.search { position: relative; flex: 1; min-width: 180px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; min-width: 140px; }
.filters .chips { width: 100%; }
.tabs { display: flex; gap: 4px; margin: 12px -4px -6px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs a:hover { background: var(--line-soft); text-decoration: none; }
.tabs a.on { background: var(--brand-soft); color: var(--brand-dark); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .ic { color: var(--line); }
.loading { color: var(--muted); padding: 16px; text-align: center; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 28px 24px; text-align: left; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 10px; }
.auth-card h1 { text-align: center; margin-bottom: 0; }
.auth-card > p.muted { text-align: center; margin: 2px 0 20px; }

/* ---------- composer & posts ---------- */
.composer-row { display: flex; gap: 12px; }
.composer textarea { border: 0; padding: 8px 0; min-height: 44px; box-shadow: none !important; resize: none; background: transparent; overflow-y: auto; scrollbar-width: thin; }
.composer-bar { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line-soft); margin-top: 8px; padding-top: 10px; }
.composer-bar select { width: auto; flex: 0 1 auto; min-width: 0; min-height: 34px; padding: 4px 10px; font-size: .88rem; text-overflow: ellipsis; }
.composer-bar .btn { flex: none; }
@media (max-width: 400px) { .composer-bar .btn-ghost span { display: none; } }
.att-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0 52px; }
.att-list:empty { display: none; }
.att-chip {
  display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border-radius: 9px; background: var(--surface-2);
  border: 1px solid var(--line); font-size: .85rem; max-width: 100%;
}
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.att-chip .att-prog { color: var(--muted); font-variant-numeric: tabular-nums; }
.att-chip.done .att-prog { color: var(--green); }
.att-chip.failed { border-color: var(--red); }
.att-chip.failed .att-prog { color: var(--red); }

.post { padding: 14px 16px 6px; }
.post-head { display: flex; gap: 10px; align-items: flex-start; }
.post-meta { flex: 1; min-width: 0; }
.post-meta a { color: var(--muted); }
.pin-tag { color: var(--brand-dark); display: inline-flex; align-items: center; gap: 2px; }
.post-body { margin: 10px 0 4px; white-space: pre-wrap; word-break: break-word; }
.img-grid { display: grid; gap: 4px; margin: 10px 0 4px; border-radius: 12px; overflow: hidden; }
.img-grid.n1 { grid-template-columns: 1fr; }
.img-grid.n2, .img-grid.n4 { grid-template-columns: 1fr 1fr; }
.img-grid.n3 { grid-template-columns: 1fr 1fr 1fr; }
.img-cell { border: 0; padding: 0; background: var(--line-soft); cursor: zoom-in; aspect-ratio: 4 / 3; overflow: hidden; }
.img-grid.n1 .img-cell { aspect-ratio: auto; max-height: 460px; }
.img-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-files { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; }
.file-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); background: var(--surface-2);
}
.file-chip:hover { border-color: var(--brand); text-decoration: none; }
.file-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-chip small { color: var(--muted); white-space: nowrap; }
.post-actions { display: flex; gap: 4px; border-top: 1px solid var(--line-soft); margin-top: 8px; padding-top: 4px; }
.act {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 9px; cursor: pointer; font-weight: 500;
}
.act:hover { background: var(--line-soft); }
.act.liked { color: var(--brand-dark); }
.act.liked .ic { fill: currentColor; }
.comments { border-top: 1px solid var(--line-soft); padding: 10px 0 8px; }
.comment { display: flex; gap: 8px; margin-bottom: 8px; }
.comment-bubble { background: var(--surface-2); border-radius: 12px; padding: 7px 12px; min-width: 0; flex: 1; }
.comment-body { white-space: pre-wrap; word-break: break-word; }
.comment-tools button { border: 0; background: none; color: var(--muted); font-size: .8rem; padding: 2px 6px 0 0; cursor: pointer; }
.comment-tools button:hover { color: var(--ink); }
.comment-form { display: flex; gap: 8px; align-items: center; }
.comment-form input { min-height: 36px; padding: 6px 12px; border-radius: 99px; }

/* ---------- classes ---------- */
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.class-card { display: flex; gap: 12px; align-items: center; color: var(--ink); margin: 0; }
.class-card:hover { border-color: var(--brand); text-decoration: none; }
.class-badge {
  flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem;
}
.class-badge.lg { width: 56px; height: 56px; font-size: 1.4rem; border-radius: 14px; }
.class-hero-top { display: flex; gap: 14px; align-items: center; }
.class-hero-top > div { flex: 1; min-width: 0; }
.class-hero h1 { margin: 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.member:last-child { border-bottom: 0; }
.member > div { flex: 1; min-width: 0; }

/* ---------- files ---------- */
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; gap: 14px; align-items: center; color: var(--ink); margin: 0; padding: 12px 14px; }
.file-row:hover { border-color: var(--brand); text-decoration: none; }
.file-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.file-icon img { width: 100%; height: 100%; object-fit: cover; }
.k-note { background: #EFF8FF; color: #175CD3; }
.k-image { background: #ECFDF3; color: #027A48; }
.k-video { background: var(--brand-soft); color: var(--brand-dark); }
.file-info { flex: 1; min-width: 0; }
.file-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 0; margin-bottom: 10px; font-weight: 500; }
.back:hover { color: var(--ink); }
.file-view h1 { margin-bottom: 4px; }
.file-desc { white-space: pre-wrap; }
.viewer { margin: 14px 0; }
.viewer-img { display: block; max-height: 75vh; margin: 0 auto; border-radius: 10px; }
.viewer-pdf { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.viewer-doc { text-align: center; padding: 30px; background: var(--surface-2); border-radius: 12px; color: var(--muted); }
.file-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- video ---------- */
.player { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; user-select: none; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.wm {
  position: absolute; z-index: 2; pointer-events: none; color: rgba(255, 255, 255, .42); font-size: clamp(11px, 1.8vw, 16px);
  font-weight: 700; text-shadow: 0 0 3px rgba(0, 0, 0, .55); white-space: nowrap; transition: left 1.2s, top 1.2s;
}
.player-cover {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #fff; text-align: center; padding: 20px;
  background: radial-gradient(circle at center, rgba(232, 89, 12, .35), rgba(11, 31, 58, .95));
}
.player-cover p { margin: 0; }
.cover-msg { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.play-big {
  width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--brand); color: var(--on-brand); cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding-left: 6px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.play-big:hover { transform: scale(1.05); }
.play-big .ic { fill: currentColor; }
.fs-btn { position: absolute; z-index: 4; top: 8px; right: 8px; background: rgba(0, 0, 0, .45); color: #fff; }
.fs-btn:hover { background: rgba(0, 0, 0, .7); color: #fff; }
.video-status { margin-top: 8px; }
.video-status b { color: var(--brand-dark); }

/* ---------- 學習資源分類 ---------- */
.crumbs { font-size: .88rem; margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--ink); word-break: break-all; }
.row-btns { display: flex; gap: 8px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.lib-card { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--ink); padding: 14px; }
.lib-card:hover { border-color: var(--brand); text-decoration: none; }
.lib-card > div { flex: 1; min-width: 0; }
.lib-card b { word-break: break-all; }
.lib-icon {
  flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem;
}
.lib-icon.school { background: var(--navy); color: var(--surface); }
.count-pill { flex: none; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-dark); }
.count-pill.zero { background: var(--line-soft); color: var(--muted); }

/* ---------- 內置 PDF 閱讀器 ---------- */
.pdfv { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.pdfv-bar { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.pdfv-bar .icon-btn { font-size: 1.2rem; font-weight: 700; }
.pdfv-zoom { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.pdfv-scroll { height: 75vh; overflow: auto; padding: 8px; -webkit-overflow-scrolling: touch; }
.pdfv-page { margin: 0 auto 8px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); width: fit-content; min-width: 100%; }
.pdfv-page canvas { display: block; margin: 0 auto; }
.pdfv-page { display: flex; align-items: center; justify-content: center; }
.pdfv-loading { color: #98A2B3; font-size: .85rem; }

/* ---------- 通知 ---------- */
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bell { position: relative; color: var(--ink); text-decoration: none !important; }
.bell.active { color: var(--brand-dark); background: var(--brand-soft); }
.bell-badge { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; font-size: .66rem; }
#notif-pop {
  position: fixed; z-index: 150; top: 12px; right: 12px; width: min(360px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
@media (max-width: 860px) { #notif-pop { top: calc(60px + env(safe-area-inset-top)); left: 12px; right: 12px; width: auto; } }
.notif-card {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(11, 31, 58, .18);
  animation: notifin .25s ease-out; color: var(--ink);
}
.notif-card:hover { border-color: var(--brand); text-decoration: none; }
.notif-more { justify-content: center; font-weight: 600; color: var(--brand-dark); }
@keyframes notifin { from { opacity: 0; transform: translateY(-8px); } }
.notif-ic { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; }
.notif-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }
.notif-txt span { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-row { display: flex; align-items: center; gap: 12px; color: var(--ink); margin-bottom: 8px; padding: 12px 14px; }
.notif-row:hover { border-color: var(--brand); text-decoration: none; }
.notif-row.unread { background: var(--brand-soft); border-color: var(--brand-tint); }
.unread-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row > span { display: flex; flex-direction: column; min-width: 0; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--line);
  position: relative; cursor: pointer; transition: background .2s;
}
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .2s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { left: 21px; }

/* ---------- 成績記錄 ---------- */
.exam-entry { margin-bottom: 14px; }
.exam-entry .ic:last-child { transform: rotate(180deg); color: var(--muted); }
.exam-list { display: flex; flex-direction: column; gap: 8px; }
.exam-card { display: flex; gap: 12px; align-items: center; color: var(--ink); margin: 0; }
.exam-card:hover { border-color: var(--brand); text-decoration: none; }
.exam-main { flex: 1; min-width: 0; }
.exam-title { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.exam-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.exam-score { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pct { margin-left: 6px; font-size: .78rem; padding: 1px 6px; border-radius: 6px; background: var(--line-soft); color: var(--muted); }
.pct.good { background: #ECFDF3; color: #027A48; }
.pct.low { background: var(--red-soft); color: var(--red); }
.exam-detail { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.exam-detail .stat { min-width: 140px; }
.exam-files { display: flex; flex-direction: column; gap: 6px; }
.exam-viewer { margin-top: 10px; }
.feedback-box { background: var(--brand-soft); border: 1px solid var(--brand-tint); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; }
.privacy-note { font-size: .82rem; color: var(--muted); background: var(--surface-2); border-radius: 9px; padding: 6px 10px; margin: 6px 0 12px; }
.chart-grid-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 12px; }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart { width: 100%; height: 90px; display: block; }
.chart .chart-line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; }
.chart .chart-dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.chart .chart-grid { stroke: var(--line); stroke-dasharray: 4 4; }

/* ---------- 錄音回覆 ---------- */
.voice-msg { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; color: var(--brand-dark); flex-wrap: wrap; }
.voice-msg audio { height: 36px; width: 240px; max-width: 100%; }
.mic-btn { flex: none; color: var(--brand-dark); }
.rec-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0; text-align: center; }
.rec-time { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }
.rec-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.rec-actions audio { width: 100%; }
.rec-actions .modal-actions { width: 100%; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: recblink 1s infinite; vertical-align: middle; }
@keyframes recblink { 50% { opacity: .2; } }

/* ---------- 問答區 ---------- */
.qa-title { display: flex; align-items: center; gap: 8px; }
.qa-ask { margin: 8px 0 14px; }
.qa-thread { border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 10px; }
.qa-replies { margin-left: 38px; }
.qa-reply { margin: 4px 0 6px 38px; }
.comment.is-teacher .comment-bubble { background: var(--brand-soft); border: 1px solid var(--brand-tint); }
.qa-empty { padding: 10px 0; }

/* ---------- 配套筆記 ---------- */
.companions { margin: 14px 0 4px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.companions h3 { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.comp-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.comp-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.comp-title { flex: 1; min-width: 120px; font-weight: 600; word-break: break-word; }
.comp-viewer { margin-top: 10px; }
.comp-viewer-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.comp-viewer .viewer-pdf { height: 70vh; }

/* ---------- 揀班（分享） ---------- */
.share-row { display: flex; align-items: center; gap: 10px; margin: -2px 0 12px; flex-wrap: wrap; }
.share-box { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .9rem; }
.share-box .btn { margin-left: auto; }
.picker-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.picker-filters select { width: auto; min-width: 130px; }
.pk-levels { margin-bottom: 8px; }
.chip-quick { border-style: dashed; }
.picker-list { max-height: 44vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 11px; }
.pk-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.pk-row:last-child { border-bottom: 0; }
.pk-row:hover { background: var(--line-soft); }
.pk-row input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.pk-name { flex: 1; min-width: 0; font-weight: 500; word-break: break-all; }
.pk-summary { margin: 10px 0 0; font-size: .95rem; }
.pk-summary b { color: var(--brand-dark); }

/* ---------- 未讀數字、新帖 ---------- */
.nav-badge, .count-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff;
  font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.side-nav a .nav-badge { margin-left: auto; }
.tabbar a { position: relative; }
.tabbar .nav-badge { position: absolute; top: 3px; left: calc(50% + 4px); min-width: 18px; height: 18px; font-size: .66rem; }
.class-card .count-badge { margin-left: auto; flex: none; }
.chat-card .class-badge { background: var(--navy); color: var(--surface); }
.post.is-new { animation: newpost 3s ease-out; }
@keyframes newpost {
  0% { box-shadow: 0 0 0 3px var(--brand-tint); background: var(--brand-soft); }
  100% { box-shadow: var(--shadow); background: var(--surface); }
}

/* ---------- 新培連結 ---------- */
.social-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.sidebar .social-row { justify-content: flex-start; padding: 0 12px; margin-top: 0; }
.social-dot {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.social-dot:hover { filter: brightness(1.1); text-decoration: none; transform: translateY(-1px); }
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.link-tile {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); background: var(--surface-2); font-weight: 500; font-size: .92rem;
}
.link-tile span { flex: 1; }
.link-tile .ic:last-child { color: var(--muted); }
.link-tile:hover { border-color: var(--brand); text-decoration: none; }
.contact-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 8px; }
.contact-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; color: var(--ink); }
.contact-item:hover { background: var(--line-soft); text-decoration: none; }
.contact-ic { flex: none; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.contact-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.contact-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 遊樂場 ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 12px; }
.game-card { padding: 0; overflow: hidden; color: var(--ink); margin: 0; display: flex; flex-direction: column; }
.game-card:hover { border-color: var(--brand); text-decoration: none; }
.game-banner {
  height: 120px; display: flex; align-items: center; justify-content: center; gap: 10px; color: #fff;
  font-weight: 800; font-size: 1.3rem; letter-spacing: .05em;
}
.game-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.game-body h2 { margin: 0; }
.game-go { align-self: flex-start; margin-top: 6px; }
.game-wrap { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #000; }
.game-bar {
  flex: none; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px;
  padding-top: env(safe-area-inset-top); background: var(--surface); border-bottom: 1px solid var(--line);
}
.game-frame { flex: 1; width: 100%; border: 0; background: #000; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; }
.table td.actions .btn { margin-left: 4px; }
.table.dim .col-allow { opacity: .35; pointer-events: none; }
.va-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.4rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.pw-box { font-family: ui-monospace, Consolas, monospace; font-size: 1.4rem; letter-spacing: .08em; background: var(--surface-2); padding: 10px 14px; border-radius: 10px; text-align: center; user-select: all; }

/* ---------- modal & toast ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(11, 31, 58, .5); display: flex; align-items: center;
  justify-content: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px);
  overflow: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal.wide { max-width: 900px; padding: 8px; background: transparent; box-shadow: none; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.sheet-list { display: flex; flex-direction: column; gap: 4px; }
.sheet-list button { justify-content: flex-start; border-color: transparent; }
.sheet-list button.danger { color: var(--red); }
@media (max-width: 560px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .modal.wide { border-radius: 0; }
}
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px; border: 2px dashed var(--line);
  border-radius: 12px; cursor: pointer; color: var(--muted); text-align: center; margin-bottom: 12px;
}
.drop:hover { border-color: var(--brand); color: var(--brand-dark); }
.drop input { max-width: 100%; font-size: .85rem; }
.progress { position: relative; height: 26px; background: var(--line-soft); border-radius: 8px; overflow: hidden; margin: 6px 0; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--brand); transition: width .2s; }
.progress .ptext { position: relative; display: block; text-align: center; font-size: .82rem; line-height: 26px; font-weight: 600; color: var(--ink); }

#toast {
  position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--navy); color: var(--surface); padding: 10px 18px; border-radius: 12px; font-weight: 500;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red); color: #fff; }
@media (max-width: 860px) { #toast { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ---------- 功課 ---------- */
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-info { background: var(--brand-soft); color: var(--brand-dark); }
.text-danger { color: var(--red); }
.text-brand { color: var(--brand-dark); }
.hw-sec { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; margin: 18px 0 8px; }
.hw-empty { margin: 0 0 8px 2px; }
.hw-card { margin-bottom: 8px; }
.hw-card .exam-main { min-width: 0; flex: 1; }
.hw-progress { flex: none; width: 128px; text-align: right; }
.hw-bar { height: 6px; border-radius: 99px; background: var(--line-soft); overflow: hidden; margin-bottom: 4px; }
.hw-bar span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.hw-due { margin: 10px 0; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: .9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hw-due.urgent { background: var(--red-soft); color: var(--red); }
.hw-due.past { color: var(--muted); }
.hw-instr { white-space: pre-wrap; margin: 10px 0; }
.hw-files { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
a.comp-item { color: var(--ink); }
a.comp-item:hover { border-color: var(--brand); text-decoration: none; }
.hw-classes .chips { margin: 4px 0 6px; }
.hw-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.hw-stats .stat b small { font-size: .9rem; color: var(--muted); }
.hw-filter { margin: 12px 0 8px; }
.hw-roster { display: flex; flex-direction: column; }
.hw-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
a.hw-row:hover { background: var(--surface-2); text-decoration: none; }
.hw-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hw-name small { font-size: .78rem; }
.hw-when { flex: none; }
.hw-score { flex: none; min-width: 2.2em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hw-mystatus { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.hw-mystatus h2 { margin: 0; }
.hw-mytext { margin: 8px 0; }
.hw-feedback { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.hw-feedback.returned { border-color: var(--red); background: var(--red-soft); }
.hw-feedback h3 { margin: 0 0 6px; font-size: 1rem; }
.hw-pick { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.hw-pick .btn { cursor: pointer; }
.hw-pending { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.hw-thumb { position: relative; width: 84px; height: 108px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.hw-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hw-thumb .hw-doc { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 4px; text-align: center; word-break: break-all; }
.hw-thumb .hw-doc small { font-size: .65rem; }
.hw-page { position: absolute; left: 4px; top: 4px; background: rgba(0, 0, 0, .6); color: #fff; font-size: .7rem; border-radius: 6px; padding: 0 5px; }
.hw-thumb .icon-btn { position: absolute; right: 2px; top: 2px; background: rgba(0, 0, 0, .55); color: #fff; width: 26px; height: 26px; }
.hw-nav { display: flex; align-items: center; gap: 10px; position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 5; padding: 10px 12px; }
#hw-form .field > .btn, #hw-form .field > .seg { align-self: flex-start; width: auto; }
#hw-form .hw-who-some .btn { width: auto; }
.hw-who { flex: 1; text-align: center; display: flex; flex-direction: column; min-width: 0; }
.hw-pages { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.hw-pageimg { margin: 0; }
.hw-pageimg img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.hw-pageimg figcaption { margin-top: 4px; }
.hw-pdf { min-height: 200px; }
.hw-voice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.hw-voice p { margin: 0; }
.hw-grade-actions { flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 4px 0 6px; }
.seg label { display: flex; align-items: center; gap: 6px; padding: 7px 12px; cursor: pointer; font-size: .9rem; }
.seg label + label { border-left: 1px solid var(--line); }
.seg label:has(input:checked) { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.hw-who-some { margin-top: 4px; }
.hw-picked { margin-bottom: 6px; }
@media (max-width: 560px) {
  .hw-progress { width: 96px; }
  .hw-when { display: none; }
}
@media (min-width: 861px) { .hw-nav { top: 12px; } }

/* ---------- 私人訊息 ---------- */
.brand-row .bell + .bell, .topbar .bell + .bell { margin-left: 2px; }
.dm-threads { padding: 4px 0; }
.dm-thread { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; color: var(--ink); border-bottom: 1px solid var(--line-soft); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font: inherit; cursor: pointer; }
.dm-thread:last-child { border-bottom: 0; }
.dm-thread:hover { background: var(--surface-2); text-decoration: none; }
.dm-thread.unread b { color: var(--brand-dark); }
.dm-t-main { flex: 1; min-width: 0; }
.dm-t-top, .dm-t-bottom { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.dm-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .9rem; }
.dm-thread.unread .dm-preview { color: var(--ink); font-weight: 600; }
.dm-contacts { margin-top: 10px; }
.dm-contact { color: var(--ink); }
.dm-contact:hover { background: var(--surface-2); text-decoration: none; }
.dm-wrap { display: flex; flex-direction: column; }
.dm-head { display: flex; align-items: center; gap: 10px; position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 5; padding: 10px 12px; }
.dm-head-main { flex: 1; min-width: 0; }
.dm-older { text-align: center; }
.dm-msgs { display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 12px; }
.dm-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; }
.dm-msg.mine { align-self: flex-end; align-items: flex-end; }
.dm-bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 9px 13px; max-width: 100%; }
.dm-msg.mine .dm-bubble { background: var(--brand-soft); border-color: var(--brand-tint); border-radius: 16px 16px 4px 16px; }
.dm-msg.recalled .dm-bubble { background: none; border-style: dashed; color: var(--muted); font-size: .85rem; }
.dm-text { white-space: pre-wrap; word-break: break-word; }
.dm-meta { font-size: .72rem; margin-top: 3px; }
.dm-who { margin-bottom: 2px; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
.dm-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.dm-img { padding: 0; border: 0; background: none; cursor: zoom-in; }
.dm-img img { max-width: 220px; max-height: 220px; border-radius: 10px; display: block; object-fit: cover; }
.dm-file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-size: .85rem; max-width: 100%; }
.dm-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-file small { color: var(--muted); flex: none; }
.dm-compose { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 5; padding: 8px 10px; margin-bottom: 8px; }
.dm-row { display: flex; align-items: flex-end; gap: 6px; }
.dm-row textarea { flex: 1; resize: none; min-height: 40px; max-height: 320px; padding: 9px 12px; border-radius: 12px; }
.dm-row label.icon-btn { cursor: pointer; }
.dm-pending { display: flex; flex-wrap: wrap; gap: 6px; }
.dm-pending:not(:empty) { margin-bottom: 6px; }
.dm-empty { padding: 30px 0; }
.dm-msgs.audit .dm-msg { max-width: 90%; }
.member .dm-btn { flex: none; }
@media (min-width: 861px) { .dm-compose { bottom: 12px; } .dm-head { top: 12px; } }
.brand-row { justify-content: flex-start; }
.brand-row .brand { margin-right: auto; min-width: 0; }

/* ---------- 數式（同北區學霸傳說 mathfmt.js 一樣） ---------- */
.mf-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .86em; line-height: 1.15; margin: 0 .1em; }
.mf-num { border-bottom: 1.5px solid currentColor; padding: 0 .2em .05em; }
.mf-den { padding: .05em .2em 0; }
.mf-sqrt { display: inline-block; position: relative; white-space: nowrap; line-height: 1; padding: calc(1.5px + .06em) .1em .14em .64em; }
.mf-rsign { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none;
  fill: none; stroke: currentColor; stroke-width: 1.5px; stroke-linecap: round; }
.mf-hasidx { margin-left: .12em; }
.mf-idx { position: absolute; left: 0; bottom: 48%; font-size: .55em; line-height: 1; }
.mf-ol { text-decoration: overline; }
.tq-q sup, .tq-q sub, .tq-text sup, .tq-text sub, .tr-exp-body sup, .tr-exp-body sub { font-size: .7em; line-height: 0; }

/* ---------- 訓練場 ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tr-resume { display: flex; align-items: center; gap: 12px; color: var(--ink); border-color: var(--brand); background: var(--brand-soft); }
.tr-resume > div { flex: 1; }
.tr-resume:hover { text-decoration: none; }
.tr-grades { display: flex; flex-wrap: wrap; gap: 6px; }
.tr-grades .chip { min-width: 58px; justify-content: center; }
.tr-seg { align-self: flex-start; }
.tr-paper { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin: 4px 0 12px; display: flex; flex-direction: column; gap: 3px; }
.tr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tr-list { display: flex; flex-direction: column; }
.tr-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.tr-row:hover { background: var(--surface-2); text-decoration: none; }
.tr-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tr-score { flex: none; text-align: right; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.tr-score.good b, .tr-big.good b { color: var(--green); }
.tr-score.mid b, .tr-big.mid b { color: var(--gold); }
.tr-score.low b, .tr-big.low b { color: var(--red); }
/* 作答中 */
.in-exam .tabbar { display: none; }
.in-exam .main { padding-bottom: 40px; }
.tx-bar { display: flex; align-items: center; gap: 12px; position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 6; padding: 10px 14px; margin-bottom: 0; }
.tx-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tx-timer { display: flex; align-items: center; gap: 6px; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }
.tx-timer.low { color: var(--red); }
.tx-progress { height: 4px; background: var(--line-soft); border-radius: 99px; margin: 8px 2px 12px; overflow: hidden; }
.tx-progress span { display: block; height: 100%; background: var(--brand); transition: width .2s; }
.tq-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tq-head .tq-flag, .tq-head .tr-meta { margin-left: auto; }
.tq-flag.on { color: var(--gold); background: var(--gold-soft); }
.tq-q { font-size: 1.08rem; line-height: 1.8; word-break: break-word; }
.tq-fig { display: flex; justify-content: center; margin: 10px 0; }
.tq-fig svg { max-width: 100%; height: auto; background: #fff; border-radius: 10px; padding: 6px; }
.tq-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.tq-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 1.02rem; text-align: left; cursor: pointer; min-height: 52px; line-height: 1.6; width: 100%; }
.tq-opt:hover { border-color: var(--brand); }
.tq-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.tq-letter { flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.tq-opt.on .tq-letter { background: var(--brand); color: var(--on-brand, #fff); border-color: var(--brand); }
.tq-text { flex: 1; min-width: 0; word-break: break-word; }
.tx-nav { display: flex; gap: 8px; justify-content: space-between; margin: 12px 0; }
.tx-nav .btn { flex: 1; justify-content: center; }
.tx-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: 10px; }
.tx-cell { height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; position: relative; }
.tx-cell.ans { background: var(--brand-soft); border-color: var(--brand-tint); }
.tx-cell.flag::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.tx-cell.cur { outline: 2px solid var(--brand); outline-offset: 1px; }
.tx-legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); vertical-align: -2px; margin: 0 2px 0 8px; }
.tx-legend .lg.ans { background: var(--brand-soft); border-color: var(--brand-tint); }
.tx-legend .lg.flag { background: var(--gold); border-color: var(--gold); }
/* 成績 */
.tr-result { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.tr-result h1 { margin-bottom: 4px; }
.tr-big { width: 128px; height: 128px; border-radius: 50%; border: 6px solid var(--line-soft); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; }
.tr-big b { font-size: 2rem; line-height: 1; }
.tr-big b small { font-size: 1rem; color: var(--muted); }
.tr-big span { font-weight: 700; color: var(--muted); }
.tr-topics { display: flex; flex-direction: column; gap: 8px; }
.tr-topic { display: grid; grid-template-columns: minmax(90px, 200px) 1fr 44px; gap: 10px; align-items: center; font-size: .9rem; }
.tr-tbar { height: 10px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.tr-tbar i { display: block; height: 100%; border-radius: 99px; }
.tr-tbar i.good { background: var(--green); }
.tr-tbar i.mid { background: #F79009; }
.tr-tbar i.low { background: var(--red); }
.tr-tval { text-align: right; font-variant-numeric: tabular-nums; }
.tr-filter { margin: 4px 0 12px; }
.tr-item.wrong { border-left: 4px solid var(--red); }
.tr-item.right { border-left: 4px solid var(--green); }
.tr-item.blank { border-left: 4px solid var(--line); }
.tr-mark { font-weight: 700; font-size: .85rem; }
.tr-mark.right { color: var(--green); }
.tr-mark.wrong { color: var(--red); }
.tr-mark.blank { color: var(--muted); }
.tr-stars { color: #F79009; letter-spacing: -1px; }
.tq-opts.review .tq-opt { cursor: default; }
.tq-opt.ans { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--surface)); }
.tq-opt.ans .tq-letter { background: var(--green); color: #fff; border-color: var(--green); }
.tq-opt.bad { border-color: var(--red); background: var(--red-soft); }
.tq-opt.bad .tq-letter { background: var(--red); color: #fff; border-color: var(--red); }
.tq-tag { flex: none; font-size: .75rem; font-weight: 700; }
.tr-exp { margin-top: 12px; }
.tr-exp summary { cursor: pointer; font-weight: 600; color: var(--brand-dark); }
.tr-exp-body { margin-top: 8px; background: var(--surface-2); border-radius: 10px; padding: 10px 14px; line-height: 1.9; }
@media (min-width: 861px) { .tx-bar { top: 12px; } }
@media (max-width: 560px) { .tr-big { width: 104px; height: 104px; } .tr-topic { grid-template-columns: 96px 1fr 40px; } }
.modal > p { white-space: pre-line; }
.tr-strands .tr-topic { font-weight: 600; }
.tr-cards .lib-card > svg:last-child { transform: rotate(180deg); }
.class-badge.lvl { width: auto; min-width: 40px; padding: 0 8px; font-size: .9rem; }

/* ---------- 首頁入口：訓練場、遊樂場 ---------- */
.quick-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.quick-tile { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 18px; color: #fff;
  overflow: hidden; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); transition: transform .15s, box-shadow .15s; min-height: 92px; }
.quick-tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, .18); }
.quick-tile.train { background: linear-gradient(135deg, #C94B09, #E8792A); }
.quick-tile.play { background: linear-gradient(135deg, #5B3CC4, #8B5CF6); }
.quick-tile::after { content: ""; position: absolute; right: -24px; top: -24px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.qt-icon { flex: none; width: 54px; height: 54px; border-radius: 16px; background: rgba(255, 255, 255, .2); display: flex; align-items: center; justify-content: center; }
.qt-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; position: relative; z-index: 1; }
.qt-text b { font-size: 1.25rem; letter-spacing: .02em; }
.qt-text small { font-size: .82rem; opacity: .92; line-height: 1.35; }
.qt-go { flex: none; transform: rotate(180deg); opacity: .85; position: relative; z-index: 1; }
@media (max-width: 560px) {
  .quick-tiles { gap: 10px; }
  .quick-tile { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; min-height: 0; }
  .qt-icon { width: 44px; height: 44px; border-radius: 13px; }
  .qt-go { position: absolute; right: 12px; top: 14px; }
  .qt-text b { font-size: 1.12rem; }
}
