:root {
  color-scheme: light;
  --page: #f4f5f3;
  --surface: #fcfcfb;
  --surface-2: #f0f1ee;
  --ink: #0f1d24;
  --ink-2: #4c5a60;
  --muted: #7d8a8f;
  --grid: #e3e5e0;
  --axis: #c3c7c0;
  --border: rgba(15, 29, 36, 0.10);
  --navy: #102b3b;
  --accent: #13796e;
  --accent-soft: #e4f3ef;
  --up: #c0362c;      /* 涨: red, CN convention; always with sign + arrow */
  --down: #0d7a3a;    /* 跌 */
  --flat: #7d8a8f;
  --warn-bg: #fff3d6;
  --warn-ink: #7a5300;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #4a3aa7;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e1214; --surface: #161b1d; --surface-2: #1d2427;
    --ink: #eef2f2; --ink-2: #b4bfc2; --muted: #85918f;
    --grid: #262e31; --axis: #3a4448; --border: rgba(255, 255, 255, 0.10);
    --accent: #3fb8a5; --accent-soft: #15302c;
    --up: #f0716a; --down: #3cc47a; --flat: #85918f;
    --warn-bg: #3a2e10; --warn-ink: #f4c963;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #9085e9;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1214; --surface: #161b1d; --surface-2: #1d2427;
  --ink: #eef2f2; --ink-2: #b4bfc2; --muted: #85918f;
  --grid: #262e31; --axis: #3a4448; --border: rgba(255, 255, 255, 0.10);
  --accent: #3fb8a5; --accent-soft: #15302c;
  --up: #f0716a; --down: #3cc47a; --flat: #85918f;
  --warn-bg: #3a2e10; --warn-ink: #f4c963;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #9085e9;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.55 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: 12px; top: -48px; background: var(--surface); padding: 8px 12px; z-index: 99; }
.skip:focus { top: 12px; }

.wrap { width: min(1280px, calc(100% - 32px)); margin: 0 auto; }

/* header */
.top { background: var(--navy); color: #fff; }
.top-inner { width: min(1280px, calc(100% - 32px)); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid #52746d; background: #203e4a; color: #84d3bf; font-size: 11px; font-weight: 700; letter-spacing: -.04em; }
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .03em; font-weight: 650; }
.brand-text em { font-style: normal; font-size: 10px; letter-spacing: .14em; color: #97b0b8; font-weight: 500; }
.brand-text > span { font-size: 11px; color: #97b0b8; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { color: #c9d6da; padding: 6px 10px; border-radius: 6px; font-size: 13px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a[aria-current="page"] { color: #fff; background: rgba(132, 211, 191, .16); }

/* intro */
.intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; padding: 28px 0 20px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .08em; }
h1 { margin: 0 0 8px; font-size: 28px; line-height: 1.2; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 17px; }
.lede { margin: 0; max-width: 760px; color: var(--ink-2); }
.facts { display: flex; gap: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.facts div { padding: 10px 18px; border-left: 1px solid var(--border); }
.facts div:first-child { border-left: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 15px; font-weight: 600; white-space: nowrap; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 14px; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.seg button:hover { color: var(--ink); background: rgba(127,127,127,.08); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.small button { padding: 3px 9px; font-size: 12px; }
.seg button .count { color: var(--muted); font-weight: 400; margin-left: 4px; font-size: 12px; }
.search { margin-left: auto; }
.search input { width: 240px; max-width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

/* chart panel */
.chart-panel, .table-panel, .notes { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.chart-head h2 { font-size: 19px; }
.chart-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.chart-figure { text-align: right; }
.hero { display: block; font-size: 34px; font-weight: 650; line-height: 1.1; letter-spacing: -.01em; }
.delta { font-size: 13px; color: var(--ink-2); }
.chart-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0 4px; flex-wrap: wrap; min-height: 28px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.legend button { border: 0; background: none; color: var(--muted); padding: 0 2px; font-size: 14px; line-height: 1; }
.legend button:hover { color: var(--ink); }
.chart { position: relative; height: 340px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .empty { display: grid; place-items: center; height: 100%; color: var(--muted); }
.chart-note { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.key-line, .key-dash { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--muted); margin-right: -8px; vertical-align: middle; }
.key-dash { border-top-style: dashed; }
.chart-note .hint { flex: 1 1 260px; }
.attr { margin-left: auto; font-weight: 600; }

.axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.grid line { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.crosshair { stroke: var(--axis); stroke-width: 1; }

/* board */
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.sort { font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.sort select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.group { margin-bottom: 18px; }
.group h3 { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; letter-spacing: .02em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; }
.card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px 10px; text-align: left; display: grid; gap: 4px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.card:hover { border-color: var(--axis); }
.card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card .name { font-weight: 600; font-size: 14px; line-height: 1.3; padding-right: 54px; }
.card .spec { font-size: 12px; color: var(--muted); }
.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .price { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.card .price.na { font-size: 14px; color: var(--muted); font-weight: 500; }
.card .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.card svg { width: 100%; height: 38px; display: block; }
.card .cmp { position: absolute; top: 9px; right: 9px; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.card .cmp:hover { color: var(--ink); background: var(--surface-2); }
.card .cmp input { margin: 0; accent-color: var(--accent); }
.unavailable { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.market-chip { justify-self: start; font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.group-note { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }
.sub-cny { font-size: 11px; color: var(--muted); }
.delta .cny { color: var(--ink-2); }
#market-switch { margin-right: auto; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--warn-bg); color: var(--warn-ink); margin-left: 4px; font-weight: 500; vertical-align: 1px; }
.chg { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.flat, .chg.none { color: var(--flat); font-weight: 500; }
.no-match { color: var(--muted); padding: 24px 0; text-align: center; }

/* table */
.table-scroll { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
tbody tr { cursor: pointer; }
.ghost { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 10px; font-size: 13px; }
.ghost:hover { border-color: var(--axis); }

/* notes */
.notes h2 { margin-bottom: 8px; }
.notes ul { margin: 0; padding-left: 18px; color: var(--ink-2); display: grid; gap: 4px; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; padding: 4px 0 32px; }

/* tooltip */
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: 0 6px 20px rgba(0,0,0,.14); font-size: 12px; min-width: 150px; max-width: 340px; }
.tooltip .t-date { color: var(--muted); margin-bottom: 4px; }
.tooltip .t-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 6px; }
.tooltip .t-row + .t-row { margin-top: 3px; }
.tooltip .t-row i { width: 12px; height: 2px; border-radius: 1px; }
.tooltip .t-row strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.tooltip .t-row span { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tooltip .t-foot { color: var(--muted); margin-top: 4px; }

@media (max-width: 760px) {
  .intro { grid-template-columns: 1fr; padding-top: 20px; }
  h1 { font-size: 23px; }
  .facts { width: 100%; }
  .facts div { flex: 1; padding: 8px 10px; }
  .facts dd { font-size: 13px; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
  .chart-panel, .table-panel, .notes { padding: 14px 12px; border-radius: 10px; }
  .chart { height: 260px; }
  .hero { font-size: 26px; }
  .chart-figure { text-align: left; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card .price { font-size: 17px; }
  .attr { margin-left: 0; }
}
