/* TW Market — 已實現波動 (spec designer tw-realized-vol-2026-12-01).
   One card: three readouts that double as the series switch, over one chart.
   Dual-theme through the role vars only — no body.dark-mode overrides here. */

#box_main {
  flex: 1;
  min-width: 0;
  min-height: 800px;
  padding-top: var(--space-16);
  padding-left: var(--space-16);
}

/* ── Page head ── */
.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-16);
  flex-wrap: wrap;
  margin-bottom: var(--space-16);
}
.titlewrap h1 { margin: 0; color: var(--ink); }
.toolbar { display: flex; gap: var(--space-8); align-items: center; flex-wrap: wrap; }
/* overflow 不能 hidden:會把撐熱區的 ::before 裁掉;圓角由頭尾兩顆自己畫(外框 1px,內半徑減 1) */
.segment { display: inline-flex; border: 1px solid var(--border-frame); border-radius: var(--radius-sm); }
.segment .btn_range {
  height: 32px; padding: 0 var(--space-12); border: none; background: transparent; color: var(--ink-3);
  font-size: 12px; font-family: inherit; white-space: nowrap; cursor: pointer; border-right: 1px solid var(--border-frame);
  transition: background var(--motion-fast) var(--ease-standard); position: relative;
}
.segment .btn_range::before { content: ""; position: absolute; inset: -6px 0; }
.segment .btn_range:first-child { border-radius: calc(var(--radius-sm) - 1px) 0 0 calc(var(--radius-sm) - 1px); }
.segment .btn_range:last-child { border-right: none; border-radius: 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0; }
@media (hover: hover) { .segment .btn_range:hover { background: var(--surface-muted); } }
.segment .btn_range.active { background: var(--surface-segment-on); color: var(--ink); font-weight: 600; }

/* ── Card ── */
.card { background: var(--surface-card); border: none; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--space-16); }
.card + .card { margin-top: var(--space-16); }
.chart_box { position: relative; height: 360px; }

/* ── Readouts = the series switch (role=tablist) ── */
.rv_tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-8); max-width: 780px; }
.rv_tab {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: var(--space-4); min-height: 44px;
  padding: var(--space-12); border: none; border-radius: var(--radius-md); background: transparent;
  color: inherit; font-family: inherit; text-align: left; cursor: pointer;
  transition: background var(--motion-fast) var(--ease-standard);
}
/* canon › Studio 側欄目前項 › 清單坐在卡面上時 */
@media (hover: hover) { .rv_tab:hover { background: color-mix(in srgb, var(--surface-muted) 50%, transparent); } }
.rv_tab[aria-selected="true"] { background: var(--surface-muted); }
.rv_tab .lab { font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.rv_tab .row { display: flex; align-items: center; gap: var(--space-8); flex-wrap: wrap; }
.rv_tab .val { font-size: 24px; font-weight: 500; line-height: 1.2; color: var(--ink); }
.rv_tab .unit { margin-left: var(--space-4); font-size: 12px; font-weight: 400; color: var(--ink-3); white-space: nowrap; }
.rv_tab .tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 var(--space-8); border-radius: var(--radius-pill);
  background: var(--tag-neutral-bg); color: var(--tag-neutral-text); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.rv_tab .tag:empty { display: none; }
/* 高低條:軌道 = 區間最低到最高,中段 = 平常範圍,直線 = 現在 */
.rv_strip { position: relative; height: 6px; margin-top: var(--space-8); border-radius: var(--radius-pill); background: var(--surface-muted); }
.rv_strip .mid { position: absolute; top: 0; bottom: 0; background: var(--chart-band); opacity: .55; }
.rv_strip .now { position: absolute; top: -4px; width: 2px; height: 14px; margin-left: -1px; background: var(--ink); }
/* 選中那格的底就是 --surface-muted,標籤與軌道退到卡面色才分得出來 */
.rv_tab[aria-selected="true"] .tag,
.rv_tab[aria-selected="true"] .rv_strip { background: var(--surface-card); }
/* --ink-3 壓在 --surface-muted 上不到 4.5:1,選中格的小字升一階 */
.rv_tab[aria-selected="true"] .lab,
.rv_tab[aria-selected="true"] .unit { color: var(--ink-2); }
/* 三格的標籤、數值列、高低條各佔同一列:標籤在某一語折成兩行時,另外兩格的數字不會錯位。
   不支援 subgrid 的瀏覽器停在上面的直排,只是各格自己排。 */
@supports (grid-template-rows: subgrid) {
  .rv_tabs { grid-template-rows: auto auto auto; row-gap: 0; }
  .rv_tab { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: var(--space-4); align-items: start; justify-content: normal; }
  .rv_tab .rv_strip { align-self: end; }
}

/* ── Legend row above the chart ── */
.rv_meta {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-12);
  margin: var(--space-16) 0 var(--space-8); font-size: 12px; color: var(--ink-3);
}
.rv_legend { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-12); }
#rv_date { flex: none; white-space: nowrap; }
.rv_sw { display: inline-block; width: 10px; height: 10px; margin-right: var(--space-4); vertical-align: -1px; }
.rv_sw.is-main { background: var(--color-data-1); }
.rv_sw.is-index { background: var(--ink-3); }
.rv_sw.is-band { background: var(--chart-band); opacity: .55; }

/* ── Daily table (collapsed by default) ── */
.rv_tblcard { padding-top: 0; padding-bottom: 0; }
.rv_acc { margin: 0; }
.rv_acc button {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-12);
  width: 100%; min-height: 48px; padding: 0; border: none; background: none;
  font: inherit; text-align: left; color: var(--ink); cursor: pointer;
}
.rv_acc button[aria-expanded="true"] .xp_chev { transform: translateY(2px) rotate(-135deg); }
#rv_tbl_panel { padding-bottom: var(--space-16); }
.tbl-wrap { overflow: auto; -webkit-overflow-scrolling: touch; max-height: 420px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.tbl thead th {
  position: sticky; top: 0; height: 36px; padding: 0 var(--space-12); background: var(--surface-card);
  color: var(--ink-3); font-weight: 600; font-size: 12px; text-align: right; white-space: nowrap;
}
table.tbl tbody td {
  padding: 7px var(--space-12); border-top: 1px solid var(--border-hairline);
  font-family: var(--font-mono); color: var(--ink); text-align: right; white-space: nowrap;
}
table.tbl :is(th, td):first-child { text-align: left; }
table.tbl tbody td:first-child { color: var(--ink-2); }
/* 窄寬橫捲時釘第一欄(main.css 的 .tbl-wide):釘住那格跟著卡面色 */
.tbl-wide { --tbl-wide-bg: var(--surface-card); }

/* ── States (hydration stack, studio/base.css › .hydra): the view keeps its box while it waits ── */
.loader_wrap { display: flex; flex-direction: column; gap: var(--space-12); justify-content: center; align-items: center; padding: var(--space-32) 0; color: var(--ink-3); font-size: 13px; }
#box_loading { display: none; }
.hydra.is-wait #box_loading { display: flex; }
.hydra.is-wait > #box_content { visibility: hidden; }

/* ── RWD ── */
@media (max-width: 1300px) {
  #box_main { padding-left: 0; }
  /* 側欄鈕那列已經寫了頁名 */
  .titlewrap h1 { display: none; }
}
@media (max-width: 768px) {
  .pagehead { flex-direction: column; align-items: stretch; }
  .toolbar { width: 100%; }
  .segment { width: 100%; }
  .segment .btn_range { flex: 1; padding: 0; }
  .rv_tabs { gap: var(--space-4); }
  .rv_tab { padding: var(--space-8); }
  .rv_tab .val { font-size: 20px; }
  .chart_box { height: 300px; }
  table.tbl thead th { padding: 0 var(--space-8); }
  table.tbl tbody td { padding: 7px var(--space-8); }
  /* 加權指數是配角欄:窄寬先收它,免得橫捲 */
  table.tbl .col-idx { display: none; }
}
