/* =========================================================
 * AI Coding 入門教學 — 樣式表
 *   結構：tokens → reset → 版面 → 元件 → 響應式 → 列印 / a11y
 * ========================================================= */

/* ========== Tokens ========== */
:root {
  --bg: oklch(0.16 0.012 240);
  --bg-elev: oklch(0.20 0.014 240);
  --bg-elev-2: oklch(0.235 0.016 240);
  --bg-card: oklch(0.215 0.014 240);
  --line: oklch(0.32 0.018 240);
  --line-soft: oklch(0.26 0.014 240);

  --fg: oklch(0.95 0.008 90);
  --fg-mute: oklch(0.78 0.012 90);
  --fg-soft: oklch(0.62 0.014 90);
  --fg-faint: oklch(0.48 0.014 240);

  --teal: oklch(0.80 0.12 200);
  --teal-soft: oklch(0.80 0.12 200 / 0.16);
  --teal-line: oklch(0.80 0.12 200 / 0.42);

  --amber: oklch(0.78 0.14 60);
  --amber-soft: oklch(0.78 0.14 60 / 0.16);
  --amber-line: oklch(0.78 0.14 60 / 0.42);

  --rose: oklch(0.72 0.16 25);
  --rose-soft: oklch(0.72 0.16 25 / 0.16);

  --green: oklch(0.78 0.13 150);
  --green-soft: oklch(0.78 0.13 150 / 0.16);

  --serif: "Noto Serif TC", "Source Han Serif TC", Georgia, "Times New Roman", serif;
  --sans:  "Noto Sans TC",  "PingFang TC", "Helvetica Neue", system-ui, sans-serif;
  --mono:  "JetBrains Mono", "Fira Code", "Source Code Pro", ui-monospace, monospace;

  --measure: 70ch;
  --radius: 6px;
  --radius-lg: 12px;
}

/* ========== Reset ========== */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "palt";
}

/* 頁面背景的點狀網格 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(oklch(0.30 0.02 240) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--teal-soft); color: var(--fg); }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ========== Layout ========== */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 64px;
}

.toc {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 80px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--line-soft);
  font-size: 13px;
}
.toc-brand {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--fg);
  margin-bottom: 8px;
  padding-right: 24px;
}
.toc-brand .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--teal);
  margin-right: 8px;
  vertical-align: middle;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.toc-list a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--fg-soft);
  padding: 6px 0;
  border-left: 2px solid transparent;
  padding-left: 10px;
  margin-left: -10px;
  transition: color .15s, border-color .15s;
  line-height: 1.45;
}
.toc-list a:hover { color: var(--fg); text-decoration: none; }
.toc-list a.active { color: var(--teal); border-left-color: var(--teal); }
.toc-list .num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  flex: 0 0 auto;
}
.toc-list .hi {
  color: var(--teal);
  font-weight: 500;
}
.toc-list a.active .hi { color: var(--teal); }

.main {
  padding: 80px 0 160px;
  min-width: 0;
}

/* ========== Hero ========== */
.hero {
  margin-bottom: 96px;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--line-soft);
}
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--teal-line), transparent);
}

h1.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
  color: var(--fg);
  text-wrap: balance;
}
h1.title em {
  font-style: normal;
  color: var(--teal);
  font-family: var(--serif);
}

.lede {
  font-size: 19px;
  line-height: 1.75;
  color: var(--fg-mute);
  max-width: 62ch;
  margin: 0 0 32px;
  text-wrap: pretty;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 36px;
  font-size: 13px;
  color: var(--fg-soft);
  font-family: var(--mono);
  padding-top: 24px;
  border-top: 1px dashed var(--line-soft);
  margin: 0;
}
.meta dt { color: var(--fg-faint); margin-right: 8px; display: inline; }
.meta dd { margin: 0; display: inline; color: var(--fg-mute); }
.meta > div { display: flex; }

/* ========== Sections / 標題 ========== */
section.chunk { margin-bottom: 88px; scroll-margin-top: 32px; }

h2.h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: -0.005em;
  line-height: 1.3;
  margin: 0 0 8px;
  color: var(--fg);
  display: flex;
  align-items: baseline;
  gap: 16px;
}
h2.h2 .num {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--teal);
  font-weight: 400;
  letter-spacing: 0.1em;
}

.h2-sub {
  font-size: 14px;
  color: var(--fg-soft);
  font-family: var(--mono);
  margin: 0 0 32px;
  letter-spacing: 0.04em;
  padding-left: 64px;
}

h3.h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  margin: 40px 0 12px;
  color: var(--fg);
}

p { margin: 0 0 18px; max-width: 68ch; text-wrap: pretty; }
p strong { color: var(--fg); font-weight: 600; }
p code, li code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: oklch(0 0 0 / 0.3);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--fg);
}

/* ========== 術語 popover ========== */
.gloss {
  border-bottom: 1px dashed var(--teal);
  cursor: help;
  color: var(--fg);
  position: relative;
  transition: background .15s;
  padding: 0 2px;
}
.gloss:hover { background: var(--teal-soft); border-bottom-style: solid; }
.gloss::before {
  content: "";
  position: absolute;
  top: 0; right: -10px;
  font-size: 9px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--teal);
  opacity: 0.7;
}

.gloss-pop {
  position: fixed;
  z-index: 200;
  background: var(--bg-elev-2);
  border: 1px solid var(--teal-line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg-mute);
  width: 320px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 24px 60px oklch(0 0 0 / 0.5);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s;
}
.gloss-pop.show { opacity: 1; transform: translateY(0); }
.gloss-pop .term {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

/* ========== 註腳 ========== */
.fn {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--teal);
  vertical-align: super;
  text-decoration: none;
  margin-left: 1px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--teal-soft);
  transition: background .15s;
}
.fn:hover { background: var(--teal-line); text-decoration: none; }
.fn:empty::before { content: "[…]"; opacity: 0.6; }  /* JS 失敗時的後備 */

/* ========== 通用卡片 ========== */
.note {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin: 28px 0;
}
.note .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--teal);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
}

/* ========== 五個關鍵詞 ========== */
.keyterms {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin: 28px 0 8px;
}
.keyterm {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .2s, transform .2s;
}
.keyterm:hover { border-color: var(--teal-line); transform: translateY(-2px); }
.keyterm .kt-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  letter-spacing: 0.06em;
}
.keyterm .kt-name {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--fg);
  font-weight: 600;
}
.keyterm .kt-desc {
  font-size: 13px;
  color: var(--fg-mute);
  line-height: 1.55;
}

/* ========== 模式切換（網頁問答 vs CLI agent） ========== */
.mode-compare {
  margin: 32px 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  overflow: hidden;
}
.mc-tabs {
  display: flex;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-elev-2);
}
.mc-tab {
  flex: 1;
  padding: 18px 22px;
  border: none;
  background: transparent;
  color: var(--fg-soft);
  font-family: var(--sans);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  position: relative;
  border-right: 1px solid var(--line-soft);
  transition: background .15s, color .15s;
}
.mc-tab:last-child { border-right: 0; }
.mc-tab .mc-tab-name {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--fg);
  margin-bottom: 2px;
  font-weight: 600;
}
.mc-tab .mc-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--fg-faint);
  margin-right: 8px;
}
.mc-tab[data-mode="web"] .mc-dot { background: var(--amber); }
.mc-tab[data-mode="cli"] .mc-dot { background: var(--teal); }
.mc-tab.active { background: var(--bg-card); color: var(--fg); }
.mc-tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--fg);
}
.mc-tab[data-mode="web"].active::after { background: var(--amber); }
.mc-tab[data-mode="cli"].active::after { background: var(--teal); }

.mc-stage {
  padding: 28px;
  background: var(--bg-card);
  min-height: 360px;
}

/* 「網頁問答」聊天框 mock */
.mock-chat {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mock-chat .bubble {
  padding: 10px 14px;
  border-radius: 10px;
  max-width: 85%;
  line-height: 1.55;
}
.mock-chat .b-you {
  background: var(--bg-elev-2);
  align-self: flex-end;
  border-top-right-radius: 4px;
  color: var(--fg-mute);
}
.mock-chat .b-ai {
  background: var(--amber-soft);
  align-self: flex-start;
  border-top-left-radius: 4px;
  border-left: 2px solid var(--amber);
  color: var(--fg);
}
.mock-chat .b-ai code {
  font-family: var(--mono);
  font-size: 12px;
  background: oklch(0 0 0 / 0.3);
  padding: 1px 5px;
  border-radius: 3px;
}
.mock-chat .copy-hint {
  font-size: 11px;
  color: var(--fg-faint);
  font-family: var(--mono);
  text-align: center;
  padding: 6px 0;
  border-top: 1px dashed var(--line-soft);
  margin-top: 4px;
}

/* 終端機 mock */
.terminal {
  background: oklch(0.10 0.012 240);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-mute);
  overflow: hidden;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: oklch(0.14 0.012 240);
  border-bottom: 1px solid var(--line-soft);
}
.terminal-bar .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: oklch(0.30 0.012 240);
}
.terminal-bar .title {
  margin-left: 12px;
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.04em;
}
.terminal-body {
  padding: 16px 18px;
  min-height: 240px;
  white-space: pre-wrap;
  word-break: break-word;
}
.terminal-body .prompt { color: var(--teal); }
.terminal-body .you    { color: var(--fg); }
.terminal-body .ai     { color: var(--fg-mute); }
.terminal-body .ok     { color: var(--green); }
.terminal-body .warn   { color: var(--amber); }
.terminal-body .dim    { color: var(--fg-faint); }
.terminal-body .add {
  color: var(--green);
  background: var(--green-soft);
  display: inline-block;
  padding: 0 4px;
  border-radius: 2px;
}
.terminal-body .del {
  color: var(--rose);
  background: var(--rose-soft);
  display: inline-block;
  padding: 0 4px;
  border-radius: 2px;
  text-decoration: line-through;
  text-decoration-color: oklch(0.72 0.16 25 / 0.5);
}
.cursor {
  display: inline-block;
  width: 8px; height: 1em;
  background: var(--fg);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.mc-summary {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  font-size: 12px;
}
.mc-summary .stat {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.mc-summary .stat .label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}
.mc-summary .stat .val {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--fg);
  font-weight: 600;
}

/* ========== 比較表 ========== */
.cmp {
  margin: 32px 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elev);
}
.cmp-head {
  display: grid;
  grid-template-columns: 1.3fr 2fr 2fr;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--line-soft);
}
.cmp-head > div {
  padding: 18px 22px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  border-right: 1px solid var(--line-soft);
}
.cmp-head > div:last-child { border-right: 0; }
.cmp-head .col-aspect {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-faint);
  text-transform: uppercase;
  font-weight: 400;
}
.cmp-head .col-web .pip { background: var(--amber); }
.cmp-head .col-cli .pip { background: var(--teal); }
.pip {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: middle;
}
.cmp-row {
  display: grid;
  grid-template-columns: 1.3fr 2fr 2fr;
  border-bottom: 1px solid var(--line-soft);
}
.cmp-row:last-child { border-bottom: 0; }
.cmp-row > div {
  padding: 18px 22px;
  border-right: 1px solid var(--line-soft);
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg-mute);
}
.cmp-row > div:last-child { border-right: 0; }
.cmp-row .aspect {
  font-family: var(--serif);
  color: var(--fg);
  font-weight: 600;
  background: var(--bg-elev-2);
}

/* ========== Capability cards ========== */
.caps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin: 28px 0;
}
.cap {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cap.cap-wide { grid-column: span 2; }
.cap .cap-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  letter-spacing: 0.1em;
}
.cap h4 {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--fg);
  margin: 0;
  font-weight: 600;
}
.cap p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg-mute);
}
.cap .cap-ill {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-soft);
}

/* 權限三等級視覺化（取代原本的 inline styles） */
.perms {
  display: flex;
  gap: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--mono);
  font-size: 12px;
}
.perms .lvl {
  flex: 1;
  padding: 14px;
  border-right: 1px solid var(--line-soft);
}
.perms .lvl:last-child { border-right: 0; }
.perms .lvl-tag {
  font-size: 10px;
  letter-spacing: 0.1em;
  opacity: 0.85;
  margin-bottom: 6px;
}
.perms .lvl-name { color: var(--fg); }
.perms .lvl-desc {
  color: var(--fg-mute);
  font-family: var(--sans);
  margin-top: 4px;
}
.perms .lvl-1 { background: var(--green-soft); color: var(--green); }
.perms .lvl-2 { background: var(--teal-soft);  color: var(--teal); }
.perms .lvl-3 { background: var(--rose-soft);  color: var(--rose); }

/* ========== 工具比較（Codex / Claude Code） ========== */

/* 共通能力卡 — 放在兩欄之上，視覺上跟 .tool 同家族但用 teal 邊框暗示「共有」 */
.tools-common {
  background: var(--bg-elev);
  border: 1px solid var(--teal-line);
  border-radius: var(--radius-lg);
  padding: 22px 26px 24px;
  margin: 28px 0 0;
}
.tools-common .common-mark {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}
.tools-common h3 {
  font-family: var(--serif);
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--fg);
  font-weight: 600;
}
.tools-common .common-sub {
  font-size: 13px;
  color: var(--fg-soft);
  margin: 0 0 16px;
  max-width: none;
}
.common-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 28px;
  font-size: 14px;
}
.common-grid .item {
  position: relative;
  padding-left: 22px;
  color: var(--fg-mute);
  line-height: 1.65;
}
.common-grid .item::before {
  content: "✓";
  color: var(--green);
  font-family: var(--mono);
  font-weight: 600;
  position: absolute;
  left: 0;
  top: 0;
}
.common-grid .item code {
  font-family: var(--mono);
  font-size: 12px;
  background: oklch(0 0 0 / 0.3);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--fg);
}

/* 「主要差異」分隔標 */
.tools-diff-mark {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tools-diff-mark::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 28px 0;
}
.tools-diff-mark + .tools { margin-top: 0; }

/* ========== Use cases（依需求選工具） ========== */
.usecases-lede {
  font-size: 14.5px;
  color: var(--fg-mute);
  margin: 0 0 18px;
  line-height: 1.75;
  max-width: 70ch;
}
.tools-diff-mark + .usecases-lede { margin-top: 0; }

/* ---------- Use-case matrix（5-row 比較矩陣） ---------- */
.uc-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.06em;
}
.uc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.uc-legend-note { color: var(--fg-faint); margin-left: auto; }
.uc-bar {
  display: inline-block;
  width: 22px;
  height: 6px;
  border-radius: 2px;
}
.uc-bar-codex  { background: var(--teal); }
.uc-bar-claude { background: var(--amber); }

.uc-matrix {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  overflow: hidden;
}
.uc-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.5fr;
  gap: 28px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
  transition: background .2s;
}
.uc-row:last-child { border-bottom: 0; }
.uc-row:hover { background: oklch(from var(--bg-elev) calc(l + 0.012) c h); }
.uc-row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.uc-row[data-winner="claude"]::before { background: var(--amber); }
.uc-row[data-winner="codex"]::before  { background: var(--teal); }
.uc-row[data-winner="split"]::before  {
  background: linear-gradient(to bottom, var(--teal) 0 50%, var(--amber) 50% 100%);
}

.uc-col-task { display: flex; flex-direction: column; gap: 8px; }
.uc-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.16em;
}
.uc-task {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
  margin: 0;
}

.uc-col-verdict {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: center;
  min-width: 0;
}
.uc-vs {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.uc-side {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-mute);
  letter-spacing: 0.06em;
}
.uc-side-label { text-align: right; }
.uc-meter {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: oklch(0 0 0 / 0.35);
  overflow: hidden;
}
.uc-meter-fill {
  display: block;
  height: 100%;
  width: var(--w, 50%);
  border-radius: 3px;
}

.uc-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  white-space: nowrap;
  align-self: flex-start;
}
.uc-pip { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.uc-pick.claude { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.uc-pick.claude .uc-pip { background: var(--amber); }
.uc-pick.codex  { color: var(--teal);  border-color: var(--teal-line);  background: var(--teal-soft); }
.uc-pick.codex .uc-pip { background: var(--teal); }
.uc-pick.split {
  color: var(--fg);
  border-color: var(--line);
  background: var(--bg-elev-2);
}
.uc-pick.split .uc-pip {
  background: linear-gradient(to right, var(--teal) 0 50%, var(--amber) 50% 100%);
}

.uc-col-note { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.uc-col-note p {
  font-size: 14px;
  color: var(--fg-mute);
  line-height: 1.7;
  margin: 0;
  max-width: none;
}
.uc-col-note p strong { color: var(--fg); font-weight: 600; }
.uc-aside {
  font-size: 12.5px;
  color: var(--fg-faint);
  font-style: italic;
}
.uc-contrast {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.uc-contrast li {
  font-size: 13.5px;
  color: var(--fg-mute);
  line-height: 1.65;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
}
.uc-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
  font-weight: 600;
}
.uc-tag-codex  { color: var(--teal);  border-color: var(--teal-line);  background: var(--teal-soft); }
.uc-tag-claude { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }

/* ========== Pick table（簡短選擇表） ========== */
.pick-table {
  margin: 0 0 28px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elev);
}
.pt-row {
  display: grid;
  grid-template-columns: 2.4fr 1fr;
  border-bottom: 1px solid var(--line-soft);
}
.pt-row:last-child { border-bottom: 0; }
.pt-row > div {
  padding: 12px 18px;
  font-size: 14px;
  color: var(--fg-mute);
  line-height: 1.55;
  border-right: 1px solid var(--line-soft);
}
.pt-row > div:last-child { border-right: 0; }
.pt-row.pt-head { background: var(--bg-elev-2); }
.pt-row.pt-head > div {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.pt-pick {
  font-family: var(--serif);
  font-weight: 600;
}
.pt-pick.claude { color: var(--amber); }
.pt-pick.codex  { color: var(--teal); }
.pt-pick.both   { color: var(--fg); }
.tool {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
}
.tool .tool-mark {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.tool h3 {
  font-family: var(--serif);
  margin: 0 0 4px;
  font-size: 22px;
  color: var(--fg);
}
.tool .vendor {
  font-size: 13px;
  color: var(--fg-soft);
  margin-bottom: 18px;
}
.tool ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}
/* 注意：li 不可使用 display:flex，否則中英並列的 inline 子元素會被當成
   獨立 flex item 並被斷字（chat1 已修過此 bug）。改用絕對定位的箭頭。 */
.tool ul li {
  position: relative;
  padding-left: 22px;
  color: var(--fg-mute);
  line-height: 1.65;
}
.tool ul li::before {
  content: "→";
  color: var(--teal);
  font-family: var(--mono);
  position: absolute;
  left: 0;
  top: 0;
}
.tool ul li code {
  font-family: var(--mono);
  font-size: 12px;
  background: oklch(0 0 0 / 0.3);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--fg);
}

/* ---------- API 價格對照表 ---------- */
.price-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 14px;
}
.price-table th,
.price-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}
.price-table thead th {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  padding-top: 0;
}
.price-table thead th:nth-child(2) { color: var(--teal); }
.price-table thead th:nth-child(3) { color: var(--amber); }
.price-table tbody tr:last-child td { border-bottom: 0; }
.price-table .pt-key {
  color: var(--fg-mute);
}
.price-table .pt-key .pt-unit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  margin-left: 4px;
}
.price-table .pt-codex,
.price-table .pt-claude {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.price-table .pt-codex  { color: var(--teal); }
.price-table .pt-claude { color: var(--amber); }

.price-note {
  font-size: 13.5px;
  color: var(--fg-mute);
  line-height: 1.65;
  margin: 0 0 16px;
  padding: 10px 14px;
  background: oklch(0 0 0 / 0.25);
  border-left: 2px solid var(--teal);
  border-radius: 4px;
}

.price-fineprint {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}
.price-fineprint .fp-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  font-size: 12.5px;
  color: var(--fg-faint);
  line-height: 1.6;
  align-items: baseline;
}
.price-fineprint .fp-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--line-soft);
  color: var(--fg-mute);
  background: var(--bg-elev-2);
  white-space: nowrap;
  font-weight: 600;
}

/* ---------- 訂閱方案列表 ---------- */
.plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plan-list .plan {
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: oklch(0 0 0 / 0.2);
  position: relative;
  padding-left: 18px;
}
.plan-list .plan::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 2px;
}
.plan-list .plan-ok::before   { background: var(--teal); }
.plan-list .plan-warn::before { background: var(--amber); }
.plan-list .plan-good::before { background: var(--green); }

.plan-list .plan-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.plan-list .plan-name {
  font-weight: 600;
  color: var(--fg);
  font-size: 14.5px;
  line-height: 1.4;
}
.plan-list .plan-verdict {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.plan-list .plan-ok   .plan-verdict { color: var(--teal); }
.plan-list .plan-warn .plan-verdict { color: var(--amber); }
.plan-list .plan-good .plan-verdict { color: var(--green); }

.plan-list .plan p {
  font-size: 13.5px;
  color: var(--fg-mute);
  line-height: 1.65;
  margin: 0;
  max-width: none;
}

/* ========== 安全升級六步驟 ========== */
.steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 28px 0;
  position: relative;
}
.steps::before {
  content: "";
  position: absolute;
  left: 22px; top: 22px; bottom: 22px;
  width: 1px;
  background: var(--line);
}
.step {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 24px;
  padding: 22px 0;
  align-items: start;
}
.step .step-marker {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--teal-line);
  color: var(--teal);
  font-family: var(--mono);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.step .step-body { padding-top: 4px; }
.step h4 {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--fg);
  margin: 0 0 8px;
}
.step p {
  font-size: 14.5px;
  color: var(--fg-mute);
  margin: 0 0 12px;
  max-width: 60ch;
}

/* ========== Prompt cards ========== */
.prompt-card {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 0;
  margin: 18px 0;
  overflow: hidden;
}
.prompt-head {
  padding: 14px 18px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.prompt-head .pc-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.prompt-head .pc-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  background: var(--teal-soft);
  padding: 3px 8px;
  border-radius: 3px;
  letter-spacing: 0.08em;
}
.prompt-head .pc-title {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--fg);
  font-weight: 600;
}
.copy-btn {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: border-color .15s, color .15s, background .15s;
}
.copy-btn:hover  { color: var(--teal);  border-color: var(--teal-line);  background: var(--teal-soft); }
.copy-btn.copied { color: var(--green); border-color: var(--green);      background: var(--green-soft); }
.prompt-body {
  padding: 18px 22px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg);
  white-space: pre-wrap;
  background: var(--bg-card);
  margin: 0;
}
.prompt-body .pl { color: var(--fg-faint); }
.prompt-body .ph { color: var(--teal); }

.prompt-foot {
  font-size: 13px;
  color: var(--fg-soft);
  margin-top: 18px;
}

/* ========== Callouts ========== */
.callout {
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin: 24px 0;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  font-size: 14.5px;
  line-height: 1.65;
}
.callout.tip  { background: var(--teal-soft);  border: 1px solid var(--teal-line); }
.callout.warn { background: var(--amber-soft); border: 1px solid var(--amber-line); }
.callout .ico {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.callout.tip  .ico { background: var(--teal);  color: oklch(0.18 0.012 240); }
.callout.warn .ico { background: var(--amber); color: oklch(0.18 0.012 240); }
.callout .body { flex: 1; }
.callout .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
  color: var(--fg);
}

/* ========== TLDR ========== */
.tldr {
  background: linear-gradient(135deg, var(--teal-soft), transparent);
  border: 1px solid var(--teal-line);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  margin: 32px 0;
}
.tldr .label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: block;
}
.tldr p {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  color: var(--fg);
  margin: 0;
  max-width: none;
}

/* ========== References / 來源 ========== */
.refs {
  margin-top: 96px;
  padding-top: 32px;
  border-top: 1px solid var(--line-soft);
}
.refs h2 {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--fg);
  margin: 0 0 18px;
}
.refs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: ref;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 32px;
}
.refs ol li {
  counter-increment: ref;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--fg-soft);
  padding-left: 28px;
  position: relative;
  font-family: var(--mono);
}
.refs ol li::before {
  content: "[" counter(ref) "]";
  position: absolute;
  left: 0; top: 0;
  color: var(--teal);
  font-size: 11px;
}
.refs a { color: var(--fg-mute); word-break: break-all; }
.refs a:hover { color: var(--teal); }
.refs li .src-name {
  color: var(--fg);
  display: block;
  margin-bottom: 2px;
  font-family: var(--sans);
  font-size: 13px;
}

/* ========== Footer ========== */
.foot {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px dashed var(--line-soft);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.06em;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* ========== 響應式 ========== */
@media (max-width: 920px) {
  .keyterms { grid-template-columns: repeat(2, 1fr); }
  .refs ol  { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; gap: 0; padding: 0 20px; }
  .toc   { display: none; }
  .main  { padding: 40px 0 80px; }
  .h2-sub { padding-left: 0; }
  .keyterms { grid-template-columns: 1fr 1fr; }
  .caps, .tools { grid-template-columns: 1fr; }
  .cap.cap-wide { grid-column: span 1; }
  .common-grid { grid-template-columns: 1fr; }
  .cmp-head, .cmp-row { grid-template-columns: 1fr; }
  .cmp-row > div, .cmp-head > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .cmp-row > div:last-child, .cmp-head > div:last-child { border-bottom: 0; }
  .mc-summary { grid-template-columns: 1fr; }
  .mc-tab { padding: 14px 16px; }
  .perms  { flex-direction: column; }
  .perms .lvl { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .perms .lvl:last-child { border-bottom: 0; }
  .pt-row { grid-template-columns: 1fr; }
  .pt-row > div { border-right: 0; border-bottom: 1px dashed var(--line-soft); padding: 10px 16px; }
  .pt-row > div:last-child { border-bottom: 0; padding-top: 0; padding-bottom: 14px; }
  .pt-row.pt-head > div:last-child { display: none; }
}
@media (max-width: 860px) {
  .uc-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 20px 22px;
  }
  .uc-col-verdict { align-self: stretch; }
}
@media (max-width: 520px) {
  .keyterms { grid-template-columns: 1fr; }
  h2.h2 { font-size: 24px; gap: 10px; }
  .meta { gap: 12px 18px; }
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .keyterm:hover { transform: none; }
  .cursor { animation: none; opacity: 1; }
}

/* ========== Print ========== */
@media print {
  body::before { display: none; }
  body { background: white; color: black; font-size: 12pt; }
  .shell { display: block; max-width: none; padding: 0; }
  .toc, .copy-btn, .mode-compare .mc-tabs { display: none; }
  .mc-stage[style*="none"] { display: block !important; }   /* 兩種模式都印出 */
  .gloss { border-bottom-style: solid; color: black; }
  a { color: black; text-decoration: underline; }
  .fn { color: black; background: transparent; }
  section.chunk { page-break-inside: avoid; margin-bottom: 24px; }
  .terminal, .mock-chat { background: #f4f4f4; color: black; border-color: #ccc; }
  .callout { border-color: #999; background: #f4f4f4; }
}
