/* Investment Assistant. Mobile first, system fonts only (LAN, no CDN).
   Colour follows the Taiwanese market convention: up is red, down is green. */
:root {
  --ink: #17233b;
  --paper: #f4f6f5;
  --surface: #ffffff;
  --rule: #d8ddd9;
  --muted: #64707d;
  --link: #1f4e8c;
  --up: #c62a2f;
  --down: #13784b;
  --warn: #a85b00;
  --up-soft: #f6dcdc;
  --down-soft: #d6ece1;
  --flat-soft: #e3e7e4;
  --warn-soft: #f5e4cc;
  --serif: "Iowan Old Style", "Songti TC", "Noto Serif TC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4e8ee;
    --paper: #12161c;
    --surface: #1a2029;
    --rule: #2c3440;
    --muted: #96a0ad;
    --link: #8db4ec;
    --up: #f0676b;
    --down: #4cc08a;
    --warn: #e8a54a;
    --up-soft: #4a2427;
    --down-soft: #1d3d2f;
    --flat-soft: #2a313b;
    --warn-soft: #463620;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.6 var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px;
}
code { font: 0.85em var(--mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar: brand, page links (scroll sideways on a phone), ticker search, logout. */
.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand find logout" "nav nav nav";
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.6rem 1rem 0;
  background: #17233b;
  color: #eef1f5;
}
.brand { grid-area: brand; font: 600 1.15rem/1 var(--serif); color: #fff; text-decoration: none; letter-spacing: 0.02em; }
.top nav { grid-area: nav; display: flex; gap: 1.1rem; overflow-x: auto; scrollbar-width: none; padding: 0.35rem 0 0.55rem; }
.top nav a { color: #c9d1dc; text-decoration: none; white-space: nowrap; padding-bottom: 0.2rem; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"] { color: #fff; border-bottom-color: #fff; }
.find { grid-area: find; }
.find input {
  width: 100%; max-width: 16rem; padding: 0.35rem 0.6rem; font: inherit; font-size: 0.9rem;
  color: #fff; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 0.4rem;
}
.find input::placeholder { color: #a9b3c1; }
.logout { grid-area: logout; }
.logout button { font: inherit; font-size: 0.85rem; color: #c9d1dc; background: none; border: 0; padding: 0.3rem 0; cursor: pointer; }
@media (min-width: 52rem) {
  .top { grid-template-columns: auto 1fr auto auto; grid-template-areas: "brand nav find logout"; padding: 0.55rem 1.5rem; }
  .top nav { padding: 0; }
  .top nav a { padding-bottom: 0.15rem; }
}

/* A container: page layouts follow the width the docked chat leaves, not the window (IA-053).
   38rem and 49rem are the window's 40rem and 52rem less main's padding at those widths. */
main { max-width: 64rem; margin: 0 auto; padding: 1.25rem 1rem 2rem; container-type: inline-size; }
@media (min-width: 52rem) { main { padding: 2rem 1.5rem 3rem; } }
h1 { font: 600 1.6rem/1.25 var(--serif); margin: 0 0 1.25rem; }
h2 { font: 600 1.15rem/1.3 var(--serif); margin: 2.25rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
section:first-of-type h2 { margin-top: 1.5rem; }

.muted, .meta { color: var(--muted); }
.lede { color: var(--muted); max-width: 42rem; }
.empty { color: var(--muted); }
.notice { padding: 0.75rem 1rem; background: var(--surface); border-left: 3px solid var(--warn); }
/* IA-036: a first fetch in progress */
.notice.loading { display: flex; align-items: center; gap: 0.6rem; }
.notice.loading::before { content: ""; flex: none; width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--rule); border-top-color: var(--warn); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .notice.loading::before { animation-duration: 3s; } }
.more { font-size: 0.9rem; margin: 0.5rem 0 0; }
.count { color: var(--muted); font-size: 0.9rem; }
.up { color: var(--up); }
.down { color: var(--down); }

/* The index strip above the overview (IA-044). */
.indices { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0 0 1rem; padding: 0; font-size: 0.9rem; }
.indices .label { color: var(--muted); }
.indices .value { font-weight: 600; }
.indices .asof { color: var(--muted); font-size: 0.8rem; }

/* Overview: the total, today's move, and the weight strip. */
.overview { padding-bottom: 0.5rem; }
.eyebrow { margin: 0; color: var(--muted); font-size: 0.9rem; }
.eyebrow .asof { margin-left: 0.6rem; }
.total { margin: 0.1rem 0 0; font: 600 clamp(2.2rem, 8vw, 3.4rem)/1.1 var(--serif); letter-spacing: -0.01em; }
.total .ccy { font-size: 0.45em; margin-right: 0.3rem; color: var(--muted); font-weight: 400; vertical-align: 0.6em; }
.today { margin: 0.35rem 0 1rem; font-size: 1.05rem; font-weight: 600; }
.today .muted { font-weight: 400; }
.split { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0 0 1.25rem; }
.split dt { color: var(--muted); font-size: 0.8rem; }
.split dd { margin: 0; font-size: 1.05rem; }
.strip {
  display: flex; gap: 2px; height: 3.25rem; margin-top: 0.5rem;
  border-radius: 0.35rem; overflow: hidden;
}
.seg {
  min-width: 3px; display: flex; flex-direction: column; justify-content: center; padding: 0 0.4rem;
  text-decoration: none; color: var(--ink); background: var(--flat-soft); overflow: hidden; white-space: nowrap;
}
.seg.up { background: var(--up-soft); color: var(--ink); }
.seg.down { background: var(--down-soft); color: var(--ink); }
.seg.up.strong { background: var(--up); color: #fff; }
.seg.down.strong { background: var(--down); color: #fff; }
.seg .sym { font-weight: 600; font-size: 0.85rem; line-height: 1.2; }
.seg .w { font-size: 0.75rem; opacity: 0.8; }
.seg:hover, .seg:focus-visible { filter: brightness(0.94); }
.legend { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.8rem; }

/* Feed of signals: a severity bar on the left, the ticker, what happened, when. */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.15rem 0.75rem; align-items: baseline;
  padding: 0.55rem 0 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); border-left: 3px solid var(--rule);
}
.feed li.sev-high { border-left-color: var(--warn); }
.feed li.sev-medium { border-left-color: #c9a46a; }
.feed li.resolved { opacity: 0.6; }
.feed .tick { font-weight: 600; text-decoration: none; }
.feed .what { min-width: 0; }
.feed time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.feed li:not(:has(.tick)) { grid-template-columns: 1fr auto; }
.feed li:has(.tick) { grid-template-columns: 4.5rem 1fr auto; }

.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 0.3rem 0; }
.date { display: inline-block; min-width: 3.5rem; color: var(--muted); }

/* Tables: numbers right-aligned, hairline rows, sticky first column on a phone. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { padding: 0.5rem 0.6rem; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
thead th { color: var(--muted); font-weight: 400; font-size: 0.8rem; white-space: nowrap; }
td.n, th.n { text-align: right; white-space: nowrap; }
.positions tbody th { font-weight: 600; white-space: nowrap; }
.positions tbody th a { text-decoration: none; }
.positions .name { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.positions tbody th { position: sticky; left: 0; background: var(--paper); }
.spark-col { width: 100px; }
.spark { display: block; }
.spark polyline { fill: none; stroke-width: 1.5; stroke: var(--muted); }
.spark.up polyline { stroke: var(--up); }
.spark.down polyline { stroke: var(--down); }
.compact { max-width: 36rem; }
.prov { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.conf { display: inline-block; min-width: 1.4rem; margin-right: 0.35rem; text-align: center; border-radius: 0.25rem; font-size: 0.75rem; color: var(--surface); }
.conf-high { background: var(--down); }
.conf-medium { background: #8a96a3; }
.conf-low { background: var(--warn); }

/* Docs and claims. */
.docs { list-style: none; margin: 0; padding: 0; }
.docs li { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); }
.docs a { text-decoration: none; color: var(--ink); }
.docs a:hover { color: var(--link); text-decoration: underline; }
.docs .meta { display: block; font-size: 0.8rem; }
.claims { list-style: none; margin: 0; padding: 0; }
.claims li { padding: 0.75rem 0 0.75rem 0.9rem; border-left: 3px solid var(--rule); margin-bottom: 0.75rem; background: var(--surface); }
.claims li.stance-bullish, .claims li.stance-bullish-but-cautious { border-left-color: var(--up); }
.claims li.stance-bearish { border-left-color: var(--down); }
.claims p { margin: 0.2rem 0.75rem 0.2rem 0; }
.claims .who { font-size: 0.85rem; color: var(--muted); }
.claims .who strong { color: var(--ink); }
.claims .tick { font-weight: 600; margin-left: 0.4rem; }
.badge { display: inline-block; margin: 0 0.4rem; padding: 0 0.4rem; border: 1px solid var(--rule); border-radius: 0.25rem; font-size: 0.75rem; color: var(--ink); }
.theme { margin-left: 0.4rem; font-size: 0.8rem; }
.falsifier { font-size: 0.85rem; color: var(--muted); }
.detail { font-size: 0.9rem; }

.pair { display: grid; gap: 0 2.5rem; }
@container (min-width: 49rem) { .pair { grid-template-columns: 3fr 2fr; } }
.facts { margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--rule); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

/* Ticker page. */
.ticker-head { display: grid; grid-template-columns: 1fr auto; gap: 0 1rem; align-items: end; margin-bottom: 1rem; }
.ticker-head h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.6rem; }
.ticker-head .sym { font-size: 2.1rem; letter-spacing: 0.01em; }
.ticker-head h1 .name { font: 400 1rem var(--sans); color: var(--muted); }
.ticker-head .mkt { margin: 0; color: var(--muted); font-size: 0.85rem; text-align: right; }
.ticker-head .watch { grid-column: 1 / -1; margin: 0.4rem 0 0; }
.ticker-head .watch button { padding: 0.25rem 0.75rem; font-size: 0.85rem; }
.quote { grid-column: 1 / -1; margin: 0.25rem 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.75rem; }
.quote .px { font: 600 1.6rem var(--serif); }
.quote .chg { font-weight: 600; }
.quote .muted { font-size: 0.85rem; }
.quote.live { margin-top: 0; }
.quote.live .px { font-size: 1.15rem; }
td .live { display: block; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
figure.price { margin: 0 0 0.75rem; }
figure.price figcaption { color: var(--muted); font-size: 0.8rem; }
/* IA-034: the candlestick chart replaces the SVG once chart.js runs */
.candles .plot { height: 22rem; }
.candles .legend-line { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.chart-toggles { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0 0.25rem; }
.chart-toggles button { font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--muted); }
.chart-toggles button::before { content: ""; display: inline-block; width: 0.6rem; height: 0.15rem; margin-right: 0.3rem; vertical-align: middle; background: var(--swatch); }
.chart-toggles button[aria-pressed="true"] { color: var(--ink); border-color: var(--swatch); }
@media (max-width: 40rem) { .candles .plot { height: 17rem; } }
.chart { width: 100%; height: auto; display: block; }
.chart .area { fill: var(--flat-soft); }
.chart.up .area { fill: var(--up-soft); }
.chart.down .area { fill: var(--down-soft); }
.chart .close { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.chart .ma { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 3; }
.chart .baseline { stroke: var(--rule); }
.chart .axis { fill: var(--muted); font: 11px var(--sans); }
.chart .axis.last { fill: var(--ink); font-weight: 600; }
.stats dd .up, .stats dd .down { font-size: 0.85rem; }

/* Search, filters, pager, chips. */
.search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.search label { width: 100%; color: var(--muted); font-size: 0.85rem; }
.search input { flex: 1; min-width: 12rem; padding: 0.55rem 0.7rem; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 0.4rem; }
button { font: inherit; padding: 0.5rem 1rem; color: var(--ink); background: var(--surface); border: 1px solid var(--muted); border-radius: 0.4rem; cursor: pointer; }
.filters { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 0.25rem; margin-bottom: 1rem; }
.filters a { flex: none; padding: 0.3rem 0.7rem; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; color: var(--ink); font-size: 0.85rem; background: var(--surface); }
.filters a span { margin-left: 0.35rem; color: var(--muted); }
.filters a[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.filters a[aria-current="page"] span { color: var(--paper); opacity: 0.7; }
.pager { display: flex; justify-content: space-between; margin-top: 1rem; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips a { display: inline-flex; gap: 0.4rem; align-items: baseline; padding: 0.35rem 0.7rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 0.4rem; text-decoration: none; color: var(--ink); font-weight: 600; }
.chips a span { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

/* Holdings: accounts, reconciliations. */
.accounts { padding: 0.75rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.recs { list-style: none; margin: 0; padding: 0; }
.recs li { padding: 0.75rem 0; border-bottom: 1px solid var(--rule); }
.recs p { margin: 0.15rem 0; }
.recs details { margin-top: 0.4rem; }
.recs summary { cursor: pointer; color: var(--link); font-size: 0.9rem; }
.explain { display: grid; gap: 0.5rem; max-width: 30rem; margin-top: 0.5rem; }
.explain label { display: grid; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.explain input { padding: 0.45rem 0.6rem; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 0.4rem; }
.explain button { justify-self: start; }

/* A document from the vault. */
.doc-head .meta { margin: 0 0 0.25rem; font-size: 0.85rem; }
.doc-head h1 { margin-bottom: 1rem; }
.prose { max-width: 42rem; line-height: 1.75; }
.prose h2, .prose h3, .prose h4 { font-family: var(--serif); }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.05rem; margin-top: 1.75rem; }
.prose table { font-size: 0.85rem; margin: 0.75rem 0; }
.prose blockquote { margin: 1rem 0; padding: 0.25rem 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
.prose pre { overflow-x: auto; padding: 0.75rem; background: var(--surface); border: 1px solid var(--rule); font-size: 0.85rem; }
.prose li { margin: 0.2rem 0; }
.doc-claims { max-width: 42rem; padding: 0.75rem 1rem; margin-bottom: 1.5rem; background: var(--surface); border-left: 3px solid var(--link); }
.doc-claims h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.source-path { color: var(--muted); font-size: 0.8rem; margin-top: 2rem; }

/* Login (no session yet). */
body.bare main { max-width: 24rem; padding-top: 4rem; }
.login { display: flex; flex-direction: column; gap: 0.75rem; }
.login input { padding: 0.6rem; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 0.4rem; }
.error { color: var(--up); margin: 0; }
.placeholder { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Thesis (S9): the statement reads as the page's argument; George's actions sit under it. */
.thesis .statement { font-family: var(--serif); font-size: 1.1rem; line-height: 1.7; margin: 0.5rem 0 1rem; max-width: 40rem; }
.thesis .statement p { margin: 0 0 0.6rem; }
.thesis .statement ul { margin: 0 0 0.6rem; padding-left: 1.2rem; }
.thesis .statement li { margin: 0.25rem 0; }
/* IA-017: a source reads as a small number; the 出處 list under the thesis says what it is. */
sup.note { font-family: var(--sans); font-size: 0.7em; line-height: 0; margin: 0 0.1em; }
sup.note a { text-decoration: none; padding: 0 0.15em; }
sup.note a::before { content: "["; }
sup.note a::after { content: "]"; }
.sources { margin: 0.25rem 0 1rem; padding-left: 1.6rem; font-size: 0.85rem; max-width: 40rem; }
.sources li { margin: 0.25rem 0; }
.sources li:target, .feed li:target { background: var(--flat-soft); }
.thesis .who { font-size: 0.85rem; color: var(--muted); margin: 0; }
.badge.status-draft { border-color: var(--warn); color: var(--warn); }
.badge.status-holding { border-color: var(--down); color: var(--down); }
.badge.status-challenged, .badge.status-broken { border-color: var(--up); color: var(--up); }
/* IA-018: the card is the page's first answer: the thesis in a sentence, then each falsifier as
   a numbered row with its distance to the threshold; the price chart's lines use the same numbers. */
.thesis.card { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--rule); border-radius: 0.5rem; padding: 0.9rem 1rem 0.6rem; margin-bottom: 1.25rem; }
.thesis.card.status-draft { border-left-color: var(--warn); }
.thesis.card.status-holding { border-left-color: var(--down); }
.thesis.card.status-challenged, .thesis.card.status-broken { border-left-color: var(--up); }
.thesis.card h2 { margin-top: 0; }
.thesis .proposal, .thesis .recommendation { border: 1px dashed var(--warn); border-radius: 0.5rem; padding: 0.6rem 0.8rem; margin: 0.5rem 0 0.75rem; }
.thesis .proposal h3, .thesis .recommendation h3 { margin-top: 0; }
.thesis .headline { font: 1.25rem/1.55 var(--serif); margin: 0.5rem 0 0.75rem; max-width: 40rem; }
.falsifiers { list-style: none; counter-reset: falsifier; margin: 0.25rem 0 0.75rem; padding: 0; }
.falsifiers li { counter-increment: falsifier; position: relative; padding: 0.5rem 0 0.5rem 4.2rem; border-top: 1px solid var(--rule); }
.falsifiers li::before { content: "反證 " counter(falsifier); position: absolute; left: 0; top: 0.55rem; font-size: 0.8rem; color: var(--muted); }
.falsifiers li.triggered::before, .falsifiers li.hit::before { color: var(--up); font-weight: 600; }
.falsifiers p { margin: 0; }
.falsifiers .rule { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.75rem; font-size: 0.95rem; }
.falsifiers .now { font-variant-numeric: tabular-nums; }
.falsifiers .dist { color: var(--muted); font-size: 0.85rem; }
.falsifiers li.hit .dist { color: var(--up); font-weight: 600; }
.falsifiers .condition { font-size: 0.82rem; color: var(--muted); max-width: 40rem; }
.gauge { display: block; max-width: 100%; margin: 0.25rem 0; }
.gauge .track { fill: var(--flat-soft); }
.gauge .zone { fill: var(--warn-soft); }
.gauge.hit .zone { fill: var(--up-soft); }
.gauge .limit { stroke: var(--warn); stroke-width: 2; }
.gauge .now { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.gauge.hit .now { fill: var(--up); }
.chart .level { stroke: var(--warn); stroke-width: 1.2; }
.chart .level-label { fill: var(--warn); font: 600 11px var(--sans); }
.chart .since { stroke: var(--muted); stroke-width: 1; }
.chart .signal { fill: var(--warn); stroke: var(--paper); stroke-width: 2; }
.chart .col { fill: var(--link); opacity: 0.75; }
.chart .zero { stroke: var(--rule); }
.chart .dot { fill: var(--ink); stroke: var(--paper); stroke-width: 1.5; }
.chart .lane { stroke: var(--rule); }
.chart .name { fill: var(--ink); font-size: 12px; }
.stance, .key { stroke: var(--paper); stroke-width: 2; }
.stance.bullish, .key.bullish { fill: var(--up); background: var(--up); }
.stance.bullish-but-cautious, .key.bullish-but-cautious { fill: var(--up-soft); stroke: var(--up); stroke-width: 1.5; background: var(--up-soft); border: 1.5px solid var(--up); }
.stance.neutral, .stance.cautious, .key.neutral { fill: var(--muted); background: var(--muted); }
.stance.bearish, .key.bearish { fill: var(--down); background: var(--down); }
.stance.mention, .key.mention { fill: none; stroke: var(--muted); stroke-width: 1.5; border: 1.5px solid var(--muted); }
figure.small { margin: 0 0 1rem; }
figure.small figcaption { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.5rem; margin-top: 0.35rem; }
.key { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; box-sizing: border-box; }
.numbers-table summary { cursor: pointer; color: var(--link); font-size: 0.9rem; margin: 0.25rem 0; }
.thesis .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.thesis .actions form { display: flex; gap: 0.4rem; }
.thesis input, .thesis select, .thesis textarea { padding: 0.45rem 0.6rem; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 0.4rem; min-width: 0; }
.rewrite form { display: grid; gap: 0.6rem; max-width: 40rem; margin-top: 0.5rem; }
.rewrite label { display: grid; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.rewrite fieldset { border: 1px solid var(--rule); border-radius: 0.4rem; display: grid; gap: 0.5rem; }
.rewrite legend { font-size: 0.85rem; color: var(--muted); }
.falsifier-row { display: grid; grid-template-columns: 1fr; gap: 0.3rem; }
@container (min-width: 38rem) { .falsifier-row { grid-template-columns: 3fr 5rem 2fr 4rem 5rem; } }
.rewrite button { justify-self: start; }
.history { font-size: 0.85rem; color: var(--muted); padding-left: 1.2rem; }
.theses { list-style: none; margin: 0; padding: 0; }
.theses li { display: grid; grid-template-columns: 1fr; gap: 0.3rem 1.25rem; padding: 0.75rem 0; border-bottom: 1px solid var(--rule); }
.theses li.hit { box-shadow: inset 3px 0 0 var(--up); padding-left: 0.6rem; }
.theses p { margin: 0; }
.theses .headline { font-size: 0.9rem; color: var(--muted); }
.theses .trend, .theses .near { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.5rem; font-size: 0.8rem; }
.theses .near .gauge { margin: 0; }
.theses .dist { color: var(--muted); }
@container (min-width: 49rem) {
  .theses li { grid-template-columns: minmax(0, 1fr) 13rem 15rem; align-items: center; }
  .theses .name, .theses .headline { grid-column: 1; }
  .theses .trend { grid-column: 2; grid-row: 1 / span 2; }
  .theses .near { grid-column: 3; grid-row: 1 / span 2; }
}

/* Tracking (S10): what needs George first on the home page; assessments under the thesis. */
.attention { margin-bottom: 1rem; }
.attention .notice { margin: 0.4rem 0; }
.assessments { list-style: none; margin: 0.25rem 0 1rem; padding: 0; }
.assessments li { padding: 0.5rem 0 0.5rem 0.75rem; border-left: 3px solid var(--rule); margin-bottom: 0.5rem; }
.assessments li.verdict-challenge { border-left-color: var(--up); }
.assessments li.verdict-support { border-left-color: var(--down); }
.assessments p { margin: 0.2rem 0; font-size: 0.8rem; }
.assessments blockquote { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.85rem; }

/* /signals (IA-020 M3): actions under a signal; the interval form on one line. */
.signals .actions { display: flex; gap: 0.5rem; margin-top: 0.35rem; }
.signals .actions form { margin: 0; }
.signals .actions button, td form button { padding: 0.2rem 0.6rem; font-size: 0.85rem; }
td form { display: inline; margin: 0; }
.interval { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* 研究 (IA-021): the ask form on a ticker page, the report page. */
.research-ask { display: grid; gap: 0.5rem; max-width: 40rem; }
.research-ask textarea { font: inherit; padding: 0.5rem; border: 1px solid var(--rule); border-radius: 0.4rem; }
.research-ask fieldset { border: 0; padding: 0; display: flex; gap: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.filters a[aria-current] { font-weight: 600; }
.question { font-weight: 600; }
.report { max-width: 46rem; }
/* IA-049: a long report is read by section: the headings carry the page, a holding folds. */
.report h3 { font: 600 1.2rem/1.3 var(--serif); margin: 2rem 0 0.6rem; padding-top: 1rem; border-top: 1px solid var(--rule); scroll-margin-top: 2.75rem; }
.report > h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.report h4 { font-size: 1rem; margin: 1.25rem 0 0.4rem; }
.report-toc { position: sticky; top: 0; z-index: 5; display: flex; gap: 1rem; max-width: 46rem; margin-bottom: 1rem; padding: 0.4rem 0; overflow-x: auto; scrollbar-width: none; font-size: 0.9rem; white-space: nowrap; background: var(--paper); border-bottom: 1px solid var(--rule); }
.report-toc a { text-decoration: none; }
.holding { border-bottom: 1px solid var(--rule); padding: 0.5rem 0; }
.holding summary { cursor: pointer; }
.holding summary h4 { display: inline; margin: 0; }
.holding > ul { margin: 0.5rem 0 0.25rem; }
summary h2 { display: inline; }
/* IA-049: each ticker's close against its levels, closest to acting on first. Stacked on a
   phone, one line from 40rem. The scale is the ticker's own: positions do not compare across rows. */
.ladders { list-style: none; margin: 0.5rem 0; padding: 0; }
.ladder { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.15rem 0.5rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid var(--rule); }
.ladder-symbol { font-weight: 600; text-decoration: none; }
.ladder-near { grid-column: 1 / -1; font-size: 0.85rem; }
.ladder-track { grid-column: 1 / -1; grid-row: 2; position: relative; display: block; height: 1rem; }
.ladder-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--rule); }
.ladder-tick { position: absolute; top: 20%; height: 60%; width: 2px; margin-left: -1px; background: var(--muted); }
.ladder-tick-exit { top: 0; height: 100%; }
.ladder-tick-hit, .ladder-tick-near { background: var(--warn); }
.ladder-dot { position: absolute; top: 50%; width: 0.6rem; height: 0.6rem; margin: -0.3rem 0 0 -0.3rem; border-radius: 50%; background: var(--ink); }
.ladder-legend { font-size: 0.8rem; }
@container (min-width: 38rem) {
  .ladder { grid-template-columns: 4.5rem 4.5rem minmax(6rem, 1fr) 15rem; }
  .ladder-near, .ladder-track { grid-column: auto; grid-row: auto; }
  .ladder-near { grid-column: 4; text-align: right; }
}
/* IA-050: the plain text carries the page; what backs it stays one click away. */
.fine-print { margin: 0.5rem 0; color: var(--muted); font-size: 0.9rem; }
.fine-print > summary { cursor: pointer; }
.fine-print > summary h3 { display: inline; border: 0; padding: 0; }
.fine-print[open] { color: var(--ink); }
/* 事實與推論分開 is the report's rule: what the agent inferred or warns of reads differently. */
.inference, .caution { display: block; margin: 0.35rem 0; padding-left: 0.6rem; border-left: 3px solid var(--muted); }
.caution { border-left-color: var(--warn); }
.ai-said { font-weight: 600; color: var(--warn); }
.falsifier-chip { white-space: nowrap; text-decoration-style: dotted; }
/* IA-049: a note opens here, so reading goes on where it stopped. */
.note-pop { position: absolute; z-index: 25; width: min(24rem, calc(100vw - 1.5rem)); padding: 0.6rem 0.75rem; font-size: 0.9rem; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 0.5rem; box-shadow: 0 4px 18px rgb(0 0 0 / 0.18); }
.actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; }
.actions form { margin: 0; }
/* /candidates (IA-035): each candidate is a thesis card waiting for George */
.candidate { border-bottom: 1px solid var(--rule); padding-bottom: 1rem; margin-bottom: 1.5rem; }

/* Chat with Hermes (IA-037): a button at the bottom right; the panel is a sheet on a phone and
   a 24rem card on a wider screen. */
.chat-open { position: fixed; right: 1rem; bottom: 1rem; z-index: 20; border-radius: 999px;
  padding: 0.6rem 1.1rem; background: var(--link); color: var(--surface); border: 0;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.2); font-weight: 600; }
.chat { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); }
.chat[hidden] { display: none; }
/* IA-053: a side panel. From 64rem the page moves aside to stay readable; below that it covers. */
body { --chat-width: 26rem; }
body.chat-wide { --chat-width: 100vw; }
@media (min-width: 40rem) {
  .chat { inset: 0 0 0 auto; width: var(--chat-width); border-left: 1px solid var(--rule);
    box-shadow: -2px 0 16px rgb(0 0 0 / 0.1); }
}
@media (min-width: 64rem) {
  body.chat-wide { --chat-width: min(50vw, 52rem); }
  body.chat-docked { padding-right: var(--chat-width); }
}
.chat-bar { display: flex; gap: 0.5rem; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--rule); }
.chat-bar button { background: none; border: 0; padding: 0.25rem 0.4rem; color: var(--ink); font-weight: 600; }
.chat-bar [data-chat="wide"] { display: none; margin-left: auto; color: var(--link); }
.chat-bar [data-chat="close"] { margin-left: auto; }
@media (min-width: 40rem) {
  .chat-bar [data-chat="wide"] { display: block; }
  .chat-bar [data-chat="close"] { margin-left: 0; }
}
.chat-body { flex: 1; overflow-y: auto; padding: 0.75rem; }
.chat-start .chips { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.chip { border: 0; border-radius: 999px; padding: 0.5rem 0.75rem; background: var(--flat-soft);
  color: var(--ink); text-align: left; font-size: 0.9rem; }
.msg { margin: 0.5rem 0; padding: 0.5rem 0.75rem; border-radius: 0.7rem; overflow-wrap: anywhere; }
.msg.user { margin-left: 2rem; background: var(--flat-soft); white-space: pre-wrap; }
.msg.assistant { margin-right: 0.5rem; }
.msg.assistant:empty { display: none; }
/* IA-051: a source in a reply, as a small link; the panel has no 出處 list. */
.chat-ref { display: inline-block; max-width: 100%; margin: 0 0.15rem; padding: 0 0.4rem; overflow: hidden; font-size: 0.75rem; line-height: 1.5; color: var(--link); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; vertical-align: text-bottom; background: var(--flat-soft); border-radius: 0.3rem; }
span.chat-ref { color: var(--muted); }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant table { display: block; overflow-x: auto; }
.chat-status { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0.75rem; }
.chat-status.warn { color: var(--warn); }
.chat-heading { font-size: 0.9rem; margin: 0 0 0.5rem; }
.chat-threads { list-style: none; padding: 0; margin: 0; }
.chat-threads button { display: grid; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--rule); padding: 0.6rem 0.25rem; color: var(--ink); }
.chat-threads .muted { font-size: 0.8rem; }
.chat-form { display: flex; gap: 0.5rem; padding: 0.6rem 0.75rem 0.25rem; border-top: 1px solid var(--rule); }
.chat-form textarea { flex: 1; font: inherit; resize: none; padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule); border-radius: 1rem; background: var(--paper); color: var(--ink); }
.chat-form button { border-radius: 50%; width: 2.5rem; height: 2.5rem; align-self: end;
  background: var(--link); color: var(--surface); border: 0; font-size: 1.1rem; }
.chat-form button:disabled { opacity: 0.5; }
.chat-foot { margin: 0 0.75rem 0.5rem; font-size: 0.75rem; color: var(--muted); }

/* The strategy form (IA-044): one field per line. */
.stack { display: flex; flex-direction: column; gap: 0.75rem; max-width: 32rem; }
.stack label { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: baseline; }
.stack fieldset { border: 1px solid var(--rule); border-radius: 0.35rem; padding: 0.5rem 0.75rem; }
.stack fieldset label { display: inline-flex; margin-right: 1rem; }
.stack button { align-self: flex-start; }

/* /themes (IA-047): a ticker's themes as checkboxes; themes George holds none of are greyed. */
.theme-row { border-bottom: 1px solid var(--rule); padding: 0.4rem 0; }
.theme-row summary { cursor: pointer; }
.theme-shares { display: grid; gap: 0.35rem; margin: 0.5rem 0; }
.share-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.share-row select { max-width: 100%; }
.share-row input { width: 3.5rem; }
.themes-table tr.zero td { color: var(--muted); }

/* /strategy (IA-047): a level's state at the latest close. */
.level { display: inline-block; min-width: 2.6rem; text-align: center; font-size: 0.75rem; border-radius: 0.25rem; padding: 0 0.3rem; border: 1px solid var(--rule); color: var(--muted); }
.level-hit { border-color: var(--warn); background: var(--warn); color: var(--surface); font-weight: 600; }
.level-near { border-color: var(--warn); background: var(--warn-soft); color: var(--ink); font-weight: 600; }
.dir { white-space: nowrap; }
