/* May — Sovereign Credit Chat
 * Design ported from claude.ai/design "May Sovereign Credit Chat"
 * (may-bank bundle, 2026-04-18).
 * Defaults to graphite (dark) theme; cream + parchment available via data-theme.
 */
:root {
    /* Sienna-tinted warm paper base (hue warmed 75 -> 62 toward Sienna). */
    --bg:        oklch(0.966 0.010 62);
    --bg-2:      oklch(0.935 0.014 60);
    --surface:   oklch(0.988 0.007 64);
    --rail:      oklch(0.945 0.011 62);
    --ink:       oklch(0.20 0.018 50);
    --ink-2:     oklch(0.40 0.020 48);
    --ink-3:     oklch(0.58 0.016 50);
    --ink-4:     oklch(0.72 0.012 52);
    --line:      oklch(0.895 0.012 58);
    --line-2:    oklch(0.84 0.016 54);

    /* Burnt sienna = primary signal; raw sienna = secondary accent.
       Together they give charts an ink -> sienna -> burnt family. */
    --signal:    oklch(0.545 0.165 38);
    --signal-soft: oklch(0.91 0.05 40);
    --sienna:      oklch(0.60 0.125 54);
    --sienna-soft: oklch(0.92 0.045 56);

    /* Andy = amber (warm, anchor), Iona = teal (cool, second).
       Hues borrowed from athena_html_v4's palette so the two apps
       feel related: #ffc940 and #00d4aa in oklch space. */
    --andy:      oklch(0.70 0.14 90);
    --andy-soft: oklch(0.93 0.05 90);
    --iona:      oklch(0.65 0.13 175);
    --iona-soft: oklch(0.92 0.05 175);
    --agent-a:   var(--andy);
    --agent-b:   var(--iona);

    --sans: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --serif: 'Source Serif 4', Georgia, serif;

    --col-nav: 216px;
    --col-data: 308px;
    --chat-pad: 32px;
    --row: 40px;
    --r: 10px;
}

[data-theme="graphite"] {
    /* Warm sienna-tinted near-black (hue 250 blue -> 48 ember) to match
       Sienna's identity; was a cold blue-grey. */
    --bg:        oklch(0.165 0.014 48);
    --bg-2:      oklch(0.205 0.016 48);
    --surface:   oklch(0.205 0.016 48);
    --rail:      oklch(0.190 0.015 48);
    --ink:       oklch(0.95 0.010 64);
    --ink-2:     oklch(0.78 0.014 58);
    --ink-3:     oklch(0.62 0.016 54);
    --ink-4:     oklch(0.48 0.018 50);
    --line:      oklch(0.32 0.018 48);
    --line-2:    oklch(0.40 0.022 48);
    --signal:    oklch(0.66 0.155 40);
    --signal-soft: oklch(0.32 0.075 38);
    --sienna:      oklch(0.70 0.13 56);
    --sienna-soft: oklch(0.32 0.060 54);
    --andy:      oklch(0.85 0.16 90);
    --andy-soft: oklch(0.35 0.06 90);
    --iona:      oklch(0.80 0.14 175);
    --iona-soft: oklch(0.32 0.06 175);
    --agent-a:   var(--andy);
    --agent-b:   var(--iona);
}
[data-theme="parchment"] {
    --bg:        oklch(0.955 0.014 70);
    --bg-2:      oklch(0.94 0.016 68);
    --surface:   oklch(0.975 0.010 70);
    --rail:      oklch(0.93 0.016 68);
    --ink:       oklch(0.22 0.018 48);
    --line:      oklch(0.87 0.014 62);
    --sienna:      oklch(0.58 0.125 52);
    --sienna-soft: oklch(0.91 0.045 54);
}

[data-accent="sienna"] { --signal: oklch(0.545 0.165 38); --signal-soft: oklch(0.91 0.05 40); }
[data-accent="olive"]  { --signal: oklch(0.48 0.08 125); --signal-soft: oklch(0.94 0.03 125); }
[data-accent="navy"]   { --signal: oklch(0.40 0.08 255); --signal-soft: oklch(0.93 0.03 255); }
[data-accent="ink"]    { --signal: oklch(0.28 0.01 60);  --signal-soft: oklch(0.92 0.01 60); }

[data-theme="graphite"][data-accent="sienna"] { --signal: oklch(0.66 0.155 40); --signal-soft: oklch(0.32 0.075 38); }
[data-theme="graphite"][data-accent="olive"]  { --signal: oklch(0.70 0.11 125); --signal-soft: oklch(0.30 0.05 125); }
[data-theme="graphite"][data-accent="navy"]   { --signal: oklch(0.65 0.12 255); --signal-soft: oklch(0.30 0.05 255); }
[data-theme="graphite"][data-accent="ink"]    { --signal: oklch(0.85 0.01 60);  --signal-soft: oklch(0.32 0.01 60); }

[data-density="compact"]     { --row: 32px; --chat-pad: 28px; }
[data-density="comfortable"] { --row: 40px; --chat-pad: 40px; }
[data-density="spacious"]    { --row: 50px; --chat-pad: 56px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "ss01", "cv11";
    overflow: hidden;
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.caps { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); font-weight: 500; }

/* ===== Scrollbars (subtle, themed) ==================================== */
* {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in oklch, var(--ink-4) 40%, transparent) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: color-mix(in oklch, var(--ink-4) 35%, transparent);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: color-mix(in oklch, var(--ink-3) 55%, transparent);
    background-clip: padding-box;
    border: 2px solid transparent;
}
*::-webkit-scrollbar-corner { background: transparent; }

/* ===== App shell ====================================================== */
.app {
    height: 100vh;
    display: grid;
    grid-template-columns: var(--col-nav) minmax(0, 1fr) var(--col-data);
    grid-template-rows: 56px 1fr;
    grid-template-areas:
        "brand  topbar topbar"
        "nav    chat   data";
}

.brand {
    grid-area: brand;
    padding: 0 18px;
    display: flex; align-items: center; gap: 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--rail);
    min-width: 0;
}
.brand .mark {
    width: 24px; height: 24px;
    border-radius: 4px;
    background: var(--ink); color: var(--bg);
    font-weight: 700; font-size: 11px;
    display: grid; place-items: center;
    letter-spacing: -0.02em;
    font-family: var(--serif);
    font-style: italic;
}
.brand .nm { font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; line-height: 1.15; }
.brand .nm small {
    display: block;
    font-size: 9.5px;
    font-weight: 500;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 1px;
}

.topbar {
    grid-area: topbar;
    padding: 0 28px 0 32px;
    display: flex; align-items: center; gap: 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}
.topbar .crumb { font-size: 12.5px; color: var(--ink-2); }
.topbar .crumb b { color: var(--ink); font-weight: 600; }
.topbar .crumb .sep { color: var(--ink-4); margin: 0 8px; }
.topbar .crumb em { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--ink-2); }
.topbar .status {
    margin-left: auto;
    display: flex; align-items: center; gap: 18px;
    font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.topbar .status .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--signal);
    box-shadow: 0 0 0 3px var(--signal-soft);
    margin-right: 6px;
    animation: breath 2.6s ease-in-out infinite;
}
@keyframes breath { 0%,100% { opacity: 0.9; } 50% { opacity: 0.4; } }
.theme-toggle {
    border: 1px solid var(--line-2);
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-family: var(--mono);
    font-size: 10.5px;
    padding: 5px 10px;
    border-radius: 100px;
    cursor: pointer;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }

/* Language picker — row of flag pills, one per supported language.
   Active language is highlighted; inactive flags fade. Scales to N
   languages without a layout change. */
.lang-picker {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--line-2);
    border-radius: 100px;
    background: transparent;
}
.lang-flag {
    border: none;
    background: transparent;
    font: inherit;
    font-size: 15px;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 100px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 120ms, background-color 120ms;
}
.lang-flag:hover { opacity: 0.75; }
.lang-flag.active {
    opacity: 1;
    background: var(--line);
}

/* ===== NAV =========================================================== */
.nav {
    grid-area: nav;
    background: var(--rail);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    padding: 22px 0 28px;
}
.nav-section { padding: 18px 22px 8px; }
.nav-section .caps { margin-bottom: 10px; display: flex; justify-content: space-between; }
.nav-section .caps span:last-child { font-family: var(--mono); color: var(--ink-4); letter-spacing: 0.05em; }

.scenario {
    padding: 10px 22px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px 12px;
    align-items: center;
    cursor: pointer;
    border-left: 2px solid transparent;
    position: relative;
}
.scenario:hover { background: var(--bg-2); }
.scenario.active { border-left-color: var(--ink); background: var(--bg-2); }
.scenario .title { font-size: 13px; font-weight: 500; line-height: 1.3; }
.scenario .sub { font-size: 11px; color: var(--ink-3); font-family: var(--serif); font-style: italic; font-weight: 400; }
.scenario .idx {
    font-family: var(--mono);
    font-size: 10px; color: var(--ink-4);
    width: 16px; text-align: right;
}
.scenario .prog { font-family: var(--mono); font-size: 9px; color: var(--ink-3); letter-spacing: 0.1em; }
.scenario .body { min-width: 0; grid-column: 2; }

.subnav {
    padding: 2px 22px 10px 56px;
    display: none;
    flex-direction: column; gap: 2px;
    border-left: 2px solid transparent;
}
.scenario.active + .subnav { display: flex; }
.sub-item {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0;
    font-size: 12px; color: var(--ink-2);
    cursor: pointer;
    font-family: var(--mono);
}
.sub-item:hover { color: var(--ink); }
.sub-item.current { color: var(--ink); font-weight: 500; }
.sub-item .visit {
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--line-2);
    flex-shrink: 0;
}
.sub-item.visited .visit { background: var(--ink-3); }
.sub-item.current .visit { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }

/* ===== CHAT ========================================================== */
.chat[hidden], .pins-wall[hidden] { display: none; }
.chat {
    grid-area: chat;
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 0;
    overflow: hidden;
    background: var(--bg);
    position: relative;
}
.chat-scroll {
    overflow-y: auto;
    padding: 36px var(--chat-pad) 180px;
}

.session-head {
    max-width: 720px;
    margin: 0 auto 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}
.session-head .eyebrow {
    font-family: var(--mono); font-size: 10.5px;
    color: var(--signal);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
    margin-bottom: 10px;
}
.session-head h1 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 28px;
    line-height: 1.2;
    letter-spacing: -0.015em;
    margin: 0 0 10px;
}
.session-head h1 em { font-style: italic; color: var(--ink-2); }
.session-intro {
    margin: 0;
    color: var(--ink-2);
    font-size: 14px;
    line-height: 1.5;
    max-width: 58ch;
}
.session-head .meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-3);
    letter-spacing: 0.02em;
    display: flex; gap: 18px;
    margin-top: 12px;
}
.session-head .suggest {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}
.session-head .suggest-chip {
    font: inherit;
    font-size: 12.5px;
    line-height: 1.3;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 13px;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.session-head .suggest-chip:hover,
.session-head .suggest-chip:focus-visible {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
    outline: none;
}
.session-head .briefing-ts {
    margin-top: 14px;
    font-size: 11px;
    font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    letter-spacing: 0.04em;
    color: var(--ink-2);
    text-transform: uppercase;
}
.session-head .briefing-ts .briefing-refresh {
    color: var(--ink-2);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.session-head .briefing-ts .briefing-refresh:hover {
    color: var(--ink);
}
.session-head.briefing-live h1,
.session-head.briefing-live .session-intro,
.session-head.briefing-live .suggest-chip {
    animation: briefing-fade 260ms ease;
}
@keyframes briefing-fade {
    from { opacity: 0.35; }
    to   { opacity: 1; }
}

/* Turn */
.turn {
    max-width: 720px;
    margin: 0 auto 22px;
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 16px;
    position: relative;
}
.turn .side { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 4px; }
.turn .side .av {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--line-2);
    display: grid; place-items: center;
    font-family: var(--serif);
    font-style: italic;
    font-size: 13px;
    color: var(--ink);
    position: relative;
}
.turn .side .av[data-agent="anchor"] {
    color: var(--andy);
    border-color: var(--andy-soft);
    background: var(--andy-soft);
}
.turn .side .av[data-agent="second"] {
    color: var(--iona);
    border-color: var(--iona-soft);
    background: var(--iona-soft);
}
.turn .side .av[data-agent="user"] {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
    font-family: var(--sans);
    font-style: normal;
    font-weight: 500;
    font-size: 11px;
}
.turn .side .line { width: 1px; flex: 1; background: var(--line); min-height: 20px; }

.turn.speaking .av::after {
    content: '';
    position: absolute; inset: -4px;
    border-radius: 50%;
    border: 1px solid var(--signal);
    animation: ring 1.8s ease-out infinite;
}
@keyframes ring {
    0%  { transform: scale(0.9); opacity: 0.7; }
    100%{ transform: scale(1.5); opacity: 0; }
}

/* Sidebar click feedback — pulses a left stripe + soft background so
   the user knows the click hit, even before the backend responds. */
.scenario.click-pulse,
.sub-item.click-pulse {
    animation: click-pulse 700ms ease-out;
}
@keyframes click-pulse {
    0%   { box-shadow: inset 3px 0 0 var(--signal); background-color: var(--signal-soft); }
    100% { box-shadow: inset 3px 0 0 transparent;   background-color: transparent;        }
}

/* "Thinking" placeholder turn — shows between user bubble and Andy's
   first sentence so there's never a silent gap after a click/submit. */
.turn.thinking .msg.thinking-msg {
    padding-top: 2px;
}
.turn.thinking .thinking-dots {
    display: inline-flex;
    gap: 5px;
    padding: 6px 2px;
}
.turn.thinking .thinking-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--andy);
    opacity: 0.35;
    animation: thinking-blink 1.1s ease-in-out infinite;
}
.turn.thinking .thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.turn.thinking .thinking-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes thinking-blink {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.9); }
    40%           { opacity: 0.95; transform: scale(1);   }
}

.bubble-stack { display: flex; flex-direction: column; gap: 6px; }
.msg { padding: 2px 0 6px; position: relative; }
.msg .who {
    display: flex; align-items: baseline; gap: 10px;
    margin-bottom: 6px;
}
.msg .who .n { font-size: 12.5px; font-weight: 600; color: var(--ink); letter-spacing: -0.005em; }
.msg .who .role { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 11.5px; color: var(--ink-3); }
.msg .who .ago { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink-4); }
.msg .body {
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    padding: 4px 0;
    text-wrap: pretty;
    max-width: 62ch;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Agent differentiation via left stripe */
.msg[data-agent="anchor"] { padding-left: 14px; border-left: 2px solid var(--ink); }
.msg[data-agent="second"] { padding-left: 14px; border-left: 2px solid var(--ink-3); }
.msg[data-agent="user"]   { padding-left: 14px; border-left: 2px solid var(--signal); }

.msg + .msg.same-agent { margin-top: -4px; }
.msg.counter::before {
    content: 'counter';
    display: inline-block;
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-3);
    margin-bottom: 8px;
    padding: 2px 7px;
    border: 1px solid var(--line-2);
    border-radius: 100px;
}
.msg.affirm::before {
    content: '+ building on';
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-3);
    display: inline-block;
    margin-bottom: 8px;
}

.msg .body .cite {
    font-family: var(--mono);
    font-size: 13px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    color: var(--ink);
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease;
}
.msg .body .cite:hover { background: var(--signal-soft); border-color: var(--signal); color: var(--signal); }
.msg .body .fig { font-family: var(--mono); font-weight: 500; letter-spacing: -0.01em; }
.msg .body .fig[data-dir="up"]::before { content: '↑ '; color: var(--signal); }
.msg .body .fig[data-dir="dn"]::before { content: '↓ '; color: var(--signal); }

.msg .wave {
    display: inline-flex; align-items: center; gap: 7px;
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--ink-3);
}
.msg .wave svg { opacity: 0.6; }

.msg.pull .body {
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.42;
    font-style: italic;
    color: var(--ink);
    letter-spacing: -0.005em;
}

.msg .list { margin-top: 10px; border-top: 1px solid var(--line); }
.msg .list .row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    align-items: baseline;
}
.msg .list .row .k { color: var(--ink); }
.msg .list .row .v { font-family: var(--mono); font-weight: 500; color: var(--ink); }
.msg .list .row .d { font-family: var(--mono); font-size: 11.5px; color: var(--signal); }

.typing { display: inline-flex; gap: 4px; padding: 0 0 4px; }
.typing i {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--ink-3);
    animation: dt 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dt { 0%,60%,100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Composer */
.composer {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 2 * var(--chat-pad)));
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    padding: 6px 6px 6px 18px;
    box-shadow: 0 18px 48px -16px oklch(0 0 0 / 0.24), 0 2px 6px -2px oklch(0 0 0 / 0.14);
    z-index: 5;
}
.composer .voice-orb {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--ink); color: var(--bg);
    border: 0;
    cursor: pointer;
    display: grid; place-items: center;
    position: relative;
    flex-shrink: 0;
    order: 3;
}
.composer .voice-orb::before {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    border: 1px solid var(--ink); opacity: 0;
    animation: ring 1.8s ease-out infinite;
}
.composer.listening .voice-orb::before { opacity: 1; }
.composer.listening .voice-orb { background: var(--signal); }
/* Inline note under the composer — the only place a refused mic
 * permission is ever mentioned. There is no toast system in may. */
.composer-note {
    margin: 6px 0 0;
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--ink-3);
}
.composer input {
    width: 100%;
    border: 0; outline: 0;
    background: transparent;
    font-size: 14px;
    color: var(--ink);
    font-family: var(--sans);
    padding: 8px 0;
}
.composer input::placeholder { color: var(--ink-3); }
.composer .mode {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--ink-3);
    padding: 4px 10px;
    border-right: 1px solid var(--line);
    margin-right: 2px;
    letter-spacing: 0.05em;
}
.composer .mode b { color: var(--ink); font-weight: 500; }

.composer-hint {
    position: absolute;
    left: 50%; bottom: 84px;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--ink-3);
    letter-spacing: 0.04em;
    z-index: 4;
    display: flex; gap: 16px;
}
.composer-hint kbd {
    font-family: var(--mono);
    font-size: 10px;
    padding: 2px 5px;
    border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink-2);
}

/* ===== DATA RAIL ===================================================== */
.data {
    grid-area: data;
    background: var(--bg-2);
    border-left: 1px solid var(--line);
    overflow-y: auto;
    padding: 0;
}
.data-section {
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}
.data-section h3 {
    margin: 0 0 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-3);
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.data-section h3 small {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-4);
    text-transform: none;
    letter-spacing: 0.02em;
}

.yields { display: grid; grid-template-columns: 1fr; gap: 10px; }
.yield-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
    align-items: baseline;
}
.yield-row:last-child { border-bottom: 0; }
.yield-row .k { font-size: 12.5px; color: var(--ink); }
.yield-row .k small { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 1px; font-family: var(--mono); }
.yield-row .v { font-family: var(--mono); font-size: 14px; font-weight: 500; letter-spacing: -0.01em; }
.yield-row .d { font-family: var(--mono); font-size: 11px; min-width: 48px; text-align: right; }

.spreads {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    gap: 0;
    font-size: 12.5px;
}
.spreads .hd, .spreads .cell { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.spreads .hd { font-family: var(--mono); font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.spreads .cell.ctry { font-weight: 500; }
.spreads .cell.ctry small { display: block; font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 1px; letter-spacing: 0; }
.spreads .cell.num { font-family: var(--mono); font-weight: 500; text-align: right; }
.spreads .cell.delta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); text-align: right; }
.spreads .cell.delta.up::before { content: '↑ '; color: var(--signal); }
.spreads .cell.delta.dn::before { content: '↓ '; color: var(--signal); }
.spreads .row-line { display: contents; }
.spreads .row-line.focus .cell { background: var(--signal-soft); }

.spreads .cell.bar {
    padding: 0;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.spreads .cell.bar::after {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    width: var(--w, 30%);
    height: 2px;
    background: var(--ink-2);
    transform: translateY(-50%);
}
.spreads .row-line.focus .cell.bar::after { background: var(--signal); }

.ratings {
    display: grid;
    grid-template-columns: 1fr repeat(3, auto) auto;
    gap: 8px 14px;
    font-size: 12.5px;
    align-items: baseline;
}
.ratings .hd { font-family: var(--mono); font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.ratings .k { font-weight: 500; padding: 4px 0; }
.ratings .r { font-family: var(--mono); font-size: 12px; color: var(--ink); padding: 4px 0; }
.ratings .nfa { font-family: var(--mono); font-size: 11px; color: var(--signal); letter-spacing: 1.5px; padding: 4px 0; }
.ratings .nfa i { color: var(--line-2); font-style: normal; }

/* ===== INLINE CHARTS ================================================== */
/* Per Chart Interaction Prototype spec: chart card blends into the chat
   (bg == page bg, sharp 2px corners, single-color border hover). The
   readout reserves space in chart-head (min-width 140px, opacity 0); the
   "pin →" CTA is absolutely positioned over that same slot and fades
   out on hover so the readout crossfades in. */
.chart {
    position: relative;
    margin: 14px 0 4px;
    padding: 12px 14px 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 2px;
    cursor: pointer;
    transition: border-color 120ms ease;
    /* Match the bubble's text width — was clamped at 54ch which made
       the chart visibly narrower than the prose it sits next to. */
    width: 100%;
}
.chart:hover { border-color: var(--line-2); }
.chart.pinned { border-color: var(--line-2); opacity: 0.72; cursor: default; }
.chart.pinned .chart-pin-cta::after { content: ' ✓ pinned'; }
.chart-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 6px;
    gap: 16px;
}
.chart-title {
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.005em;
}
.chart-title em {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    color: var(--ink-3);
    margin-left: 2px;
}
.chart-readout {
    /* Absolutely positioned so its reserved flex width doesn't push
       the title into a 2-3 line wrap in narrow bubbles. Crossfades
       in over .chart-pin-cta on hover. */
    position: absolute;
    right: 14px;
    top: 12px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink);
    font-feature-settings: "tnum";
    white-space: nowrap;
    text-align: right;
    opacity: 0;
    transition: opacity 140ms ease;
    pointer-events: none;
}
.chart-readout b { color: var(--signal); font-weight: 500; margin-left: 8px; }
.chart-readout .ago { color: var(--ink-3); }
.chart-pin-cta {
    position: absolute;
    right: 14px;
    top: 12px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    transition: opacity 140ms ease;
    pointer-events: none;
}
.chart.hovered .chart-readout { opacity: 1; }
.chart.hovered .chart-pin-cta { opacity: 0; }
/* Crosshair defaults — hidden until .on is added by hover handler.
   Global (not .chart-scoped) so rail-pin and wall-card charts also get
   the default-hidden state — previously they showed a stray black dot
   at cx=0, cy=0 because no rule applied. */
.crosshair {
    stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3;
    opacity: 0; pointer-events: none;
}
.crosshair.on { opacity: 0.8; }
.crosshair-dot {
    fill: var(--ink); stroke: var(--bg); stroke-width: 2;
    opacity: 0; pointer-events: none;
}
.crosshair-dot.on { opacity: 1; }
.chart-body { width: 100%; height: 160px; position: relative; }
.chart-body svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-skeleton {
    width: 100%; height: 100%;
    background:
        repeating-linear-gradient(
            to bottom,
            var(--line) 0,
            var(--line) 1px,
            transparent 1px,
            transparent calc(25% - 1px),
            var(--line) calc(25%),
            var(--line) calc(25% + 1px),
            transparent calc(25% + 1px),
            transparent 100%
        );
    opacity: 0.5;
    border-radius: 4px;
    position: relative;
}
.chart-skeleton::after {
    content: 'loading…';
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--ink-3);
    letter-spacing: 0.1em;
}
.chart-unavailable {
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    height: 100%;
    text-align: center;
    padding: 0 16px;
    background: repeating-linear-gradient(
        45deg,
        var(--bg-2) 0, var(--bg-2) 8px,
        transparent 8px, transparent 16px
    );
    border-radius: 4px;
}
.chart-unavailable-title {
    font-family: var(--serif);
    font-style: italic;
    font-size: 14px;
    color: var(--ink-2);
    margin-bottom: 4px;
}
.chart-unavailable-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--ink-3);
    letter-spacing: 0.02em;
    max-width: 36ch;
}
.chart-cap {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-3);
    letter-spacing: 0.06em;
    margin-top: 6px;
}
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .axis-label { font-family: 'JetBrains Mono', monospace; font-size: 9px; fill: var(--ink-3); letter-spacing: 0.02em; }
.chart .axis-label.last-value { fill: var(--signal); font-weight: 600; }
.chart .series-line { stroke: var(--ink); stroke-width: 1.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart .series-area { fill: var(--signal); opacity: 0.10; }
.chart .ghost-line { stroke: var(--ink-3); stroke-width: 1; fill: none; stroke-dasharray: 3 3; opacity: 0.7; }
.chart .event-dot { fill: var(--signal); stroke: var(--bg); stroke-width: 1.5; }
.chart .legend { font-family: 'JetBrains Mono', monospace; font-size: 10px; }

/* Chart Pins in right rail */
.pins-section { padding: 20px 22px; border-bottom: 1px solid var(--line); display: none; }
.pins-section.on { display: block; }
.pins-section h3 {
    margin: 0 0 12px; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.12em; color: var(--ink-3); font-weight: 500;
    display: flex; justify-content: space-between; align-items: baseline;
}
.pins-section h3 small {
    font-family: var(--mono); font-size: 10px; color: var(--ink-4);
    text-transform: none; letter-spacing: 0.02em;
}
.pin {
    margin-bottom: 12px;
    padding: 10px 10px 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.pin:last-child { margin-bottom: 0; }
.pin-head {
    display: flex; align-items: baseline; gap: 8px;
    margin-bottom: 2px;
}
.pin-title { font-size: 11px; font-weight: 600; color: var(--ink); flex: 1; min-width: 0; }
.pin-title em { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--ink-3); margin-left: 2px; }
.pin-value {
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    color: var(--signal); font-feature-settings: "tnum"; letter-spacing: -0.01em;
    white-space: nowrap;
}
.pin-dismiss {
    background: transparent; border: 0; cursor: pointer;
    font-family: var(--mono); font-size: 10px; color: var(--ink-4);
    padding: 2px 4px; border-radius: 3px;
}
.pin-dismiss:hover { color: var(--signal); background: var(--bg-2); }
.pin-body { width: 100%; height: 100px; }
.pin-body svg { width: 100%; height: 100%; overflow: visible; display: block; }
.pin-cap {
    font-family: var(--mono); font-size: 9.5px; color: var(--ink-3);
    margin-top: 4px;
    letter-spacing: 0.04em;
}
/* Stacked ledger: legend below a comparative pin. Matches the chat's
   visual language — reads like a tiny holdings table. */
.pin-ledger {
    margin-top: 8px;
    border-top: 1px solid var(--line);
    padding-top: 6px;
    display: grid;
    grid-template-columns: 10px 1fr auto auto;
    gap: 4px 8px;
    align-items: baseline;
    font-family: var(--mono); font-size: 10px;
}
.pin-ledger .sw { width: 8px; height: 8px; align-self: center; border-radius: 1px; }
.pin-ledger .nm { color: var(--ink-2); font-family: var(--sans); font-size: 11px; }
.pin-ledger .val { color: var(--ink); font-feature-settings: "tnum"; text-align: right; }
.pin-ledger .d { color: var(--ink-3); font-size: 9.5px; text-align: right; min-width: 38px; }
.pin-ledger .d.up { color: var(--signal); }

.context-pin {
    padding: 14px 22px;
    background: var(--signal-soft);
    border-bottom: 1px solid var(--line);
    display: flex; gap: 10px;
    align-items: flex-start;
    font-size: 12px;
    color: var(--ink);
}
.context-pin .caps { color: var(--signal); }
.context-pin .body { font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink); margin-top: 4px; line-height: 1.4; }

.citations { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.citations .item {
    display: flex; gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.citations .item:last-child { border-bottom: 0; }
.citations .item .num { color: var(--ink-3); font-size: 10px; width: 14px; }
.citations .item .from { font-family: var(--serif); font-style: italic; font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ===== NAV LINK (pins wall entry) ==================================== */
.nav-link {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: 10px 12px;
    align-items: center;
    padding: 10px 22px;
    font-size: 13px; font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: color 120ms ease, background 120ms ease;
}
.nav-link:hover, .nav-link.active {
    color: var(--ink);
    border-left-color: var(--ink);
    background: var(--bg-2);
}
.nav-link .idx {
    font-family: var(--mono);
    font-size: 12px; color: var(--ink-4);
    text-align: right;
}
.nav-link .nm { flex: 1; }
.nav-link .badge {
    font-family: var(--mono); font-size: 10px; color: var(--ink-4);
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: 100px; padding: 1px 7px;
    min-width: 18px; text-align: center;
}
.nav-link .badge:empty { display: none; }

/* ===== PINS WALL ====================================================== */
.pins-wall {
    grid-area: chat;
    background: var(--bg);
    overflow-y: auto;
    padding: 40px var(--chat-pad) 60px;
}
.pins-wall-inner { max-width: 1000px; margin: 0 auto; }
.pins-wall-head {
    display: flex; align-items: baseline; gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 28px;
}
.pins-wall-back {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-2);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: color 140ms ease, border-color 140ms ease;
}
.pins-wall-back:hover { color: var(--ink); border-color: var(--ink-2); }
.pins-wall-head h2 {
    font-family: var(--serif);
    font-size: 22px; font-weight: 400;
    margin: 0; letter-spacing: -0.01em;
}
.pins-wall-count {
    font-family: var(--mono);
    font-size: 11px; color: var(--ink-3);
}
.pins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.pins-empty {
    font-family: var(--serif);
    font-style: italic;
    font-size: 15px; color: var(--ink-3);
    text-align: center;
    line-height: 1.6;
    margin: 60px auto;
    max-width: 44ch;
}

/* Wall thumbnail card */
.wall-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
.wall-card:hover {
    border-color: var(--signal);
    box-shadow: 0 4px 16px -6px oklch(0 0 0 / 0.18);
}
.wall-card-chart {
    width: 100%;
    height: 160px;
    position: relative;
    padding: 8px 6px 4px;
}
.wall-card-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.wall-card-chart .grid-line  { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.wall-card-chart .axis-label { font-family: 'JetBrains Mono', monospace; font-size: 9px; fill: var(--ink-3); letter-spacing: 0.02em; }
.wall-card-chart .series-line { stroke: var(--ink); stroke-width: 1.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wall-card-chart .series-area { fill: var(--signal); opacity: 0.10; }
.wall-card-chart .ghost-line  { stroke: var(--ink-3); stroke-width: 1; fill: none; stroke-dasharray: 3 3; opacity: 0.7; }
.wall-card-chart .event-dot   { fill: var(--signal); stroke: var(--surface); stroke-width: 1.5; }
.wall-card-chart .legend      { font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.wall-card-foot {
    padding: 8px 12px 10px;
    border-top: 1px solid var(--line);
}
.wall-card-title {
    font-size: 12px; font-weight: 600; color: var(--ink);
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: flex; align-items: baseline; gap: 8px;
}
.wall-card-title em {
    font-family: var(--serif); font-style: italic;
    font-weight: 400; color: var(--ink-3);
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.wall-card-value {
    font-family: var(--mono); font-size: 12px; font-weight: 600;
    color: var(--signal); font-feature-settings: "tnum"; letter-spacing: -0.01em;
    margin-left: auto;
}
.wall-card-meta {
    font-family: var(--mono); font-size: 10px; color: var(--ink-4);
    margin-top: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wall-card-dismiss {
    position: absolute; top: 6px; right: 6px;
    background: var(--bg); border: 1px solid var(--line);
    border-radius: 3px;
    font-family: var(--mono); font-size: 10px; color: var(--ink-4);
    cursor: pointer; padding: 2px 5px;
    opacity: 0; transition: opacity 120ms ease, color 120ms ease;
}
.wall-card:hover .wall-card-dismiss { opacity: 1; }
.wall-card-dismiss:hover { color: var(--signal); border-color: var(--signal); }

/* Expand overlay */
.wall-expand-overlay {
    position: fixed; inset: 0;
    background: oklch(0 0 0 / 0.55);
    display: grid; place-items: center;
    z-index: 100;
}
.wall-expand {
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    padding: 20px 24px;
    width: min(760px, calc(100vw - 48px));
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: 0 24px 64px -16px oklch(0 0 0 / 0.4);
}
.wall-expand-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 16px;
}
.wall-expand-title {
    font-size: 14px; font-weight: 600; color: var(--ink);
}
.wall-expand-title em {
    font-family: var(--serif); font-style: italic;
    font-weight: 400; color: var(--ink-3);
}
.wall-expand-close {
    background: transparent; border: 0;
    font-family: var(--mono); font-size: 12px;
    color: var(--ink-3); cursor: pointer; padding: 4px 6px; border-radius: 3px;
}
.wall-expand-close:hover { color: var(--signal); }
.wall-expand-chart {
    width: 100%; height: 400px; position: relative;
}
.wall-expand-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.wall-expand-chart .grid-line  { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.wall-expand-chart .axis-label { font-family: 'JetBrains Mono', monospace; font-size: 9px; fill: var(--ink-3); letter-spacing: 0.02em; }
.wall-expand-chart .series-line { stroke: var(--ink); stroke-width: 1.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wall-expand-chart .series-area { fill: var(--signal); opacity: 0.10; }
.wall-expand-chart .ghost-line  { stroke: var(--ink-3); stroke-width: 1; fill: none; stroke-dasharray: 3 3; opacity: 0.7; }
.wall-expand-chart .event-dot   { fill: var(--signal); stroke: var(--surface); stroke-width: 1.5; }
.wall-expand-chart .legend      { font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.wall-expand-ledger { margin-top: 12px; }
.wall-expand-cap {
    font-family: var(--mono); font-size: 10px; color: var(--ink-3);
    margin-top: 10px; letter-spacing: 0.02em;
}

/* ===== Mobile ======================================================== */
.mobile-chrome { display: none; }

@media (max-width: 820px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: 48px 44px 1fr auto;
        grid-template-areas:
            "brand"
            "mnav"
            "chat"
            "mdata";
    }
    .brand { border-right: 0; padding: 0 16px; }
    .topbar, .nav, .data { display: none; }

    .mobile-chrome { display: block; }
    .mnav {
        grid-area: mnav;
        display: flex; align-items: center; gap: 10px;
        padding: 0 16px;
        border-bottom: 1px solid var(--line);
        background: var(--bg);
        overflow-x: auto;
    }
    .mnav .pill {
        font-family: var(--mono);
        font-size: 11px;
        padding: 5px 11px;
        border-radius: 100px;
        border: 1px solid var(--line-2);
        color: var(--ink-2);
        white-space: nowrap;
        background: transparent;
        cursor: pointer;
        flex-shrink: 0;
    }
    .mnav .pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

    .chat { padding-bottom: 0; }
    .chat-scroll { padding: 20px 18px 120px; }
    .composer { width: calc(100% - 24px); }

    .mdata {
        grid-area: mdata;
        background: var(--bg-2);
        border-top: 1px solid var(--line);
        padding: 0;
        max-height: 50vh;
        overflow: hidden;
        transition: max-height 300ms ease;
    }
    .mdata.collapsed { max-height: 52px; }
    .mdata .mdata-handle {
        padding: 10px 18px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-family: var(--mono);
        font-size: 11px;
        color: var(--ink-2);
        border-bottom: 1px solid var(--line);
        cursor: pointer;
        position: relative;
        padding-top: 16px;
    }
    .mdata .mdata-handle::before {
        content: '';
        position: absolute;
        top: 6px; left: 50%;
        transform: translateX(-50%);
        width: 32px; height: 3px;
        background: var(--line-2);
        border-radius: 2px;
    }
    .mdata-content { max-height: calc(50vh - 52px); overflow-y: auto; }
    .mdata.collapsed .mdata-content { display: none; }

    .session-head { padding-top: 4px; }
    .session-head h1 { font-size: 22px; }

    .chart-body { height: 140px; }

    .pins-wall { padding: 20px 18px 60px; }
    .pins-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .wall-expand-chart { height: 260px; }
}

@media (max-width: 600px) {
    .pins-grid { grid-template-columns: 1fr; }
}
