:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #16202c;
  --muted: #5a6575;
  --line: #e1e5eb;
  --soft: #eef1f5;
  --ip: #7048e8;
  --net: #0b8a7c;
  --net-soft: #e0f4f1;
  --bank: #2459d9;
  --bank-soft: #e8eefc;
  --warn: #b45309;
  --warn-soft: #fff1e0;
  --bad: #b3261e;
  --bad-soft: #fbe8e6;
  --side-w: 296px;
  --top-h: 56px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.7; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
}
/* 英文版用 Source Sans 3（與 Noto Sans TC 的英文字形同源，寬度一致），引號與撇號才不會變成全形 */
html[lang="en"] body { font-family: "Source Sans 3", "Noto Sans TC", "Segoe UI", system-ui, sans-serif; }
[hidden] { display: none !important; }
code { font-family: var(--mono); font-size: .9em; background: var(--soft); padding: 0 6px; border-radius: 5px; }
a { color: var(--net); }
mark { background: #fff1a8; color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- 頂列 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; flex: none; height: var(--top-h);
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--net); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.brand-mark circle { fill: #fff; stroke: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: 16px; font-weight: 900; }
.brand-text span { font-size: 11.5px; color: var(--muted); letter-spacing: .04em; }
.menu-btn { display: none; flex: none; width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--soft); cursor: pointer; place-items: center; }
.menu-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }

/* ---------- 版面 ---------- */
.layout { flex: 1; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 0; }
.content { min-width: 0; }
/* 主內容至少佔滿一屏，頁尾在下方，捲到底才看到 */
.main { padding: 18px 28px 20px; outline: none; min-width: 0; }
.main > * { max-width: 1180px; margin-left: auto; margin-right: auto; }

/* ---------- 側欄 ---------- */
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
/* 頂列的搜尋框 */
.search-wrap { margin-left: auto; width: min(440px, 50vw); display: flex; align-items: center; gap: 8px; }
.search { position: relative; flex: 1; min-width: 0; }
/* 語言切換：搜尋框右邊的小按鈕 */
.lang-switch {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  font-size: 13px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.lang-switch svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.lang-switch:hover { border-color: var(--net); color: var(--net); }
.search svg { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); padding: 7px 12px 7px 35px; outline: none;
}
.search input:focus { border-color: var(--net); background: #fff; }
.nav-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 8px 2px; font-size: 12px; color: var(--muted); }
.nav-legend span { display: inline-flex; align-items: center; gap: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 10px;
  background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left;
}
.nav-head:hover { background: var(--soft); }
.nav-icon { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--soft); display: grid; place-items: center; transition: background .2s; }
.nav-icon svg, .tile-icon svg, .crumb svg { fill: none; stroke: var(--net); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-cat.open .nav-icon, .nav-cat.cur .nav-icon { background: var(--net); }
.nav-cat.open .nav-icon svg, .nav-cat.cur .nav-icon svg { stroke: #fff; }
.nav-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; line-height: 1.4; }
.nav-count { flex: none; font-size: 12px; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 0 8px; line-height: 1.7; }
.chev { flex: none; width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.nav-cat.open .chev { transform: rotate(90deg); }
.nav-list { list-style: none; margin: 0 0 6px 23px; padding: 0 0 0 10px; border-left: 1.5px solid var(--line); display: none; }
.nav-cat.open .nav-list { display: block; }
.nav-list a { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.5; }
.nav-list a:hover { background: var(--soft); }
.nav-list a.on { background: var(--net-soft); color: var(--net); font-weight: 700; }
.dot { flex: none; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--net); }
.dot.dev, .dot.tbd { background: #c3cad4; }
.nav-empty { margin: 8px 12px; font-size: 14px; color: var(--muted); }
.scrim { position: fixed; inset: var(--top-h) 0 0 0; background: rgba(15, 23, 32, .42); z-index: 40; }

/* ---------- 狀態標籤 ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.sbadge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 10px; white-space: nowrap; line-height: 1.7; }
.sbadge.ok { background: var(--net-soft); color: var(--net); }
.sbadge.dev, .sbadge.tbd { background: var(--soft); color: var(--muted); }
.sbadge.spec { background: var(--bank-soft); color: var(--bank); }

/* ---------- 首頁 ---------- */
.home-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.eyebrow { font-size: 13.5px; font-weight: 700; letter-spacing: .08em; color: var(--net); }
.home h1 { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.25; margin: 8px 0 14px; font-weight: 900; }
.home-text > p { font-size: 16px; color: var(--muted); margin: 0; }
.concept { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px; }
.concept svg { display: block; width: 100%; height: auto; }
.concept figcaption { margin: 6px 8px 2px; font-size: 14px; color: var(--muted); text-align: center; }
.concept .flowdot { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 9; animation: flow 1.1s linear infinite; }

.tile-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--net-soft); display: grid; place-items: center; }
.tile-icon svg { width: 22px; height: 22px; }
.tile-icon.big { width: 56px; height: 56px; border-radius: 16px; background: var(--net); flex: none; }
.tile-icon.big svg { width: 30px; height: 30px; stroke: #fff; }
.tile-count { font-size: 12.5px; color: var(--net); font-weight: 700; }
/* 首頁 Landing Page：不顯示側欄與選單鈕，內容佔滿整寬 */
body.landing .side, body.landing .scrim, body.landing .menu-btn { display: none !important; }
body.landing .layout { grid-template-columns: minmax(0, 1fr); }
.cta { display: inline-flex; align-items: center; gap: 10px; margin-top: 26px; padding: 13px 28px; border-radius: 999px;
  background: var(--net); color: #fff; font-size: 17px; font-weight: 900; text-decoration: none; box-shadow: 0 10px 24px rgba(11, 138, 124, .28); transition: background .2s, transform .2s; }
.cta:hover { background: #087266; transform: translateY(-1px); }
.cta svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* 首頁只剩標語與概念動畫，桌面版垂直置中 */
.home { display: grid; align-content: center; }

/* ---------- 分類頁 ---------- */
.cat-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.cat-head h1 { font-size: clamp(24px, 3vw, 32px); margin: 0 0 2px; font-weight: 900; line-height: 1.3; }
.cat-head p { margin: 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 16px; color: var(--ink); text-decoration: none; transition: border-color .2s, transform .2s;
  animation: rise .35s ease-out both;
}
.card:hover { border-color: var(--net); transform: translateY(-2px); }
.card-name b { display: block; font-size: 16px; line-height: 1.4; }
.en { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 500; }
.card-name .en { display: block; line-height: 1.4; }
.card-desc { font-size: 14px; line-height: 1.55; flex: 1; }

/* ---------- API 頁 ---------- */
.api-view { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px 24px 12px; }
.api-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 20px; }
.api-title { min-width: 0; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--muted); text-decoration: none; }
.crumb svg { width: 16px; height: 16px; stroke: currentColor; }
.crumb:hover { color: var(--net); }
.api-head h1 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 900; margin: 2px 0 6px; line-height: 1.3; }
.api-head h1 .en { font-size: .52em; margin-left: 10px; }
.api-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 700; line-height: 1.5;
  border: 1.5px solid var(--ink); background: #fff; color: var(--ink); border-radius: 999px; padding: 5px 16px; cursor: pointer;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn.ghost { border-color: var(--line); }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lead { color: var(--muted); font-size: 15.5px; max-width: 920px; margin: 10px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 13.5px; color: var(--muted); margin: 0 0 12px; }
.sw { display: inline-block; vertical-align: -3px; margin-right: 8px; }
.sw-ip { width: 22px; height: 0; border-top: 3px dotted var(--ip); vertical-align: 4px; }
.sw-net { width: 22px; height: 0; border-top: 3px solid var(--net); vertical-align: 4px; }
.sw-bank { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--bank); background: rgba(36, 89, 217, .08); }
.sw-est { width: 16px; height: 16px; border-radius: 50%; border: 2px dashed var(--net); background: rgba(11, 138, 124, .3); }
.sw-warn { width: 16px; height: 16px; border-radius: 4px; background: var(--warn); }
.sw-teal { width: 16px; height: 16px; border-radius: 4px; background: var(--net); }
.sw-gray { width: 16px; height: 16px; border-radius: 4px; background: #b7bec9; }

.scene-tabs { display: none; }
.panels { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.panel { position: relative; display: flex; flex-direction: column; min-width: 0; }
/* 依序播放：還沒輪到的情境先隱藏內容 */
.panel .scene svg, .panel .result, .panel .panel-note { transition: opacity .3s; }
.panel.wait .scene svg, .panel.wait .result, .panel.wait .panel-note { opacity: 0; transition: none; }
.panel.wait .panel-title { opacity: .45; }
/* 情境之間的先後箭頭；「或」代表擇一 */
.panels.seq { column-gap: 30px; }
.panels.seq .panel[data-join]::before {
  position: absolute; left: -26px; top: 118px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 900; line-height: 1;
}
.panels.seq .panel[data-join="next"]::before { content: "→"; background: var(--ink); color: #fff; }
.panels.seq .panel[data-join="or"]::before { content: "或"; background: var(--soft); color: var(--muted); font-size: 11px; }
html[lang="en"] .panels.seq .panel[data-join="or"]::before { content: "or"; }
.panel-title { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 15.5px; margin-bottom: 8px; line-height: 1.4; }
.panel-title .k { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 13.5px; }
.scene { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.scene svg { display: block; width: 100%; height: auto; }

.resp-badge { font-weight: 900; font-size: 15px; padding: 1px 12px; border-radius: 999px; text-align: right; }
.resp-badge.ok { background: var(--net-soft); color: var(--net); }
.resp-badge.warn { background: var(--warn-soft); color: var(--warn); }
.resp-badge.bad { background: var(--bad-soft); color: var(--bad); }
.resp-badge.info { background: var(--bank-soft); color: var(--bank); }
/* 一列放「欄位名・意思・值」，放不下就自動換行；值太長時獨立一列 */
.field { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; padding: 4px 0; border-top: 1px dashed var(--line); }
.field .name { order: 1; flex: none; max-width: 100%; font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-word; }
.field .name.zh { font-family: inherit; font-size: 12.5px; }
.field .mean { order: 2; flex: 1 1 7.5em; font-size: 13px; line-height: 1.45; }
.field code { order: 3; margin-left: auto; font-size: 12.5px; }
.field code.long { order: 4; flex-basis: 100%; margin: 2px 0 0; white-space: normal; word-break: break-word; }
/* 情境下方的一行結果 */
/* 結果太長放不下時，結果標籤換到下一行靠右，左邊的說明文字不被壓縮 */
.result { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.result-icon { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; }
.result-icon svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.result.push .result-icon { background: var(--warn-soft); }
.result.push .result-icon svg { stroke: var(--warn); }
.result-label { flex: 1 0 auto; font-size: 13px; color: var(--muted); }
.result .resp-badge { margin-left: auto; max-width: 100%; }
html[lang="en"] .resp-badge { font-size: 14px; line-height: 1.5; }
/* 情境卡太窄時，三格一律把結果標籤放到第二行，避免有的換行有的沒換、三格高度不齊（34px＝圖示寬＋間距） */
.panel { container-type: inline-size; }
@container (max-width: 250px) { .result-label { flex: 1 0 calc(100% - 34px); } }
@container (max-width: 320px) { html[lang="en"] .result-label { flex: 1 0 calc(100% - 34px); } }
.panel-note { font-size: 13.5px; line-height: 1.6; color: var(--muted); margin: 8px 2px 0; }
/* 「API 規格」視窗裡的三個情境回覆內容 */
.modal-sub { font-size: 16px; font-weight: 900; margin: 20px 0 10px; }
.scene-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.sf { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; min-width: 0; }
.sf-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 14px; }
.sf-head .k { flex: none; width: 22px; height: 22px; border-radius: 7px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 900; }

/* 比較重點：上下排列；左欄標題寬度跟著最長的標題，最多 12 字寬 */
.compare { margin-top: 12px; background: var(--net-soft); border-radius: 14px; padding: 2px 16px; display: grid; grid-template-columns: fit-content(12em) minmax(0, 1fr); column-gap: 16px; font-size: 14.5px; line-height: 1.6; }
.compare p { display: contents; }
.compare b, .compare span { padding: 7px 0; }
.compare p + p b, .compare p + p span { border-top: 1px dashed rgba(11, 138, 124, .3); }
.compare b { color: var(--net); }

.brief { display: flex; gap: 16px; align-items: flex-start; background: var(--net-soft); border-radius: 16px; padding: 18px 20px; margin-top: 16px; }
.brief dl { margin: 0; flex: 1; min-width: 0; display: grid; gap: 8px; }
.brief dl > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); column-gap: 12px; }
.brief dt { font-size: 13px; font-weight: 700; color: var(--net); padding-top: 2px; }
.brief dd { margin: 0; font-size: 15px; line-height: 1.6; }
.brief dl > div:first-child dd { font-size: 17px; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; max-width: 48%; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 14.5px; line-height: 1.45; }
.pager a span { font-size: 12px; color: var(--muted); font-weight: 500; }
.pager a:hover { color: var(--net); }
.pager .prev span::before { content: "‹ "; }
.pager .next { align-items: flex-end; text-align: right; }
.pager .next span::after { content: " ›"; }

/* ---------- 彈出視窗 ---------- */
.modal {
  border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--ink);
  width: min(760px, calc(100vw - 32px)); max-width: none; max-height: min(86vh, 880px); max-height: min(86dvh, 880px);
  box-shadow: 0 24px 60px rgba(15, 23, 32, .25); overflow: hidden;
}
.modal.wide { width: min(1000px, calc(100vw - 32px)); }
.modal[open] { display: flex; flex-direction: column; animation: rise .25s ease-out both; }
.modal::backdrop { background: rgba(15, 23, 32, .45); }
.modal-box { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { flex: none; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px 24px; border-bottom: 1px solid var(--line); }
.modal-kicker { font-size: 13px; color: var(--muted); font-weight: 700; }
.modal-head h2 { margin: 0; font-size: 22px; font-weight: 900; line-height: 1.35; }
.modal-close { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--soft); display: grid; place-items: center; cursor: pointer; }
.modal-close:hover { background: var(--line); }
.modal-close svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.modal-body { padding: 18px 24px 24px; overflow-y: auto; min-height: 0; }
.modal-extra { margin: 16px 2px 0; font-size: 14.5px; font-weight: 700; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 14px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; counter-increment: s; }
.steps li::before { content: counter(s); grid-row: span 2; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--net); color: #fff; font-weight: 900; }
.steps b { font-size: 16px; line-height: 1.5; }
.steps span { font-size: 14.5px; color: var(--muted); }

.spec { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
/* 很長的欄位名稱（例如 config.subscriptionDetail.…）在手機上可以斷行，不被規格框裁掉 */
.spec code { overflow-wrap: anywhere; }
.spec-row { display: grid; grid-template-columns: 120px 1fr; border-bottom: 1px solid var(--line); }
.spec-row > div { padding: 9px 16px; font-size: 14.5px; min-width: 0; }
.spec-row .k { background: var(--soft); color: var(--muted); font-weight: 700; font-size: 13.5px; }
.spec table { width: 100%; border-collapse: collapse; font-size: 14px; }
.spec th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 700; background: var(--soft); padding: 8px 16px; }
.spec td { padding: 8px 16px; border-top: 1px solid var(--line); vertical-align: top; }
/* 欄位名稱通常不換行；一格列了好幾個欄位時才在欄位之間換行，表格不會撐出視窗 */
.spec td:first-child { font-family: var(--mono); font-size: 13px; min-width: 10em; max-width: 18em; overflow-wrap: anywhere; }
.spec-src { font-size: 13px; color: var(--muted); margin: 10px 2px 0; }

/* ---------- 30 秒動畫播放器 ---------- */
.film-screen { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #f4f5f7; }
.film-host { position: absolute; inset: 0; }
.film-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.film-play { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; cursor: pointer; }
.film-play svg { width: 16px; height: 16px; fill: currentColor; }
.film-track { position: relative; flex: 1; height: 22px; cursor: pointer; touch-action: none; outline: none; }
.film-track::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 8px; border-radius: 999px; background: var(--soft); }
.film-track:focus-visible::before { box-shadow: 0 0 0 2px var(--net); }
.film-fill { position: absolute; left: 0; top: 7px; height: 8px; width: 0; border-radius: 999px; background: var(--net); }
.film-mark { position: absolute; top: 7px; width: 2px; height: 8px; background: #fff; }
.film-time { font-family: var(--mono); font-size: 13px; color: var(--muted); min-width: 92px; text-align: right; }
.film-chapters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.film-chapters button { font: inherit; font-size: 13px; border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 2px 12px; cursor: pointer; }
.film-chapters button.on { border-color: var(--net); color: var(--net); background: var(--net-soft); font-weight: 700; }

/* ---------- 情境動畫（共用） ---------- */
.draw { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.pop { transform-box: fill-box; transform-origin: center; }
.panel.play .fx-f1 { animation: fade .5s .1s both; }
.panel.play .fx-f2 { animation: fade .5s .7s both; }
.panel.play .fx-f3 { animation: fade .5s 1.2s both; }
.panel.play .fx-f4 { animation: fade .5s 1.6s both; }
.panel.play .fx-f5 { animation: fade .5s 2.0s both; }
.panel.play .fx-d1 { animation: draw .6s .2s ease-out both; }
.panel.play .fx-d2 { animation: draw .6s .7s ease-out both; }
.panel.play .fx-d3 { animation: draw .6s 1.3s ease-out both; }
.panel.play .fx-d4 { animation: draw .6s 1.8s ease-out both; }
.panel.play .fx-p1 { animation: pop .45s .8s both; }
.panel.play .fx-p2 { animation: pop .45s 1.1s both; }
.panel.play .fx-p3 { animation: pop .45s 1.4s both; }
.panel.play .fx-p4 { animation: pop .45s 1.8s both; }
.panel.play .fx-hit { animation: hit .6s 1.4s both; }
.panel.play .fx-m1 { animation: move .9s .3s ease-in-out both; }
.panel.play .fx-m2 { animation: move .9s .9s ease-in-out both; }
.panel.play .result { animation: rise .5s 2s both; }
.loopflow { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 2 9; animation: flow 1s linear infinite; }

/* ---------- 漫遊情境 ---------- */
.tower .mast, .tower .arc { fill: none; stroke: #a9b1bd; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tower circle { fill: #a9b1bd; }
.tower .arc { opacity: .5; }
.tower.on .mast, .tower.on .arc { stroke: var(--net); }
.tower.on circle { fill: var(--net); }
.tower.on .arc { opacity: 1; }
.link { stroke: var(--net); }
.trunk { stroke: #2fb5a5; }
.flow { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 1.5 7; animation: flow 1s linear infinite; }
.ipline { fill: none; stroke: var(--ip); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 2 5; }
.tunnel { fill: none; stroke: rgba(112, 72, 232, .22); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 1; }
.ring { fill: none; stroke: var(--net); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
.node rect { fill: #123f3b; stroke: #2fb5a5; stroke-width: 1.5; }
.node text { fill: #bff3ea; font-size: 11.5px; font-weight: 700; }
.panel.play .ring { animation: ping 1.1s .1s ease-out 2; }
.panel.play .ipgrp { animation: fade .5s .1s both; }
.panel.play .tunnel { animation: draw .8s .2s ease-out both; }
.panel.play .link { animation: draw .6s .5s ease-out both; }
.panel.play .trunk { animation: draw .8s 1.1s ease-out both; }
.panel.play .flow { animation: flow 1s linear infinite, fade .3s 1.9s both; }
.panel.play .node rect { animation: glow 1s 1.7s both; }

@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes flow { to { stroke-dashoffset: -22; } }
@keyframes ping { from { opacity: .9; transform: scale(.5); } to { opacity: 0; transform: scale(1.6); } }
@keyframes pop { from { opacity: 0; transform: scale(.3); } 70% { opacity: 1; transform: scale(1.12); } to { opacity: 1; transform: none; } }
@keyframes hit { from { stroke-opacity: 0; } to { stroke-opacity: 1; } }
@keyframes move { from { transform: translate(var(--dx, 0px), var(--dy, 0px)); } to { transform: none; } }
@keyframes glow { 0%, 100% { stroke: #2fb5a5; stroke-width: 1.5; } 50% { stroke: #8ff5e6; stroke-width: 3.5; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 桌面：側欄與主畫面各自捲動，整頁不捲 ---------- */
@media (min-width: 1000px) {
  /* 整頁捲動：側欄停留在畫面上，主內容至少佔滿一屏，全寬頁尾在最下方 */
  .side { position: sticky; top: var(--top-h); align-self: start; height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); overflow-y: auto; }
  .main { min-height: calc(100vh - var(--top-h)); min-height: calc(100dvh - var(--top-h)); }
  .home { min-height: calc(100vh - var(--top-h) - 38px); min-height: calc(100dvh - var(--top-h) - 38px); }
  /* 頂列分兩欄對齊下方版面：左欄等於側欄寬；搜尋框固定寬度，右緣和內容卡片切齊 */
  .topbar { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); padding: 0; gap: 0; }
  .topbar .brand { padding-left: 18px; }
  .search-wrap { width: auto; margin: 0; padding: 0 28px; }
  .search { flex: 0 1 360px; margin-left: auto; }
  .lang-switch { margin-right: max(0px, calc((100% - 1180px) / 2)); }
}

/* ---------- 平板與手機：側欄改成抽屜 ---------- */
@media (max-width: 999px) {
  .menu-btn { display: grid; }
  .layout { display: block; }
  /* 抽屜從頂列下方展開，頂列的搜尋框保持可見 */
  .side {
    position: fixed; top: var(--top-h); bottom: 0; left: 0; z-index: 50; width: min(320px, 86vw);
    overflow-y: auto; transform: translateX(-102%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(15, 23, 32, .18);
  }
  .side.open { transform: none; }
  .main { padding: 20px 20px 28px; }
  .home-hero { grid-template-columns: 1fr; }
  .concept { max-width: 520px; }
}
@media (max-width: 759px) {
  .main { padding: 14px 12px 24px; }
  .api-view { padding: 16px 14px 12px; border-radius: 18px; }
  .api-head { align-items: flex-start; }
  .btn { padding: 4px 13px; font-size: 13.5px; }
  .scene-tabs { display: flex; gap: 6px; margin: 4px 0 10px; }
  .scene-tabs button {
    flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; line-height: 1.35;
    color: var(--muted); background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 8px; cursor: pointer; text-align: left;
  }
  .scene-tabs button span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .btn .t { display: none; }
  .btn:has(.t) { padding: 4px 9px; }
  .scene-tabs button b { flex: none; width: 20px; height: 20px; border-radius: 6px; background: var(--soft); color: var(--ink); display: grid; place-items: center; font-size: 12px; }
  .scene-tabs button[aria-selected="true"] { border-color: var(--ink); color: var(--ink); }
  .scene-tabs button[aria-selected="true"] b { background: var(--ink); color: #fff; }
  .panels { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .panels::-webkit-scrollbar { display: none; }
  .panel { flex: 0 0 100%; scroll-snap-align: start; }
  .panels.seq .panel[data-join]::before { display: none; }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .compare span { padding-top: 0; }
  .compare p + p span { border-top: 0; }
  .modal { width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 90vh; max-height: 90dvh; }
  .modal.wide { width: 100vw; }
  .modal-body { padding: 16px 16px 24px; }
  .spec-row { grid-template-columns: 1fr; }
  .spec-row .k { padding-bottom: 4px; }
  /* 規格表在手機上改成一欄一張小卡：欄位名、意思、範例由上而下 */
  .spec table, .spec thead, .spec tbody, .spec tr, .spec td { display: block; }
  .spec thead tr { padding: 6px 14px; background: var(--soft); border-top: 0; }
  .spec th { display: none; padding: 0; background: none; }
  .spec th:first-child { display: block; }
  .spec tr { padding: 8px 14px; border-top: 1px solid var(--line); }
  .spec td { padding: 0; border: 0; }
  .spec td:first-child { white-space: normal; word-break: break-word; font-weight: 700; color: var(--ink); }
  .spec td:nth-child(3) { margin-top: 2px; color: var(--muted); font-size: 13px; }
  .spec td:nth-child(3)::before { content: "範例："; }
  html[lang="en"] .spec td:nth-child(3)::before { content: "Example: "; }
  .topbar .brand-text { display: none; }
  .search-wrap { width: auto; flex: 1; min-width: 0; margin-left: 2px; gap: 6px; }
  .lang-switch { padding: 0 9px; }
  .lang-switch svg { display: none; }
  .search input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

/* ---------- GSMA 應用情境 ---------- */
.uc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: -2px 0 12px; }
.uc-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-right: 2px; }
/* 英文的 GSMA 情境名稱較長：標籤維持一行，放不下以「…」結尾（完整名稱在彈出視窗） */
.uc-chip { font: inherit; font-size: 13px; line-height: 1.5; border: 1px solid #cfd8e6; background: var(--bank-soft); color: var(--bank); border-radius: 999px; padding: 2px 12px; cursor: pointer; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-chip:hover { border-color: var(--bank); }
.uc-chip.case { background: #fff; color: var(--muted); }
.brief + .uc-row { margin: 14px 0 0; }
.uc-list { display: grid; gap: 12px; }
.uc-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.uc-card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 900; line-height: 1.4; }
.uc-card h3 .en { display: block; font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted); }
.uc-card p { margin: 8px 0 0; font-size: 14.5px; line-height: 1.65; }
.uc-card p b { display: block; font-size: 12.5px; color: var(--muted); }
.uc-card .uc-apis { font-size: 13px; color: var(--muted); }
.uc-card a { display: inline-block; margin-top: 8px; font-size: 13.5px; font-weight: 700; }
.case-list { margin: 0; padding-left: 20px; columns: 2; column-gap: 24px; font-size: 14px; line-height: 1.9; }
@media (max-width: 759px) { .case-list { columns: 1; } }

/* ---------- 頁尾 ---------- */
.site-foot { flex: none; background: #0f2f2c; color: #a9cfc8; padding: 40px 28px 0; }
.foot-inner { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(0, .8fr) minmax(0, 1.3fr); gap: 32px; }
.foot-brand .brand { color: #fff; }
.foot-brand .brand-mark { background: #2fb5a5; }
.foot-brand .brand-text span { color: #8fd9cf; }
.foot-brand p { margin: 14px 0 0; font-size: 14px; line-height: 1.7; max-width: 30em; }
.foot-col h4 { margin: 2px 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .08em; color: #fff; }
.foot-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.foot-col ul.two { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.foot-col a { color: #cfe8e3; text-decoration: none; font-size: 14px; line-height: 1.5; }
.foot-col a:hover { color: #fff; text-decoration: underline; }
.foot-bottom { max-width: 1180px; margin: 32px auto 0; padding: 16px 0 22px; border-top: 1px solid rgba(255, 255, 255, .14);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; font-size: 12.5px; color: #8fb8b1; }
@media (max-width: 1199px) {
  .foot-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 手機版頁尾精簡：只留網站名稱、一列連結與底部聲明 */
@media (max-width: 759px) {
  .site-foot { padding: 22px 16px 0; }
  .foot-inner { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .foot-brand p, .foot-cats, .foot-src, .foot-col h4 { display: none; }
  .foot-brand .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
  .foot-brand .brand-mark svg { width: 18px; height: 18px; }
  .foot-info ul { display: flex; flex-wrap: wrap; gap: 6px 20px; }
  .foot-bottom { flex-direction: column; margin-top: 14px; padding: 12px 0 16px; font-size: 12px; }
}

/* ---------- 關於網站、使用條款 ---------- */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 26px 30px; }
/* 卡片與其他頁同寬，內文維持適合閱讀的行寬 */
.doc > * { max-width: 860px; }
.doc h1 { font-size: clamp(24px, 3vw, 30px); font-weight: 900; margin: 0 0 14px; line-height: 1.3; }
.doc h2 { font-size: 18px; font-weight: 900; margin: 24px 0 8px; }
.doc p, .doc li { font-size: 15.5px; line-height: 1.75; }
.doc p { margin: 0 0 8px; }
.doc ul { margin: 0; padding-left: 22px; }
.notice { border-left: 5px solid var(--warn); background: var(--warn-soft); border-radius: 12px; padding: 14px 18px; margin: 4px 0 8px; }
.notice b { display: block; font-size: 17px; color: var(--warn); margin-bottom: 4px; }
.notice p { margin: 0; }
.notice strong { color: var(--ink); }
.doc-dl { margin: 0; display: grid; gap: 10px; }
.doc-dl > div { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); column-gap: 14px; align-items: baseline; }
.doc-dl dd { margin: 0; font-size: 15px; line-height: 1.7; }
.terms { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 10px; }
.terms b { display: block; font-size: 15.5px; }
.terms span { color: var(--muted); }
@media (max-width: 759px) {
  .doc { padding: 20px 16px; border-radius: 18px; }
  .doc-dl > div { grid-template-columns: minmax(0, 1fr); }
}
