/* ============================================================================
   PORTFOLIO TRACKER

   Calm and institutional. Numbers lead; chrome recedes into hairline
   dividers and one navy accent. Gold is reserved for Ask, the research
   assistant, so it is recognisable anywhere. Green and red belong to data
   only, and always travel with a sign, an arrow and a word.

   Plain CSS, no build step. IBM Plex is served from /static/fonts.
   ========================================================================= */

@font-face {
    font-family: "IBM Plex Sans";
    src: url("fonts/IBMPlexSans-Variable.woff2") format("woff2");
    font-weight: 400 700;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/IBMPlexMono-400.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/IBMPlexMono-500.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

/* ---------------------------------------------------------- tokens ----- */
/* Contrast ratios are measured against the surface each colour sits on.
   The divider fails 3:1 on purpose: it is decoration. Anything whose edge
   is how you find it (inputs, outlined buttons) uses --border-control. */

:root {
    --color-bg:              #F8FAFC;
    --color-surface:         #FFFFFF;
    --color-surface-2:       #F1F4F8;
    --color-muted:           #E8ECF1;
    --color-text:            #0F172A;   /* 17.9:1 */
    --color-text-2:          #475569;   /*  7.6:1 */
    --color-text-3:          #64748B;   /*  4.8:1 */
    --border-divider:        #E2E8F0;
    --border-control:        #64748B;
    --color-brand:           #1E3A8A;   /* 10.4:1 */
    --color-on-brand:        #FFFFFF;
    --color-primary:         #0F172A;
    --color-on-primary:      #FFFFFF;
    --color-primary-hover:   #1E293B;
    --color-research:        #A16207;   /*  4.9:1 */
    --color-research-strong: #854D0E;   /*  6.4:1 on wash */
    --color-research-wash:   #FEF6E7;
    --color-gain:            #15803D;   /*  5.0:1, 4.8:1 on wash */
    --color-gain-wash:       #ECFDF3;
    --color-loss:            #B91C1C;   /*  6.5:1, 5.9:1 on wash */
    --color-loss-wash:       #FEF2F2;
    --color-error:           #DC2626;
    --color-error-text:      #991B1B;
    --color-error-wash:      #FEF2F2;
    --color-info-wash:       #EEF2FB;
    --chart-line:            #1E3A8A;
    --chart-area:            rgba(30, 58, 138, .08);
    --hero-dot:              #1E3A8A;
    --hero-mark:             #A16207;

    --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
    --shadow-2: 0 16px 40px -16px rgba(15, 23, 42, .28), 0 2px 6px rgba(15, 23, 42, .06);

    --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

    /* 4px base. */
    --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem;
    --s5: 1.5rem; --s6: 2rem;  --s7: 3rem;   --s8: 4rem;

    --radius-control: 6px;
    --radius-panel:   10px;
    --radius-pill:    999px;

    --shell: 1180px;
    --ease:  cubic-bezier(.22, .61, .36, 1);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg:              #0B1220;
        --color-surface:         #111A2E;
        --color-surface-2:       #16213A;
        --color-muted:           #1B2640;
        --color-text:            #E6EAF2;
        --color-text-2:          #A3AFC2;
        --color-text-3:          #A3AFC2;
        --border-divider:        #243150;
        --border-control:        #7A89A6;
        --color-brand:           #8FB0FF;
        --color-on-brand:        #0B1220;
        --color-primary:         #E6EAF2;
        --color-on-primary:      #0B1220;
        --color-primary-hover:   #C9D2E3;
        --color-research:        #E2B04A;
        --color-research-strong: #E2B04A;
        --color-research-wash:   #2A2210;
        --color-gain:            #4ADE80;
        --color-gain-wash:       #0F2A1C;
        --color-loss:            #F87171;
        --color-loss-wash:       #2E1417;
        --color-error:           #F87171;
        --color-error-text:      #FCA5A5;
        --color-error-wash:      #2E1417;
        --color-info-wash:       #16213A;
        --chart-line:            #8FB0FF;
        --chart-area:            rgba(143, 176, 255, .10);
        --hero-dot:              #8FB0FF;
        --hero-mark:             #E2B04A;
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-2: 0 18px 44px -14px rgba(0, 0, 0, .65);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

/* `hidden` must win over any component's display value. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ------------------------------------------------------------ type ----- */

h1, h2, h3 {
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.01em;
    margin: 0 0 var(--s3);
    text-wrap: balance;
}
h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2rem); letter-spacing: -.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 var(--s4); }

a { color: var(--color-brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.label {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--color-text-3);
}
.label-mark { color: var(--color-brand); }

.lede  { color: var(--color-text-2); font-size: 1.0625rem; max-width: 64ch; }
.muted { color: var(--color-text-2); }
.faint { color: var(--color-text-3); font-size: .875rem; }

/* Figures never re-flow as they change. */
.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}
code, .mono { font-family: var(--font-mono); }

/* ---------------------------------------------------------- focus ------ */

:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
    border-radius: 3px;
}
.skip-link {
    position: absolute; left: var(--s4); top: var(--s4);
    background: var(--color-primary); color: var(--color-on-primary);
    padding: var(--s2) var(--s4); border-radius: var(--radius-control);
    z-index: 100; text-decoration: none;
    transform: translateY(-200%);
    transition: transform 200ms var(--ease);
}
.skip-link:focus { transform: none; color: var(--color-on-primary); }

/* ----------------------------------------------------------- shell ----- */

.masthead {
    background: var(--color-surface);
    border-bottom: 1px solid var(--border-divider);
    position: sticky; top: 0; z-index: 30;
}
.masthead-inner {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0 var(--s5);
    min-height: 60px;
    display: flex; flex-wrap: wrap; align-items: center;
    gap: var(--s2) var(--s6);
}

.wordmark {
    display: inline-flex; align-items: center; gap: var(--s2);
    font-size: 1rem; font-weight: 600; letter-spacing: -.01em;
    color: var(--color-text); text-decoration: none;
}
.wordmark-mark { width: 22px; height: 22px; flex: none; color: var(--color-brand); }

.nav { display: flex; flex-wrap: wrap; align-self: stretch; margin-right: auto; }
.nav a {
    display: inline-flex; align-items: center;
    color: var(--color-text-2); text-decoration: none;
    padding: 0 var(--s3);
    font-size: .9375rem; font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.nav a:hover { color: var(--color-text); }
.nav a.is-active { color: var(--color-text); border-bottom-color: var(--color-brand); font-weight: 600; }

.account { display: flex; align-items: center; gap: var(--s4); font-size: .875rem; }
.account-name { color: var(--color-text-2); max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout-form { display: inline; margin: 0; }
button.signout { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.signout { color: var(--color-text-2); text-decoration: none; }
.signout:hover { color: var(--color-text); text-decoration: underline; }

.cash-chip {
    display: inline-flex; align-items: baseline; gap: var(--s2);
    border: 1px solid var(--border-divider);
    background: var(--color-surface-2);
    border-radius: var(--radius-pill);
    padding: var(--s1) var(--s3);
    text-decoration: none; color: var(--color-text);
    transition: border-color 150ms var(--ease);
}
.cash-chip:hover { border-color: var(--border-control); color: var(--color-text); }
.cash-chip .label { font-size: .6875rem; }
.cash-figure { font-weight: 600; font-variant-numeric: tabular-nums; }

main { max-width: var(--shell); margin: 0 auto; padding: var(--s6) var(--s5) var(--s8); }

.crumbs { margin-bottom: var(--s3); font-size: .875rem; color: var(--color-text-3); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0; padding: 0; }
.crumbs li::after { content: "/"; margin-left: var(--s2); color: var(--border-control); }
.crumbs li:last-child::after { content: none; }
.crumbs a { color: var(--color-text-2); text-decoration: none; }
.crumbs a:hover { color: var(--color-text); text-decoration: underline; }
.crumbs [aria-current] { color: var(--color-text); }

.page-head { margin-bottom: var(--s5); }
.page-head h1 { margin-bottom: var(--s2); }
.page-head .label { display: block; margin-bottom: var(--s1); }
.page-head .lede { margin-bottom: 0; }

.page-head-row {
    display: flex; flex-wrap: wrap; gap: var(--s4);
    justify-content: space-between; align-items: flex-end;
}

.footer { border-top: 1px solid var(--border-divider); padding: var(--s5); }
.footer p { color: var(--color-text-3); font-size: .8125rem; margin: 0 auto; max-width: calc(var(--shell) - 2 * var(--s5)); }

/* ----------------------------------------------------------- panel ----- */

.panel {
    background: var(--color-surface);
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-panel);
    padding: var(--s5);
}
.panel + .panel, .panel + .grid-main, .grid-main + .panel { margin-top: var(--s4); }
.panel-head {
    display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4);
    justify-content: space-between; align-items: baseline;
    margin-bottom: var(--s4);
}
.panel-head h2 { margin: 0; font-size: 1.0625rem; }
.panel-head p { margin: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-flush .panel-head { padding: var(--s4) var(--s5) 0; }

.grid-main {
    display: grid; gap: var(--s4);
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: start;
}
.grid-main > .panel + .panel { margin-top: 0; }

/* ---------------------------------------------------------- notices ---- */

.flashes { margin-bottom: var(--s4); display: grid; gap: var(--s2); }
.flash, .inline-error, .notice {
    position: relative;
    padding: var(--s3) var(--s4) var(--s3) 2.25rem;
    border-radius: var(--radius-control);
    border: 1px solid var(--border-divider);
    background: var(--color-info-wash);
    color: var(--color-text);
    font-size: .9375rem;
}
.flash::before, .inline-error::before, .notice::before {
    content: ""; position: absolute; left: 1rem; top: calc(var(--s3) + .5em);
    width: 8px; height: 8px;
    border-radius: 50%; background: var(--color-brand);
}
.flash-success { background: var(--color-surface); }
.flash-success::before { background: var(--color-gain); }
.flash-error, .inline-error { background: var(--color-error-wash); border-color: transparent; }
.flash-error::before, .inline-error::before { background: var(--color-error); border-radius: 1px; transform: rotate(45deg); }
.inline-error { margin-bottom: var(--s4); }
.inline-error strong { display: block; margin-bottom: var(--s1); }
.notice p { margin: 0; color: var(--color-text-2); }
.notice strong { color: var(--color-text); }

/* ----------------------------------------------------------- table ----- */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }

thead th {
    text-align: left;
    font-size: .75rem; font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase;
    color: var(--color-text-3);
    padding: var(--s3) var(--s4);
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--border-divider);
    white-space: nowrap;
}
td {
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--border-divider);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
.r { text-align: right; }
thead th.r .sortable { flex-direction: row-reverse; }

tbody tr.row-link { cursor: pointer; transition: background-color 150ms var(--ease); }
tbody tr.row-link:hover { background: var(--color-surface-2); }

.sortable {
    background: none; border: 0; padding: 0;
    font: inherit; color: inherit; letter-spacing: inherit;
    text-transform: inherit; cursor: pointer;
    display: inline-flex; align-items: center; gap: var(--s1);
    min-height: 24px;
}
.sortable:hover { color: var(--color-text); }
.sortable .caret { opacity: 0; transition: opacity 150ms var(--ease); }
.sortable:hover .caret { opacity: .5; }
[aria-sort] .sortable { color: var(--color-text); }
[aria-sort] .sortable .caret { opacity: 1; color: var(--color-brand); }

.ticker  { font-family: var(--font-mono); font-weight: 500; font-size: .9375rem; display: block; }
.company { color: var(--color-text-2); font-size: .8125rem; display: block; min-width: 14ch; max-width: 30ch; }

/* ------------------------------------------ direction, never colour alone */
/* Sign, arrow and word travel together at the same weight for gains and
   losses. Colour is added on top, at AA contrast, so the figure still
   reads in greyscale. */

.delta { display: inline-flex; align-items: baseline; gap: var(--s2); white-space: nowrap; }
.delta-fig { font-variant-numeric: tabular-nums; color: var(--color-text); font-weight: 500; }
.delta-pct { font-size: .875rem; color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.delta-arrow { font-size: .75em; }
.delta-tag {
    font-size: .6875rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    padding: .0625rem .4375rem; border-radius: var(--radius-pill);
    background: var(--color-surface-2); color: var(--color-text-2);
}
.delta-gain .delta-fig, .delta-gain .delta-arrow { color: var(--color-gain); }
.delta-loss .delta-fig, .delta-loss .delta-arrow { color: var(--color-loss); }
.delta-gain .delta-tag { background: var(--color-gain-wash); color: var(--color-gain); }
.delta-loss .delta-tag { background: var(--color-loss-wash); color: var(--color-loss); }
.delta-flat .delta-arrow, .delta-none .delta-arrow { color: var(--color-text-2); }
.delta-lg .delta-fig { font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }

/* ---------------------------------------------------------- figures ---- */

.kpis {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--color-surface);
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-panel);
    margin-bottom: var(--s4);
}
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { padding: var(--s4) var(--s5); border-left: 1px solid var(--border-divider); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: .8125rem; color: var(--color-text-2); margin: 0 0 var(--s1); }
.kpi-value {
    font-size: 1.625rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.2;
    margin: 0; font-variant-numeric: tabular-nums;
}
.kpi-value .delta { justify-content: flex-start; }
.kpi-value .delta-fig { font-weight: 600; }
.kpi-foot { font-size: .8125rem; color: var(--color-text-2); margin: var(--s1) 0 0; }

.ledger { display: grid; gap: 0; margin-top: var(--s4); border-top: 1px solid var(--border-divider); }
.ledger-row {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: var(--s4); padding: var(--s3) 0; border-bottom: 1px solid var(--border-divider);
}
.ledger-row:last-child { border-bottom: 0; }
.ledger-row dt { color: var(--color-text-2); margin: 0; }
.ledger-row dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; }
.ledger-total { border-top: 1px solid var(--border-control); }
.ledger-total dt { color: var(--color-text); font-weight: 600; }
.ledger-total dd { font-size: 1.125rem; font-weight: 600; }

.figures {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--s4) var(--s5);
}
.figure-label { margin-bottom: var(--s1); }
.figure-value { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; margin: 0; }

/* Share of the account per holding: a list with bars, not a pie. */
.allocation { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.allocation li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s1) var(--s3); font-size: .875rem; }
.allocation .alloc-name { font-family: var(--font-mono); font-weight: 500; }
.allocation .alloc-pct { font-variant-numeric: tabular-nums; color: var(--color-text-2); }
.alloc-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--color-muted); overflow: hidden; }
.alloc-bar span { display: block; height: 100%; background: var(--color-brand); border-radius: 3px; }
.alloc-bar.is-cash span { background: var(--border-control); }

/* ------------------------------------------------------------ forms ---- */

form { margin: 0; }
.field { margin-bottom: var(--s5); max-width: 28rem; }
label { display: block; font-weight: 600; margin-bottom: var(--s1); font-size: .9375rem; }
.hint { color: var(--color-text-2); font-size: .875rem; margin: 0 0 var(--s2); }

input[type="text"], input[type="number"], input[type="email"], textarea {
    width: 100%; font: inherit; font-size: 1rem;
    min-height: 44px;
    padding: var(--s2) var(--s3);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-control);
    background: var(--color-surface); color: var(--color-text);
    transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
input:focus, textarea:focus { border-color: var(--color-brand); box-shadow: 0 0 0 1px var(--color-brand); }
input:focus:not(:focus-visible), textarea:focus:not(:focus-visible) { outline: none; }
input[aria-invalid="true"] { border-color: var(--color-error); }
input.ticker-input {
    text-transform: uppercase; letter-spacing: .08em;
    font-weight: 500; font-family: var(--font-mono); font-size: 1.0625rem;
}
textarea { resize: vertical; line-height: 1.45; }

.field-status { min-height: 1.4rem; font-size: .875rem; margin-top: var(--s2); }
.field-status[data-state="looking"] { color: var(--color-text-3); }
.field-status[data-state="ok"]      { color: var(--color-text); }
.field-status[data-state="bad"]     { color: var(--color-error-text); }
.field-status .resolved-name { font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-top: var(--s5); }

/* ---------------------------------------------------------- buttons ---- */
/* Primary is ink, never green; secondary is outlined, never red. A coloured
   Buy or Sell would read as a gain or a loss. Gold belongs to Ask. */

.btn {
    font: inherit; font-size: .9375rem; font-weight: 500;
    min-height: 44px; padding: 0 var(--s5);
    border: 1px solid transparent; border-radius: var(--radius-control);
    cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    line-height: 1.2;
    transition: background-color 150ms var(--ease), color 150ms var(--ease),
                border-color 150ms var(--ease);
}
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { background: var(--color-primary-hover); color: var(--color-on-primary); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--border-control); }
.btn-secondary:hover { background: var(--color-surface-2); color: var(--color-text); }
.btn-quiet { background: none; color: var(--color-brand); padding: 0 var(--s3); }
.btn-quiet:hover { background: var(--color-surface-2); color: var(--color-brand); }
.btn-ask { background: var(--color-research-wash); color: var(--color-research-strong); border-color: var(--color-research); }
.btn-ask:hover { color: var(--color-research-strong); border-color: var(--color-research-strong); }
.btn-ask svg { width: 16px; height: 16px; flex: none; }
.btn-lg { min-height: 52px; padding: 0 var(--s6); font-size: 1rem; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: .875rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-google { background: var(--color-surface); color: var(--color-text); border-color: var(--border-control); }
.btn-google:hover { background: var(--color-surface-2); color: var(--color-text); }
.g-mark { width: 18px; height: 18px; flex: none; }

.btn[data-busy="true"] { pointer-events: none; opacity: .75; }
.spinner {
    width: 14px; height: 14px; flex: none;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; border-right-color: currentColor; opacity: .5; }
}

/* ------------------------------------------------------------ quote ---- */

.quote {
    border: 1px solid var(--border-divider); border-radius: var(--radius-panel);
    padding: var(--s4) var(--s5); margin-bottom: var(--s5); background: var(--color-surface-2);
}
.quote-name { font-size: 1.125rem; font-weight: 600; }
.quote-sym  { font-family: var(--font-mono); font-size: .8125rem; letter-spacing: .04em; color: var(--color-text-2); }
.quote-price { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: var(--s1); }
.quote-note { color: var(--color-text-2); font-size: .875rem; margin: var(--s1) 0 0; }

/* ------------------------------------------------------------ empty ---- */

.empty { padding: var(--s7) var(--s5); max-width: 50ch; margin: 0 auto; text-align: center; }
.empty h2 { margin-bottom: var(--s3); }
.empty p { color: var(--color-text-2); }
.empty .actions { justify-content: center; }
.empty-rule { width: 40px; height: 4px; border-radius: 2px; background: var(--color-muted); margin: 0 auto var(--s4); }

/* --------------------------------------------------------- glossary ---- */

.glossary { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--border-divider); }
.glossary h3 { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase;
               color: var(--color-text-3); font-weight: 600; margin-bottom: var(--s4); }
.glossary dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4) var(--s5); margin: 0; }
.glossary dt { font-weight: 600; margin-bottom: var(--s1); }
.glossary dd { margin: 0; color: var(--color-text-2); font-size: .9375rem; }

/* ---------------------------------------------------------- actions ---- */

.job { display: flex; flex-wrap: wrap; gap: var(--s4); justify-content: space-between; align-items: flex-start; }
.job + .job { margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--border-divider); }
.job-copy { max-width: 50ch; }
.job-copy h3 { margin-bottom: var(--s1); }
.job-copy p { margin: 0; color: var(--color-text-2); font-size: .9375rem; }

.outcomes { list-style: none; padding: 0; margin: var(--s4) 0 0; border-top: 1px solid var(--border-divider); }
.outcomes li { display: flex; justify-content: space-between; gap: var(--s4);
               padding: var(--s3) 0; border-bottom: 1px solid var(--border-divider); font-size: .9375rem; }
.outcome-sym { font-weight: 500; font-family: var(--font-mono); font-size: .875rem; }
.outcome-ok  { color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.outcome-bad { color: var(--color-error-text); }

/* ---------------------------------------------------------- balance ---- */

.split { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: var(--s4); align-items: center; }
.split-part p { margin: var(--s1) 0 0; }
.split-fig { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.split-op { font-size: 1.25rem; color: var(--color-text-3); text-align: center; }

/* ============================================================== landing = */

.hero { position: relative; min-height: 70vh; display: flex; align-items: center; }

/* A finished static ground is painted first, so the hero is complete
   before, and without, any WebGL. */
.hero-stage {
    position: absolute; inset: 0 calc(50% - 50vw);
    z-index: 0; overflow: hidden;
    background:
        radial-gradient(110% 80% at 15% 10%, var(--color-surface) 0%, transparent 60%),
        radial-gradient(80% 70% at 88% 90%, var(--color-info-wash) 0%, transparent 65%),
        var(--color-bg);
}
.hero-stage canvas {
    position: absolute; inset: 0; width: 100% !important; height: 100% !important;
    opacity: 0;
    transition: opacity 400ms var(--ease);
}
.hero-stage canvas.is-ready { opacity: 1; }
.hero-stage::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 26%;
    height: 1px; background: linear-gradient(90deg, transparent, var(--border-divider) 30%, var(--border-divider) 70%, transparent);
}

.hero-inner { position: relative; z-index: 1; max-width: 42rem; padding: var(--s8) 0; }
.hero h1 {
    font-size: clamp(2.25rem, 1.4rem + 3.4vw, 3.5rem);
    line-height: 1.08; letter-spacing: -.03em; margin-bottom: var(--s4);
}
.hero h1 .rule-under { color: var(--color-brand); }
.hero .lede { font-size: 1.125rem; margin-bottom: var(--s5); }
.hero .actions { margin-top: 0; }

.section { margin-top: var(--s8); }
.section-head { max-width: 50ch; margin-bottom: var(--s5); }
.section-head .label { display: block; margin-bottom: var(--s2); }

.steps {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    background: var(--color-surface); border: 1px solid var(--border-divider); border-radius: var(--radius-panel);
}
.step { padding: var(--s5); }
.step + .step { border-left: 1px solid var(--border-divider); }
.step-n { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-brand); margin-bottom: var(--s3); }
.step h3 { margin-bottom: var(--s2); }
.step p { margin: 0; color: var(--color-text-2); font-size: .9375rem; }

.specimen {
    border: 1px solid var(--border-divider); border-radius: var(--radius-panel);
    background: var(--color-surface); padding: var(--s5); max-width: 32rem; box-shadow: var(--shadow-1);
}
.specimen .label { display: block; margin-bottom: var(--s3); }
.specimen-row { display: flex; justify-content: space-between; align-items: baseline;
                gap: var(--s4); padding: var(--s3) 0; border-bottom: 1px solid var(--border-divider);
                font-variant-numeric: tabular-nums; font-size: .9375rem; }
.specimen-row:last-of-type { border-bottom: none; }
.specimen-total { border-top: 1px solid var(--border-control); }

.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.checks li { display: flex; gap: var(--s3); color: var(--color-text-2); font-size: .9375rem; }
.checks .tick { color: var(--color-brand); flex: none; font-weight: 600; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s6); align-items: start; }

/* ============================================================= sign-in == */

.gate { max-width: 29rem; margin: var(--s7) auto; }
.gate .panel { padding: var(--s6); box-shadow: var(--shadow-1); }
.gate-head { text-align: center; margin-bottom: var(--s5); }
.gate-head h1 { font-size: 1.625rem; margin-bottom: var(--s2); }
.gate-head p { color: var(--color-text-2); margin: 0; }
.gate .btn { width: 100%; }
.gate-alt { text-align: center; margin: var(--s5) 0 0; padding-top: var(--s4);
            border-top: 1px solid var(--border-divider); font-size: .9375rem; color: var(--color-text-2); }
.gate-note { font-size: .875rem; color: var(--color-text-3); text-align: center; margin: var(--s4) 0 0; }

.setup-note, .dev-note {
    text-align: left; background: var(--color-surface-2);
    border: 1px solid var(--border-divider); border-radius: var(--radius-control);
    padding: var(--s4); margin-top: var(--s5); font-size: .875rem;
}
.dev-note { background: var(--color-info-wash); }
.setup-note h3, .dev-note h3 { font-size: .9375rem; margin-bottom: var(--s2); }
.setup-note ol { margin: 0 0 var(--s3); padding-left: 1.25rem; }
.setup-note li { margin-bottom: var(--s1); }
.setup-note code, .dev-note code {
    background: var(--color-surface); border: 1px solid var(--border-divider); border-radius: 4px;
    padding: .05rem .3rem; font-size: .8125rem;
}
.setup-note code.uri { display: inline-block; margin-top: var(--s1); word-break: break-all; }
.setup-note pre { background: var(--color-surface); border: 1px solid var(--border-divider); border-radius: 4px;
                  padding: var(--s3); margin: var(--s1) 0 0; overflow-x: auto; font-size: .8125rem; font-family: var(--font-mono); }
.dev-note .field { max-width: none; margin-bottom: var(--s3); }
.dev-note .btn { width: 100%; }

/* ------------------------------------------------------------- misc ---- */

.back { display: inline-block; margin-bottom: var(--s4); color: var(--color-text-2);
        text-decoration: none; font-size: .9375rem; }
.back:hover { color: var(--color-text); text-decoration: underline; }

.step-of { font-size: .75rem; font-weight: 600; letter-spacing: .06em;
           color: var(--color-text-3); text-transform: uppercase; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.symbol-link { color: inherit; text-decoration: none; display: block; }
.symbol-link:hover .ticker { text-decoration: underline; }
.symbol-link:hover { color: var(--color-text); }

/* ============================================================ stock ===== */

.stock-head {
    display: flex; flex-wrap: wrap; gap: var(--s4);
    justify-content: space-between; align-items: flex-end;
    margin-bottom: var(--s5);
}
.stock-sym {
    display: inline-block; font-family: var(--font-mono); font-weight: 500; font-size: .8125rem;
    padding: .0625rem .5rem; border-radius: var(--radius-pill);
    border: 1px solid var(--border-divider); background: var(--color-surface-2); color: var(--color-text-2);
    margin-bottom: var(--s2);
}
.stock-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s4); margin: 0; }
.stock-price-fig { font-size: 2rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stock-head .lede { margin: var(--s1) 0 0; font-size: .9375rem; }

.ranges {
    display: inline-flex; flex-wrap: wrap; gap: 2px;
    padding: 2px; border-radius: var(--radius-control);
    background: var(--color-surface-2); border: 1px solid var(--border-divider);
}
.range {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 36px; padding: 0 var(--s3);
    font-size: .8125rem; font-weight: 500; text-decoration: none;
    color: var(--color-text-2); border-radius: 4px;
    transition: color 150ms var(--ease), background-color 150ms var(--ease);
}
.range:hover { color: var(--color-text); }
.range.is-active { color: var(--color-text); background: var(--color-surface); box-shadow: var(--shadow-1); font-weight: 600; }

.chart-head {
    display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4);
    justify-content: space-between; align-items: flex-end;
    margin-bottom: var(--s4);
}
.chart-figure { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; margin: var(--s1) 0 0; }
.chart-change { text-align: right; }

.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }

/* The line is navy whichever way the range went: the headline carries up
   or down, so a falling year is not painted as an alarm. */
.chart-line {
    fill: none;
    stroke: var(--chart-line);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.chart-area { fill: var(--chart-area); stroke: none; }
.chart-baseline { stroke: var(--color-text-3); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.chart-grid { stroke: var(--border-divider); stroke-width: 1; }

/* Axes live in HTML around the stretched plot, positioned by percentage. */
.chart-frame {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "ytitle ."
        "yaxis  plot"
        ".      xaxis"
        ".      xtitle";
    column-gap: var(--s3);
}
.axis-title { margin: 0; font-size: .75rem; color: var(--color-text-3); }
.axis-title-y { grid-area: ytitle; margin-bottom: var(--s2); }
.axis-title-x { grid-area: xtitle; text-align: right; margin-top: var(--s1); }

.chart-y { grid-area: yaxis; position: relative; min-width: 3.5rem; }
.y-tick {
    position: absolute; right: 0; transform: translateY(-50%);
    font-size: .75rem; color: var(--color-text-3); white-space: nowrap; line-height: 1;
}

.chart-plot { grid-area: plot; min-width: 0; position: relative; }
.chart-plot:focus-visible { outline-offset: 6px; }

.chart-x { grid-area: xaxis; position: relative; height: 1.6rem; border-top: 1px solid var(--border-control); }
.x-tick {
    position: absolute; top: var(--s2); transform: translateX(-50%);
    font-size: .75rem; color: var(--color-text-3); white-space: nowrap;
}
.x-tick-start { transform: none; }
.x-tick-end { transform: translateX(-100%); }
.x-tick::before {
    content: ""; position: absolute; left: 50%; top: calc(-1 * var(--s2) - 1px);
    width: 1px; height: 4px; background: var(--border-control);
}
.x-tick-start::before { left: 0; }
.x-tick-end::before { left: auto; right: 0; }

/* Hover and keyboard readout, drawn by app.js over the plot. */
.readout { position: absolute; inset: 0; pointer-events: none; }
.readout-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--color-text-3); }
.readout-dot {
    position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
    background: var(--chart-line); box-shadow: 0 0 0 2px var(--color-surface);
}
.readout-tip {
    position: absolute; top: 0;
    background: var(--color-surface); border: 1px solid var(--border-divider); border-radius: var(--radius-control);
    box-shadow: var(--shadow-2); padding: var(--s2) var(--s3); white-space: nowrap;
}
.readout-when { display: block; font-size: .75rem; color: var(--color-text-2); }
.readout-price { display: block; font-size: .9375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-end {
    position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
    background: var(--chart-line); box-shadow: 0 0 0 2px var(--color-surface);
}

.chart-tools { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); justify-content: space-between; align-items: center; margin-top: var(--s3); font-size: .8125rem; color: var(--color-text-3); }
.chart-table { margin-top: var(--s3); max-height: 320px; overflow-y: auto; border: 1px solid var(--border-divider); border-radius: var(--radius-control); }
.chart-table table { font-size: .875rem; }
.chart-table td, .chart-table th { padding: var(--s2) var(--s3); }
.chart-table thead th { position: sticky; top: 0; }

.chart-notice {
    display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4);
    align-items: center; justify-content: space-between;
    background: var(--color-info-wash); border: 1px solid var(--border-divider);
    border-radius: var(--radius-control);
    padding: var(--s3) var(--s4); margin-bottom: var(--s4);
    font-size: .9375rem;
}
.chart-notice p { margin: 0; max-width: 64ch; color: var(--color-text-2); }
.chart-notice strong { color: var(--color-text); }
.chart-notice .btn { width: auto; }

.position-panel .ledger { margin-top: 0; border-top: 0; }
.position-panel .actions { margin-top: var(--s4); }
.position-panel .actions .btn { flex: 1; }

.starter-list { display: grid; gap: var(--s2); }
.starter-list button, .ask-starters button {
    font: inherit; font-size: .875rem; text-align: left; cursor: pointer;
    min-height: 40px; padding: var(--s2) var(--s3);
    background: var(--color-surface); color: var(--color-text);
    border: 1px solid var(--border-divider); border-radius: var(--radius-control);
    transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.starter-list button:hover, .ask-starters button:hover { border-color: var(--color-research); background: var(--color-research-wash); }

/* ============================================================ Ask ======= */
/* A research panel beside the page on desktop, full screen on phones. */

.assistant-toggle {
    position: fixed; right: var(--s5); bottom: var(--s5); z-index: 35;
    display: inline-flex; align-items: center; gap: var(--s2);
    min-height: 44px; padding: 0 var(--s4);
    background: var(--color-research-wash); color: var(--color-research-strong);
    border: 1px solid var(--color-research); border-radius: var(--radius-pill);
    font-size: .9375rem; font-weight: 600; text-decoration: none;
    box-shadow: var(--shadow-2);
    transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.assistant-toggle:hover { color: var(--color-research-strong); border-color: var(--color-research-strong); }
.assistant-toggle[aria-expanded="true"] { visibility: hidden; }
.ask-icon { width: 18px; height: 18px; flex: none; }

.assistant {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 36;
    width: min(26rem, 100%);
    display: flex; flex-direction: column;
    background: var(--color-surface);
    border-left: 1px solid var(--border-divider);
    box-shadow: var(--shadow-2);
    transform: translateX(100%);
    transition: transform 180ms var(--ease);
}
.assistant.is-open { transform: none; transition-duration: 240ms; }

.ask-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: var(--s4); padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--border-divider);
}
.ask-title { display: flex; align-items: center; gap: var(--s2); font-size: 1.0625rem; margin: 0; }
.ask-title .ask-icon { color: var(--color-research-strong); }
.ask-sub { margin: 2px 0 0; font-size: .75rem; color: var(--color-text-2); }
.assistant-close {
    font: inherit; font-size: .875rem; color: var(--color-text-2);
    background: var(--color-surface); border: 1px solid var(--border-control); border-radius: var(--radius-control);
    min-height: 36px; padding: 0 var(--s3); cursor: pointer;
}
.assistant-close:hover { color: var(--color-text); background: var(--color-surface-2); }

.ask-context {
    padding: var(--s2) var(--s5); font-size: .8125rem; color: var(--color-text-2);
    background: var(--color-surface-2); border-bottom: 1px solid var(--border-divider);
}
.ask-context-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); min-height: 28px; }
.ask-pill {
    font-family: var(--font-mono); font-weight: 500; font-size: .75rem; color: var(--color-text);
    padding: 0 .5rem; border-radius: var(--radius-pill); background: var(--color-surface); border: 1px solid var(--border-divider);
}
.ask-research { margin-left: auto; font-size: .75rem; }
.ask-scope summary { cursor: pointer; color: var(--color-brand); list-style: none; }
.ask-scope summary::-webkit-details-marker { display: none; }
.ask-scope summary::after { content: " ▾"; font-size: .75em; }
.ask-scope[open] summary::after { content: " ▴"; }
.ask-scope-body { padding: var(--s2) 0 var(--s3); }
.ask-scope-body h3 { font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-3); margin: var(--s2) 0 var(--s1); }
.ask-scope-body ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 2px; }

.assistant-log { flex: 1; overflow-y: auto; padding: var(--s4) var(--s5); overscroll-behavior: contain; }
.ask-intro { color: var(--color-text-2); font-size: .875rem; margin-bottom: var(--s3); }

.turn { font-size: .9375rem; margin-bottom: var(--s4); }
.turn p { margin: 0 0 var(--s3); max-width: 62ch; }
.turn p:last-child { margin-bottom: 0; }
.turn-question { font-weight: 600; color: var(--color-text); margin-bottom: var(--s2); }
.turn-answer { color: var(--color-text); padding-bottom: var(--s4); border-bottom: 1px solid var(--border-divider); }
.turn-error {
    padding: var(--s3); border-radius: var(--radius-control);
    background: var(--color-error-wash); color: var(--color-text);
}
.turn-error strong { display: block; margin-bottom: var(--s1); }
.turn-error.is-info { background: var(--color-info-wash); }
.turn-error .btn { margin-top: var(--s2); }

.turn-pending { display: grid; gap: var(--s3); padding-bottom: var(--s4); }
.pending-line { display: flex; align-items: center; gap: var(--s2); color: var(--color-text); font-size: .875rem; }
.pending-line .spinner { color: var(--color-research); }
.pending-elapsed { margin-left: auto; font-size: .75rem; color: var(--color-text-3); font-variant-numeric: tabular-nums; }
.skeleton { display: grid; gap: var(--s2); }
.skeleton i { display: block; height: 10px; border-radius: 3px; background: var(--color-muted); }
.skeleton i:nth-child(1) { width: 92%; }
.skeleton i:nth-child(2) { width: 78%; }
.skeleton i:nth-child(3) { width: 58%; }

.answer-badge {
    display: inline-block; font-size: .6875rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    padding: .0625rem .5rem; border-radius: var(--radius-pill);
}
.answer-badge.is-researched { background: var(--color-research-wash); color: var(--color-research-strong); }
.answer-badge.is-plain { background: var(--color-surface-2); color: var(--color-text-2); border: 1px solid var(--border-divider); }

.answer-notice {
    margin: 0 0 var(--s3); padding: var(--s2) var(--s3);
    font-size: .8125rem; color: var(--color-text);
    background: var(--color-research-wash); border-radius: var(--radius-control);
}
.answer-notice strong { display: block; }

.provenance {
    margin-top: var(--s3); padding: var(--s3);
    background: var(--color-surface-2); border: 1px solid var(--border-divider); border-radius: var(--radius-control);
    font-size: .8125rem; display: grid; gap: var(--s2);
}
.provenance-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); color: var(--color-text-2); }
.searches { margin: 0; color: var(--color-text-2); }
.searches q { font-family: var(--font-mono); font-size: .75rem; quotes: none; color: var(--color-text); }

.search-suggestions {
    display: block; width: 100%; height: 4.25rem;
    border: 0; margin: 0;
    background: transparent;
}

.sources ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 2px; }
.sources li { line-height: 1.4; }
.sources a { color: var(--color-text); text-decoration-color: var(--border-control); overflow-wrap: anywhere; }
.sources a:hover { color: var(--color-brand); text-decoration-color: currentColor; }
.source-domain { color: var(--color-text-3); font-size: .75rem; }

.answer-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2); margin-top: var(--s3); font-size: .75rem; color: var(--color-text-3); }
.answer-tools { display: flex; gap: var(--s1); }
.answer-tools button {
    font: inherit; font-size: .75rem; cursor: pointer; min-height: 28px; padding: 0 var(--s2);
    color: var(--color-text-2); background: var(--color-surface);
    border: 1px solid var(--border-divider); border-radius: 4px;
}
.answer-tools button:hover { color: var(--color-text); border-color: var(--border-control); }

.ask-starters { display: grid; gap: var(--s2); padding: 0 var(--s5) var(--s4); }
.ask-starters .label { margin: 0; }

.assistant-form { padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--border-divider); display: grid; gap: var(--s2); }
.assistant-form label { font-size: .8125rem; margin: 0; }
.assistant-form textarea { min-height: 52px; max-height: 40vh; font-size: .9375rem; }
.composer-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); font-size: .75rem; color: var(--color-text-3); }
.composer-count { font-variant-numeric: tabular-nums; }
.composer-count.is-near { color: var(--color-error-text); }
.assistant-form .btn { min-height: 36px; }
.assistant-note { margin: 0; font-size: .75rem; color: var(--color-text-3); line-height: 1.45; }

.assistant-answer p { margin: 0 0 var(--s3); max-width: 68ch; }
.assistant-q { font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
    .assistant, .assistant-toggle { transition: none !important; }
}

/* ========================================================== responsive == */

@media (max-width: 960px) {
    .grid-main { grid-template-columns: minmax(0, 1fr); }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpis .kpi:nth-child(3) { border-left: 0; }
    .kpis .kpi:nth-child(n+3) { border-top: 1px solid var(--border-divider); }
    .kpis-3 .kpi:nth-child(3) { grid-column: 1 / -1; }
    .two-col { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .split { grid-template-columns: 1fr; }
    .split-op { text-align: left; }
    .step + .step { border-left: 0; border-top: 1px solid var(--border-divider); }
}

@media (max-width: 720px) {
    :root { --s5: 1.125rem; --s6: 1.5rem; --s7: 2.25rem; --s8: 3rem; }
    .masthead { position: static; }
    .masthead-inner { padding: var(--s2) var(--s4); gap: var(--s2); }
    .nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; order: 3; min-height: 44px; -webkit-overflow-scrolling: touch; }
    .nav a { white-space: nowrap; }
    .account { margin-left: auto; gap: var(--s3); }
    .account-name, .cash-chip .label { display: none; }
    .page-head-row .actions { width: 100%; }
    .page-head-row .actions .btn { width: auto; flex: 1; }
    main { padding: var(--s5) var(--s4) var(--s7); }
    .panel { padding: var(--s4); }
    .panel-flush { padding: 0; }
    .panel-flush .panel-head { padding: var(--s4) var(--s4) 0; }
    .hero { min-height: 0; }
    .quote-price { font-size: 1.5rem; }
    .stock-price-fig { font-size: 1.75rem; }
    .kpi { padding: var(--s3) var(--s4); }
    .kpi-value { font-size: 1.25rem; }
    .company { max-width: none; }
    .btn { width: 100%; }
    .actions .btn-quiet { width: auto; }
    .account .btn, .chart-notice .btn, .answer-tools button { width: auto; }
    .glossary dl { grid-template-columns: 1fr; }
    .x-tick:nth-child(even):not(.x-tick-end) { display: none; }
    .chart-y { min-width: 2.9rem; }
    .ranges { display: flex; width: 100%; }
    .range { flex: 1; min-width: 0; padding: 0; }

    .stack-on-mobile thead { display: none; }
    .stack-on-mobile, .stack-on-mobile tbody, .stack-on-mobile tr, .stack-on-mobile td { display: block; width: 100%; }
    .stack-on-mobile tr { border-bottom: 1px solid var(--border-divider); padding: var(--s3) var(--s4); }
    .stack-on-mobile tbody tr:last-child { border-bottom: none; }
    .stack-on-mobile td { border: 0; padding: var(--s1) 0; display: flex;
                          justify-content: space-between; align-items: baseline; gap: var(--s4); text-align: right; }
    .stack-on-mobile td::before {
        content: attr(data-label);
        font-size: .75rem; font-weight: 600; letter-spacing: .04em;
        text-transform: uppercase; color: var(--color-text-3); text-align: left; flex: none;
    }
    .stack-on-mobile td:first-child { display: block; text-align: left; margin-bottom: var(--s1); }
    .stack-on-mobile td:first-child::before { content: none; }

    .assistant { width: 100%; border-left: 0; }
    .assistant-toggle { right: var(--s4); bottom: var(--s4); }
}

/* ============================================================================
   MOTION
   Additive only. Every element's default state is its FINAL state, so a
   browser without scroll timelines, or a reader who asked for less motion,
   gets the finished page immediately. Only transform and opacity animate.
   ========================================================================= */

.scroll-progress {
    position: fixed; inset: 0 0 auto 0; height: 2px;
    background: var(--color-brand); transform: scaleX(0); transform-origin: 0 50%;
    z-index: 40; pointer-events: none;
}

[data-motion="calm"]   { --rise: 6px;  --drift: -6px; }
[data-motion="lively"] { --rise: 14px; --drift: -12px; }

@keyframes rise-in   { from { opacity: 0; transform: translateY(var(--rise, 10px)); }
                       to   { opacity: 1; transform: none; } }
@keyframes drift     { from { transform: translateY(0); }
                       to   { transform: translateY(var(--drift, -8px)); } }
@keyframes progress  { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes settle    { from { opacity: 0; transform: translateY(-4px); }
                       to   { opacity: 1; transform: none; } }
@keyframes fade-out  { to { opacity: 0; } }
@keyframes pulse     { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

@media (prefers-reduced-motion: no-preference) {

    /* Tier 1: native scroll-driven timelines (Chrome, Edge). */
    @supports (animation-timeline: view()) {
        .reveal {
            animation: rise-in both linear;
            animation-timeline: view();
            animation-range: entry 2% entry 32%;
        }
        .stagger > * {
            animation: rise-in both linear;
            animation-timeline: view();
            animation-range: entry 0% entry 20%;
        }
        .hero-inner {
            animation: drift both linear;
            animation-timeline: scroll(root block);
            animation-range: 0 320px;
        }
        .scroll-progress {
            animation: progress both linear;
            animation-timeline: scroll(root block);
        }
    }

    /* Tier 2: IntersectionObserver, for Safari and Firefox.
       .js-reveal is added by app.js only, so no JS means no hiding. */
    .js-reveal .reveal,
    .js-reveal .stagger > * {
        opacity: 0;
        transform: translateY(var(--rise, 10px));
    }
    .js-reveal .reveal.is-in,
    .js-reveal .stagger > *.is-in {
        opacity: 1; transform: none;
        transition: opacity 300ms var(--ease), transform 300ms var(--ease);
    }

    /* A position that has just changed settles in, the same for a buy or a sell. */
    .just-changed { animation: settle 300ms var(--ease) both; }

    .self-dismiss { animation: fade-out 400ms var(--ease) 6s both; }

    .skeleton i { animation: pulse 1600ms ease-in-out infinite; }
    .skeleton i:nth-child(2) { animation-delay: 160ms; }
    .skeleton i:nth-child(3) { animation-delay: 320ms; }
}

@media (prefers-reduced-motion: reduce) {
    .reveal, .stagger > *, .page-head, .hero-inner,
    .scroll-progress, .just-changed, .self-dismiss, .skeleton i {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .scroll-progress { display: none; }
    .hero-stage canvas { display: none; }
}

/* ---------------------------------------------- trades and activity ----

   A trade is a fact, not a verdict: the side tag is neutral, because
   selling is not a failure and buying is not an achievement. Realized
   figures reuse .delta, so a banked gain and a paper one read alike —
   the column heading is what tells them apart.                         */

.side-tag {
    display: inline-block; white-space: nowrap;
    font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    padding: .125rem var(--s2); border-radius: var(--radius-pill);
    background: var(--color-surface-2); color: var(--color-text-2);
    border: 1px solid var(--border-divider);
}
.side-buy  { border-color: var(--color-brand); color: var(--color-brand); }
.account-name:hover { color: var(--color-text); }

.activity { list-style: none; margin: 0; padding: 0; }
.activity-row {
    display: grid; align-items: center; gap: var(--s2) var(--s4);
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto;
    padding: var(--s3) 0; border-top: 1px solid var(--border-divider);
}
.activity-row:first-child { border-top: 0; padding-top: 0; }
.activity-symbol { color: inherit; text-decoration: none; }
.activity-symbol:hover .ticker { text-decoration: underline; }
.activity-what {
    display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
    color: var(--color-text-2); font-size: .875rem;
}
.activity-what .num { color: var(--color-text); }
.activity-when { font-size: .8125rem; }
.activity-value { font-weight: 600; text-align: right; white-space: nowrap; }

.pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s4); padding: var(--s3) var(--s5);
    border-top: 1px solid var(--border-divider);
}
.pager-count { margin: 0; font-size: .875rem; }
/* Kept in the layout, not removed, so the controls do not shift sideways
   on the first and last page. */
.is-disabled { opacity: .4; pointer-events: none; }

.detail-list { margin: 0; display: grid; gap: var(--s3); }
.detail-list > div {
    display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4);
    justify-content: space-between; align-items: baseline;
    padding-bottom: var(--s3); border-bottom: 1px solid var(--border-divider);
}
.detail-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.detail-list dt { color: var(--color-text-2); font-size: .9375rem; }
.detail-list dd { margin: 0; font-weight: 600; }

/* --------------------------------------------------- destructive acts --

   Deliberately the error palette, never --color-loss: red here means
   "this cannot be undone", not "this investment lost money". Borrowing
   the loss colour would make the two read as the same kind of news.
   The panel is bordered rather than filled, because a red wash behind a
   whole block reads as an error that has already happened.             */

.panel-danger { border-color: var(--color-error); }
.panel-danger .panel-head h2 { color: var(--color-error-text); }
.btn-danger { background: var(--color-error); color: #FFF; border-color: var(--color-error); }
.btn-danger:hover { background: var(--color-error-text); border-color: var(--color-error-text); color: #FFF; }
.delete-form .field { max-width: 20rem; }
.confirm-word { font-family: var(--font-mono); letter-spacing: .08em; }
.field-help { color: var(--color-text-2); font-size: .8125rem; margin: var(--s2) 0 0; }

@media (max-width: 720px) {
    .activity-row { grid-template-columns: minmax(0, 1fr) auto; }
    .activity-when { grid-column: 1 / -1; }
    .pager { flex-wrap: wrap; justify-content: center; }
}

/* ------------------------------------------------------- leaderboard --- */

/* The viewer's own row, marked by weight and a rule rather than a fill:
   a highlighted band would read as a warning on a table of results. */
tr.is-you > td { background: var(--color-surface-2); font-weight: 600; }
tr.is-you > td:first-child { box-shadow: inset 3px 0 0 var(--color-brand); }

.panel-quiet { background: var(--color-surface-2); box-shadow: none; }

.checkline { display: flex; align-items: center; gap: var(--s2); font-weight: 400; }
.checkline input { width: auto; min-height: 0; }

/* --------------------------------------------------------- watchlist --- */

.inline-form { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; }
.inline-form .field { max-width: 12rem; }
.row-actions { display: inline-flex; align-items: center; gap: var(--s2); justify-content: flex-end; }
@media (max-width: 720px) { .row-actions { justify-content: flex-start; } }

/* ---------------------------------------------------------- policies --- */

.footer-disclaimer { max-width: 62ch; margin: 0 auto var(--s3); }
.footer-links { display: flex; gap: var(--s4); justify-content: center; flex-wrap: wrap; }
.footer-links a { font-size: .875rem; }

/* A draft banner that cannot be mistaken for chrome. */
.draft-notice {
    border: 1px solid var(--color-research);
    background: var(--color-research-wash);
    color: var(--color-research-strong);
    border-radius: var(--radius-panel);
    padding: var(--s4) var(--s5);
    margin-bottom: var(--s5);
}
.draft-notice p { margin: 0 0 var(--s2); }
.draft-notice p:last-child { margin-bottom: 0; }

.legal { max-width: 68ch; }
.legal h2 { margin-top: var(--s6); }
.legal h3 { margin-top: var(--s5); }
.legal ul { padding-left: var(--s5); }
.legal li { margin-bottom: var(--s2); }
.legal .updated { color: var(--color-text-3); font-size: .875rem; }
.gate-terms { margin: var(--s4) 0 0; font-size: .8125rem; line-height: 1.5; }

/* ------------------------------------------------------------ search --- */

/* The live result list. Absent entirely without JavaScript — the form
   falls back to the search page, which is a real page with real rows. */
.search-results {
    list-style: none; margin: var(--s2) 0 0; padding: 0;
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    box-shadow: var(--shadow-1);
    max-height: 17rem; overflow-y: auto;
}
.search-results li { border-top: 1px solid var(--border-divider); }
.search-results li:first-child { border-top: 0; }
.search-results button {
    display: flex; width: 100%; gap: var(--s3); align-items: baseline;
    padding: var(--s2) var(--s3);
    background: none; border: 0; text-align: left; font: inherit;
    color: var(--color-text); cursor: pointer;
}
.search-results button:hover,
.search-results li[aria-selected="true"] button { background: var(--color-surface-2); }
.search-results .ticker { flex: 0 0 auto; color: var(--color-brand); }
.search-results .company {
    flex: 1 1 auto; min-width: 0; max-width: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.as-of { margin: var(--s3) 0 0; font-size: .8125rem; }
