/* ============================================================
   Stocky — Dashboard (logged-in home)
   Layered on colors_and_type.css + components.css.
   Forks the Stocky UI kit: two-pane watchlist (left) + ticker
   detail (right). The AI conversation is the LOCKED surface from
   ai-conversation.html, folded into the dock's floating modal.
   This file only adds APP-LAYOUT + the enhanced .term surface;
   every atom/molecule comes from components.css.
   ============================================================ */

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-surface);
  font-family: var(--font-ui);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ----- Shell + fluid margins ----- */
.shell { flex: 1; display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-primary); position: relative; overflow: hidden; }

/* Top bar: floating overlay chrome, mirrors the island dock. Hides while
   scrolling, springs back when scroll stops (see .appbar--hidden + js). */
.appbar { position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px; height: 60px;
  padding: 0 clamp(40px, 6vw, 160px);
  background: color-mix(in oklab, var(--bg-primary) 80%, transparent);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border-bottom: 0.5px solid var(--border-default);
  transition: transform 0.34s var(--ease-out), opacity 0.28s var(--ease-out); }
.appbar--hidden { transform: translateY(-130%); opacity: 0; pointer-events: none; }
.brandword { font-family: var(--font-display); }
.wm { display: flex; align-items: center; gap: 8px; }
.wm__name { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

.main { flex: 1; overflow-y: auto; padding: 82px clamp(40px, 6vw, 160px) 132px; }

/* fluid content type + spacing — scales with viewport, capped (mirrors the kit) */
.shell .dt thead th { font-size: clamp(12px, 1vw, 17px); padding: clamp(9px, 1vw, 13px) clamp(8px, 0.95vw, 17px); }
.shell .dt tbody td { font-size: clamp(13px, 1.1vw, 19px); padding: clamp(11px, 1.2vw, 16px) clamp(8px, 0.95vw, 17px); }
.shell .dt .sym { font-size: clamp(15px, 1.3vw, 23px); }
.shell .dt .co  { font-size: clamp(11px, 1vw, 15px); }

/* ----- Page header ----- */
.page-h { display: flex; align-items: baseline; gap: 14px; margin: 2px 0 0; flex-wrap: wrap; }
.page-h h1 { font-family: var(--font-heading); font-size: clamp(24px, 2.4vw, 38px);
  font-weight: 600; margin: 0; letter-spacing: -0.4px; color: var(--text-primary); }
.page-h .meta { font-family: var(--font-display); font-size: 13px; color: var(--text-muted); }
.page-h .meta b { color: var(--text-secondary); font-weight: 600; }

/* ----- Persistent hobby-tier disclaimer ----- */
.kit-disclaimer { margin: 16px 0 18px; }
.callout__msg a { color: var(--color-signal); }

/* ----- Two-pane: watchlist + detail ----- */
.layout { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(380px, 1.35fr);
  gap: 20px; align-items: start; }
@media (max-width: 1280px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* detail pane stays anchored in view while a long list scrolls under it —
   so selecting row 50 still shows the detail, no conditional anchoring needed. */
@media (min-width: 1281px) {
  .layout:not(.view-list):not(.view-detail) .detail-surface {
    position: sticky; top: 12px; align-self: start;
    max-height: calc(100vh - 104px); display: flex; flex-direction: column; }
  .layout:not(.view-list):not(.view-detail) .detail-surface .detail { overflow-y: auto; }
}

/* view modes: expand either pane to full width */
.layout.view-list { grid-template-columns: minmax(0, 1fr); }
.layout.view-list .detail-surface { display: none; }
.layout.view-detail { grid-template-columns: minmax(0, 1fr); }
.layout.view-detail .list-surface { display: none; }

/* expand/collapse toggle: show the right glyph per mode */
.view-toggle .ic-collapse { display: none; }
.list-surface .view-toggle .ic-expand,
.detail-surface .view-toggle .ic-expand { display: inline; }
.layout.view-list .list-surface .view-toggle .ic-expand { display: none; }
.layout.view-list .list-surface .view-toggle .ic-collapse { display: inline; }
.layout.view-detail .detail-surface .view-toggle .ic-expand { display: none; }
.layout.view-detail .detail-surface .view-toggle .ic-collapse { display: inline; }

.surface { border: 0.5px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--bg-primary); overflow: hidden; min-width: 0; }

/* the detail sheet's close (✕) is mobile-only; hidden in the desktop split */
.detail__bar .detail__sheet-close { display: none; }
.surface__bar { display: flex; align-items: center; gap: 12px; padding: 13px 16px 12px;
  border-bottom: 0.5px solid var(--border-default); }
.surface__head { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; }
.surface__ttl { font-family: var(--font-heading); font-size: 14px; font-weight: 600; color: var(--text-primary); }
.surface__cnt { font-family: var(--font-display); font-size: 12px; color: var(--text-muted); }
.surface__spacer { flex: 1; }

/* freshness + refresh */
.freshness { display: inline-flex; align-items: center; gap: 9px; }
.freshness__t { font-family: var(--font-display); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.freshness__t .dot { color: var(--data-up); }
.surface__bar.is-updating .freshness__t { color: var(--color-signal); }
.refresh-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0.5px solid var(--border-default); background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.refresh-btn:hover { color: var(--color-signal); border-color: var(--color-signal); background: var(--signal-bg); }
.refresh-btn.is-spinning svg { animation: spin 0.7s linear infinite; }

/* add control + type-ahead */
.wl-add { padding: 12px 16px; border-bottom: 0.5px solid var(--border-default); position: relative;
  display: flex; align-items: center; gap: 12px; }
.wl-cap { font-family: var(--font-display); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.wl-cap b { color: var(--text-secondary); }
.wl-cap.is-cap { color: var(--data-warn); }
.wl-typeahead { position: absolute; left: 16px; right: 16px; top: calc(100% - 1px); z-index: 20;
  background: var(--bg-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  overflow: hidden; display: none; }
.wl-typeahead.open { display: block; }
.wl-ta__row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px;
  border: 0; background: transparent; cursor: pointer; text-align: left;
  border-bottom: 0.5px solid var(--border-default); }
.wl-ta__row:last-child { border-bottom: 0; }
.wl-ta__row:hover, .wl-ta__row.is-active { background: var(--bg-surface); }
.wl-ta__sym { font-family: var(--font-display); font-weight: 600; color: var(--text-primary); font-size: 13px; }
.wl-ta__co { font-family: var(--font-body); font-size: 11.5px; color: var(--text-muted); }
.wl-ta__add { margin-left: auto; color: var(--color-signal); display: inline-flex; }
.wl-ta__empty { padding: 12px; font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); text-align: center; }

/* watchlist rows clickable + selected */
.dt tbody tr.wl-row { cursor: pointer; }
.dt tbody tr.wl-row:hover { background: var(--bg-surface); }
.dt tbody tr.is-selected { background: var(--signal-bg); box-shadow: inset 2px 0 0 var(--color-signal); }
.dt tbody tr.is-selected:hover { background: var(--signal-bg); }
.spark { display: block; width: clamp(46px, 5.5vw, 92px); height: auto; }
.wl-day { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.wl-day.up { color: var(--data-up); } .wl-day.down { color: var(--data-down); } .wl-day.flat { color: var(--data-flat); }
.wl-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out); }
.dt tbody tr:hover .wl-actions, .dt tbody tr.is-selected .wl-actions { opacity: 1; }
td.wl-actions-cell { width: 1%; white-space: nowrap; padding-left: 4px; padding-right: 12px; text-align: right; }

/* table lives in a horizontal-scroll wrapper so no column is ever unreachable
   when the split pane is tight (safety net; rarely engaged once scaled). */
.dt-scroll { overflow-x: auto; overflow-y: hidden; }
.dt-scroll .dt { min-width: 440px; }
.row-x { width: 26px; height: 26px; display: inline-grid; place-items: center; border: 0; background: transparent;
  color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer; transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out); }
.row-x:hover { color: var(--data-down); background: var(--data-down-bg); }

/* ----- Watchlist as cards (phones only) -----
   Robinhood-style rows: symbol / company / alert chip on the left, last price
   over day-change on the right. Hidden on desktop (the .dt table is used). */
.wl-cards { display: none; }
.wl-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; width: 100%;
  padding: 14px; border: 0; border-bottom: 0.5px solid var(--border-default);
  background: transparent; text-align: left; cursor: pointer; font-family: var(--font-ui);
  transition: background var(--dur-fast) var(--ease-out); }
.wl-card:last-child { border-bottom: 0; }
.wl-card:active { background: var(--bg-surface); }
.wl-card__main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.wl-card__sym { font-family: var(--font-display); font-weight: 700; font-size: 17px;
  color: var(--text-primary); letter-spacing: -0.3px; line-height: 1.15; }
.wl-card__co { font-family: var(--font-body); font-size: 12px; color: var(--text-muted);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-card__main .badge { margin-top: 5px; }
.wl-card__spark { flex: none; line-height: 0; }
.wl-card__spark svg { display: block; width: 62px; height: 30px; }
.wl-card__nums { flex: none; justify-self: end; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.wl-card__last { font-family: var(--font-display); font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 16px; color: var(--text-primary); }
.wl-card__day { font-family: var(--font-display); font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 13px; white-space: nowrap; }
.wl-card__day.up { color: var(--data-up); }
.wl-card__day.down { color: var(--data-down); }
.wl-card__day.flat { color: var(--data-flat); }

/* skeleton + non-table states */
.skel-row td { padding: 15px 16px; }
.wl-statebox { padding: 10px 16px 24px; }

/* ----- Detail panel (from kit) ----- */
.detail { display: flex; flex-direction: column; gap: 16px; padding: 18px; }
.detail__bar { display: flex; align-items: center; gap: 8px; margin: -2px 0 2px; }
.detail__nav { display: inline-flex; align-items: center; gap: 4px; }
.detail__bar-sp { flex: 1; }
.detail__navbtn { width: 30px; height: 30px; display: inline-grid; place-items: center; flex: none;
  border: 0.5px solid var(--border-default); background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.detail__navbtn:hover { color: var(--color-signal); border-color: var(--color-signal); background: var(--signal-bg); }
.detail__navbtn:disabled { opacity: 0.4; cursor: default; }
.detail__navbtn:disabled:hover { color: var(--text-muted); border-color: var(--border-default); background: transparent; }
.detail__navbtn--danger:hover { color: var(--data-down); border-color: var(--data-down); background: var(--data-down-bg); }
.detail__pos { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 11.5px;
  color: var(--text-muted); min-width: 46px; text-align: center; }

/* quick-jump filter — only visible when the detail view is maximized
   (in split view the list is on screen, so its own filter is used instead) */
.detail__jump { display: none; position: relative; flex: 0 1 280px; min-width: 0; }
.layout.view-detail .detail__jump { display: block; }
.detail__jump .input { padding: 6px 32px 6px 11px; font-size: 12.5px; height: 30px; box-sizing: border-box; }
.detail__jump .input-wrap__affix { width: 26px; height: 26px; }
.detail__jump-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 25;
  background: var(--bg-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  overflow: hidden; max-height: 280px; overflow-y: auto; display: none; }
.detail__jump-menu.open { display: block; }
.djump-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  width: 100%; padding: 8px 12px; border: 0; background: transparent; cursor: pointer; text-align: left;
  border-bottom: 0.5px solid var(--border-default); }
.djump-row:last-child { border-bottom: 0; }
.djump-row:hover, .djump-row.is-active { background: var(--bg-surface); }
.djump-row.is-current { background: var(--signal-bg); }
.djump-row__sym { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--text-primary); }
.djump-row__co { font-family: var(--font-body); font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.djump-row__day { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; }
.djump-row__day.up { color: var(--data-up); } .djump-row__day.down { color: var(--data-down); } .djump-row__day.flat { color: var(--data-flat); }
.djump-empty { padding: 12px; text-align: center; font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); }
.detail__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.detail__id { display: flex; flex-direction: column; gap: 4px; }
.detail__symrow { display: inline-flex; align-items: center; gap: 9px; }
.detail__sym { font-family: var(--font-display); font-size: clamp(22px, 2vw, 30px); font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.5px; line-height: 1; text-decoration: none; }
a.detail__sym:hover { color: var(--text-primary); }
.detail__open { font-family: var(--font-ui); font-size: 11px; color: var(--color-signal); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border: 0.5px solid var(--border-default);
  border-radius: var(--radius-sm); transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.detail__open:hover { background: var(--signal-bg); border-color: var(--color-signal); color: var(--color-signal); }
.detail__co { font-size: 12.5px; color: var(--text-muted); }
.detail__price { text-align: right; }
.detail__last { font-family: var(--font-display); font-size: clamp(22px, 2vw, 30px); font-weight: 600;
  color: var(--text-primary); line-height: 1; letter-spacing: -0.5px; }
.detail__delta { font-family: var(--font-display); font-size: 13px; font-weight: 600; margin-top: 5px;
  display: inline-flex; align-items: center; gap: 3px; }
.detail__delta.up { color: var(--data-up); } .detail__delta.down { color: var(--data-down); } .detail__delta.flat { color: var(--data-flat); }

.detail__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ministat { border: 0.5px solid var(--border-default); border-radius: var(--radius-sm);
  padding: 9px 11px; display: flex; flex-direction: column; gap: 4px; }
.ministat__k { font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); }
.ministat__v { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 15px;
  font-weight: 600; color: var(--text-primary); }
.ministat__v.up { color: var(--data-up); } .ministat__v.down { color: var(--data-down); }

/* chart */
.chartwrap { position: relative; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chart-head .lbl { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
#chart, #td-chart { width: 100%; height: auto; display: block;
  border: 0.5px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); }
#chart .axis text, #td-chart .axis text { font-family: var(--font-display); font-size: 9.5px; fill: var(--text-muted); }
#chart .axis .domain, #td-chart .axis .domain { stroke: var(--border-strong); }
#chart .axis line, #td-chart .axis line { stroke: var(--border-default); }
#chart .gridline, #td-chart .gridline { stroke: var(--border-default); stroke-dasharray: 2 3; }
#chart .up, #td-chart .up { fill: var(--data-up); stroke: var(--data-up); }
#chart .down, #td-chart .down { fill: var(--data-down); stroke: var(--data-down); }
#chart .crosshair line, #td-chart .crosshair line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
#chart .crosshair circle, #td-chart .crosshair circle { fill: none; stroke: var(--text-primary); stroke-width: 1.5; }
.charttip { position: absolute; pointer-events: none; opacity: 0; z-index: 5;
  background: var(--bg-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-width: 120px; font-family: var(--font-display); font-size: 11px; line-height: 1.5;
  color: var(--text-secondary); transition: opacity var(--dur-fast) var(--ease-out); }
.charttip .d { font-family: var(--font-ui); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 4px; }
.charttip .r { display: flex; justify-content: space-between; gap: 14px; }
.charttip .r span:first-child { color: var(--text-muted); } .charttip .r b { color: var(--text-primary); font-weight: 600; }

/* alerts list inside detail */
.alerts { display: flex; flex-direction: column; gap: 0; }
.alertrow { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 2px; border-bottom: 0.5px solid var(--border-default); }
.alertrow:last-child { border-bottom: 0; }
.alertrow__txt { font-size: 12.5px; color: var(--text-secondary); }
.alertrow__txt b { font-family: var(--font-display); color: var(--text-primary); font-weight: 600; }

/* per-symbol briefing snippet */
.briefing { border-left: 3px solid var(--color-highlight); background: var(--bg-surface);
  border-radius: 0 var(--radius-md) var(--radius-md) 0; padding: 13px 15px; }
.briefing__k { font-family: var(--font-ui); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--color-highlight); margin-bottom: 6px; }
.briefing__txt { font-size: 12.5px; line-height: 1.6; color: var(--text-secondary); }
.briefing__txt b { color: var(--text-primary); font-weight: 600; }
.section-k { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin: 2px 0 0; }

/* ===========================================================
   AI conversation — the LOCKED surface from ai-conversation.html
   (folded verbatim into the dock's floating modal)
   =========================================================== */
.dock-pop .term { width: clamp(380px, 40vw, 600px); }
.term { display: flex; flex-direction: column; font-family: var(--font-display);
  background: var(--bg-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); overflow: hidden; }
.term__head { padding: 11px 14px; border-bottom: 0.5px solid var(--border-default); display: flex; align-items: center; gap: 8px; font-family: var(--font-ui); }
.term__caret { font-family: var(--font-display); color: var(--color-signal); font-weight: 700; font-size: 13px; }
.term__title { font-family: var(--font-display); font-size: 13px; font-weight: 700; color: var(--text-primary); letter-spacing: 0; }
.term__live { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--color-signal); }
.term__live .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--color-signal); animation: lpulse 1.6s ease-in-out infinite; }
@keyframes lpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.term__close { margin-left: auto; width: 28px; height: 28px; display: inline-grid; place-items: center; flex: none;
  border: 0; background: transparent; color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out); }
.term__close:hover { color: var(--text-primary); background: var(--bg-surface); }
.term__body { padding: 4px 14px; display: flex; flex-direction: column; font-size: 13px; line-height: 1.65;
  height: clamp(280px, 44vh, 460px); overflow-y: auto; overflow-x: hidden; }
.term__sep { height: 0; border: 0; border-top: 0.5px solid var(--border-default); margin: 0; }
.turn { display: grid; grid-template-columns: 58px 1fr; gap: 8px; align-items: start; padding: 12px 0; }
.pre-you { color: var(--color-signal); font-weight: 600; white-space: nowrap; }
.pre-bot { color: var(--color-highlight); font-weight: 700; white-space: nowrap; }
.t-you { color: var(--text-primary); }
.t-bot { color: var(--text-secondary); }
.t-you, .t-bot { min-width: 0; overflow-wrap: anywhere; }
.t-bot p { margin: 0 0 8px; font-family: var(--font-display); line-height: 1.65; color: var(--text-secondary); max-width: none; }
.t-bot p:last-child { margin-bottom: 0; }
.n-up { color: var(--data-up); font-weight: 600; } .n-down { color: var(--data-down); font-weight: 600; }
.bul { color: var(--text-muted); }

/* generic thinking indicator: muted phrase + block cursor (no italics) */
.term__thinking { color: var(--text-muted); }
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--color-signal); vertical-align: text-bottom; margin-left: 4px; animation: cdblink 1s steps(1) infinite; }
@keyframes cdblink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

/* per-response feedback affordance */
.fb { display: flex; align-items: center; gap: 2px; margin-top: 10px; }
.fb-btn { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; background: transparent;
  color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out); }
.fb-btn:hover { color: var(--color-signal); background: var(--bg-surface); }
.fb-btn[aria-pressed="true"] { color: var(--color-signal); background: var(--signal-bg); }
.fb-btn--down:hover { color: var(--data-down); background: var(--data-down-bg); }
.fb-btn[aria-pressed="true"].fb-btn--down { color: var(--data-down); background: var(--data-down-bg); }
.fb-sep { width: 0.5px; height: 16px; background: var(--border-default); margin: 0 4px; }
.fb-note { font-family: var(--font-ui); font-size: 10.5px; color: var(--text-muted); margin-left: 4px; }

.term__composer { padding: 11px 14px 6px; border-top: 0.5px solid var(--border-default); display: grid; grid-template-columns: 58px 1fr auto; gap: 8px; align-items: end; }
.term__prompt { color: var(--color-signal); font-weight: 600; white-space: nowrap; line-height: 1.65; padding-top: 9px; align-self: start; }
.term__input { font-family: var(--font-display); font-size: 13px; line-height: 1.65; border: 0; border-bottom: 1px solid var(--border-strong); padding: 9px 4px; min-height: 22px; background: transparent; color: var(--text-primary); outline: none; width: 100%; resize: none; overflow: hidden; box-sizing: border-box; }
.term__input:focus { border-bottom-color: var(--color-signal); }
.term__send { align-self: end; width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0.5px solid var(--color-signal); background: var(--color-signal); color: var(--bg-primary); border-radius: var(--radius-md); cursor: pointer; transition: opacity var(--dur-base) var(--ease-out); }
.term__send:hover { opacity: 0.88; }
.term__send svg { display: block; }
.term__disc { padding: 9px 14px 12px; font-family: var(--font-ui); font-size: 10px; color: var(--text-muted); text-align: left; line-height: 1.45; display: flex; gap: 7px; align-items: flex-start; border-top: 0.5px solid var(--border-default); }
.term__disc svg { flex: none; margin-top: 1px; }
.term__disc .ground-wave { font-family: var(--font-ui); }

/* first-use BYO-key prompt (composer replacement) */
.keyprompt { margin: 8px 14px; border: 0.5px dashed var(--border-strong); border-radius: var(--radius-md); padding: 16px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; background: var(--bg-surface); }
.keyprompt__row { display: flex; gap: 10px; align-items: flex-start; }
.keyprompt__ic { flex: none; width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--signal-bg); color: var(--color-signal); }
.keyprompt p { font-family: var(--font-ui); font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); margin: 0; }
.keyprompt p b { color: var(--text-primary); font-weight: 600; }
.keyprompt .btn { font-size: 12px; padding: 8px 14px; }

/* empty state (key set, no messages) */
.emptyq { font-family: var(--font-display); font-size: 13px; color: var(--text-muted); padding: 28px 8px; text-align: center; line-height: 1.6; }
.emptyq .pre-bot { color: var(--color-highlight); }

/* assistant error frames (stack, shown inline above composer) */
.term__errors { padding: 10px 14px 2px; display: flex; flex-direction: column; gap: 10px; }
.term__errors:empty { display: none; }
.term__errors .callout + .callout { margin-top: 0; }

/* ----- Top-bar popovers ----- */
.tb-pop { position: absolute; top: 66px; z-index: 40; display: none; }
.tb-pop.open { display: block; }
.tb-pop--user { right: clamp(40px, 6vw, 160px); }
.tb-pop--bell { right: calc(clamp(40px, 6vw, 160px) + 92px); }

/* ----- Dock popovers ----- */
.dock-pop { display: none; }
.dock-pop.open { display: block; }
/* Anchor each popover's carat under its OWN trigger button — search (left),
   ask Stocky (centre), add (right) — instead of all pointing at the centre.
   The popovers are always centred on the dock, so these offsets hold on desktop
   and mobile alike. (Carat keeps the translateX(-50%) rotate from .dock-pop::after.) */
#pop-dockSearch::after { left: calc(50% - 67px); }
#pop-dockStocky::after { left: calc(50% - 7px); }
#pop-dockAdd::after    { left: calc(50% + 67px); }

/* ----- App scrim: blur + dim behind any open overlay ----- */
.app-scrim { position: absolute; inset: 0; z-index: 14; opacity: 0; pointer-events: none;
  background: color-mix(in oklab, var(--bg-primary) 30%, transparent);
  backdrop-filter: blur(7px) saturate(1.05); -webkit-backdrop-filter: blur(7px) saturate(1.05);
  transition: opacity var(--dur-base) var(--ease-out); }
.app-scrim.open { opacity: 1; pointer-events: auto; }

/* ----- Search / quick-add popover bodies ----- */
.search-pop { width: clamp(360px, 42vw, 560px); display: flex; flex-direction: column; max-height: min(560px, 72vh); }
.search-pop__field { padding: 12px 14px; border-bottom: 0.5px solid var(--border-default); flex: none; }
.search-pop__hint { font-family: var(--font-ui); font-size: 10.5px; color: var(--text-muted); padding: 9px 16px 4px; flex: none; }
.sresults { overflow-y: auto; padding: 6px 8px 6px 16px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.sresult { box-sizing: border-box; display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 12px;
  width: auto; padding: 10px; border: 0; background: transparent; cursor: pointer; text-align: left;
  border-radius: var(--radius-sm); transition: background var(--dur-fast) var(--ease-out); }
.sresult:hover, .sresult.is-active { background: var(--bg-surface); }
.sresult__id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sresult__sym { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--text-primary); }
.sresult__co { font-family: var(--font-body); font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sresult__last { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-secondary); text-align: right; }
.sresult__day { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; text-align: right; min-width: 54px; }
.sresult__day.up { color: var(--data-up); } .sresult__day.down { color: var(--data-down); } .sresult__day.flat { color: var(--data-flat); }
.sresult__quickadd { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0.5px solid var(--border-default);
  background: transparent; color: var(--color-signal); border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.sresult__quickadd:hover { background: var(--signal-bg); border-color: var(--color-signal); }
.sresult__have { width: 30px; display: inline-grid; place-items: center; color: var(--color-signal); }
.sresult-empty { padding: 22px 14px; text-align: center; font-family: var(--font-ui); font-size: 12.5px; color: var(--text-muted); }

/* ----- Filter (watchlist) ----- */
.wl-filter__clear { width: 30px; height: 30px; display: none; place-items: center; border: 0.5px solid var(--border-default);
  background: transparent; color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer; flex: none; }
.wl-filter__clear.show { display: inline-grid; }
.wl-filter__clear:hover { color: var(--text-primary); border-color: var(--text-muted); }
.wl-nomatch { padding: 26px 16px; text-align: center; font-family: var(--font-ui); font-size: 13px; color: var(--text-muted); }
.wl-nomatch b { font-family: var(--font-display); color: var(--text-secondary); }

/* ----- Ticker detail modal (opened from search / quick-add) ----- */
.tdetail-modal { max-width: 620px; width: 100%; max-height: 86vh; display: flex; flex-direction: column; }
.tdetail-modal .modal__body { padding: 0; overflow-y: auto; }
.tdetail-modal .detail { gap: 15px; padding: 20px; }

/* ----- Toasts (canonical DS .toast component; placement top-center by choice) ----- */
.toast-stack { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; flex-direction: column; gap: 10px; align-items: center; width: auto; max-width: calc(100% - 32px); }
/* desktop: size to content so the message sits on one line */
.toast { animation: toast-in 0.34s var(--ease-out) both; width: max-content; min-width: 300px; max-width: min(640px, calc(100vw - 40px)); }
.toast.is-leaving { animation: toast-out 0.28s var(--ease-out) both; }
.toast__msg { white-space: nowrap; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }
/* mobile: let the message wrap and the toast take a sensible fixed width */
@media (max-width: 600px) {
  .toast-stack { width: min(360px, calc(100% - 24px)); }
  .toast { width: 100%; min-width: 0; max-width: none; }
  .toast__msg { white-space: normal; }
}

/* ----- Notification bell pulse + briefing variant ----- */
.iconbtn--ring { animation: bell-swing 0.6s var(--ease-out) 2; transform-origin: top center; }
@keyframes bell-swing { 0%,100% { transform: rotate(0); } 25% { transform: rotate(11deg); } 75% { transform: rotate(-9deg); } }
.notif__mark--brief { background: var(--signal-bg); color: var(--color-signal); }
.notif__item { cursor: pointer; }
.notif__item--brief .notif__txt b { color: var(--color-signal); }

/* ----- Theme toggle in bar ----- */
.theme-toggle .ic-moon { display: none; }
html[data-theme="dark"] .theme-toggle .ic-sun { display: none; }
html[data-theme="dark"] .theme-toggle .ic-moon { display: inline; }

/* ----- Disclaimer dismiss + modals ----- */
.callout__dismiss { flex: none; align-self: center; font-family: var(--font-ui);
  font-size: 11.5px; font-weight: 500; color: var(--text-secondary); white-space: nowrap;
  background: transparent; border: 0.5px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 6px 13px; cursor: pointer;
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.callout__dismiss:hover { background: var(--bg-primary); color: var(--text-primary); border-color: var(--text-muted); }

.modal-overlay { position: absolute; inset: 0; z-index: 80;
  display: none; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in oklab, var(--text-primary) 30%, transparent);
  backdrop-filter: blur(7px) saturate(1.05); -webkit-backdrop-filter: blur(7px) saturate(1.05); }
.modal-overlay.open { display: flex; }
.modal-overlay .modal { width: 100%; max-height: 82vh; display: flex; flex-direction: column; }
.disc-body { max-height: 58vh; overflow-y: auto; gap: 16px; }
.disc-intro { font-size: 12.5px; line-height: 1.6; color: var(--text-secondary); margin: 0; }
.disc-sec h5 { font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; color: var(--text-primary); margin: 0 0 4px; letter-spacing: 0.2px; }
.disc-sec p { font-size: 12.5px; line-height: 1.6; color: var(--text-secondary); margin: 0; }
.confirm-modal { max-width: 380px; }
.confirm-modal .modal__body { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); }
.confirm-modal b { font-family: var(--font-display); color: var(--text-primary); }

/* ============================================================
   RESPONSIVE — tablet / mobile  (v1 posture: graceful, not optimized)
   Desktop-first. The two-pane split already collapses to one column
   ≤1280px (see .layout above). This layer adapts the island chrome,
   the floating dock + its popovers, the bell/user dropdowns, modals,
   the watchlist table, and bumps touch targets to the 44px floor.
   ============================================================ */

/* ---- Tablet & narrow desktop: tighten the shell gutters ---- */
@media (max-width: 900px) {
  .appbar { padding: 0 22px; gap: 12px; }
  .main { padding: 78px 22px 126px; }
  .tb-pop--user { right: 18px; }
  .tb-pop--bell { right: 18px; }
}

/* ---- Phone (≤640px) ---- */
@media (max-width: 640px) {
  /* never let the page scroll sideways (#1 — belt-and-braces over the grid fix) */
  .main { overflow-x: hidden; }

  /* TOP BAR — drop secondary nav + name; reserve the notch / status-bar inset (#7) */
  .appbar { height: 56px; padding: env(safe-area-inset-top) 14px 0; gap: 6px; }
  .appnav { display: none; }
  .wm__name { display: none; }
  .usermenu { padding: 4px; }
  .main { padding: calc(72px + env(safe-area-inset-top)) 14px calc(116px + env(safe-area-inset-bottom)); }
  .tb-pop { top: calc(62px + env(safe-area-inset-top)); }

  /* HEADER — shrink the metadata line so the big title leads (#6) */
  .page-h { gap: 4px 12px; }
  .page-h .meta { font-size: 10.5px; }
  .kit-disclaimer { margin: 14px 0 16px; }

  /* BELL / USER DROPDOWNS — pin between both gutters, fill width (no off-screen clip) */
  .tb-pop--user, .tb-pop--bell { left: 12px; right: 12px; }
  .tb-pop .dropdown, .tb-pop .notif { width: 100%; }

  /* DOCK + FLOATERS — span gutters, ride above the home-bar inset (#7) */
  .dock { bottom: calc(18px + env(safe-area-inset-bottom)); }
  /* 92px replicates the desktop dock→popover offset (dock bottom + its height),
     so the carat tip meets the top of the island instead of overlapping it. */
  .dock-pop { left: 12px; right: 12px; transform: none; bottom: calc(92px + env(safe-area-inset-bottom)); }
  .dock-pop .term,
  .dock-pop .search-pop { width: 100%; }
  /* taller conversation + a 2-line composer so the long placeholder isn't clipped
     (46vh keeps the whole floater clear of the top bar on shorter phones) */
  .term__body { height: clamp(280px, 46vh, 440px); }
  .term__composer { padding: 12px 14px 8px; }
  .term__input { min-height: 48px; }

  /* WATCHLIST — swap the desktop table for the Robinhood-style card list */
  .dt-scroll { display: none; }
  .wl-cards { display: block; }
  .wl-add { padding: 12px 14px; }
  /* surface bar: stack the symbol count under the title; drop the inert expand toggle */
  .surface__head { flex-direction: column; align-items: flex-start; gap: 1px; }
  #wlExpand { display: none; }

  /* ===== DETAIL AS A SHEET (#2a / #3) =====
     The watchlist is the mobile home. Tapping a row slides the detail up as a
     full-screen sheet — the same overlay language as the chat + modals. */
  .detail-surface {
    position: fixed; inset: 0; z-index: 70; border: 0; border-radius: 0;
    background: var(--bg-primary);
    transform: translateY(100%); visibility: hidden;
    transition: transform var(--dur-slow) var(--ease-out), visibility 0s linear var(--dur-slow);
    display: flex; flex-direction: column;
    padding-top: env(safe-area-inset-top);
  }
  .shell.detail-open .detail-surface {
    transform: none; visibility: visible;
    transition: transform var(--dur-slow) var(--ease-out);
  }
  .detail-surface .detail {
    flex: 1; overflow-y: auto;
    padding: 0 14px calc(28px + env(safe-area-inset-bottom));
  }

  /* DETAIL TOOLBAR — sticky so cycling + ✕ stay reachable while content scrolls.
     line 1: cycling · trash · close ✕ ;  line 2: full-width jump (#3).
     The cramped placeholder ("Jump to t…") clears once the field owns its row. */
  .detail-surface .detail__bar {
    position: sticky; top: 0; z-index: 3; background: var(--bg-primary);
    flex-wrap: wrap; gap: 8px; margin: 0; padding: 12px 0 10px;
  }
  .detail__nav { order: 1; }
  .detail__bar-sp { order: 2; }
  #d-remove { order: 3; }
  .detail__bar .detail__sheet-close { order: 4; display: inline-grid; }
  #d-expand { display: none; }
  .detail__jump { order: 5; display: block; flex: 0 0 100%; min-width: 0; }
  .detail__jump .input { height: 40px; }

  /* MINISTATS — give Day range its own full-width row so it stops wrapping (#5) */
  .detail__stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .detail__stats .ministat:first-child { grid-column: 1 / -1; }
  .ministat { padding: 9px 11px; }
  #d-range { font-size: 14.5px !important; }

  /* MODALS — bottom-sheet feel; reserve the bottom inset */
  .modal-overlay { padding: 10px; }
  .modal-overlay .modal { max-height: 88vh; }
  .tdetail-modal .detail { padding: 16px 14px; }

  /* TOUCH TARGETS — lift the dense controls to the 44px floor */
  .iconbtn { width: 42px; height: 42px; }
  .refresh-btn,
  .detail__navbtn,
  .wl-filter__clear.show { width: 40px; height: 40px; }
  .row-x { width: 38px; height: 38px; }
  .segmented button { padding: 11px 16px; }
  .modal__x { width: 40px; height: 40px; margin: -6px -6px 0 0; }
  .term__close { width: 38px; height: 38px; }
  .term__send { width: 42px; height: 42px; }
  .fb-btn { width: 36px; height: 36px; }
  .sresult__quickadd, .sresult__have { width: 40px; height: 40px; }
  .callout__dismiss { padding: 10px 14px; }
}
