/* wk-pro：只給週末哥一個人看的專家分析工具。固定淺色（他手機開深色模式也不准變黑底）
   設計判讀與放掉 taste 的哪幾條寫在 .qa/taste.md */
:root {
  color-scheme: light;
  --accent: #F5C518;
  --accent-deep: #7A5E00;
  --accent-soft: #FFF6D1;
  --ink: #1C1C21;
  --ink-2: #4A4A51;
  --ink-3: #6B6B72;
  --bg: #F6F6F4;
  --surface: #FFFFFF;
  --line: #E3E3DE;
  --ok: #1E7A4C;
  --ok-soft: #E6F4EC;
  --run: #1D5FB8;
  --run-soft: #E8F0FB;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --r-card: 16px;
  --r-input: 10px;
  --shadow: 0 1px 2px rgba(60, 50, 10, .05), 0 6px 20px rgba(60, 50, 10, .05);
  --font: 'Geist', 'Noto Sans TC', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.7;
  line-break: strict; text-wrap: pretty; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
h1, h2, h3, b, strong { font-weight: 600; }
h1, h2, h3 { text-wrap: balance; }
button { font: inherit; color: inherit; }
a { color: inherit; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.num { font-variant-numeric: tabular-nums; }
.mute { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* 頂欄 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; margin-top: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.top a.ext { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--ink-2); text-decoration: none; min-height: 44px; }

/* 標題區 */
.head { margin: 20px 0 16px; }
.head h1 { font-size: 24px; line-height: 1.35; letter-spacing: -.01em; }
.head p { color: var(--ink-2); margin-top: 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--ink-2); text-decoration: none; font-size: 15px; }

/* 卡片與清單 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 18px 16px; }
.list { display: grid; gap: 12px; }
a.item { display: block; text-decoration: none; }
a.item:active, button.pick:active { transform: scale(.99); }
.item .t { font-weight: 600; font-size: 17px; line-height: 1.45; }
.item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 14px; color: var(--ink-3); }
.item .sum { margin-top: 8px; color: var(--ink-2); font-size: 15px; }

/* 狀態（真的有狀態意義才用圓點） */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.st::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st.queued { background: var(--accent-soft); color: var(--accent-deep); }
.st.running { background: var(--run-soft); color: var(--run); }
.st.done { background: var(--ok-soft); color: var(--ok); }
.st.failed { background: var(--danger-soft); color: var(--danger); }
.chip { display: inline-block; font-size: 13px; padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); background: var(--surface); }

/* 按鈕：一律膠囊 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 22px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1C1C21; }
.btn.block { width: 100%; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"] svg { display: none; }
.btn[aria-busy="true"]::before { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(28, 28, 33, .2); border-top-color: var(--ink); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 底部固定的主要動作（拇指按得到） */
.dock { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); padding: 10px 16px; background: linear-gradient(rgba(246, 246, 244, 0), var(--bg) 30%); }
.dock .in { max-width: 720px; margin: 0 auto; }
.has-dock { padding-bottom: 80px; }

/* 底部分頁 */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs .in { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; font-size: 13px; color: var(--ink-3); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabs a[aria-current="page"] svg.i { stroke: var(--accent-deep); }

/* 步驟條 */
.steps { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); margin: 4px 0 16px; }
.steps span.on { color: var(--ink); font-weight: 600; }
.steps svg.i { width: 14px; height: 14px; }

/* 可勾選的卡（框架、客戶） */
button.pick { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; cursor: pointer; }
button.pick .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; }
button.pick[aria-pressed="true"] { border-color: var(--accent-deep); box-shadow: 0 0 0 1px var(--accent-deep), var(--shadow); }
button.pick[aria-pressed="true"] .box { background: var(--accent); border-color: var(--accent); }
button.pick .box svg.i { width: 16px; height: 16px; stroke-width: 2.5; visibility: hidden; }
button.pick[aria-pressed="true"] .box svg.i { visibility: visible; }
.radio .box { border-radius: 50% !important; }

/* 分段切換 */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #ECECE8; border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.seg button { min-height: 44px; border: 0; background: none; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* 表單 */
label.lb { display: block; font-weight: 600; font-size: 15px; margin: 16px 0 4px; }
.help { font-size: 14px; color: var(--ink-3); margin-bottom: 8px; }
textarea { width: 100%; min-height: 110px; padding: 12px; font: inherit; font-size: 16px; border: 1px solid var(--line); border-radius: var(--r-input); background: var(--surface); color: var(--ink); resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent-deep); }
.err { color: var(--danger); font-size: 15px; margin-top: 10px; }

/* 圖解（框架與分析結果的 SVG） */
.dia { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px; }
.dia svg { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; }
.thumb { width: 88px; height: 66px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); overflow: hidden; display: grid; place-items: center; }
.thumb svg { width: 100%; height: 100%; }
.fwrow { display: grid; grid-template-columns: 88px 1fr; gap: 14px; align-items: center; }

/* 結果頁 */
.verdict { font-size: 20px; line-height: 1.5; font-weight: 600; }
ol.acts { list-style: none; counter-reset: a; display: grid; gap: 10px; margin-top: 14px; }
ol.acts li { counter-increment: a; display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
ol.acts li::before { content: counter(a); width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #1C1C21; font-weight: 700; font-size: 14px; display: grid; place-items: center; margin-top: 1px; }
.sec { margin-top: 28px; }
.sec h2 { font-size: 19px; margin-bottom: 10px; }
.sec .concl { margin: 12px 0; }
details.cells { margin-top: 12px; }
details.cells > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent-deep); list-style: none; }
details.cells > summary::-webkit-details-marker { display: none; }
details.cells[open] > summary svg.i { transform: rotate(90deg); }
.cell { padding: 14px 0; border-top: 1px solid var(--line); }
.cell .lbl { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-weight: 600; }
.cell .ev { font-size: 15px; color: var(--ink-2); margin-top: 4px; }
.lv { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.lv.l1 { background: var(--ok-soft); color: var(--ok); }
.lv.l2 { background: var(--run-soft); color: var(--run); }
.lv.l3 { background: var(--accent-soft); color: var(--accent-deep); }
.lv.l4 { background: var(--danger-soft); color: var(--danger); }
.missing { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; }
.missing ul { padding-left: 1.2em; }
.src { font-size: 14px; color: var(--ink-3); word-break: break-all; }

/* 框架卡 */
.kv { margin-top: 18px; }
.kv h3 { font-size: 16px; margin-bottom: 6px; }
.kv ol, .kv ul { padding-left: 1.3em; display: grid; gap: 4px; }

/* 空狀態與流程圖 */
.empty { text-align: left; }
.empty h2 { font-size: 19px; margin: 14px 0 6px; }
.empty p { color: var(--ink-2); }
.flow { display: block; width: 100%; height: auto; margin-top: 8px; }

/* 骨架載入 */
.sk { height: 86px; border-radius: var(--r-card); background: linear-gradient(90deg, #ECECE8 0%, #F5F5F2 50%, #ECECE8 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* 複製提示 */
.cmd { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 10px 10px 10px 16px; border: 1px dashed var(--accent-deep); border-radius: 12px; background: var(--accent-soft); }
.cmd code { font-family: var(--font); font-weight: 600; font-size: 17px; }

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
  a.item:active, button.pick:active, .btn:active { transform: none; }
}
@media (max-width: 360px) {
  .fwrow { grid-template-columns: 72px 1fr; gap: 10px; }
  .thumb { width: 72px; height: 54px; }
  .head h1 { font-size: 22px; }
}
