:root {
  --brand: #21a4b1;
  --brand-dark: #007481;
  --brand-soft: #d6eef1;
  --action: #e77e47;
  --action-soft: #fce6d5;
  --yellow: #f6b85a;
  --ink: #2b2a2f;
  --text: #3a3a3a;
  --muted: #8a8378;
  --paper: rgba(253, 250, 244, 0.9);
  --paper-solid: #fdfaf4;
  --line: rgba(60, 50, 40, 0.1);
  --shadow: 0 10px 30px rgba(60, 45, 30, 0.14), 0 2px 6px rgba(60, 45, 30, 0.08);
  --r: 18px;
  --font: "Noto Sans TC", -apple-system, "PingFang TC", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe6ea; color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; z-index: 0; isolation: isolate; }
#stage canvas { display: block; outline: none; }
#labels { position: absolute; inset: 0; pointer-events: none; }

/* ── 浮動面板共用 ── */
.brand, .stats, .toolbar, .side, .card, .dock .seg, .mascot, .tour-caption {
  background: var(--paper);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  border-radius: var(--r);
}

.brand { position: absolute; top: 16px; left: 16px; display: flex; align-items: center; gap: 12px; padding: 12px 18px 12px 14px; z-index: 5; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: 0.04em; color: var(--ink); line-height: 1.15; }
.brand-sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.brand-logo { display: block; width: 46px; height: 46px; border-radius: 11px; box-shadow: 0 2px 8px rgba(0, 74, 82, 0.18); transition: transform 0.15s; flex: none; }
.brand-logo:hover { transform: translateY(-1px) scale(1.04); }
.brand-logo img { display: block; width: 100%; height: 100%; border-radius: 11px; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #2f9e7e; margin-right: 5px; box-shadow: 0 0 0 0 rgba(47, 158, 126, 0.6); animation: ping 2s infinite; vertical-align: 1px; }
.live-dot.off { background: var(--muted); animation: none; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(47, 158, 126, 0.55); } 70% { box-shadow: 0 0 0 7px rgba(47, 158, 126, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 158, 126, 0); } }

.stats { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 6px; z-index: 5; }
.stat { padding: 6px 14px; border-radius: 12px; text-align: center; min-width: 76px; }
.stat b { display: block; font-size: 18px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.stat.event { background: var(--action-soft); text-align: left; max-width: 260px; cursor: pointer; }
.stat.event b { font-size: 13px; line-height: 1.35; color: #a14d22; }

.toolbar { position: absolute; top: 16px; right: 16px; display: flex; gap: 4px; padding: 6px; z-index: 6; }
.toolbar button { padding: 8px 12px; border-radius: 12px; font-size: 13px; font-weight: 500; }
.toolbar button:hover { background: rgba(0, 0, 0, 0.05); }
.toolbar button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ── 右側索引／日誌 ── */
.side { position: absolute; top: 80px; right: 16px; bottom: 96px; width: 340px; display: flex; flex-direction: column; overflow: hidden; z-index: 4; transition: transform 0.35s ease, opacity 0.35s; }
.side.hide { transform: translateX(380px); opacity: 0; pointer-events: none; }
.side-tabs { display: flex; padding: 6px; gap: 4px; border-bottom: 1px solid var(--line); }
.side-tabs button { flex: 1; padding: 9px; border-radius: 12px; font-size: 14px; font-weight: 700; color: var(--muted); }
.side-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--action); color: #fff; font-size: 11px; line-height: 18px; }
.side-body { flex: 1; overflow-y: auto; padding: 10px 12px 16px; scrollbar-width: thin; }
.sec-title { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); margin: 10px 4px 8px; text-transform: uppercase; }
.course { display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: 14px; background: #fff; margin-bottom: 8px; border: 1px solid var(--line); transition: transform 0.15s, box-shadow 0.15s; }
.course:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); }
.course-top { display: flex; align-items: center; gap: 8px; }
.course-top b { font-size: 15px; color: var(--ink); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill.live { background: #dff3ea; color: #23775f; }
.pill.soft { background: var(--brand-soft); color: var(--brand-dark); }
.pill.warm { background: var(--action-soft); color: #a14d22; }
.course-meta { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.course-meta strong { color: var(--ink); font-size: 15px; font-weight: 900; margin-right: 3px; font-variant-numeric: tabular-nums; }
.cluster { margin-bottom: 6px; }
.cluster-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 6px; border-radius: 10px; font-weight: 700; color: var(--ink); font-size: 14px; }
.cluster-head:hover { background: rgba(0, 0, 0, 0.04); }
.swatch { width: 12px; height: 13px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); flex: none; }
.cluster-head .sum { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }
.tile-row { display: grid; grid-template-columns: 1fr 70px 34px; align-items: center; gap: 8px; width: 100%; padding: 6px 6px 6px 26px; border-radius: 10px; font-size: 13px; text-align: left; }
.tile-row:hover, .tile-row.sel { background: rgba(33, 164, 177, 0.1); }
.heat { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.06); overflow: hidden; }
.heat i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--yellow), var(--action)); }
.tile-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.tile-row .n.hot { color: var(--action); font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.chips button { padding: 5px 11px; border-radius: 999px; font-size: 12px; background: rgba(0, 0, 0, 0.05); }
.chips button.on { background: var(--ink); color: #fff; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 42px 26px 1fr; gap: 6px; align-items: start; padding: 8px 6px; border-radius: 10px; font-size: 13px; line-height: 1.5; cursor: pointer; }
.feed li:hover { background: rgba(0, 0, 0, 0.04); }
.feed li.new { animation: flash 2.4s ease; }
@keyframes flash { 0% { background: var(--action-soft); } 100% { background: transparent; } }
.feed .hm { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.feed .ic { font-size: 16px; line-height: 1.2; }
.feed .day { grid-column: 1 / -1; font-size: 11px; color: var(--muted); letter-spacing: 0.1em; padding: 8px 6px 2px; cursor: default; }
.feed .day:hover { background: none; }

/* ── 選取卡片 ── */
.card { position: absolute; left: 16px; top: 96px; width: 360px; max-height: calc(100% - 200px); overflow-y: auto; padding: 18px 18px 16px; z-index: 6; animation: rise 0.3s ease; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.card-close { position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border-radius: 50%; font-size: 20px; color: var(--muted); }
.card-close:hover { background: rgba(0, 0, 0, 0.06); }
.card .eyebrow { font-size: 11px; letter-spacing: 0.14em; font-weight: 700; }
.card h2 { margin: 4px 0 2px; font-size: 22px; font-weight: 900; color: var(--ink); }
.card .sub { font-size: 13px; color: var(--muted); }
.card p.desc { font-size: 14px; line-height: 1.7; margin: 10px 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.kpi b { display: block; font-size: 19px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi span { font-size: 11px; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 38px; margin: 6px 0 2px; }
.spark i { flex: 1; background: var(--brand); opacity: 0.75; border-radius: 2px 2px 0 0; min-height: 2px; }
.spark-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.card h3 { font-size: 13px; margin: 14px 0 6px; color: var(--ink); }
.card ul.mini { list-style: none; padding: 0; margin: 0; font-size: 13px; line-height: 1.6; }
.card ul.mini li { display: flex; gap: 8px; padding: 3px 0; }
.card ul.mini li .t { color: var(--muted); font-size: 12px; min-width: 38px; font-variant-numeric: tabular-nums; }
.teams { display: grid; gap: 6px; }
.team { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.team i { width: 12px; height: 12px; border-radius: 4px; }
.bar { height: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.06); grid-column: 2 / 4; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }
.chan { display: flex; flex-wrap: wrap; gap: 4px; }
.chan span { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.05); }
.note { font-size: 11px; color: var(--muted); margin-top: 12px; line-height: 1.5; }

/* ── 下方時間與圖層 ── */
.dock { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 8px; z-index: 5; flex-wrap: wrap; max-width: calc(100% - 420px); }
.seg { display: flex; padding: 5px; gap: 2px; }
.seg button { padding: 7px 11px; border-radius: 11px; font-size: 13px; white-space: nowrap; }
.seg button:hover { background: rgba(0, 0, 0, 0.05); }
.seg button.on { background: var(--ink); color: #fff; }
#clock { font-variant-numeric: tabular-nums; opacity: 0.8; }

.mascot { position: absolute; right: 16px; bottom: 16px; width: 340px; display: flex; gap: 10px; align-items: center; padding: 10px 14px; z-index: 5; }
.mascot-face { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 14px; flex: none; }
.mascot-text { font-size: 13px; line-height: 1.5; min-height: 38px; }
.mascot-text b { display: block; font-size: 11px; color: var(--brand-dark); letter-spacing: 0.08em; }

/* ── 3D 名牌 ── */
.tl { pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 7px; border-radius: 999px; background: rgba(255, 252, 246, 0.94); box-shadow: 0 3px 10px rgba(40, 30, 20, 0.18); font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; transform: translateY(-4px); transition: opacity 0.25s, transform 0.2s; }
.tl:hover, .tl.sel { transform: translateY(-7px) scale(1.06); }
.tl .dot { width: 8px; height: 9px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.tl .n { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.06); color: var(--muted); font-variant-numeric: tabular-nums; }
.tl .n.hot { background: var(--action); color: #fff; }
.tl.live::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #2f9e7e; animation: ping 2s infinite; }
.tl.hidden, .cl.hidden, .hl.hidden, .ev.hidden { opacity: 0; pointer-events: none; }
.cl { pointer-events: auto; cursor: pointer; text-align: center; transition: opacity 0.3s; }
.cl .plate { display: inline-block; padding: 7px 16px 6px; border-radius: 12px; color: #fff; font-weight: 900; font-size: 17px; letter-spacing: 0.08em; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); }
.cl .en { display: block; font-size: 9px; letter-spacing: 0.2em; opacity: 0.85; font-weight: 700; margin-top: 1px; }
.cl .course-tag { display: inline-block; margin-top: 5px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 252, 246, 0.95); color: var(--ink); font-size: 11px; font-weight: 700; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15); }
.cl .course-tag::before { content: "●"; color: #2f9e7e; margin-right: 4px; font-size: 9px; vertical-align: 1px; }
.hl { font-size: 11px; font-weight: 700; color: #5b4a38; background: rgba(255, 248, 236, 0.85); padding: 2px 8px; border-radius: 999px; white-space: nowrap; transition: opacity 0.3s; }
.ev { transition: opacity 0.3s; pointer-events: auto; cursor: pointer; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 10px; white-space: nowrap; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25); }
.ev small { display: block; font-size: 10px; font-weight: 500; opacity: 0.8; }

/* ── 導覽與晨報 ── */
.toasts { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 8; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); animation: rise 0.3s ease; }
.tour-caption { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); padding: 16px 20px; z-index: 9; }
.tour-step { font-size: 11px; letter-spacing: 0.14em; color: var(--action); font-weight: 700; }
.tour-caption p { margin: 6px 0 12px; font-size: 15px; line-height: 1.7; color: var(--ink); }
.tour-ctl { display: flex; gap: 8px; justify-content: flex-end; }
.tour-ctl button, .intro-actions button { padding: 8px 14px; border-radius: 12px; font-size: 13px; background: rgba(0, 0, 0, 0.06); }
.tour-ctl button.primary, .intro-actions button.primary { background: var(--ink); color: #fff; }
.intro { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(30, 40, 50, 0.28); z-index: 20; backdrop-filter: blur(3px); }
.intro-box { width: min(520px, calc(100% - 32px)); background: var(--paper-solid); border-radius: 22px; padding: 26px 26px 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); animation: rise 0.4s ease; }
.intro .eyebrow { font-size: 11px; letter-spacing: 0.18em; color: var(--action); font-weight: 700; }
.intro h2 { margin: 4px 0 12px; font-size: 26px; font-weight: 900; color: var(--ink); }
.report { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.report div { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.report b { display: block; font-size: 22px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.report span { font-size: 12px; color: var(--muted); }
.highlights { list-style: none; padding: 0; margin: 0 0 16px; font-size: 14px; line-height: 1.6; }
.highlights li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.highlights li:last-child { border-bottom: 0; }
.intro-actions { display: flex; gap: 8px; justify-content: flex-end; }

.loading { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: linear-gradient(#e9f4f3, #f6efe3); z-index: 30; transition: opacity 0.6s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading h2 { margin: 18px 0 4px; font-size: 24px; font-weight: 900; color: var(--ink); letter-spacing: 0.06em; }
.loading p { margin: 0; color: var(--muted); font-size: 14px; }
.loading-hex { position: relative; width: 120px; height: 100px; margin: 0 auto; }
.loading-hex i { position: absolute; width: 36px; height: 40px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); animation: pop 1.6s infinite ease-in-out; }
.loading-hex i:nth-child(1) { left: 42px; top: 30px; background: var(--action); }
.loading-hex i:nth-child(2) { left: 80px; top: 30px; background: var(--brand); animation-delay: 0.1s; }
.loading-hex i:nth-child(3) { left: 61px; top: 0; background: var(--yellow); animation-delay: 0.2s; }
.loading-hex i:nth-child(4) { left: 23px; top: 0; background: #8e6cf0; animation-delay: 0.3s; }
.loading-hex i:nth-child(5) { left: 4px; top: 30px; background: #5b8def; animation-delay: 0.4s; }
.loading-hex i:nth-child(6) { left: 23px; top: 60px; background: #d9608a; animation-delay: 0.5s; }
.loading-hex i:nth-child(7) { left: 61px; top: 60px; background: #4fb38f; animation-delay: 0.6s; }
@keyframes pop { 0%, 100% { transform: scale(0.85); opacity: 0.7; } 50% { transform: scale(1); opacity: 1; } }

@media (max-width: 900px) {
  .stats { display: none; }
  .brand { padding: 9px 12px; }
  .brand h1 { font-size: 18px; }
  .side { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 52%; }
  .side.hide { transform: translateY(110%); }
  .card { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 55%; }
  .dock { left: 8px; bottom: 8px; max-width: calc(100% - 16px); }
  .dock .seg:last-child { display: none; }
  .mascot { display: none; }
  .toolbar { top: auto; bottom: 64px; right: 8px; }
  .cl .plate { font-size: 13px; padding: 5px 10px 4px; }
  .cl .en, .hl { display: none; }
  .cl .course-tag { font-size: 10px; }
  .tl { font-size: 11px; }
}
