/* ── 基礎 ───────────────────────────────────────────────── */
:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e2e8f0;
  --text:      #1a2233;
  --text-mid:  #566179;
  --text-dim:  #8a94a8;
  --accent:    #2563eb;
  --accent-sf: #eff4ff;
  --cheap:     #0f9d58;   /* 保留給狀態訊息（成功） */
  --cheap-sf:  #e8f6ee;
  --fair:      #d4a017;   /* 保留給狀態訊息（提醒） */
  --fair-sf:   #fdf6e3;
  --rich:      #d93025;   /* 保留給狀態訊息（錯誤） */
  --rich-sf:   #fdecea;
  /* 數值階層：僅表示大小順序，不帶好壞評價 */
  --num-lo:    #5b7cb8;
  --num-mid:   #3c5a94;
  --num-hi:    #24406e;
  --num-lo-sf: #eef2f9;
  --num-mid-sf:#e6ecf6;
  --num-hi-sf: #dde5f2;
  --shadow:    0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
  --radius:    14px;
}
:root[data-theme="dark"] {
  --bg:        #0e1420;
  --surface:   #161d2b;
  --surface-2: #1c2534;
  --border:    #2a3446;
  --text:      #e6ebf4;
  --text-mid:  #a3aec4;
  --text-dim:  #6f7c94;
  --accent:    #6ba0ff;
  --accent-sf: #17233c;
  --cheap:     #4ade80;
  --cheap-sf:  #14301f;
  --fair:      #fbc02d;
  --fair-sf:   #322710;
  --rich:      #ff6b6b;
  --rich-sf:   #351a1a;
  --num-lo:    #8fb3e6;
  --num-mid:   #a9c6f0;
  --num-hi:    #c6dbfa;
  --num-lo-sf: #182236;
  --num-mid-sf:#1c2941;
  --num-hi-sf: #21304c;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
/* hidden 屬性只給 display:none 的預設值，會被元素自己的 display 規則蓋掉，
   所以明確宣告一次，否則設了 display:flex 的元素隱藏不了 */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* 數字一律等寬，避免跳動 */
.num, strong, dd, .code, input[type="number"] { font-variant-numeric: tabular-nums; }

/* ── 頂列 ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
/* 站名旁的折線圖。用 currentColor + var(--accent)，深色模式會自動換成亮藍 */
.brand-mark { display: flex; align-items: center; color: var(--accent); }
.brand-mark svg { width: 27px; height: 27px; display: block; }
.brand h1 { font-size: 18px; }
.brand-sub { margin: 1px 0 0; font-size: 11.5px; color: var(--text-dim); letter-spacing: .02em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.datainfo { text-align: right; line-height: 1.3; }
.datainfo-date { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-mid); }
.datainfo-count { display: block; font-size: 11px; color: var(--text-dim); }

.btn {
  font: inherit; font-size: 13px; font-weight: 550;
  padding: 7px 13px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-mid); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--accent-sf); color: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-icon { padding: 7px 10px; font-size: 15px; }
.btn-sm { font-size: 12.5px; padding: 6px 11px; }
.btn-ico { display: inline-block; }
.btn.busy .btn-ico { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 搜尋 ───────────────────────────────────────────────── */
.search-block { position: relative; margin: 28px 0 20px; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 4px 14px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
.search-ico { font-size: 16px; opacity: .55; }
#q {
  flex: 1; font: inherit; font-size: 16px; padding: 12px 0;
  border: 0; outline: 0; background: none; color: var(--text); min-width: 0;
}
#q::placeholder { color: var(--text-dim); }
#q::-webkit-search-cancel-button { display: none; }
.search-clear {
  border: 0; background: none; cursor: pointer; font-size: 14px;
  color: var(--text-dim); padding: 4px 6px; border-radius: 6px;
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }

.suggest {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none; max-height: 340px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.suggest li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
}
.suggest li:hover, .suggest li.active { background: var(--accent-sf); }
.suggest .no-hit { color: var(--text-dim); font-size: 13px; cursor: default; }
.suggest .no-hit:hover { background: none; }
.suggest .s-code { font-weight: 650; min-width: 52px; color: var(--accent); }
.suggest .s-name { flex: 1; }
.suggest .s-meta { font-size: 12px; color: var(--text-dim); }

.quickpicks { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.quickpicks-label { font-size: 12.5px; color: var(--text-dim); }
.chip {
  font: inherit; font-size: 12.5px; padding: 5px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-mid);
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--accent-sf); color: var(--accent); border-color: var(--accent); }

/* ── 狀態訊息 ────────────────────────────────────────────── */
.state-msg {
  padding: 16px; border-radius: var(--radius); text-align: center;
  color: var(--text-mid); font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); margin-bottom: 18px;
}
.state-msg b { display: block; margin-bottom: 3px; }
.state-error { background: var(--rich-sf); border-color: var(--rich); color: var(--rich); text-align: left; }
.state-warn  { background: var(--fair-sf); border-color: var(--fair); color: var(--fair); text-align: left; }
.state-ok    { background: var(--cheap-sf); border-color: var(--cheap); color: var(--cheap); text-align: left; }
.state-warn b, .state-ok b, .state-error b { font-weight: 700; }
.state-warn b:not(:first-child) { display: inline; }

/* ── 卡片 ───────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}

/* 個股概況 */
.stock-head { display: grid; gap: 16px; }
.stock-id { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.stock-id h2 { font-size: 22px; }
.code { color: var(--text-dim); font-weight: 550; font-size: 17px; }
.tag {
  font-size: 11.5px; font-weight: 600; padding: 2.5px 9px; border-radius: 999px;
  background: var(--accent-sf); color: var(--accent);
}
.tag-quiet { background: var(--surface-2); color: var(--text-dim); }
.stock-price { display: flex; align-items: baseline; gap: 8px; }
.stock-price .label { font-size: 12.5px; color: var(--text-dim); }
.stock-price strong { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.stock-price .unit { font-size: 13px; color: var(--text-dim); }

.fundamentals {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  margin: 0; background: var(--border); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.fundamentals > div { background: var(--surface); padding: 11px 13px; }
.fundamentals dt { font-size: 11.5px; color: var(--text-dim); margin-bottom: 3px; }
.fundamentals dt small { font-size: 10px; opacity: .75; margin-left: 3px; }
.fundamentals dd { margin: 0; font-size: 17px; font-weight: 650; }

/* 除權配股攤薄提示 */
.dilution-note {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: 11px;
  background: var(--accent-sf);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  font-size: 12.5px; line-height: 1.7; color: var(--text-mid);
}
.dilution-note b { color: var(--accent); font-weight: 650; }
.dilution-note .dn-ico { font-size: 15px; line-height: 1.4; flex-shrink: 0; }
.formula-adj { color: var(--accent); }

/* ── 綜合評估 ────────────────────────────────────────────── */
.summary-head { margin-bottom: 16px; }
.summary h3 { font-size: 16px; }
.summary-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-dim); }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sum-cell { padding: 14px; border-radius: 11px; text-align: center; border: 1px solid transparent; }
.sum-cell .sum-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.sum-cell strong { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.sum-cell.lo  { background: var(--num-lo-sf);  border-color: color-mix(in srgb, var(--num-lo) 30%, transparent);  color: var(--num-lo); }
.sum-cell.mid { background: var(--num-mid-sf); border-color: color-mix(in srgb, var(--num-mid) 35%, transparent); color: var(--num-mid); }
.sum-cell.hi  { background: var(--num-hi-sf);  border-color: color-mix(in srgb, var(--num-hi) 30%, transparent);  color: var(--num-hi); }

/* 位階尺標 */
.gauge { margin: 26px 0 12px; }
.gauge-track { position: relative; display: flex; height: 12px; border-radius: 999px; overflow: visible; }
/* 段寬對應 app.js 的位階映射：便宜段 0–25%、合理段 25–75%、昂貴段 75–100% */
.seg-cheap { flex: 0 0 25%; }
.seg-fair  { flex: 1 1 auto; }
.seg-rich  { flex: 0 0 25%; }
.seg-cheap { background: linear-gradient(90deg, var(--num-lo), color-mix(in srgb, var(--num-lo) 50%, var(--num-mid))); border-radius: 999px 0 0 999px; }
.seg-fair  { background: linear-gradient(90deg, color-mix(in srgb, var(--num-lo) 50%, var(--num-mid)), var(--num-mid)); }
.seg-rich  { background: linear-gradient(90deg, var(--num-mid), var(--num-hi)); border-radius: 0 999px 999px 0; }
.gauge-mark {
  position: absolute; top: -5px; width: 4px; height: 22px; border-radius: 3px;
  background: var(--text); transform: translateX(-50%);
  box-shadow: 0 0 0 3px var(--surface); transition: left .45s cubic-bezier(.4,0,.2,1);
}
.gauge-bubble {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 600;
  background: var(--text); color: var(--surface);
  padding: 4px 10px; border-radius: 7px;
}
.gauge-bubble::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--text);
}
.gauge-scale {
  position: relative; height: 20px; margin-top: 12px;
  font-size: 11.5px; color: var(--text-dim);
}
/* 刻度絕對定位在 25% / 50% / 75%，與軌道上的價位邊界一致 */
.gauge-scale span {
  position: absolute; transform: translateX(-50%); white-space: nowrap;
}
.gauge-scale b { font-weight: 650; }
.gauge-scale i { font-style: normal; }
#gScaleL b { color: var(--num-lo); }
#gScaleM b { color: var(--num-mid); }
#gScaleR b { color: var(--num-hi); }
.gauge-scale span::before {
  content: ""; position: absolute; top: -13px; left: 50%;
  width: 1px; height: 6px; background: var(--border);
}
.verdict {
  margin: 16px 0 0; padding: 13px 15px; border-radius: 10px;
  background: var(--surface-2); font-size: 14px; line-height: 1.6;
}
.verdict b { font-weight: 700; }
.verdict-thin {
  display: block; margin-top: 9px; padding-top: 9px;
  border-top: 1px dashed currentColor; font-size: 12.5px; opacity: .95;
}
.verdict-note {
  display: block; margin-top: 8px; font-size: 12px; color: var(--text-dim); line-height: 1.65;
}

/* ── 四大估價法 ──────────────────────────────────────────── */
.methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-bottom: 18px; }
.method {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column;
}
.method.off { opacity: .5; }
.method.na { opacity: .72; }
.method-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.method-head h3 { font-size: 15.5px; flex: 1; }
.method-head h3 .m-en { font-weight: 500; color: var(--text-dim); font-size: 12px; margin-left: 5px; }
.method-head h3 .m-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-sf); color: var(--accent); font-size: 11px; font-weight: 600;
  vertical-align: 1.5px;
}
.basis-src { margin-left: 6px; opacity: .85; }
.formula-warn { color: var(--fair); }
.method-toggle { width: 17px; height: 17px; margin: 3px 0 0; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.method-basis { font-size: 11.5px; color: var(--text-dim); margin: 0 0 14px; }
.method-basis .basis-tag {
  display: inline-block; padding: 1.5px 7px; border-radius: 999px;
  background: var(--surface-2); margin-right: 5px; font-weight: 600;
}
.method-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.mp { text-align: center; padding: 10px 6px; border-radius: 9px; background: var(--surface-2); }
.mp span { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
.mp strong { font-size: 19px; font-weight: 700; }
.mp.lo  strong { color: var(--num-lo); }
.mp.mid strong { color: var(--num-mid); }
.mp.hi  strong { color: var(--num-hi); }
.method-formula {
  margin: auto 0 0; padding-top: 12px; border-top: 1px dashed var(--border);
  font-size: 11.5px; color: var(--text-dim); line-height: 1.65; font-variant-numeric: tabular-nums;
}
.method-na {
  margin: auto 0 0; padding: 10px 12px; border-radius: 9px;
  background: var(--surface-2); font-size: 12.5px; color: var(--text-mid);
}

/* ── 參數 / 說明 ─────────────────────────────────────────── */
details.card > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline;
  gap: 10px; user-select: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: "▾"; margin-left: auto; color: var(--text-dim);
  transition: transform .2s; font-size: 12px;
}
details.card[open] > summary::after { transform: rotate(180deg); }
details.card summary h3 { font-size: 15.5px; }
.params-hint { font-size: 12px; color: var(--text-dim); }
.params-body { margin-top: 18px; display: grid; gap: 18px; }
.param-group h4 { font-size: 13px; margin-bottom: 8px; color: var(--text-mid); }
.param-row { display: flex; flex-wrap: wrap; gap: 12px; }
.param-row label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-mid);
}
.param-row input[type="number"] {
  font: inherit; font-size: 13px; width: 78px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.param-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.switch-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; cursor: pointer; }
.switch-row input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.param-note { margin: 7px 0 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.6; }

.explain-body { margin-top: 14px; font-size: 13.5px; color: var(--text-mid); }
.explain-body h4 { font-size: 13.5px; color: var(--text); margin: 20px 0 6px; }
.explain-body h4:first-child { margin-top: 4px; }
.explain-body p { margin: 0 0 8px; }
.explain-body pre {
  margin: 8px 0 10px; padding: 11px 13px; overflow-x: auto;
  background: var(--surface-2); border-radius: 9px; border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.7; color: var(--text);
}

/* ── 空狀態 / 頁尾 ───────────────────────────────────────── */
.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-ico { font-size: 42px; margin: 0 0 10px; }
.empty p { margin: 0; font-size: 15px; }
.empty-sub { margin-top: 6px !important; font-size: 12.5px; }
.foot { margin: 36px auto 40px; padding-top: 20px; border-top: 1px solid var(--border); }
.disclaimer, .foot-src { font-size: 11.5px; color: var(--text-dim); line-height: 1.7; margin: 0 0 7px; }
.disclaimer strong { color: var(--text-mid); }

/* ── 響應式 ─────────────────────────────────────────────── */
@media (max-width: 860px) {
  .methods { grid-template-columns: 1fr; }
  .fundamentals { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .brand h1 { font-size: 16px; }
  .brand-sub { display: none; }
  .datainfo { text-align: left; }
  .stock-price strong { font-size: 28px; }
  .summary-grid { grid-template-columns: 1fr; gap: 8px; }
  .sum-cell { display: flex; align-items: baseline; justify-content: space-between; text-align: left; }
  .sum-cell .sum-label { margin-bottom: 0; }
  .sum-cell strong { font-size: 21px; }
  .param-row label { flex: 1 1 100%; justify-content: space-between; }
  .param-row input[type="number"] { width: 96px; }
  /* 窄螢幕只留數字，否則三個刻度會黏成一片 */
  .gauge-scale { font-size: 10.5px; }
  .gauge-scale i { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   專業版（pro.html）的覆蓋規則

   計算版刻意用中性藍階，只表示數值大小；專業版改回台股
   習慣的綠（便宜）／黃（合理）／紅（昂貴），並加上位階配色。
   兩版共用同一份 style.css 與 app.js，只有這一段不同。
   ═══════════════════════════════════════════════════════════ */
body[data-mode="pro"] .sum-cell.lo  { background: var(--cheap-sf); border-color: color-mix(in srgb, var(--cheap) 30%, transparent); color: var(--cheap); }
body[data-mode="pro"] .sum-cell.mid { background: var(--fair-sf);  border-color: color-mix(in srgb, var(--fair) 30%, transparent);  color: var(--fair); }
body[data-mode="pro"] .sum-cell.hi  { background: var(--rich-sf);  border-color: color-mix(in srgb, var(--rich) 30%, transparent);  color: var(--rich); }

body[data-mode="pro"] .mp.lo  strong { color: var(--cheap); }
body[data-mode="pro"] .mp.mid strong { color: var(--fair); }
body[data-mode="pro"] .mp.hi  strong { color: var(--rich); }

body[data-mode="pro"] .seg-cheap { background: linear-gradient(90deg, var(--cheap), color-mix(in srgb, var(--cheap) 55%, var(--fair))); }
body[data-mode="pro"] .seg-fair  { background: linear-gradient(90deg, color-mix(in srgb, var(--cheap) 55%, var(--fair)), var(--fair)); }
body[data-mode="pro"] .seg-rich  { background: linear-gradient(90deg, var(--fair), var(--rich)); }

body[data-mode="pro"] #gScaleL b { color: var(--cheap); }
body[data-mode="pro"] #gScaleM b { color: var(--fair); }
body[data-mode="pro"] #gScaleR b { color: var(--rich); }

/* 位階配色 */
body[data-mode="pro"] .verdict.is-cheap  { background: var(--cheap-sf); color: var(--cheap); }
body[data-mode="pro"] .verdict.is-nearby { background: var(--cheap-sf); color: var(--cheap); opacity: .92; }
body[data-mode="pro"] .verdict.is-fair   { background: var(--fair-sf);  color: var(--fair); }
body[data-mode="pro"] .verdict.is-rich   { background: var(--rich-sf);  color: var(--rich); }
body[data-mode="pro"] .verdict-note { color: inherit; opacity: .78; }

/* 版本切換列 */
.editions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 11px 15px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim);
}
.editions-label { font-weight: 600; color: var(--text-mid); }
.editions a {
  padding: 4px 12px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--border); color: var(--text-mid); transition: all .15s;
}
.editions a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-sf); }
.editions a.current {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.editions .editions-hint { flex: 1 1 100%; margin-top: 2px; line-height: 1.6; }

/* 進場規則卡（僅專業版） */
.rules h3 { font-size: 15.5px; }
.rules-sub { margin: 4px 0 14px; font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.rules-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rules-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.rules-table tr:last-child td { border-bottom: 0; }
.rules-table td:first-child { color: var(--text-mid); white-space: nowrap; width: 45%; }
.rules-table b { font-weight: 700; }
.dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 8px; vertical-align: 0;
}
.dot-cheap  { background: var(--cheap); }
.dot-nearby { background: color-mix(in srgb, var(--cheap) 55%, var(--fair)); }
.dot-fair   { background: var(--fair); }
.dot-rich   { background: var(--rich); }
.rules-note {
  margin: 14px 0 0; padding: 11px 13px; border-radius: 9px;
  background: var(--surface-2); font-size: 12px; color: var(--text-mid); line-height: 1.7;
}
@media (max-width: 640px) {
  .rules-table td:first-child { width: auto; white-space: normal; }
  .rules-table td { padding: 8px 6px; font-size: 12.5px; }
}

/* ═══════════════════════════════════════════════════════════
   ETF 頁（etf.html）
   ═══════════════════════════════════════════════════════════ */
.etf-head { display: grid; gap: 14px; }
.etf-full { margin: -6px 0 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

.etf-prem {
  display: grid; gap: 16px; padding: 18px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.etf-prem-main { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.etf-prem-main .label { font-size: 12.5px; color: var(--text-dim); }
.etf-prem-main strong { font-size: 40px; font-weight: 700; letter-spacing: -.02em; }
.etf-prem-main strong.prem-up { color: var(--rich); }
.etf-prem-main strong.prem-down { color: var(--cheap); }
.etf-prem-word { font-size: 13px; color: var(--text-mid); }

.etf-prem-calc {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px;
  padding-top: 14px; border-top: 1px dashed var(--border);
}
.etf-prem-calc > div { display: flex; flex-direction: column; gap: 2px; }
.etf-prem-calc span { font-size: 11px; color: var(--text-dim); }
.etf-prem-calc b { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.etf-prem-calc .op { justify-content: flex-end; font-size: 15px; color: var(--text-dim); padding-bottom: 2px; }

/* 適用性對照表 */
.etf-fit td:first-child { width: 55%; }
.etf-fit .no { color: var(--text-dim); }
.etf-fit .partial { color: var(--fair); font-weight: 600; }
.etf-fit .yes { color: var(--cheap); font-weight: 600; }
.etf-why { margin-bottom: 18px; }

/* 排行 */
.board-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 14px; }
.board-title { font-size: 13px; margin-bottom: 8px; }
.board-title.rich { color: var(--rich); }
.board-title.cheap { color: var(--cheap); }
.board-list { list-style: none; margin: 0; padding: 0; counter-reset: b; }
.board-list li { counter-increment: b; }
.board-list a {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  border-radius: 8px; text-decoration: none; color: var(--text-mid); font-size: 13px;
}
.board-list a:hover { background: var(--accent-sf); }
.board-list a::before {
  content: counter(b); font-size: 11px; color: var(--text-dim);
  min-width: 16px; text-align: right;
}
.bl-code { font-weight: 650; color: var(--accent); min-width: 58px; }
.bl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-kind { font-size: 11px; color: var(--text-dim); }
.bl-prem { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 58px; text-align: right; }
.bl-prem.up { color: var(--rich); }
.bl-prem.down { color: var(--cheap); }

@media (max-width: 720px) {
  .board-grid { grid-template-columns: 1fr; }
  .etf-prem-main strong { font-size: 32px; }
  .bl-kind { display: none; }
}

.etf-caveats { margin: 8px 0 10px; padding-left: 20px; font-size: 13.5px; color: var(--text-mid); }
.etf-caveats li { margin-bottom: 8px; line-height: 1.7; }
.etf-caveats strong { color: var(--text); }


/* ── 中英切換 ─────────────────────────────────────────────
   靜態文字的中英兩份都在 HTML 裡，靠這兩條規則決定顯示哪一份。
   用 !important 是因為被藏的那一份可能自己有 display:flex/grid。
   兩條規則都不套用時（JS 還沒跑、或 JS 掛掉）預設顯示中文那一份，
   英文那一份先藏著，這樣最壞情況是看到中文，而不是中英一起冒出來。 */
/* 語言鈕要放得下 "中文" 兩個字，不能沿用圓形的 btn-icon 寬度 */
.btn-lang { width: auto; min-width: 38px; padding: 7px 9px; font-size: 12px; font-weight: 600; }

.i18n-en { display: none !important; }
html[data-lang="zh"] /* 語言鈕要放得下 "中文" 兩個字，不能沿用圓形的 btn-icon 寬度 */
.btn-lang { width: auto; min-width: 38px; padding: 7px 9px; font-size: 12px; font-weight: 600; }

.i18n-en { display: none !important; }
html[data-lang="zh"] .i18n-zh { display: revert !important; }
html[data-lang="en"] .i18n-zh { display: none !important; }
html[data-lang="en"] .i18n-en { display: revert !important; }


/* ── 迷你彙總列 ─────────────────────────────────────────────
   彙總卡在頁面上方，九張公式卡從它下方 1,100px 才開始、再往下延伸 1,200px，
   所以使用者捲到卡片去勾選時，彙總早就滾出畫面 —— 數字有重算，只是看不到，
   看起來就像「勾了沒反應」。這條列在彙總卡捲出畫面後貼在頂列下方補上回饋。 */
.minibar {
  position: sticky; top: 57px; z-index: 40;
  margin: 0 0 14px; border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 9px 15px; font-size: 12.5px;
  /* 預設不占空間，由 JS 依彙總卡是否可見決定 */
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.minibar.show { opacity: 1; transform: none; pointer-events: auto; }
.minibar-label { color: var(--text-dim); font-weight: 600; flex-shrink: 0; }
.minibar-cells { display: flex; gap: 12px; flex-wrap: wrap; }
.minibar-cell { display: flex; align-items: baseline; gap: 5px; }
.minibar-cell i { font-style: normal; color: var(--text-dim); font-size: 11px; }
.minibar-cell b { font-weight: 700; font-variant-numeric: tabular-nums; }
.minibar-cell.lo b  { color: var(--num-lo); }
.minibar-cell.mid b { color: var(--num-mid); }
.minibar-cell.hi b  { color: var(--num-hi); }
.minibar-count { margin-left: auto; color: var(--text-dim); }
/* 數字變動時閃一下，讓「勾選有生效」看得見 */
@keyframes minibar-flash {
  0% { background: var(--accent-sf); }
  100% { background: transparent; }
}
.minibar.bump { animation: minibar-flash .5s ease; }
@media (prefers-reduced-motion: reduce) {
  .minibar { transition: none; }
  .minibar.bump { animation: none; }
}
@media (max-width: 640px) {
  .minibar { top: 53px; font-size: 12px; padding: 8px 12px; gap: 10px; }
  .minibar-count { margin-left: 0; width: 100%; }
}


/* ── 獲利品質（毛利率／營業利益率）─────────────────────────
   刻意和上面的估價卡分開呈現：這不是估價指標，不進彙總統計。
   它回答的是另一個問題 —— 各公式分母的那個「盈餘」品質如何。 */
.margins {
  margin-top: 14px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface-2); padding: 12px 15px 14px;
}
.margins-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
}
.margins-head h4 { margin: 0; font-size: 13px; }
.margins-head .margins-sub { font-size: 11.5px; color: var(--text-dim); }
.margins-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.margins-table th, .margins-table td {
  padding: 5px 8px; text-align: right; font-variant-numeric: tabular-nums;
}
.margins-table th:first-child, .margins-table td:first-child {
  text-align: left; color: var(--text-mid); font-weight: 600; white-space: nowrap;
}
.margins-table thead th {
  font-size: 11px; color: var(--text-dim); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.margins-table tbody td { font-weight: 650; }
.margins-table .now { color: var(--accent); }
.margins-note { margin: 10px 0 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.65; }
.margins-note b { color: var(--text-mid); }
@media (max-width: 640px) {
  .margins-table { font-size: 12px; }
  .margins-table th, .margins-table td { padding: 4px 5px; }
}


/* ── 瀏覽人次 ───────────────────────────────────────────────
   徽章自帶背景色，所以標籤與數值都用中間調（slate / accent），
   深淺兩種主題下都讀得到，不必為了換色而載入第二張圖 ——
   那會讓每次瀏覽被記成兩次。 */
.hitbox {
  margin: 14px 0 0; display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--text-dim);
}
.hitbox .hitcount { display: block; height: 18px; width: auto; border-radius: 4px; }

/* ═══════════════════════════════════════════════════════════
   頂列導覽（取代舊的 .editions 區塊，五頁共用）
   桌機：夾在品牌與右側按鈕之間；窄螢幕：獨立成第二列、可橫向捲動
   ═══════════════════════════════════════════════════════════ */
.topnav {
  display: flex; align-items: center; gap: 4px;
  margin-right: auto; margin-left: 8px;
  padding: 3px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.topnav a {
  padding: 6px 13px; border-radius: 8px; white-space: nowrap;
  font-size: 13px; font-weight: 550; text-decoration: none;
  color: var(--text-mid); transition: background .15s, color .15s;
}
.topnav a:hover { color: var(--accent); background: var(--accent-sf); }
.topnav a.current {
  background: var(--surface); color: var(--accent); font-weight: 650;
  box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 0 0 1px var(--border);
}
.topnav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 版本說明卡（原本附在 .editions 裡） */
.edition-note {
  margin: 0 0 18px; padding: 11px 15px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12.5px; line-height: 1.65; color: var(--text-dim);
}
.edition-note strong { color: var(--text-mid); }
.edition-note a { color: var(--accent); text-decoration: none; font-weight: 600; }
.edition-note a:hover { text-decoration: underline; }

@media (max-width: 860px) {
  .topnav { order: 3; flex: 1 1 100%; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { flex: 1 0 auto; text-align: center; }
  .topbar-inner { flex-wrap: wrap; row-gap: 10px; }
}
@media (max-width: 640px) {
  .topnav a { padding: 7px 10px; font-size: 13.5px; }   /* 手指好點 */
}

/* 頁尾連結（隱私權政策等） */
.foot-links { font-size: 12px; margin: 4px 0 0; }
.foot-links a { color: var(--text-dim); text-decoration: underline; }
.foot-links a:hover { color: var(--accent); }

/* 自行輸入頁的欄位格 */
.manual-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 12px; }
.manual-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-mid); }
.manual-grid input {
  font: inherit; font-size: 15px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.manual-grid input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
@media (max-width: 860px) { .manual-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .manual-grid { grid-template-columns: 1fr; } }

/* 隱私權政策頁 */
.privacy h2 { font-size: 20px; margin-bottom: 4px; }
.privacy ul { padding-left: 20px; margin: 6px 0 10px; }
.privacy li { margin-bottom: 6px; line-height: 1.7; }
.privacy a { color: var(--accent); }
