/* Colors are tokens so the whole app can switch theme. Dark is the base
   palette; base.html sets data-theme="light" or "dark" on <html> before this
   stylesheet paints (saved choice first, otherwise the system setting). */
:root {
    color-scheme: dark;
    --bg: #0f1115;
    --panel: #171a21;
    --panel-raised: #1f232c;
    --border: #2a2e37;
    --border-strong: #3a404c;
    --text: #e6e8eb;
    --text-2: #c5cad3;
    --muted: #9aa1ac;
    --accent: #4f8ef7;
    --green: #3bb273;
    --red: #e0575b;
    --amber: #e6a84c;
    --input-bg: #0f1115;
    --placeholder: #6b7280;
    --row-hover: rgba(255, 255, 255, 0.03);
    --tip-bg: #242935;
    --shadow: rgba(0, 0, 0, 0.5);
    --chart-wash: rgba(79, 142, 247, 0.10);
    --chart-hold: rgba(255, 255, 255, 0.05);
}

/* Status colors are darker than in dark mode so text stays readable on white. */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f5f7;
    --panel: #ffffff;
    --panel-raised: #eceef2;
    --border: #dfe2e7;
    --border-strong: #c3c9d2;
    --text: #1b1f24;
    --text-2: #3d4450;
    --muted: #5f6773;
    --accent: #2563eb;
    --green: #1a7f4b;
    --red: #c62f35;
    --amber: #9a6200;
    --input-bg: #ffffff;
    --placeholder: #7a818c;
    --row-hover: rgba(15, 23, 42, 0.03);
    --tip-bg: #ffffff;
    --shadow: rgba(15, 23, 42, 0.14);
    --chart-wash: rgba(37, 99, 235, 0.08);
    --chart-hold: rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

/* Classes that set `display` (e.g. .callout) would otherwise override the hidden attribute. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

h1 { font-size: 26px; margin: 8px 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */

/* Stays at the top while you scroll, so the menu is always a tap away. */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}
/* Jumping to a section lands below the top bar rather than under it. */
html { scroll-padding-top: 72px; }

/* For keyboard users: the first Tab stop jumps past the menu. */
.skip-link {
    position: absolute;
    left: 8px;
    top: -48px;
    z-index: 200;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
}
.skip-link:focus { top: 8px; }
.content:focus { outline: none; }

.brand { font-weight: 600; margin-right: auto; }

.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 6px;
}
.topbar nav a:hover { color: var(--text); background: var(--panel-raised); }
.topbar nav a.active {
    color: var(--text);
    background: var(--panel-raised);
    box-shadow: inset 0 -2px 0 var(--accent);
}
/* Trades waiting for your review, beside Review. */
.nav-count {
    display: inline-block;
    min-width: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--amber);
    color: var(--bg);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.theme-switch {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}
.theme-switch button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] {
    background: var(--panel-raised);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--border-strong);
}
.theme-switch svg { width: 16px; height: 16px; }

.content { padding: 24px; max-width: 1100px; margin: 0 auto; }

/* What a table cell sits on, so a cell pinned in place can cover the ones scrolling under it. */
body { --cell-bg: var(--bg); }
.panel { --cell-bg: var(--panel); }

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 16px;
    margin-bottom: 12px;
}
.page-header h2 { margin: 16px 0 8px; }
.header-actions { display: flex; align-items: center; gap: 12px; }

.hint { color: var(--muted); font-size: 13px; }
.error-msg { color: var(--red); }
.nowrap { white-space: nowrap; }

/* A button that reads as a link, for small actions in a table row. */
.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Signing in ---------- */

.signout-form { margin: 0; }
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card .stacked-form { max-width: none; margin-top: 16px; }

.callout {
    margin: 12px 0 16px;
    padding: 10px 14px;
    border-left: 3px solid var(--amber);
    border-radius: 4px;
    background: color-mix(in srgb, var(--amber) 10%, transparent);
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.5;
}

.footnote {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 20px;
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.primary-btn:hover { opacity: 0.9; }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border-strong);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.secondary-btn:hover { background: var(--panel-raised); }
.secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-link { color: var(--accent); font-size: 14px; text-decoration: none; }
.secondary-link:hover { text-decoration: underline; }

/* ---------- Stat tiles & panels ---------- */

.tile-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.tile-row.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tile {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
}
.tile-label { color: var(--muted); font-size: 12px; }
.tile-value { font-size: 20px; font-weight: 600; margin-top: 4px; }
.tile-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}
.panel h2 { margin-top: 0; font-size: 15px; color: var(--muted); }
.panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 16px;
    margin-bottom: 8px;
}
.panel-header h2 { margin: 0; }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Charts fill a fixed-height box (maintainAspectRatio: false) so they keep a
   readable height on narrow screens instead of shrinking with the width. */
.chart-box { position: relative; height: 280px; }
.chart-box-sm { height: 220px; }

.chart-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 20px 0 8px;
}
.chart-title { margin: 0 auto 0 0; font-size: 14px; font-weight: 600; color: var(--muted); }

/* TAO and BTC side by side: the measure, then one column each. The notes
   under each figure wrap on a phone rather than widening the table. */
.market-table th[scope="row"] { width: 130px; }
.market-table td { width: 50%; }
.market-table .cell-sub { white-space: normal; }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px 20px;
    margin: 0 0 12px;
}
.settings-grid dt { color: var(--muted); font-size: 12px; }
.settings-grid dd { margin: 2px 0 0; font-size: 14px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.data-table tbody tr:hover { background: var(--row-hover); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .empty-cell { color: var(--muted); }

.data-table input {
    width: 100%;
    min-width: 120px;
    padding: 5px 8px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font: inherit;
    transition: border-color 0.2s;
}
.data-table input:hover { border-color: var(--border-strong); }
.data-table input:focus { border-color: var(--accent); outline: none; }
.data-table input.is-saved { border-color: var(--green); }
.data-table input.is-error { border-color: var(--red); }
.data-table input.notes-input { min-width: 220px; }

input::placeholder, textarea::placeholder { color: var(--placeholder); }

.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }

/* ---------- Forms ---------- */

.stacked-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
}
.stacked-form label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    color: var(--muted);
    gap: 4px;
}
.stacked-form input, .stacked-form select, .stacked-form textarea {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.stacked-form textarea { resize: vertical; }
.wide-form { max-width: 100%; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
}
.form-grid:empty { display: none; }

.field-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}
.badge-sm { padding: 2px 8px; font-size: 12px; }
a.badge { text-decoration: none; }
a.badge:hover { text-decoration: underline; }

/* Tints are mixed from the theme's own status colors, so they adapt with it. */
.sentiment-bullish, .verdict-aligned, .side-long {
    background: color-mix(in srgb, var(--green) 15%, transparent);
    color: var(--green);
}
.sentiment-bearish, .verdict-conflicts, .side-short {
    background: color-mix(in srgb, var(--red) 15%, transparent);
    color: var(--red);
}
.sentiment-neutral, .verdict-unclear {
    background: color-mix(in srgb, var(--muted) 15%, transparent);
    color: var(--muted);
}
.sentiment-mixed, .badge-info {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}
.verdict-wait, .badge-warn {
    background: color-mix(in srgb, var(--amber) 15%, transparent);
    color: var(--amber);
}

.tag-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tag-list li {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
}

/* ---------- Advisor ---------- */

.panel-summary {
    cursor: pointer;
    font-size: 15px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.verdict-line {
    margin: 4px 0 16px;
    font-size: 14px;
    line-height: 1.6;
}
.verdict-line .badge { margin: 0 8px 0 4px; }
.verdict-line .term + .read-text { margin-left: 8px; }

.gauge-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 14px;
}
.gauge-end { font-size: 11px; color: var(--muted); white-space: nowrap; }
.gauge {
    position: relative;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--red), var(--muted), var(--green));
}
/* Neutral (0) tick, so the marker's side of centre is readable at a glance. */
.gauge::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -3px;
    width: 1px;
    height: 12px;
    background: var(--bg);
}
.gauge-marker {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: var(--text);
    transform: translateX(-50%);
}

.compact-table th {
    width: 110px;
    vertical-align: top;
    color: var(--muted);
    font-weight: 500;
}
.compact-table td { line-height: 1.5; }
.compact-table .tag-list { margin: 0; }

.tight-list {
    margin: 0;
    padding-left: 18px;
}
.tight-list li { margin-bottom: 3px; }

/* Keep history rows scannable; full text stays in the title tooltip. */
.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 520px;
}

/* ---------- Trade review ---------- */

.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.section-title { margin: 20px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }

/* Where the entry sat in the prior range: low at the left edge, high at the right. */
.range-bar {
    position: relative;
    display: inline-block;
    width: 72px;
    height: 6px;
    margin-right: 8px;
    vertical-align: middle;
    border-radius: 3px;
    background: var(--panel-raised);
    box-shadow: inset 0 0 0 1px var(--border);
}
.range-bar-marker {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: var(--text);
    transform: translateX(-50%);
}
.range-bar.chase .range-bar-marker { background: var(--amber); }

.narrative { margin: 0; padding-left: 20px; line-height: 1.6; }
.narrative li + li { margin-top: 6px; }

/* The dashboard's "Right now": one entry per open position. */
.now-list { list-style: none; margin: 8px 0 0; padding: 0; }
.now-position { padding: 12px 0; border-top: 1px solid var(--border); }
.now-position:first-child { border-top: 0; padding-top: 4px; }
.now-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 4px; }
.now-name { color: var(--text); font-weight: 600; text-decoration: none; }
.now-name:hover { text-decoration: underline; }
.now-pnl { font-weight: 600; }
.now-position .plan-checks { margin-top: 6px; }

.plan-box { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.plan-box .plan-checks { margin-bottom: 8px; }
.plan-box .plan-checks:empty { display: none; }
.add-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.add-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.add-table { margin-top: 12px; }
.add-table th[scope="row"] { color: var(--muted); font-weight: 500; }

/* ---------- Alerts ---------- */

.alert-table tr.is-off td:first-child { color: var(--muted); }
.rule-actions { display: flex; align-items: center; gap: 12px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.inline-number {
    width: 4.5em;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 2px 6px;
    font: inherit;
    text-align: right;
}
.rule-form { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); }
.rule-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.delivery-list, .event-list { margin: 0; padding-left: 20px; line-height: 1.7; }
.delivery-list li + li, .event-list li + li { margin-top: 8px; }
.delivery-list .secondary-btn { margin-left: 6px; padding: 4px 10px; font-size: 13px; }

/* A plan's checks: kept, broken, or a note that decides nothing. */
.plan-checks { list-style: none; margin: 8px 0 0; padding: 0; line-height: 1.6; }
.plan-check { position: relative; padding-left: 24px; }
.plan-check + .plan-check { margin-top: 6px; }
.plan-check::before { position: absolute; left: 0; width: 18px; text-align: center; font-weight: 700; }
.plan-check.is-kept::before { content: "✓"; color: var(--green); }
.plan-check.is-broken::before { content: "✗"; color: var(--red); }
.plan-check.is-note::before { content: "•"; color: var(--muted); }
.plan-check.is-act::before { content: "!"; color: var(--red); }
.plan-check.is-warn::before { content: "!"; color: var(--amber); }
.plan-check.is-info::before { content: "i"; color: var(--accent); font-style: italic; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- Your review ---------- */

.debrief-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
fieldset.debrief-field { display: block; margin: 0; padding: 0; border: 0; }
fieldset.debrief-field legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.debrief-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }

/* Quick picks under a tag field; the pressed one matches what's typed. */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text-2);
    font-size: 12px;
    cursor: pointer;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
a.chip { text-decoration: none; }
.chip[aria-pressed="true"], .chip[aria-current="page"] {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}

/* Which coin a page shows: journal pages add "All coins". */
.coin-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 16px; }
.coin-picker-label { margin-right: 4px; font-size: 13px; color: var(--muted); }
.coin-picker .chip { padding: 4px 12px; font-size: 13px; }

/* Links to the sections of a long page. */
.jump-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: -4px 0 16px; font-size: 13px; }
.jump-bar a { text-decoration: none; }
.jump-bar a:hover { text-decoration: underline; }

/* One row of buttons built on real radio inputs: Yes / Partly / No on a
   review, TAO / BTC and the time range on the Advisor's chart. */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}
.segment { position: relative; display: block; }
.segment input { position: absolute; inset: 0; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.segment span { display: block; padding: 5px 18px; border-radius: 6px; font-size: 14px; color: var(--muted); }
.chart-toolbar .segment span { padding: 3px 12px; font-size: 13px; }
.segment:hover span { color: var(--text); }
.segment input:checked + span {
    background: var(--panel-raised);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--border-strong);
}
.segment input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li + li { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.lesson-text { margin: 0 0 4px; line-height: 1.5; }

/* ---------- Weekly reports ---------- */

.focus-panel { border-left: 3px solid var(--accent); }
.focus-text { margin: 0 0 6px; font-size: 17px; line-height: 1.5; color: var(--text); }
.report-text { margin: 0 0 8px; line-height: 1.6; }
.report-text:last-child { margin-bottom: 0; }
.report-list li { line-height: 1.5; }

/* ---------- Setup test ---------- */

/* The settings read as sentences, with small boxes where the numbers go. */
.setup-sentence { margin: 0 0 12px; font-size: 15px; line-height: 2.2; }
.setup-sentence input, .setup-sentence select {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 6px;
    border-radius: 6px;
    font: inherit;
}
.setup-sentence input { width: 5.5em; text-align: right; }
.setup-sentence input:focus, .setup-sentence select:focus { border-color: var(--accent); outline: none; }
.setup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
/* The size box and note for the margin mode that isn't chosen. */
.setup-form:has(select[name="margin"] option[value="cross"]:checked) .when-isolated,
.setup-form:has(select[name="margin"] option[value="isolated"]:checked) .when-cross { display: none; }
.setup-form > .field-help { margin: 12px 0 0; }

.findings { margin: 0; padding-left: 20px; line-height: 1.7; }
.findings li + li { margin-top: 6px; }

.leverage-table tr.is-yours { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.leverage-table th[scope="row"] { color: var(--text); white-space: nowrap; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.outcome-target { background: var(--green); }
.outcome-liquidated { background: var(--red); }
.outcome-stopped { background: var(--amber); }
.outcome-time_up { background: var(--muted); }

/* ---------- Glossary terms & tooltip ---------- */

.term {
    cursor: help;
    border-radius: 3px;
    text-decoration: underline dotted color-mix(in srgb, var(--muted) 50%, transparent);
    text-underline-offset: 3px;
}
.term:hover, .term[aria-describedby] { text-decoration-color: var(--muted); }
.term-icon { text-decoration: none; }

.term::after,
.help-glyph {
    content: "?";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 4px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 12px;
    text-align: center;
    vertical-align: 2px;
}
.term-icon::after { margin-left: 0; }
.term:hover::after,
.term:focus-visible::after,
.term[aria-describedby]::after {
    border-color: var(--accent);
    color: var(--text);
}

.term-tip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    max-width: min(320px, calc(100vw - 16px));
    padding: 10px 12px;
    background: var(--tip-bg);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 12px 32px var(--shadow);
    color: var(--text);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
}
.term-tip strong { display: block; margin-bottom: 4px; }
.term-tip p { margin: 0; color: var(--text-2); }

/* ---------- Small screens ---------- */

@media (max-width: 800px) {
    .two-col { grid-template-columns: 1fr; }
    .tile-row.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .topbar { padding: 10px 16px; }
    /* Theme switch stays beside the brand; the nav gets its own row. */
    .theme-switch { order: 1; }
    /* One row you can swipe, rather than two rows of menu taking a sixth of the screen. */
    .topbar nav {
        order: 2;
        flex-wrap: nowrap;
        width: calc(100% + 32px);
        margin: 0 -16px;
        padding: 0 16px;
        gap: 2px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
        mask-image: linear-gradient(to right, #000 85%, transparent);
    }
    .topbar nav::-webkit-scrollbar { display: none; }
    /* A table wider than the phone keeps its first column in view as you swipe. */
    .table-wrap .data-table th:first-child,
    .table-wrap .data-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--cell-bg);
        box-shadow: 1px 0 0 var(--border);
    }
    .topbar nav a { flex: none; white-space: nowrap; padding: 6px 10px; font-size: 13px; }
    html { scroll-padding-top: 104px; }
    .content { padding: 16px; }
    h1 { font-size: 22px; }
    .form-grid { grid-template-columns: 1fr; }
    .chart-box { height: 220px; }
    .chart-box-sm { height: 200px; }
    .market-table th[scope="row"] { width: auto; }
    .market-table th, .market-table td { padding: 8px 6px; }
}
