/* CompoundWater 設計系統：近黑底、電光黃 #e9ff2e 唯一強調色、Space Grotesk / IBM Plex Mono / Noto Sans TC、2px 圓角 */
:root {
  --bg: #0c0d0b; --panel: #131411; --panel2: #191a16; --line: #272822; --line2: #34352e;
  --text: #eceee6; --muted: #8d9086; --dim: #5f6259;
  --acc: #e9ff2e; --acc-ink: #0c0d0b; --acc-soft: rgba(233, 255, 46, .13); --acc-line: rgba(233, 255, 46, .45);
  --down: #a9aca1;
  --r: 2px;
  --page: 960px;  /* 頁面最大寬度，閱讀較舒服 */
  --f-head: 'Space Grotesk', 'Noto Sans TC', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --f-body: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { color-scheme: dark; } }
:root[data-theme="dark"] { color-scheme: dark; }
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 64px); background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.65 var(--f-body); -webkit-font-smoothing: antialiased; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--acc-line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--acc); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--f-head); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h4 { font-size: 14px; margin: 18px 0 8px; color: var(--text); }
p { margin: 0; }
ul { margin: 0; padding-left: 1.2em; } li { margin: 3px 0; }

/* 頁首 */
.top { position: sticky; top: 0; z-index: 10; background: rgba(12, 13, 11, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.top-in { max-width: var(--page); margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--f-head); font-weight: 700; font-size: 16px; letter-spacing: .01em; white-space: nowrap; color: var(--text); text-decoration: none; }
.brand img { width: 28px; height: 28px; display: block; flex: none; }
.brand b { color: var(--acc); font-family: var(--f-body); font-weight: 700; letter-spacing: .02em; margin-left: 6px; }
.tabs { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; }
.tabs a { text-decoration: none; padding: 6px 14px; border-radius: var(--r); font-family: var(--f-head); font-size: 14px; color: var(--muted); }
.tabs a[aria-current="page"] { background: var(--acc); color: var(--acc-ink); font-weight: 600; }
.tabs a:not([aria-current="page"]):hover { color: var(--text); }
/* 頁首 BTC 背景列 */
.btcbar { border-top: 1px solid var(--line); background: rgba(19, 20, 17, .6); }
.btcbar-in { max-width: var(--page); margin: 0 auto; padding: 6px 20px; display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; font: 12px var(--f-mono); }
.bb-data { display: flex; gap: 6px 18px; flex-wrap: wrap; min-width: 0; }
.bb-i { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.bb-l { color: var(--dim); }
.bb-i b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.bb-i b.up { color: var(--acc); } .bb-i b.down { color: var(--down); }
/* 頁首第一行：左邊品牌，右邊分頁與更新時間 */
.top-r { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.top-time { font: 12px var(--f-mono); color: var(--dim); white-space: nowrap; margin-right: -8px; }
.bb-link { margin-left: auto; color: var(--muted); white-space: nowrap; font-family: var(--f-body); }
.bb-link:hover { color: var(--acc); }
.refresh { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; background: transparent; border: 0; border-radius: var(--r); color: var(--muted); cursor: pointer; }
.refresh:hover { color: var(--acc); }
.refresh svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.refresh.spin svg { animation: bb-spin .8s linear infinite; }
@keyframes bb-spin { to { transform: rotate(360deg); } }
/* 手機：頁首三行（品牌＋時間／分頁滿版／BTC 一行可左右滑） */
@media (max-width: 600px) {
  .top-r { display: contents; }
  .brand { order: 1; }
  .top-time { order: 2; margin-left: auto; margin-right: -4px; }
  .refresh { order: 3; }
  .tabs { order: 4; width: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 7px 4px; }
  .btcbar-in { padding: 6px 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 14px; }
  .btcbar-in::-webkit-scrollbar { display: none; }
  .bb-data { flex: none; flex-wrap: nowrap; gap: 12px; }
  .bb-link { flex: none; }
  .q-dot text { font-size: 10px; }
  .qchart .q-lab { font-size: 12px; }
}
/* 窄螢幕的寬表格：左右滑動時第一欄固定，才知道是哪一列 */
@media (max-width: 760px) {
  .tbl-wrap th:first-child, .tbl-wrap td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
  .tbl-wrap tr.me td:first-child { background: linear-gradient(var(--acc-soft), var(--acc-soft)), var(--panel); box-shadow: inset 2px 0 0 var(--acc), 1px 0 0 var(--line); }
}
.demo-bar { max-width: calc(var(--page) - 40px); width: calc(100% - 40px); margin: 14px auto 0; padding: 10px 14px; border: 1px dashed var(--acc-line); border-radius: var(--r); color: var(--muted); font-size: 13px; }
.demo-bar b { color: var(--acc); font-weight: 600; }
.demo-bar[hidden] { display: none; }

main { max-width: var(--page); margin: 0 auto; padding: 18px 20px 60px; }
.view[hidden] { display: none; }

/* 按鈕 */
.btn { font: 600 14px var(--f-head); background: var(--acc); color: var(--acc-ink); border: 1px solid var(--acc); border-radius: var(--r); padding: 8px 16px; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.ghost { background: transparent; color: var(--acc); }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* 區塊 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-top: 16px; min-width: 0; }
.panel > header { margin-bottom: 14px; }
.panel > header h2 { font-size: 17px; }
.panel > header p { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 72ch; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid2 > .panel { margin-top: 16px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .two { grid-template-columns: minmax(0, 1fr); gap: 0; } }

.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.note.warn { color: var(--acc); }
.empty { color: var(--dim); text-align: center; padding: 18px; font-size: 13px; }
.skel { color: var(--dim); font: 13px var(--f-mono); padding: 30px 0; }
.up { color: var(--acc); } .down { color: var(--down); } .hot { color: var(--acc); font-weight: 600; } .acc { color: var(--acc); }

/* 數據格 */
.stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.s-l { font-size: 12px; color: var(--muted); }
.s-v { font: 600 20px/1.3 var(--f-mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.s-s { font-size: 12px; color: var(--dim); }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 22px; margin: 4px 0 14px; }
.stats-col { display: grid; gap: 16px; }

/* 表格 */
.tbl-wrap { overflow-x: auto; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 7px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th.n, td.n { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.me td { background: var(--acc-soft); }
tr.me td:first-child { box-shadow: inset 2px 0 0 var(--acc); }

/* 圖表 */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--dim); font: 10.5px var(--f-mono); }
.chart .ln { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.chart .l1 { stroke: var(--acc); stroke-width: 2; }
.chart .l2 { stroke: var(--text); opacity: .75; }
.chart .l3 { stroke: var(--muted); stroke-dasharray: 5 4; }
.chart .band { stroke: var(--line2); stroke-dasharray: 3 4; }
.chart .band-t { fill: var(--muted); font: 10.5px var(--f-mono); }
.chart .bar { fill: var(--acc); }
.chart .bar.neg { fill: var(--down); opacity: .55; }
.chart .bar.dim { fill: var(--line2); }
.chart .zero { stroke: var(--line2); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.sw { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; background: var(--muted); }
.sw.l1 { background: var(--acc); } .sw.l2 { background: var(--text); } .sw.l3 { background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 9px); }
.sw.h1 { background: var(--acc); height: 10px; } .sw.h2 { background: #b5c729; height: 10px; } .sw.h3 { background: #6c7621; height: 10px; } .sw.h4 { background: var(--line2); height: 10px; }

/* BTC 溫度計 */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; padding: 22px 0 8px; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.t-top { display: flex; align-items: flex-end; gap: 20px; }
.t-num { font: 700 clamp(88px, 13vw, 148px)/.82 var(--f-head); color: var(--acc); letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.t-num sup { font-size: .35em; vertical-align: top; margin-left: 2px; }
.t-cap b { display: block; font: 600 26px var(--f-head); }
.t-cap span { display: block; color: var(--muted); font-size: 13px; max-width: 34ch; margin-top: 4px; }
.t-scale { position: relative; height: 12px; background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--r); margin-top: 22px; overflow: hidden; }
.t-fill { position: absolute; inset: 0 auto 0 0; background: var(--acc); }
.t-scale i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--bg); }
.t-ticks { display: grid; grid-template-columns: repeat(5, 1fr); font-size: 11px; color: var(--dim); margin-top: 4px; }
.t-ticks span:nth-child(n+2) { text-align: center; } .t-ticks span:last-child { text-align: right; }
.t-parts { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 7px; }
.t-parts li { display: grid; grid-template-columns: 9.5em minmax(0, 1fr) 7.5em; gap: 12px; align-items: center; font-size: 13px; }
.tp-l em { font: normal 11px var(--f-mono); color: var(--dim); margin-left: 6px; }
.tp-bar { height: 6px; background: var(--panel2); border-radius: var(--r); overflow: hidden; }
.tp-bar i { display: block; height: 100%; background: var(--text); opacity: .8; }
.tp-v { font: 12.5px var(--f-mono); text-align: right; color: var(--muted); }
.hero-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; align-content: center; }

/* 牛來 */
.nl-name h1 { font: 700 clamp(56px, 9vw, 96px)/.9 var(--f-body); letter-spacing: -.02em; }
.nl-name span { display: block; color: var(--muted); font-size: 13px; margin-top: 10px; }
.nl-price { display: flex; align-items: baseline; gap: 14px; margin: 16px 0 14px; }
.nl-price b { font: 600 34px var(--f-mono); letter-spacing: -.03em; }
.nl-price span { font: 15px var(--f-mono); }
.addr { font: 12px var(--f-mono); color: var(--dim); }
.risk-strip { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: center; }
.rk { display: grid; grid-template-columns: 7em minmax(0, 1fr) auto; align-items: baseline; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.rk-l { font-size: 13px; }
.rk b { font: 600 18px var(--f-mono); text-align: right; order: 3; }
.rk-s { font-size: 12px; color: var(--dim); }
.rk.warn { border-color: var(--acc-line); }
.rk.alert { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.rk.alert .rk-s { color: rgba(12, 13, 11, .7); }
.rk.na { opacity: .55; }
.split { display: flex; height: 30px; border-radius: var(--r); overflow: hidden; margin-bottom: 14px; font: 12px/30px var(--f-mono); }
.sp-a { background: var(--panel2); border: 1px solid var(--line2); padding-left: 10px; white-space: nowrap; }
.sp-b { background: var(--acc); color: var(--acc-ink); padding-left: 8px; white-space: nowrap; overflow: hidden; min-width: 70px; }
.stack { display: flex; height: 22px; border-radius: var(--r); overflow: hidden; margin-top: 4px; }
.stack .h1 { background: var(--acc); } .stack .h2 { background: #b5c729; } .stack .h3 { background: #6c7621; } .stack .h4 { background: var(--line2); }

/* BSC 資金地圖 */
.bsc-hero { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.map-head h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1; }
.map-head p { color: var(--muted); font-size: 13.5px; margin: 12px 0 18px; max-width: 46ch; }
.map-head .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.flowmap { font-size: 13px; }
.fm-axis { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) 3.2em 5.5em; font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.fm-axis { gap: 10px; } .fm-ends { display: flex; justify-content: space-between; } .fm-ends em { font-style: normal; }
.fm-row { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) 3.2em 5.5em; gap: 10px; align-items: center; padding: 3px 0; }
.fm-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-track { position: relative; height: 14px; background: linear-gradient(var(--line2), var(--line2)) 50% 0 / 1px 100% no-repeat; }
.fm-track i { position: absolute; top: 2px; bottom: 2px; }
.fm-track i.pos { background: var(--acc); } .fm-track i.neg { background: var(--down); opacity: .5; }
.fm-v { font-family: var(--f-mono); text-align: right; }
.fm-s { font: 11.5px var(--f-mono); color: var(--dim); text-align: right; }
.fm-row.me { background: var(--acc-soft); box-shadow: inset 2px 0 0 var(--acc); padding-left: 6px; }

/* Claude 判讀 */
.v-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.v-body { margin-top: 14px; }
.v-head { font: 600 19px/1.45 var(--f-body); max-width: 60ch; }
.v-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 6px; font-size: 12px; }
.chip { border: 1px solid var(--line2); border-radius: var(--r); padding: 2px 8px; font: 12px var(--f-mono); }
.chip.on { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.kvs { margin: 10px 0 0; display: grid; gap: 8px; }
.kv { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 12px; }
.kv dt { color: var(--muted); font-size: 13px; } .kv dd { margin: 0; }
.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 12px 0; }
.scores div { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.scores span { display: block; font-size: 12px; color: var(--muted); } .scores b { font: 600 16px var(--f-mono); }
.counter { margin-top: 18px; border-left: 3px solid var(--acc); padding: 4px 0 4px 14px; }
.counter h4 { margin-top: 0; color: var(--acc); }

/* 規則 */
.rules { display: grid; gap: 6px; }
.rule { display: grid; grid-template-columns: 5em minmax(0, 1.2fr) minmax(0, .8fr) minmax(0, 1.6fr) auto; gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); font-size: 13px; }
.rule.hit { border-color: var(--acc); background: var(--acc-soft); }
.r-state { font: 12px var(--f-mono); color: var(--muted); } .rule.hit .r-state { color: var(--acc); font-weight: 600; }
.r-cond, .r-now { font-family: var(--f-mono); } .r-now { color: var(--muted); } .r-note { color: var(--muted); }
.rule .x { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 12px; } .rule .x:hover { color: var(--text); }
@media (max-width: 760px) { .rule { grid-template-columns: 4.5em minmax(0, 1fr) auto; } .r-now, .r-note { grid-column: 2 / 4; } }
.rule-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.rule-add select, .rule-add input { background: var(--panel2); border: 1px solid var(--line2); color: var(--text); border-radius: var(--r); padding: 7px 9px; font: 13px var(--f-body); min-width: 0; }
.rule-add input[name="value"] { width: 7em; font-family: var(--f-mono); } .rule-add input[name="note"] { flex: 1 1 14em; }
.rlog { margin-top: 12px; font-size: 12.5px; color: var(--muted); } .rlog summary { cursor: pointer; }

footer { max-width: var(--page); margin: 0 auto; padding: 24px 20px 40px; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); }
footer p + p { margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 600px) { main { padding: 12px 12px 48px; } .demo-bar { width: calc(100% - 24px); } .panel { padding: 14px; } .top-in { padding: 8px 12px; gap: 10px; } .t-parts li { grid-template-columns: 7.5em minmax(0, 1fr) 6em; } .hero-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 900px) { .hero.bsc-hero, .hero.btc-hero, .hero.nl-hero { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) { .top { position: static; } .kv { grid-template-columns: 5.5em minmax(0, 1fr); } .fm-row, .fm-axis { grid-template-columns: 5.5em minmax(0, 1fr) 2.6em 4.6em; gap: 6px; } }
td.nw { white-space: nowrap; }

/* 山寨強弱 */
.alts-hero { grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbtn { font: 12.5px var(--f-body); background: transparent; color: var(--muted); border: 1px solid var(--line2); border-radius: var(--r); padding: 4px 10px; cursor: pointer; }
.chipbtn[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.chipbtn:not([aria-pressed="true"]):hover { color: var(--text); border-color: var(--muted); }
.qchart .q-sb { fill: var(--acc-soft); }
.qchart .q-neutral { fill: rgba(255, 255, 255, .025); }
.qchart .q-axis { stroke: var(--line2); }
.qchart .q-lab { fill: var(--muted); font: 600 13px var(--f-head); }
.qchart .q-band { fill: var(--dim); font: 10.5px var(--f-mono); }
.qchart .q-trail { stroke: var(--muted); stroke-width: 1; opacity: .45; }
.qchart .q-btc { fill: var(--text); }
.qchart .q-btc-t { fill: var(--text); font: 600 11px var(--f-mono); }
.q-dot circle { fill: var(--bg); stroke: var(--muted); stroke-width: 1.4; }
.q-dot text { fill: var(--muted); font: 11px var(--f-mono); }
.q-dot.on circle { fill: var(--acc); stroke: var(--acc); }
.q-dot.on text { fill: var(--text); font-weight: 600; }
.q-dot.me circle { stroke: var(--acc); stroke-width: 2.5; }
.q-dot.me text { fill: var(--acc); font: 700 13px var(--f-body); }
.q-dot.off { opacity: .15; }
.qtag { font-size: 12px; padding: 1px 7px; border-radius: var(--r); border: 1px solid var(--line2); white-space: nowrap; }
.qtag.qsb { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.qtag.qwb, .qtag.qsa { border-color: var(--acc-line); color: var(--acc); }
.qtag.qwa { color: var(--text); border-color: var(--muted); }
.qtag.qn { color: var(--dim); }
table.sortable th button { all: unset; cursor: pointer; } table.sortable th button:focus-visible { outline: 2px solid var(--acc); }
.method { display: grid; gap: 10px; font-size: 13.5px; max-width: 80ch; } .method b { color: var(--acc); font-weight: 600; margin-right: 4px; }
@media (max-width: 900px) { .hero.alts-hero { grid-template-columns: minmax(0, 1fr); } }

/* 手機：統計數字兩欄（放在最後，才蓋得過上面的一般規則） */
@media (max-width: 600px) { .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; } .s-v { font-size: 18px; } }
