:root {
  color-scheme: dark;
  --background: #10191d;
  --surface: #172226;
  --surface-raised: #1b292d;
  --border: #314044;
  --muted: #9baaaa;
  --text: #f0f1e9;
  --teal: #8cdbc7;
  --teal-strong: #3fbfa3;
  --amber: #e5bf78;
  --red: #df897d;
  --line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html { background: var(--background); scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--background); font-family: "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: wait; opacity: .65; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
[hidden] { display: none !important; }

.site-shell { max-width: 1600px; margin: 0 auto; padding: 0 clamp(18px, 4.2vw, 72px); }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 106px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 18px; }
.brand-mark { width: 40px; height: 40px; display: flex; align-items: flex-end; gap: 5px; padding: 5px 4px; border: 1px solid var(--teal-strong); transform: skew(-10deg); }
.brand-mark span { display: block; width: 6px; background: var(--teal); }
.brand-mark span:nth-child(1) { height: 11px; }
.brand-mark span:nth-child(2) { height: 23px; }
.brand-mark span:nth-child(3) { height: 16px; }
.brand h1 { margin: 4px 0 0; font-size: clamp(18px, 2vw, 25px); font-weight: 650; letter-spacing: .01em; }
.brand h1 span { color: var(--teal); font-weight: 400; }
.eyebrow { margin: 0; color: var(--teal); font-family: Consolas, "Courier New", monospace; font-size: 10px; font-weight: 700; letter-spacing: .17em; }
.header-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal-strong); box-shadow: 0 0 0 4px rgba(63,191,163,.12); }

.intro { display: grid; grid-template-columns: minmax(0, 1fr) 270px; align-items: end; gap: 42px; padding: clamp(46px, 5.5vw, 88px) 0 50px; }
.intro h2 { margin: 18px 0 22px; max-width: 760px; font-size: clamp(40px, 5.1vw, 80px); line-height: 1.14; letter-spacing: -.055em; font-weight: 680; }
.intro h2 em { color: var(--teal); font-style: normal; }
.intro-copy { max-width: 660px; margin: 0; color: #b7c3c0; font-size: 15px; line-height: 1.85; }
.intro-side { padding: 0 0 7px 28px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.intro-side strong { font-size: 17px; font-weight: 580; letter-spacing: .01em; }
.intro-side .current-date { font-size: 27px; font-variant-numeric: tabular-nums; }
.intro-side > span:last-child { color: var(--muted); font-size: 13px; }
.range-label { color: var(--muted); font-size: 11px; letter-spacing: .09em; }
.intro-rule { height: 1px; background: var(--border); margin: 12px 0; }
.load-error { margin-bottom: 24px; padding: 18px 20px; border: 1px solid var(--red); background: rgba(223,137,125,.08); color: #f1b5ab; line-height: 1.7; }

.control-panel { border: 1px solid var(--border); background: var(--surface); padding: 25px 28px 19px; }
.control-top { display: grid; grid-template-columns: minmax(240px,1.5fr) minmax(220px,1.3fr) minmax(170px,.8fr); gap: 20px; }
.field { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.field > span, .speed-control > span { color: var(--muted); font-size: 11px; letter-spacing: .09em; }
.field select, .field input, .speed-control select { width: 100%; height: 44px; padding: 0 12px; color: var(--text); background: #111d20; border: 1px solid #3a4a4d; border-radius: 2px; outline: none; }
.field select:hover, .field input:hover, .speed-control select:hover { border-color: #65998d; }
.field input { color-scheme: dark; }
.timeline-row { display: flex; align-items: center; gap: 20px; padding-top: 26px; }
.play-button { display: grid; place-items: center; flex: 0 0 47px; width: 47px; height: 47px; color: #102021; background: var(--teal); border: 0; border-radius: 50%; transition: transform .15s, background .15s; }
.play-button:hover { background: #b3eedb; transform: scale(1.05); }
.play-button span { font-size: 16px; margin-left: 2px; }
.timeline-wrap { flex: 1; min-width: 0; }
#date-slider { display: block; width: 100%; margin: 0; accent-color: var(--teal); cursor: pointer; }
.timeline-labels { display: flex; justify-content: space-between; gap: 12px; margin-top: 9px; color: var(--muted); font: 11px Consolas, "Courier New", monospace; }
.timeline-labels span:nth-child(2) { color: var(--teal); }
.speed-control { width: 104px; display: flex; flex-direction: column; gap: 6px; }
.speed-control select { height: 36px; }

.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin: 28px 0; border: 1px solid var(--border); }
.metric-card { min-width: 0; padding: 24px 26px 22px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.metric-card:last-child { border-right: 0; }
.metric-card.primary { background: #213330; }
.metric-label { color: #acbdb9; font-size: 12px; }
.metric-card strong { margin: 14px 0 9px; font-size: clamp(22px, 2.45vw, 36px); font-weight: 590; font-variant-numeric: tabular-nums; letter-spacing: -.045em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-card.primary strong { color: var(--teal); }
.metric-card strong.negative { color: var(--red); }
.metric-detail { color: var(--muted); font-size: 11px; }

.chart-grid, .detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 28px; margin-bottom: 28px; }
.panel { min-width: 0; padding: 28px; border: 1px solid var(--border); background: var(--surface); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-heading h3 { margin: 7px 0 0; font-size: 21px; font-weight: 620; }
.segmented { display: flex; border: 1px solid var(--border); }
.segmented button { padding: 7px 14px; color: var(--muted); border: 0; background: transparent; font: 12px Consolas, "Courier New", monospace; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { color: #102021; background: var(--teal); font-weight: 700; }
.chart-current { display: flex; align-items: baseline; gap: 8px; margin-top: 25px; }
.chart-current strong { font-size: clamp(24px,2.6vw,36px); font-weight: 570; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.chart-current span, .chart-period { color: var(--muted); font-size: 11px; }
.chart-canvas { display: block; width: 100%; height: 260px; margin-top: 10px; }
.chart-footer { display: flex; align-items: center; justify-content: space-between; min-height: 25px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.chart-footer > span { display: inline-flex; align-items: center; gap: 7px; }
.legend-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.legend-dot.buy { background: var(--teal); }
.legend-dot.sell { background: var(--red); margin-left: 7px; }
.legend-line { display: inline-block; width: 20px; height: 2px; }
.legend-line.selected { background: var(--teal); }
.legend-line.comparison { background: var(--amber); }
.legend-footer { justify-content: flex-start; gap: 22px; }

.panel-index { color: #6f8885; font: 10px Consolas, "Courier New", monospace; letter-spacing: .08em; white-space: nowrap; }
.allocation { margin: 33px 0 22px; }
.allocation-bar { width: 100%; height: 11px; background: #52615d; overflow: hidden; }
.allocation-bar > span { display: block; width: 0; height: 100%; background: var(--teal-strong); transition: width .2s; }
.allocation-labels { display: flex; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: 12px; }
.allocation-labels span:first-child { color: var(--teal); }
.detail-list { margin: 0; }
.detail-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 14px 0; border-top: 1px solid var(--line); }
.detail-list dt { color: var(--muted); font-size: 12px; }
.detail-list dd { margin: 0; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.signal-banner { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 27px 0 19px; padding: 17px 19px; background: #233630; border-left: 3px solid var(--teal); }
.signal-banner span { color: #a9c5b9; font-size: 12px; }
.signal-banner strong { color: var(--teal); font-size: 22px; font-weight: 630; }
.signal-note { margin: 15px 0 0; color: #a8b7b3; font-size: 11px; line-height: 1.65; }

.provenance { display: grid; grid-template-columns: 1fr 1.2fr; gap: 38px; padding: 35px 0 43px; border-top: 1px solid var(--border); }
.provenance h3 { max-width: 490px; margin: 11px 0 0; font-size: 20px; line-height: 1.5; font-weight: 590; }
.provenance > p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.9; }
footer { display: flex; gap: 10px; padding: 24px 0 36px; color: #79908a; border-top: 1px solid var(--border); font: 10px Consolas, "Courier New", monospace; letter-spacing: .16em; }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric-card:nth-child(2) { border-right: 0; }
  .metric-card:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .chart-grid, .detail-grid { gap: 18px; }
  .panel { padding: 22px; }
}
@media (max-width: 760px) {
  .masthead { min-height: 86px; }
  .header-meta { display: none; }
  .intro { grid-template-columns: 1fr; gap: 31px; padding: 49px 0 36px; }
  .intro-side { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 0; border: 0; }
  .intro-side .range-label:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  .intro-side strong.current-date { grid-column: 2; grid-row: 2; font-size: 19px; }
  .intro-side > span:last-child { grid-column: 2; }
  .intro-rule { display: none; }
  .control-top { grid-template-columns: 1fr 1fr; gap: 15px; }
  .field:first-child { grid-column: 1 / -1; }
  .chart-grid, .detail-grid { grid-template-columns: 1fr; }
  .provenance { grid-template-columns: 1fr; gap: 15px; }
}
@media (max-width: 520px) {
  .site-shell { padding: 0 16px; }
  .brand { gap: 12px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand h1 { font-size: 18px; }
  .intro h2 { font-size: 38px; }
  .control-panel { padding: 18px 17px; }
  .control-top { grid-template-columns: 1fr; }
  .field:first-child { grid-column: auto; }
  .timeline-row { gap: 11px; }
  .speed-control { width: 80px; }
  .metrics { gap: 0; margin: 18px 0; }
  .metric-card { padding: 18px 15px; }
  .metric-card strong { font-size: 23px; }
  .metric-detail { font-size: 10px; }
  .chart-current strong { font-size: 26px; }
  .chart-canvas { height: 220px; }
}
