/* 沿用 RS Terminal 兩套已批准的 Lazybeanz 主題（terminal-design.css：classic 深色／studio 淺色）。
   圖表三色由品牌色相推導，並以 dataviz validate_palette.js 驗證（色弱分辨、對比均通過）。 */
:root,
[data-theme="dark"] {
  --bg: #171819;
  --card: #202123;
  --card-deep: #262729;
  --text: #f2f0eb;
  --text-2: #b7b4ad;
  --text-3: #9b9892;
  --border: #3d3d3b;
  --accent: #d8bc87;
  --good: #70d4aa;
  --watch: #e8b86a;
  --alert: #f08e96;
  --s1: #b8892d; /* 準備金 */
  --s2: #8864c0; /* TGA */
  --s3: #1ea28f; /* ON RRP */
  --grid: #2c2d2f;
  --ref: #8f8c85;
  --bar: #b7b4ad;
  --c-btc: #d67523; --c-gold: #4682cc; --c-eth: #bb5faa; --c-usd: #29a077; --c-spx: #c4464f; --c-ndx: #139cb6; /* 對比資產，已驗證 */
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f2ede3;
  --card: #fcf9f2;
  --card-deep: #e9e3d7;
  --text: #252b29;
  --text-2: #5c635d;
  --text-3: #686b61;
  --border: #d2cec1;
  --accent: #804126;
  --good: #087346;
  --watch: #8a5700;
  --alert: #b32645;
  --s1: #ad721c;
  --s2: #724aab;
  --s3: #008c7a;
  --grid: #e6e0d4;
  --ref: #7d8078;
  --bar: #5c635d;
  --c-btc: #be5a0a; --c-gold: #2063b0; --c-eth: #a0388f; --c-usd: #008760; --c-spx: #ac2f3b; --c-ndx: #0078a2;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "IBM Plex Sans", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-underline-offset: 3px; }
.num, .m-val, .nl-val b, table td.n {
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.page { max-width: 1080px; margin: 0 auto; padding: 14px 24px 40px; }

/* 頁頭 */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; min-width: 0; }
.brand img { border-radius: 6px; flex: none; }
.brand-name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--text-2); letter-spacing: 0.08em; white-space: nowrap; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font: inherit; font-size: 12px; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 99px; min-height: 40px; padding: 6px 14px; cursor: pointer;
}
.theme-toggle:hover { background: var(--card-deep); }
.stale-banner { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid var(--watch); background: var(--card); }

/* 首屏：一句結論＋淨流動性 */
/* 背景文章：直接來到本頁的讀者先看兩篇文章 */
.articles { margin-top: 14px; }
.articles-k { margin: 0 0 8px; font-size: 13px; color: var(--text-2); }
.articles-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.article-card { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 14px; align-items: center; min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); text-decoration: none; }
.article-thumb { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; background: var(--card-deep); }
.article-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.article-card:hover { border-color: var(--text-3); }
.article-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.article-no { font-size: 12px; font-weight: 500; color: var(--accent); }
.article-card b { font-size: 15px; font-weight: 600; line-height: 1.4; text-wrap: balance; }
.article-card b::after { content: " ↗"; font-weight: 400; color: var(--text-3); }
.article-sum { font-size: 13px; line-height: 1.5; color: var(--text-2); }

.hero { padding: 20px 0 4px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; color: var(--text-2); }
.hero h1 { margin: 0; font-size: 28px; line-height: 1.3; letter-spacing: -0.02em; font-weight: 600; }
.hero h1 .clause { display: inline-block; }
.lede { margin: 8px 0 0; font-size: 15px; color: var(--text-2); max-width: 46em; }
.hero-note { margin: 10px 0 0; font-size: 12px; color: var(--text-3); }

.netliq { margin-top: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px 10px; }
.nl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.nl-title h2 { margin: 0; font-size: 17px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.nl-title h2 span { font-size: 12px; font-weight: 400; color: var(--text-2); }
.read { margin: 2px 0 0; font-size: 12px; color: var(--text-2); }
.nl-val { text-align: right; flex: none; }
.nl-val b { display: block; font-size: 32px; line-height: 1.1; font-weight: 500; letter-spacing: -0.02em; white-space: nowrap; }
.nl-val small { font-size: 11px; color: var(--text-3); }
.nl-chg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* 數字卡：名稱＋數值、一句怎樣看、變化＋標籤 */
.metrics { display: grid; gap: 10px; margin-top: 14px; }
.metrics.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; min-width: 0; display: grid; gap: 4px; }
.m-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.m-top h3 { margin: 0; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; min-width: 0; }
.m-top h3 small { font-size: 11px; font-weight: 400; color: var(--text-3); }
.m-val { font-size: 22px; font-weight: 500; white-space: nowrap; letter-spacing: -0.01em; }
.m-val small { font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif; font-size: 11px; font-weight: 400; color: var(--text-2); margin-left: 2px; }
.m-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; font-size: 12px; color: var(--text-2); }
.m-foot b { color: var(--text); font-weight: 500; font-family: "IBM Plex Mono", ui-monospace, monospace; }

.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--c); flex: none; }
.sw.dash { background: none; border-top: 2px dashed var(--c); height: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; white-space: nowrap;
  font-size: 12px; line-height: 1.4; padding: 2px 10px 2px 8px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--card-deep); color: var(--text);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone, var(--text-3)); flex: none; }
.chip.good { --tone: var(--good); }
.chip.watch { --tone: var(--watch); }
.chip.alert { --tone: var(--alert); }
.chip.plain::before { display: none; }
.chip.plain { padding-left: 10px; }
.chip b { font-weight: 500; font-family: "IBM Plex Mono", ui-monospace, monospace; }

/* 區塊 */
.block { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.block-head h2 { margin: 0; font-size: 20px; line-height: 1.35; font-weight: 600; }
.block-head p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.fine { margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: var(--text-3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sub { background: var(--card-deep); border-radius: 12px; padding: 12px 12px 4px; min-width: 0; }
.sub h3 { margin: 0; font-size: 14px; font-weight: 600; }

/* 可展開說明 */
details.more { margin-top: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.netliq details.more { border: 0; border-top: 1px solid var(--border); border-radius: 0; background: transparent; margin: 6px -18px 0; }
details.more > summary {
  list-style: none; cursor: pointer; min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 14px; font-size: 13px; color: var(--text-2);
}
.netliq details.more > summary { padding: 0 18px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "展開"; font-size: 12px; color: var(--text-3); }
details.more[open] > summary::after { content: "收起"; }
details.more > summary:hover { color: var(--text); }
.more-body { padding: 0 14px 14px; font-size: 14px; color: var(--text-2); }
.netliq .more-body { padding: 0 18px 12px; }
.more-body p { margin: 0 0 8px; }
.more-body b { color: var(--text); font-weight: 600; }
.formula { color: var(--text); }
.formula b { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; }
.rules { margin: 0; padding-left: 18px; }
.rules li { margin: 4px 0; }

/* 圖表 */
.chart { margin-top: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 12px 6px; min-width: 0; }
.chart.bare { background: transparent; border: 0; padding: 0; margin-top: 10px; }
.chart-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; min-width: 0; font-size: 12px; color: var(--text-2); }
.legend .lg-date { flex-basis: 100%; color: var(--text-3); }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend .lg b { color: var(--text); font-weight: 500; font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { font: inherit; font-size: 12px; color: var(--text-2); background: transparent; border: 0; min-height: 32px; min-width: 48px; padding: 4px 9px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--card-deep); color: var(--text); font-weight: 600; }
.plot { position: relative; margin-top: 6px; touch-action: pan-y; }
.plot svg { display: block; width: 100%; overflow: visible; }
.plot svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.plot text { font-size: 11px; fill: var(--text-3); font-family: "IBM Plex Mono", ui-monospace, monospace; }
.plot text.mk { fill: var(--text-2); font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif; }
.plot .grid line { stroke: var(--grid); stroke-width: 1; }
.plot .ref { stroke: var(--ref); stroke-width: 1.2; stroke-dasharray: 5 4; fill: none; }
.plot .zero { stroke: var(--ref); stroke-width: 1; fill: none; }
.plot .mark { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 3; }
.plot .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .bars { stroke: var(--bar); fill: none; }
.plot .cross { stroke: var(--text-2); stroke-width: 1; }
.plot .dot { stroke: var(--card); stroke-width: 2; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 8px; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 500; color: var(--text-2); background: var(--card-deep); }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; }

.footer { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 12px; line-height: 1.7; color: var(--text-3); }
.footer p { margin: 0 0 6px; max-width: 70em; }
.footer b { color: var(--text-2); }

@media (max-width: 900px) {
  .articles-list { grid-template-columns: minmax(0, 1fr); }
  .metrics.three { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* 手機：一屏看到結論、淨流動性數字及走勢 */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .page { padding: 10px 16px 32px; }
  .masthead { padding-bottom: 10px; }
  .brand-name { font-size: 18px; }
  .brand-sub { display: none; }
  .theme-toggle { min-height: 36px; padding: 4px 12px; }
  .articles { margin-top: 8px; }
  .articles-k { margin-bottom: 6px; font-size: 12px; }
  .articles-list { gap: 6px; }
  .article-card { grid-template-columns: 112px minmax(0, 1fr); gap: 10px; padding: 8px; border-radius: 10px; }
  .article-thumb { border-radius: 6px; }
  .article-text { gap: 2px; }
  .article-no { font-size: 11px; }
  .article-card b { font-size: 14px; }
  .article-sum { font-size: 12px; }
  .hero { padding-top: 10px; }
  .eyebrow { font-size: 11px; margin-bottom: 4px; }
  .hero h1 { font-size: 21px; line-height: 1.35; }
  .lede { font-size: 13px; margin-top: 4px; }
  .netliq { margin-top: 12px; padding: 12px 12px 6px; border-radius: 14px; }
  .netliq details.more { margin: 4px -12px 0; }
  .netliq details.more > summary, .netliq .more-body { padding-left: 12px; padding-right: 12px; }
  .nl-val b { font-size: 26px; }
  .nl-chg { margin-top: 8px; }
  .metrics.two { grid-template-columns: minmax(0, 1fr); }
  .metric { padding: 10px 12px; border-radius: 12px; }
  .m-val { font-size: 20px; }
  .block { margin-top: 22px; padding-top: 18px; }
  .block-head h2 { font-size: 18px; }
  .chart { padding: 10px 10px 6px; border-radius: 12px; }
  .seg button { min-width: 44px; min-height: 34px; padding: 4px 6px; }
  .hero-note { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (prefers-contrast: more) {
  [data-theme="dark"] { --border: #8998aa; --grid: #4a4b4e; }
  [data-theme="light"] { --border: #65695f; --grid: #b9b4a8; }
}
.metric .read { margin: 0; }
.nl-val b .u, .m-val .u { font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif; font-size: 13px; font-weight: 400; color: var(--text-2); margin-left: 2px; letter-spacing: 0; }
.legend .lg-hint { color: var(--text-3); min-height: 19px; }

/* 對比資產按鈕 */
.cmp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.cmp button { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12px; color: var(--text-2); background: transparent; border: 1px solid var(--border); border-radius: 99px; min-height: 32px; padding: 3px 11px; cursor: pointer; }
.cmp button[aria-pressed="true"] { background: var(--card-deep); color: var(--text); border-color: var(--text-3); font-weight: 600; }
.cmp button:not([aria-pressed="true"]) .sw { opacity: 0.45; }
.chart-note { margin: 8px 0 0; font-size: 12px; line-height: 1.6; color: var(--text-3); }
.chart-note b { color: var(--text-2); font-weight: 600; }
.sw.dash { background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 8px); border: 0; height: 3px; }
.legend .lg-chg { color: var(--text-3); font-size: 11px; }
.sw.dot { background: repeating-linear-gradient(90deg, var(--c) 0 3px, transparent 3px 6px); border: 0; height: 3px; }
