:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #141a22;
  --muted: #66707e;
  --line: #e2e6ec;
  --accent: #d97a1e;
  --accent-2: #f2b84b;
  --up: #0f9d6b;
  --down: #e0394f;
  --chip: #eef1f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
/* Dark colours: when the system is dark (unless 白天 is forced), or when 黑夜 is forced. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f14;
    --surface: #121821;
    --surface-2: #161d28;
    --ink: #e8edf3;
    --muted: #8590a0;
    --line: #222b38;
    --accent: #f0a24b;
    --accent-2: #ffd27a;
    --up: #2ebd85;
    --down: #f6465d;
    --chip: #1b2330;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0b0f14;
    --surface: #121821;
    --surface-2: #161d28;
    --ink: #e8edf3;
    --muted: #8590a0;
    --line: #222b38;
    --accent: #f0a24b;
    --accent-2: #ffd27a;
    --up: #2ebd85;
    --down: #f6465d;
    --chip: #1b2330;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; justify-content: space-between; align-items: center; height: 52px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.brand-mark { width: 12px; height: 12px; background: var(--accent); transform: rotate(45deg); }
.clock { display: flex; gap: 8px; align-items: center; font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--chip); font-family: inherit; }
.pill:empty { display: none; }
.pill.up { color: var(--up); }
.pill.down { color: var(--down); }
.up { color: var(--up); }
.down { color: var(--down); }

main { padding-top: 16px; padding-bottom: 48px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.notice { padding: 14px 16px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 16px; color: var(--muted); }
h2 { font-size: 17px; margin: 0 0 12px; }
.prose h2:not(:first-child) { margin-top: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; }

.summary-row { display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: flex-end; }
.big { font: 700 40px/1.1 var(--mono); }
.kpis { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0; }
.kpis dt { color: var(--muted); font-size: 12px; }
.kpis dd { margin: 0; font: 600 20px/1.3 var(--mono); }
.equity { height: 220px; margin-top: 12px; }
.monthly { height: 140px; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.lv-rows { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; font-size: 13px; margin-top: 4px; }
.lv-rows span { color: var(--muted); }
.lv-rows b { font: 500 13px var(--mono); text-align: right; }
.impact-High { color: var(--down); font-weight: 600; }
.past { opacity: 0.5; }
.report-h { font-size: 15px; margin: 16px 0 6px; }
.fold { border-top: 1px solid var(--line); padding: 8px 0; }
.fold summary { cursor: pointer; font-weight: 600; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 12px; margin-bottom: 12px; }
.form label { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.form input { font: 14px var(--mono); padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); min-width: 0; }
a { color: var(--accent); }
#report .two-col { margin-top: 4px; }
.flag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--chip); margin-right: 4px; }

.tabs, .tfs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs { margin-bottom: 12px; }
.tabs button, .tfs button, .btn {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--chip);
  border: 1px solid transparent; border-radius: 6px; padding: 4px 12px; cursor: pointer;
}
.tabs button[aria-selected="true"], .tfs button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn { margin-top: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin-bottom: 20px; }
.tile { text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.tile[aria-current="true"] { border-color: var(--accent); }
.tile .t-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .t-id { font-size: 11px; color: var(--muted); }
.tile .t-price { font: 600 14px var(--mono); }
.tile .t-chg { font: 12px var(--mono); }
.tile .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 4px; vertical-align: middle; }

.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: baseline; }
.c-name { font-size: 18px; font-weight: 700; margin-right: 6px; }
.c-price { font: 700 20px var(--mono); }
.chart-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin: 10px 0 6px; align-items: center; }
.check { font-size: 13px; display: flex; gap: 4px; align-items: center; }
.ohlc { min-height: 20px; font-family: var(--mono); }
.chart { height: 400px; }

.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.sig { text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.sig[aria-current="true"] { border-color: var(--accent); }
.sig-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sig-name { font-weight: 600; }
.sig-status { font-size: 12px; color: var(--muted); }
.sig-tp { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sig-tp b { color: var(--up); font-weight: 600; }
.sig-usd { font: 600 16px var(--mono); }
.sig-time { font: 12px var(--mono); color: var(--muted); }

.detail { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail h3 { margin: 0 0 4px; font-size: 16px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 12px; }
.facts { margin: 0; padding-left: 18px; }
.facts li { margin-bottom: 4px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, .levels td { font-family: var(--mono); }

.closed-list { display: grid; gap: 8px; }
.closed { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.closed-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; }
.closed-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 4px 12px; margin-top: 6px; font-size: 13px; }
.closed-levels span { color: var(--muted); font-size: 12px; display: block; }
.closed-levels b { font: 500 13px var(--mono); }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
code { font-family: var(--mono); font-size: 13px; background: var(--chip); padding: 1px 5px; border-radius: 4px; }
.prose ul { padding-left: 20px; margin: 8px 0; }

/* ---- navigation -------------------------------------------------------------- */
.top-row { gap: 16px; }
.nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.nav a {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; display: flex; align-items: center; gap: 6px;
}
.nav a:hover { color: var(--ink); background: var(--chip); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--chip); }
.nav-k { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; line-height: 16px; }
.tabbar { display: none; }
.view[hidden] { display: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- header tools: connection light, sound, theme ------------------------------------ */
.top-tools { display: flex; align-items: center; gap: 10px; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn-ok .conn-dot { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 25%, transparent); }
.conn-slow .conn-dot { background: #d9a400; }
.conn-bad .conn-dot { background: var(--down); }
.conn-bad .conn-text { color: var(--down); }
.icon-btn {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--chip); border: 1px solid transparent;
  border-radius: 8px; height: 32px; min-width: 32px; padding: 0 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.icon-btn:hover { border-color: var(--line); }
.icon-btn .mute-line { display: none; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.icon-btn[aria-pressed="false"] .mute-line { display: inline; }
.theme-icon { font-size: 15px; line-height: 1; }

/* ---- new-signal popup -------------------------------------------------------------------- */
.alert-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; }
.btn-small { margin-top: 0; padding: 2px 10px; font-size: 12px; }
.alert-dialog {
  width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.alert-dialog::backdrop { background: rgba(20, 18, 14, 0.45); }
.alert-dialog[open] { animation: pop 0.18s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .alert-dialog[open] { animation: none; } }
.alert-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.alert-head h2 { margin: 0; }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.alert-sig { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.alert-sig .lv-rows { max-width: 220px; margin-top: 6px; }
.alert-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.alert-actions .btn { margin-top: 0; padding: 6px 14px; }

/* ---- 今日: status strip ----------------------------------------------------------- */
.status { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 20px; padding: 16px 20px; }
.stat { display: grid; gap: 2px; min-width: 0; }
.stat span { color: var(--muted); font-size: 12px; }
.stat b { font: 600 18px/1.3 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#st-open { white-space: normal; }
.stat-link { color: inherit; text-decoration: none; border-left: 1px solid var(--line); padding-left: 16px; }
.stat-link:hover span { color: var(--accent); }
.two-col-wide { display: contents; }
.detail-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.detail-head .btn { margin-top: 0; }
.btn-primary { background: var(--accent); color: var(--surface); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }

/* ---- 今日: personal risk, countdown, alerts --------------------------------------- */
.status-tools {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  border-top: 1px solid var(--line); padding-top: 12px;
}
.risk-input { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.risk-input input {
  width: 96px; font: 600 14px var(--mono); padding: 4px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--ink);
}
.position { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 8px; }
.position-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.position-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 16px; }
.position-grid span { display: block; color: var(--muted); font-size: 12px; }
.position-grid b { font: 600 16px var(--mono); }
.copy-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.copy {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--chip); border: 1px solid transparent;
  border-radius: 6px; padding: 4px 10px; cursor: pointer; display: flex; gap: 6px; align-items: center;
}
.copy b { font: 600 13px var(--mono); }
.copy span { color: var(--muted); }
.copy:hover { border-color: var(--line); }
.copy.copied { border-color: var(--up); }
.copy.copied span::after { content: ' 已複製'; color: var(--up); font-size: 12px; }

/* ---- 工具: suggested risk per signal ----------------------------------------------- */
.sizing-result { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 8px; }
.sizing-result span { display: block; color: var(--muted); font-size: 12px; }
.sizing-result b { font: 700 26px/1.2 var(--mono); }
.sizing-result .btn { margin-top: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- futures mode ---------------------------------------------------------------- */
[hidden] { display: none !important; }
.mode-row { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.futures { margin-top: 10px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 8px; }
.futures-bad { border: 1px solid var(--down); }
#margin-out p { margin: 8px 0; }
#sizing-out td:first-child, #sizing-out th:first-child, #margin-out th { white-space: normal; }
#sizing-out td:first-child { min-width: 9em; }

/* ---- 今日: distance to the next signal ------------------------------------------- */
.next-summary { margin: 0 0 10px; }
.c-note { margin: 4px 0 6px; color: var(--muted); }
td.dist { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.dist-bar { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--chip); position: relative; overflow: hidden; }
.dist-bar::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--accent); border-radius: 3px; }

/* ---- 盤中預警 toast ------------------------------------------------------------------ */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; width: min(360px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--accent); border-radius: 10px;
  padding: 12px 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.toast p { margin: 6px 0; font-size: 14px; }
.toast-head { display: flex; justify-content: space-between; align-items: center; color: var(--accent); }
.toast-x { font: inherit; font-size: 18px; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; }
@media (max-width: 760px) { .toast { bottom: calc(64px + env(safe-area-inset-bottom)); } }

/* ---- 規則健康 --------------------------------------------------------------------------- */
.health-row { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.health-row:first-child { border-top: 0; padding-top: 4px; }
.health-row p { margin: 4px 0 0; font-size: 14px; }
.health-title { display: flex; align-items: center; gap: 8px; }
.light { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; background: var(--muted); flex: none; }
.light-ok { background: var(--up); }
.light-warn { background: #d9a400; }
.light-bad { background: var(--down); }
.light-wait { background: transparent; border: 2px solid var(--muted); }
.health-notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 16px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px;
}
.health-notice .light { margin-top: 0; }
.nav a.has-alert::after, .tabbar a.has-alert::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--down); margin-left: 4px; display: inline-block; }

/* ---- 看盤: watchlist beside the chart ---------------------------------------------- */
.market { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.watch { position: sticky; top: 68px; max-height: calc(100vh - 84px); overflow-y: auto; padding: 16px; }
.watch .tabs { gap: 4px; }
.watch .tabs button { padding: 3px 9px; font-size: 12px; }
.watch .tiles { grid-template-columns: minmax(0, 1fr); gap: 2px; margin-bottom: 0; }
.watch .tile {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name price" "id chg";
  column-gap: 8px; border-color: transparent; padding: 6px 8px;
}
.watch .tile:hover { background: var(--chip); }
.watch .tile[aria-current="true"] { border-color: var(--accent); background: var(--chip); }
.watch .t-name { grid-area: name; }
.watch .t-id { grid-area: id; }
.watch .t-price { grid-area: price; text-align: right; }
.watch .t-chg { grid-area: chg; text-align: right; }
.chart { height: 460px; }

/* ---- 日曆: released events hidden until asked for ------------------------------------ */
#t-calendar:not(.show-past) tr.past { display: none; }

@media (max-width: 760px) {
  .two-col, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .big { font-size: 32px; }
  .chart { height: 320px; }
  .card { padding: 16px; }

  /* bottom tab bar instead of the header links */
  .nav { display: none; }
  .clock > .muted, .clock > .pill, .theme-label, .conn-text { display: none; }
  .top-tools { gap: 8px; }
  main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    text-align: center; padding: 12px 0; font-size: 13px; font-weight: 600;
    color: var(--muted); text-decoration: none; border-top: 2px solid transparent;
  }
  .tabbar a[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }

  .status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-link { border-left: 0; padding-left: 0; }

  /* watchlist becomes a swipeable strip above the chart */
  .market { grid-template-columns: minmax(0, 1fr); }
  .watch { position: static; max-height: none; overflow: visible; }
  .watch .tabs, .tfs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .watch .tabs button, .tfs button { flex: none; white-space: nowrap; }
  .watch .tiles { grid-auto-flow: column; grid-auto-columns: minmax(150px, 46%); grid-template-columns: none; overflow-x: auto; gap: 6px; scroll-snap-type: x proximity; }
  .watch .tile {
    border-color: var(--line); scroll-snap-align: start;
    /* name and change on top, the price on its own full line below */
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name chg" "price price";
  }
  .watch .t-id { display: none; }
  .watch .t-price { text-align: left; }
}
.lab-flag { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-weight: 600; }
#t-lab td:nth-child(2), #t-lab td:nth-child(3), #t-lab td:nth-child(4), #t-lab td:nth-child(8), #t-lab th:nth-child(2), #t-lab th:nth-child(3), #t-lab th:nth-child(4), #t-lab th:nth-child(8) { text-align: left; }
.row-core td { background: color-mix(in srgb, var(--up, #16a34a) 7%, transparent); }
.chart-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; }
.zoom { display: flex; gap: 4px; }
.zoom .btn { min-width: 32px; }
.off-levels { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; }
.off-chip { font: inherit; font-size: 12px; padding: 2px 8px; border-radius: 999px; cursor: pointer; background: transparent; color: var(--ink);
  border: 1px solid var(--c, var(--line)); }
.off-chip b { font-family: var(--mono); font-weight: 600; }
.chart { touch-action: pan-y; cursor: crosshair; }
@media (max-width: 640px) {
  .off-levels { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .off-levels::-webkit-scrollbar { display: none; }
  .off-chip { white-space: nowrap; flex: none; }
  .off-levels > .muted { white-space: nowrap; flex: none; }
  .c-note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
  .c-note.open { display: block; }
}
/* Production: secondary notes stay in the DOM for the scripts but are not shown. */
#radar-note, #c-source, #sum-note, #pattern-note, #recent-note, #sum-span { display: none !important; }

/* ==== Visual design (production) ======================================================= */
body {
  font-family: "Inter", -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  background:
    radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    radial-gradient(900px 400px at -10% 0%, color-mix(in srgb, var(--up) 7%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
:root { --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace; }
.top { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); }
.brand { font-size: 18px; letter-spacing: .06em; }
.brand-mark { width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 55%, transparent); }

.card { border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); border-color: var(--line); position: relative; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card > h2::before, .card > .card-head > h2::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: linear-gradient(var(--accent-2), var(--accent)); flex: none; }
.muted.small { font-size: 12px; }

/* tables */
table { font-size: 13.5px; }
thead th { text-transform: none; letter-spacing: .03em; font-size: 11.5px; background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
thead th:first-child { border-top-left-radius: 8px; }
thead th:last-child { border-top-right-radius: 8px; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
th, td { padding: 8px 12px; }
td.num { font-variant-numeric: tabular-nums; }
.table-wrap { border-radius: 10px; }
.row-core td { background: color-mix(in srgb, var(--up) 8%, transparent); }
.row-core td:first-child { box-shadow: inset 3px 0 0 var(--up); }

/* buttons and chips */
.tabs button, .tfs button, .btn { border-radius: 8px; padding: 5px 12px; transition: background .15s, border-color .15s, color .15s, transform .05s; }
.tabs button:hover, .tfs button:hover, .btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.btn:active, .tfs button:active { transform: translateY(1px); }
.tabs button[aria-selected="true"], .tfs button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.btn-primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #1a1205; border: 0; font-weight: 600; }
.pill { font-weight: 600; letter-spacing: .02em; }
.pill.up { background: color-mix(in srgb, var(--up) 15%, transparent); }
.pill.down { background: color-mix(in srgb, var(--down) 15%, transparent); }
.flag { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.light { box-shadow: 0 0 8px currentColor; }

/* tiles, signal cards */
.tile, .sig { border-radius: 10px; background: var(--surface-2); transition: border-color .15s, transform .15s, box-shadow .15s; }
.tile:hover, .sig:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.tile[aria-current="true"], .sig[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.sig-usd, .tile .t-price, .c-price, .big, .kpis dd { font-variant-numeric: tabular-nums; }
.c-price { font-size: 24px; }
.c-name { font-size: 20px; }

/* chart frame */
.chart { border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.off-chip { background: color-mix(in srgb, var(--c) 10%, transparent); }

/* status strip numbers */
.stat b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.next-summary { font-size: 14px; }


/* ==== Market brief tabs ==== */
.b-tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.b-tabs::-webkit-scrollbar { display: none; }
.b-tabs button { flex: 1 0 auto; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.b-tabs button:hover { color: var(--ink); }
.b-tabs button[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .18), inset 0 -2px 0 var(--accent); }
.b-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.b-kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; position: relative; }
.b-kpi span { font-size: 11.5px; color: var(--muted); }
.b-kpi b { font: 700 18px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.b-kpi small { font: 12px var(--mono); }
.b-gauge { display: block; height: 5px; border-radius: 3px; margin-top: 6px; position: relative; background: linear-gradient(90deg, var(--down), var(--accent-2) 50%, var(--up)); }
.b-gauge i { position: absolute; top: -3px; width: 3px; height: 11px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); }
.b-heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-bottom: 12px; }
.b-cell { font: inherit; text-align: left; cursor: pointer; border: 1px solid color-mix(in srgb, var(--c) calc(var(--a) * 60%), var(--line)); border-radius: 8px; padding: 8px 10px; color: var(--ink);
  background: color-mix(in srgb, var(--c) calc(var(--a) * 35%), var(--surface-2)); display: grid; gap: 2px; transition: transform .12s; }
.b-cell:hover { transform: translateY(-1px); }
.b-cell span { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-cell b { font: 600 13px var(--mono); }
.b-lines { margin: 0 0 12px; padding-left: 18px; font-size: 13.5px; }
.b-news { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.b-news li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }
.b-news a { color: var(--ink); text-decoration: none; font-weight: 500; }
.b-news a:hover { color: var(--accent); }
.b-news .muted { margin-left: 6px; }
.b-news .flag { margin-left: 4px; }
td.warn, .warn { color: var(--accent); }
#brief td.txt, #brief th.txt { text-align: left; }
#brief td.num, #brief th.num { text-align: right; }
/* Brand: 北辰 Polaris — a four-point star */
.brand-mark { width: 18px; height: 18px; border-radius: 0; transform: none; box-shadow: none;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent)); }
.brand-en { font: 600 10px/1 var(--mono); letter-spacing: .22em; color: var(--muted); margin-left: 2px; align-self: center; }
@media (max-width: 640px) { .brand-en { display: none; } }
.stat small { display: block; font-size: 11.5px; margin-top: 2px; }
.st-rule { grid-column: 1 / -1; margin: 6px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); }

/* ==== 今日 category cards ==== */
.groups { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
.group { font: inherit; color: var(--ink); text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  position: relative; overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s; min-width: 0; }
.group:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.g-icon { width: 42px; height: 42px; flex: none; border-radius: 11px; display: grid; place-items: center; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line); transition: background .15s, color .15s; }
.g-icon svg { width: 20px; height: 20px; }
.g-text { display: grid; gap: 2px; min-width: 0; }
.g-text b { font-size: 15px; font-weight: 650; white-space: nowrap; }
.g-text small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group[aria-pressed="true"] { border-color: color-mix(in srgb, var(--up) 55%, var(--line));
  background: linear-gradient(160deg, color-mix(in srgb, var(--up) 10%, var(--surface)), var(--surface) 70%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--up) 25%, transparent), 0 10px 30px color-mix(in srgb, var(--up) 12%, transparent); }
.group[aria-pressed="true"] .g-icon { color: #0b0f14; border-color: transparent; background: linear-gradient(135deg, var(--up), #8b7cf6); }
.group[aria-pressed="true"] .g-text small { color: var(--up); }
.group[aria-pressed="true"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--up), #8b7cf6); }
@media (max-width: 1100px) { .groups { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .groups { display: flex; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; padding: 2px 0 6px; }
  .groups::-webkit-scrollbar { display: none; }
  .group { flex: 0 0 auto; width: 168px; padding: 12px; scroll-snap-align: start; }
  .g-icon { width: 36px; height: 36px; }
}
@media (min-width: 1101px) {
  .group { padding: 10px; gap: 8px; }
  .g-icon { width: 34px; height: 34px; border-radius: 9px; }
  .g-icon svg { width: 17px; height: 17px; }
  .g-text b { font-size: 14px; }
  .g-text small { font-size: 11.5px; }
  .group[aria-pressed="true"]::after { left: 10px; right: 10px; }
}

/* ==== Research log ==== */
.rl-intro { margin: 0 0 10px; }
.flag.up { color: var(--up); background: color-mix(in srgb, var(--up) 14%, transparent); }
.flag.down { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.site-foot { display: grid; gap: 4px; margin: 8px 0 24px; padding: 16px 4px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.site-foot span:first-child { font-weight: 650; color: var(--ink); letter-spacing: .06em; }
@media (max-width: 640px) { .site-foot { margin-bottom: 80px; } }

/* Long first-column text wraps instead of forcing a wide sideways scroll on phones. */
#research-log td:first-child, #t-score td:first-child, #lab-board td:first-child { white-space: normal; min-width: 7em; }
.sig-plan { opacity: .85; }
table.levels tr.plan-head th { font-size: 12px; font-weight: 500; color: var(--muted); padding-top: 10px; border-top: 1px dashed var(--line, rgba(127,127,127,.3)); text-align: left; }
table.levels tr.plan-row th { font-weight: 500; }
tr.row-plan td:first-child b { font-weight: 500; color: var(--muted); }

/* ---- member accounts ---- */
.acct-btn { display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 10px; font-size: 13px; }
.acct-btn .acct-label { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn.signed-in { color: var(--accent); }
@media (max-width: 640px) { .acct-btn .acct-label { display: none; } .acct-btn { padding: 0; width: 34px; justify-content: center; } }
.acct-dialog { width: min(400px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.acct-dialog::backdrop { background: rgba(20, 18, 14, 0.45); }
.acct-dialog h2 { margin: 0 0 16px; font-size: 20px; }
.acct-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.acct-field { display: block; margin-bottom: 12px; }
.acct-field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.acct-field input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font: inherit; }
.acct-field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.acct-dialog form .btn { margin-top: 4px; }
.acct-submit { width: 100%; padding: 10px; }
.acct-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; box-sizing: border-box; padding: 10px; margin: 0; text-decoration: none; color: var(--ink); }
.acct-or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 12px; }
.acct-or::before, .acct-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.acct-switch { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.linklike { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0 2px; }
.acct-note { padding: 8px 12px; border-radius: 10px; font-size: 13px; margin: 0 0 14px; }
.acct-ok { background: color-mix(in srgb, var(--up) 12%, transparent); color: var(--up); }
.acct-bad { background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.acct-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
.acct-info dt { color: var(--muted); }
.acct-info dd { margin: 0; overflow-wrap: anywhere; }
.acct-more { margin-top: 12px; font-size: 14px; }
.acct-more summary { cursor: pointer; color: var(--accent); }
.acct-more form { margin-top: 10px; }
.acct-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
.acct-dialog a.btn-primary { display: inline-block; text-decoration: none; margin-right: 8px; }
.acct-code { font: 600 24px var(--mono); letter-spacing: .4em; text-align: center; }
