/* 樣式跟課程教學網（course_web：Fumadocs notebook 版面、neutral 色、Geist＋Noto Sans TC）。 */
:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --radius: 0.625rem;
  --surface-subtle: oklch(0.985 0 0);
  --surface: oklch(0.97 0 0);
  --surface-strong: oklch(0.945 0 0);
  --surface-hover: oklch(0.925 0 0);
  --info: oklch(0.62 0.19 259);
  --success: oklch(0.62 0.15 150);
  --warning: oklch(0.72 0.16 65);
  --header-h: 101px;
  --font-sans: "Geist", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --surface-subtle: oklch(0.18 0 0);
  --surface: oklch(0.205 0 0);
  --surface-strong: oklch(0.235 0 0);
  --surface-hover: oklch(0.269 0 0);
  --info: oklch(0.7 0.15 255);
  --success: oklch(0.72 0.14 150);
  --warning: oklch(0.8 0.14 70);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ico { flex: none; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 頂部 */
.banner {
  background: var(--surface);
  color: var(--muted-foreground);
  font-size: 12px;
  padding: 7px 16px;
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 20px; font-weight: 500; white-space: nowrap; }
.brand .tag {
  font-size: 11px; font-weight: 500; line-height: 18px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--muted-foreground);
}
.header-center { flex: 1; display: flex; justify-content: center; padding: 0 8px; position: relative; }
.pill {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 384px; height: 36px;
  padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: transparent;
  color: var(--muted-foreground); font-size: 14px; cursor: pointer; text-align: left;
}
.pill:hover { background: var(--accent); }
.pill .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill b { color: var(--foreground); font-weight: 500; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 8px; border: 0; background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.icon-btn:hover { background: var(--accent); color: var(--foreground); }
.menu-btn { display: none; margin-left: -6px; }
.theme-switch { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; }
.theme-switch button {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--foreground); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.tabs { display: flex; align-items: stretch; gap: 24px; height: 44px; padding: 0 24px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; flex: none; font-size: 14px; font-weight: 500;
  color: var(--muted-foreground); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--foreground); }
.tab[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab .soon { font-size: 11px; color: var(--muted-foreground); font-weight: 400; }

/* 彈出選單 */
.popover {
  position: absolute; top: 44px; z-index: 50; min-width: 260px; padding: 6px;
  background: var(--background); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.12);
}
.popover .item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; text-align: left; cursor: pointer; font-size: 14px;
}
.popover .item:hover { background: var(--accent); }
.popover .item small { display: block; color: var(--muted-foreground); font-size: 12px; }
.popover .sep { height: 1px; background: var(--border); margin: 6px 0; }
.popover .meta { padding: 8px 10px; font-size: 13px; color: var(--muted-foreground); }
.popover .meta b { color: var(--foreground); font-weight: 600; }

/* ---------------------------------------------------------------- 版面 */
.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 240px;
  max-width: 1400px;
  margin: 0 auto;
}
.sidebar {
  position: sticky; top: var(--header-h); align-self: start;
  height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 16px 12px 40px;
}
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; background: transparent;
  font-size: 14px; font-weight: 500; color: var(--foreground); text-align: left; cursor: default;
}
.nav-items { display: flex; flex-direction: column; gap: 1px; margin-left: 15px; padding-left: 8px; border-left: 1px solid var(--border); }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted-foreground); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.nav-item:hover { background: var(--accent); color: var(--foreground); }
.nav-item.active { background: color-mix(in oklab, var(--primary) 9%, transparent); color: var(--primary); font-weight: 500; }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--border); flex: none; }
.nav-item .dot.on { background: var(--success); }
.nav-sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; }
.nav-empty { padding: 6px 8px; font-size: 13px; color: var(--muted-foreground); }
.side-action { width: calc(100% - 16px); margin: 0 8px 12px; }

.main { min-width: 0; padding: 24px 32px 120px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 8px; }
.page-title { font-size: 30px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }
.page-desc { font-size: 16px; color: var(--muted-foreground); margin: 0 0 24px; max-width: 46em; }
.content h2 { font-size: 22px; line-height: 1.35; font-weight: 600; margin: 44px 0 12px; scroll-margin-top: calc(var(--header-h) + 16px); }
.content h2:first-child { margin-top: 8px; }
.content h3 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; scroll-margin-top: calc(var(--header-h) + 16px); }
.content p { margin: 0 0 12px; line-height: 1.75; }
.muted { color: var(--muted-foreground); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.pre { white-space: pre-wrap; }
mark { background: color-mix(in oklab, var(--warning) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

.toc { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 24px 16px 40px; font-size: 13px; }
.toc-title { display: flex; align-items: center; gap: 8px; color: var(--muted-foreground); margin-bottom: 10px; }
.toc a {
  display: block; padding: 5px 0 5px 12px; border-left: 1px solid var(--border); color: var(--muted-foreground);
  text-decoration: none; line-height: 1.45;
}
.toc a:hover { color: var(--foreground); }
.toc a.active { border-left: 2px solid var(--primary); padding-left: 11px; color: var(--foreground); font-weight: 600; }

/* ---------------------------------------------------------------- 內容元件（跟課程網：用底色分層，唔用陰影） */
.callout {
  --c: var(--info);
  display: flex; gap: 10px; padding: 16px; margin: 16px 0; border-radius: 12px;
  background: color-mix(in oklab, var(--c) 10%, var(--surface));
}
.callout > .ico { color: var(--c); margin-top: 3px; }
.callout .t { display: block; font-weight: 600; margin-bottom: 2px; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn { --c: var(--warning); }
.callout.error { --c: var(--destructive); }
.callout.ok { --c: var(--success); }
.callout.plain { --c: var(--muted-foreground); }

.card { background: var(--surface); border-radius: 12px; padding: 18px; min-width: 0; }
.card + .card { margin-top: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin: 12px 0; }
.cards > .card + .card { margin-top: 0; }
.cards.two { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card h3, .card h4 { margin: 0 0 6px; font-size: 15px; font-weight: 600; line-height: 1.45; }
.card .row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.card .kv { margin: 6px 0 0; font-size: 14px; line-height: 1.65; }
.card .kv b { font-weight: 500; color: var(--muted-foreground); margin-right: 6px; }
.card.pick { cursor: pointer; outline: 2px solid transparent; transition: background 0.15s; }
.card.pick:hover { background: var(--surface-strong); }
.card.pick.on { outline-color: var(--primary); background: var(--surface-strong); }
.card.soft { background: var(--surface-subtle); border: 1px solid var(--border); }
.card.off { opacity: 0.6; }

.quote {
  margin: 8px 0; padding: 10px 14px; border-radius: 10px; background: var(--surface-strong);
  font-size: 14px; line-height: 1.65;
}
.quote.big { font-size: 17px; font-weight: 500; }
.src-line { font-size: 12px; color: var(--muted-foreground); margin-top: 4px; line-height: 1.55; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--surface-strong); color: var(--foreground); white-space: nowrap;
}
.badge.pass { background: color-mix(in oklab, var(--success) 16%, var(--surface)); color: color-mix(in oklab, var(--success) 70%, var(--foreground)); }
.badge.weak { background: color-mix(in oklab, var(--warning) 20%, var(--surface)); color: color-mix(in oklab, var(--warning) 55%, var(--foreground)); }
.badge.fail { background: color-mix(in oklab, var(--destructive) 14%, var(--surface)); color: var(--destructive); }
.badge.ask { background: color-mix(in oklab, var(--info) 14%, var(--surface)); color: color-mix(in oklab, var(--info) 75%, var(--foreground)); }
.badge.outline { background: transparent; border: 1px solid var(--border); color: var(--muted-foreground); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }

details.acc { background: var(--surface); border-radius: var(--radius); margin: 8px 0; }
details.acc > summary {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 500; border-radius: var(--radius);
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary:hover { background: var(--surface-strong); }
details.acc > summary .chev { transition: transform 0.15s; color: var(--muted-foreground); }
details.acc[open] > summary .chev { transform: rotate(90deg); }
details.acc[open] > summary { background: var(--surface-strong); border-radius: var(--radius) var(--radius) 0 0; }
details.acc > .acc-body { padding: 12px 14px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--surface); margin: 12px 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.55; }
table.t thead { background: var(--surface-strong); }
table.t th { font-weight: 500; text-align: left; color: var(--muted-foreground); white-space: nowrap; }
table.t th, table.t td { padding: 9px 16px; vertical-align: top; }
table.t tbody tr:nth-child(even) { background: var(--surface-subtle); }
table.t td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

dl.kvs { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 6px 14px; margin: 6px 0; font-size: 14px; }
dl.kvs dt { color: var(--muted-foreground); }
dl.kvs dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
ul.plain { margin: 6px 0; padding-left: 20px; }
ul.plain li { margin: 3px 0; }

/* ---------------------------------------------------------------- 表單同掣 */
.field { margin: 0 0 18px; }
.field > label, .field-label { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.field-label .n {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--surface-strong); font-size: 12px; font-weight: 600;
}
.field-label .req { font-size: 12px; color: var(--destructive); font-weight: 500; }
.field-label .src { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted-foreground); white-space: nowrap; }
.field .help { font-size: 13px; color: var(--muted-foreground); margin: -2px 0 6px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--input); border-radius: 8px; background: var(--background);
  padding: 8px 12px; font-size: 14px; line-height: 1.6; transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 76px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 28%, transparent); }
.input.flash, .textarea.flash { animation: flash 1.4s ease; }
@keyframes flash { 0% { background: color-mix(in oklab, var(--success) 22%, var(--background)); } 100% { background: var(--background); } }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sub-grid .field { margin: 0; }
.sub-grid label { font-size: 13px; font-weight: 400; color: var(--muted-foreground); display: block; margin-bottom: 4px; }
.group-box { background: var(--surface); border-radius: 12px; padding: 14px; }
.counter { font-size: 12px; color: var(--muted-foreground); text-align: right; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 8px; background: var(--primary); color: var(--primary-foreground);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { opacity: 0.9; }
.btn.secondary { background: var(--secondary); color: var(--foreground); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-strong); opacity: 1; }
.btn.ghost { background: transparent; color: var(--foreground); }
.btn.ghost:hover { background: var(--accent); opacity: 1; }
.btn.danger { background: transparent; color: var(--destructive); border-color: var(--border); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }

.step-box { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 16px 0; }
.step-box .head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.step-box .head .txt { flex: 1; min-width: 240px; }
.step-box .head h3 { margin: 0 0 2px; font-size: 15px; }
.step-box .head p { margin: 0; font-size: 13px; color: var(--muted-foreground); line-height: 1.6; }
.step-box .why { font-size: 13px; color: var(--muted-foreground); margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.step-box .result:not(:empty) { margin-top: 14px; }
.progress { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted-foreground); padding: 12px 0; }
.run-meta { font-size: 12px; color: var(--muted-foreground); margin-top: 10px; }

.status-strip { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--surface); font-size: 14px; margin-bottom: 8px; }
.status-strip .k { color: var(--muted-foreground); margin-right: 4px; }
.save-state { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-foreground); }

.step-list .srow { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 14px; border-radius: 10px; }
.step-list .srow:nth-child(odd) { background: var(--surface-subtle); }
.step-list .srow .id { font-family: var(--font-mono); font-size: 12px; color: var(--muted-foreground); padding-top: 3px; }
.step-list .srow .nm { font-weight: 500; }
.step-list .srow .q { font-size: 13px; color: var(--muted-foreground); }
.step-list .srow .acts { display: flex; align-items: center; gap: 6px; }

.seg { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.seg:first-child { border-top: 0; }
.seg .when { font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 7px; height: 7px; border-radius: 999px; background: var(--border); }
.dots i.on { background: var(--foreground); }
.frames { display: flex; gap: 8px; flex-wrap: wrap; }
.frames figure { margin: 0; font-size: 12px; color: var(--muted-foreground); text-align: center; }
.frames img { display: block; height: 150px; border-radius: 8px; background: var(--surface); }

.score-big { font-size: 44px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-strong); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--foreground); border-radius: 999px; }

/* ---------------------------------------------------------------- 登入 */
.auth-wrap { min-height: calc(100vh - 34px); display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); }
.auth-card .brand { justify-content: center; margin-bottom: 18px; }
.auth-card .card { padding: 24px; }
.auth-card h1 { font-size: 24px; margin: 0 0 4px; font-weight: 600; }

/* ---------------------------------------------------------------- 右下角浮動掣 */
.float-pill {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--primary); color: var(--primary-foreground);
  font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgb(0 0 0 / 0.16); cursor: pointer;
}
.toast-box { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; padding: 10px 16px; border-radius: 10px; background: var(--primary); color: var(--primary-foreground); font-size: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
.toast.error { background: var(--destructive); color: #fff; }
.toast-act { margin-left: 12px; border: 0; background: transparent; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ---------------------------------------------------------------- 同 AI 諗定位（樣跟課程網「問功課」） */
.chat-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 440px; height: min(720px, calc(100dvh - 40px));
  display: flex; flex-direction: column; background: var(--background); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 24px 60px rgb(0 0 0 / 0.18); overflow: hidden;
}
.chat-head { display: flex; align-items: center; gap: 4px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.chat-head .ttl { flex: 1; min-width: 0; }
.chat-head .ttl b { display: block; font-size: 14px; font-weight: 600; }
.chat-head .ttl small { display: block; font-size: 12px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.65; }
.msg { max-width: 92%; border-radius: 16px; padding: 8px 12px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 85%; background: var(--primary); color: var(--primary-foreground); white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: var(--secondary); }
.msg.ai p { margin: 0 0 6px; }
.msg.ai p:last-child { margin-bottom: 0; }
.msg.ai p.li { display: flex; gap: 8px; }
.msg.ai p.li > span:first-child { flex: none; color: var(--muted-foreground); }
.msg.ai.muted { display: inline-flex; align-items: center; gap: 4px; color: var(--muted-foreground); }
.msg-meta { font-size: 11px; color: var(--muted-foreground); margin: -4px 0 0 4px; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--background); color: var(--foreground); border-radius: 999px; padding: 5px 12px; font-size: 13px; line-height: 1.4; cursor: pointer; text-align: left; }
.chip:hover { background: var(--accent); }
.chip.skip { color: var(--muted-foreground); }
.opt-card { align-self: stretch; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--background); }
.opt-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.opt-own { font-size: 12px; line-height: 1.55; color: var(--muted-foreground); margin: 2px 0 4px; }
.opt-own summary { cursor: pointer; }
.opt-row { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.opt-head + .opt-row, .opt-own + .opt-row { border-top: 0; }
.opt-text { flex: 1; min-width: 0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.opt-self { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 2px 0 0; color: var(--muted-foreground); font-size: 12px; cursor: pointer; }
.opt-self:hover { color: var(--foreground); }
.chat-start { display: grid; gap: 10px; padding-top: 8px; }
.chat-start h3 { margin: 0 0 4px; text-align: center; font-size: 16px; font-weight: 600; }
.chat-start .note { margin: 4px 0 0; text-align: center; font-size: 12px; color: var(--muted-foreground); }
.start-btn { display: block; text-align: left; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--background); color: var(--foreground); cursor: pointer; }
.start-btn:hover { background: var(--accent); }
.start-btn b { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.start-btn small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.55; color: var(--muted-foreground); }
.chat-err { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted-foreground); }
.chat-err button { margin-left: 6px; border: 0; background: none; color: var(--foreground); font-weight: 600; text-decoration: underline; cursor: pointer; }
.chat-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-compose textarea {
  flex: 1; min-height: 40px; max-height: 160px; resize: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; background: var(--background); font-size: 14px; line-height: 1.5;
}
.chat-compose textarea:focus { outline: none; border-color: var(--ring); }
.round-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); cursor: pointer; }
.round-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.hist-item { display: block; width: 100%; text-align: left; border: 0; border-radius: 10px; padding: 8px 10px; background: transparent; color: var(--foreground); cursor: pointer; }
.hist-item:hover { background: var(--accent); }
.hist-item b { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item small { font-size: 12px; color: var(--muted-foreground); }
@media (max-width: 640px) {
  .chat-panel { inset: 0; width: auto; height: auto; border: 0; border-radius: 0; }
}

/* ---------------------------------------------------------------- 拆解／選題／寫稿／評分 */
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-foreground); text-decoration: none; margin-bottom: 12px; }
.back:hover { color: var(--foreground); }
.metrics { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 14px; font-size: 14px; }
.metric { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.metric .ico { color: var(--muted-foreground); }
.metric .k { color: var(--muted-foreground); font-size: 13px; }
.td-bullets { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.td-bullets li { display: flex; gap: 10px; align-items: baseline; font-size: 14px; line-height: 1.7; }
.td-bullets .badge { flex: none; }
.src-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-foreground); }
.run-log:empty { display: none; }
.run-log .progress.warn { color: color-mix(in oklab, var(--warning) 60%, var(--foreground)); }
.run-log .progress.ok { color: color-mix(in oklab, var(--success) 70%, var(--foreground)); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0; cursor: pointer; }
.file { font-size: 13px; }
.subtabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin: 32px 0 16px; overflow-x: auto; scrollbar-width: none; }
.subtabs button {
  display: inline-flex; align-items: baseline; gap: 6px; flex: none; padding: 10px 0; border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted-foreground); font-size: 15px; font-weight: 500; cursor: pointer; margin-bottom: -1px;
}
.subtabs button small { font-size: 12px; font-weight: 400; }
.subtabs button:hover { color: var(--foreground); }
.subtabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.td-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.td-grid > .card + .card { margin-top: 0; }
.td-grid > .wide { grid-column: 1 / -1; }
.td-grid > .wide svg.curve { max-width: 760px; }
.td-card { scroll-margin-top: calc(var(--header-h) + 16px); }
.td-card > .row .ico { color: var(--muted-foreground); }
.td-card > .row h3 { margin: 0; }
.row.between { justify-content: space-between; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.lead { font-size: 16px; font-weight: 500; line-height: 1.6; margin: 0 0 8px; }
.not-run { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.tpl { font-size: 15px; line-height: 1.9; padding: 12px 14px; border-radius: 10px; background: var(--background); }
.slot { text-decoration: underline; text-decoration-color: var(--ring); text-underline-offset: 4px; font-weight: 500; }
.why-parts { display: grid; gap: 4px; margin: 6px 0 0; font-size: 13px; }
.why-parts b { font-weight: 500; color: var(--muted-foreground); margin-right: 6px; }
.rule { margin: 8px 0 0; font-size: 13px; }
.rule > b { font-weight: 600; }
.rule.deny > b { color: var(--destructive); }
.rule.allow > b { color: color-mix(in oklab, var(--success) 70%, var(--foreground)); }
svg.curve { width: 100%; height: auto; display: block; margin: 4px 0; }
svg.curve .grid { stroke: var(--border); stroke-width: 1; }
svg.curve .axis { fill: var(--muted-foreground); font-size: 11px; }
svg.curve .line { fill: none; stroke: var(--foreground); stroke-width: 2; stroke-linejoin: round; }
svg.curve .pt { fill: var(--background); stroke: var(--foreground); stroke-width: 2; }
svg.curve .rh { fill: var(--warning); }
svg.curve .word { fill: var(--foreground); font-size: 12px; }
.seg .when b { color: var(--foreground); font-weight: 600; }
.seg h3 { margin: 0; }
.seg-text { font-size: 15px; line-height: 1.8; margin: 8px 0; }
.emo { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-foreground); margin-left: auto; }
.mech { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; margin: 8px 0; font-size: 14px; line-height: 1.65; }
.mech .muted { flex-basis: 100%; font-size: 13px; }
.transcript { background: var(--surface); border-radius: 12px; padding: 16px 18px; }
.transcript p { font-size: 15px; line-height: 1.9; margin: 0 0 10px; }
.transcript p:last-child { margin: 0; }
.rh-line { text-decoration: underline wavy var(--warning); text-underline-offset: 5px; }
.topic { display: grid; gap: 6px; }
.topic h3 { font-size: 16px; line-height: 1.5; }
.topic .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.pick-list { display: grid; gap: 6px; margin-top: 8px; }
.pick-list button { text-align: left; }
.layer-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 12px 0; }
.layer-cards .card { cursor: pointer; border: 2px solid transparent; }
.layer-cards .card.on { border-color: var(--primary); background: var(--surface-strong); }
.layer-cards .card.off { cursor: not-allowed; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.week div { background: var(--surface); border-radius: 8px; padding: 8px; font-size: 12px; text-align: center; line-height: 1.5; }
.week b { display: block; font-size: 13px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare > div { min-width: 0; }
.compare .src { color: var(--muted-foreground); font-size: 14px; line-height: 1.8; }
.compare .mine { font-size: 15px; line-height: 1.8; }
.dim { display: grid; grid-template-columns: 120px minmax(0, 1fr) 48px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.dim:first-child { border-top: 0; }
.dim .s { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.fail-item { border-left: 2px solid var(--destructive); padding: 4px 0 4px 12px; margin: 10px 0; font-size: 14px; }
.fail-item .quote { margin: 6px 0; }

/* ---------------------------------------------------------------- 窄畫面 */
@media (max-width: 1279px) {
  .layout { grid-template-columns: 268px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 767px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .header-row { padding: 0 16px; }
  .tabs { padding: 0 16px; }
  .menu-btn { display: inline-flex; }
  .header-center { display: none; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 35; width: 288px; height: auto;
    background: var(--background); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform 0.2s;
  }
  body.nav-open .sidebar { transform: none; }
  .main { padding: 16px 16px 120px; }
  .page-title { font-size: 26px; }
  .step-list .srow { grid-template-columns: minmax(0, 1fr); }
  .seg { grid-template-columns: minmax(0, 1fr); }
  .brand .tag { display: none; }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dim { grid-template-columns: 90px minmax(0, 1fr) 40px; }
}
