/* ============================================================================
   ALGOM report - mobile first.
   Base styles target a ~360px viewport; everything wider is a progressive
   enhancement via min-width queries at 480 / 600 / 900 / 1280 / 1600.
   ========================================================================== */

:root {
    color-scheme: light dark;

    --bg: #f5f6fa;
    --bg-elevated: #ffffff;
    --bg-sunken: #eceef5;
    --border: #e0e3ed;
    --border-strong: #c9cee0;

    --text: #10131c;
    --text-muted: #5c6479;
    --text-faint: #8b93a7;

    --accent: #3b6bf0;
    --accent-soft: rgba(59, 107, 240, 0.12);
    --positive: #128a5b;
    --positive-soft: rgba(18, 138, 91, 0.12);
    --negative: #cf3341;
    --negative-soft: rgba(207, 51, 65, 0.12);
    --warning: #c67608;
    --warning-soft: rgba(198, 118, 8, 0.14);

    --shadow-sm: 0 1px 2px rgba(16, 19, 28, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 19, 28, 0.08);
    --shadow-lg: 0 10px 34px rgba(16, 19, 28, 0.18);

    --radius: 14px;
    --radius-sm: 9px;
    --radius-pill: 999px;

    --gap: 10px;
    --pad: 13px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    --font-num: "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

    --header-h: 52px;
}

:root[data-theme="dark"] {
    --bg: #0c0e14;
    --bg-elevated: #151925;
    --bg-sunken: #1e2331;
    --border: #262c3c;
    --border-strong: #38405a;

    --text: #eef1f8;
    --text-muted: #9aa3ba;
    --text-faint: #6b7489;

    --accent: #6b93ff;
    --accent-soft: rgba(107, 147, 255, 0.16);
    --positive: #3ddc9a;
    --positive-soft: rgba(61, 220, 154, 0.14);
    --negative: #ff6b78;
    --negative-soft: rgba(255, 107, 120, 0.14);
    --warning: #ffb74d;
    --warning-soft: rgba(255, 183, 77, 0.16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

/* The browser hides [hidden] with a UA rule, but any author rule that sets
   `display` on the same element outranks it - so `node.hidden = true` silently
   did nothing on .bar, .bar-empty and .hedge-legend. Restate it as a win. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    padding: 0 0 calc(18px + env(safe-area-inset-bottom));
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

/* Numbers use tabular figures so digits do not jitter as values tick. */
.num {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.pos { color: var(--positive); }
.neg { color: var(--negative); }
.warn { color: var(--warning); }

/* ---------------------------------------------------------------- header -- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 var(--pad);
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.14em;
    margin-right: auto;
    flex: none;
}

.brand span { color: var(--accent); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--bg-sunken);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex: none;
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }

.pill[data-state="on"] { background: var(--positive-soft); color: var(--positive); }
.pill[data-state="on"] .dot { background: var(--positive); animation: pulse 2s ease-in-out infinite; }
.pill[data-state="off"] { background: var(--negative-soft); color: var(--negative); }
.pill[data-state="off"] .dot { background: var(--negative); }
.pill[data-state="unknown"] { background: var(--warning-soft); color: var(--warning); }
.pill[data-state="unknown"] .dot { background: var(--warning); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    50% { box-shadow: 0 0 0 4px transparent; opacity: 0.55; }
}

/* Resource alarm. Hidden until the system card's numbers turn dangerous, so a
   problem is visible from the top of the page instead of only at the bottom. */
.alarm {
    display: none;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    flex: none;
}

.alarm[data-show="1"] { display: inline-flex; }
.alarm[data-level="critical"] {
    background: var(--negative-soft);
    color: var(--negative);
    animation: alarm-pulse 1.6s ease-in-out infinite;
}

@keyframes alarm-pulse { 50% { opacity: 0.55; } }
.alarm svg { width: 13px; height: 13px; flex: none; }

.icon-btn {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    flex: none;
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn[data-busy="1"] svg { animation: spin 0.9s linear infinite; }
.icon-btn.danger:hover { background: var(--negative-soft); color: var(--negative); }

@keyframes spin { to { transform: rotate(360deg); } }

/* On the narrowest phones the autotrading pill loses its word to save room. */
@media (max-width: 400px) {
    .pill .label-long { display: none; }
    .brand { font-size: 13px; }
}

/* ------------------------------------------------------------ connection -- */
.stale-banner {
    display: none;
    align-items: center;
    gap: 8px;
    margin: var(--gap) var(--pad) 0;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 12px;
    font-weight: 600;
}

body[data-conn="stale"] .stale-banner { display: flex; }

/* ---------------------------------------------------------------- layout -- */
.page {
    padding: var(--gap) var(--pad) 0;
    display: grid;
    gap: var(--gap);
    grid-template-columns: 1fr;
    max-width: 1500px;
    margin: 0 auto;
    align-items: start;
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: var(--pad);
    min-width: 0;
}

.card-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 9px;
}

.card-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.card-note { margin-left: auto; font-size: 11px; color: var(--text-faint); }

/* ------------------------------------------------------------------ hero -- */
.hero {
    background:
        radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 60%),
        var(--bg-elevated);
}

.hero-total {
    font-size: clamp(26px, 7.6vw, 36px);
    font-weight: 750;
    line-height: 1.05;
    letter-spacing: -0.025em;
    display: flex;
    align-items: baseline;
    gap: 7px;
    flex-wrap: wrap;
}

.hero-unit { font-size: 0.42em; font-weight: 600; color: var(--text-faint); letter-spacing: 0.08em; }

.hero-sub {
    margin-top: 5px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    gap: 6px 14px;
    flex-wrap: wrap;
}

.delta-grid {
    margin-top: 11px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.delta { background: var(--bg-elevated); padding: 7px 10px; min-width: 0; }

.delta-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: 4px;
}

.delta-value {
    font-size: 15px;
    font-weight: 700;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delta-meta { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Ratios live inside the hero as a thin strip rather than owning a card of
   their own - three numbers never justified a full grid cell next to the
   allocation and exchange rows. */
.ratio-strip {
    display: flex;
    margin-top: 9px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    gap: 6px;
}

.ratio {
    flex: 1;
    min-width: 0;
    padding-left: 8px;
    border-left: 2px solid var(--text-faint);
}

.ratio[data-tone="good"] { border-left-color: var(--positive); }
.ratio[data-tone="warn"] { border-left-color: var(--warning); }
.ratio[data-tone="bad"] { border-left-color: var(--negative); }

.ratio-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ratio-value { font-size: 14px; font-weight: 700; line-height: 1.2; }
.ratio[data-tone="good"] .ratio-value { color: var(--positive); }
.ratio[data-tone="warn"] .ratio-value { color: var(--warning); }
.ratio[data-tone="bad"] .ratio-value { color: var(--negative); }

/* ----------------------------------------------------------- stacked bar -- */
.bar {
    display: flex;
    justify-content: flex-start;
    height: 40px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-sunken);
    cursor: default;
}

/* flex:none is load-bearing: with a hundred segments the default flex-shrink
   would let them collapse into each other and ignore their real widths. */
.bar-seg {
    flex: none;
    height: 100%;
    min-width: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    overflow: hidden;
    white-space: nowrap;
    transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1), filter 0.15s;
}

.bar-seg:hover, .bar-seg[data-active="1"] { filter: brightness(1.16) saturate(1.1); }

.seg-sym {
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.seg-val { font-size: 9px; font-weight: 600; opacity: 0.82; font-family: var(--font-num); }

.bar-empty {
    display: grid;
    place-items: center;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-sunken);
    color: var(--text-faint);
    font-size: 11px;
}

/* --------------------------------------------------------------- tooltip -- */
/* One shared element for every chart. Follows the pointer on a mouse, and
   pins itself above the bar when a touch taps a segment. */
.tip {
    position: fixed;
    z-index: 300;
    min-width: 130px;
    max-width: min(260px, calc(100vw - 20px));
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.12s, transform 0.12s;
}

.tip[data-open="1"] { opacity: 1; transform: none; }

.tip-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    margin-bottom: 5px;
}

.tip-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    font-size: 11.5px;
    color: var(--text-muted);
}

.tip-row b { color: var(--text); font-weight: 650; font-family: var(--font-num); }

.tip-list {
    margin-top: 7px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 2px;
    max-height: 180px;
    overflow: hidden;
}

.tip-more { margin-top: 5px; font-size: 10.5px; color: var(--text-faint); }

/* ----------------------------------------------------------------- hedge -- */
.hedge-row { margin-bottom: 9px; }
.hedge-row:last-child { margin-bottom: 0; }

.hedge-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 11px;
}

.hedge-label { font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); }
.hedge-total { margin-left: auto; font-weight: 700; }

.hedge-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 10px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 10.5px;
    color: var(--text-muted);
}

.hedge-legend span { display: inline-flex; align-items: center; gap: 4px; }

.swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }

.coverage {
    font-weight: 700;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    font-size: 11px;
}

.coverage[data-tone="good"] { background: var(--positive-soft); color: var(--positive); }
.coverage[data-tone="warn"] { background: var(--warning-soft); color: var(--warning); }
.coverage[data-tone="bad"] { background: var(--negative-soft); color: var(--negative); }

/* ------------------------------------------------------------ diff table -- */
.diff {
    margin-top: 11px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.diff-group { margin-bottom: 10px; }
.diff-group:last-child { margin-bottom: 0; }

.diff-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.diff-head[data-kind="open"] { color: var(--negative); }
.diff-head[data-kind="close"] { color: var(--positive); }

.diff-row {
    display: grid;
    grid-template-columns: 12px minmax(40px, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

.diff-row:last-child { border-bottom: none; }
.diff-sym { font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.diff-amount { color: var(--text-muted); text-align: right; }
.diff-toman { font-weight: 650; text-align: right; min-width: 74px; }

.diff-ok {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--positive);
    font-weight: 600;
}

/* ------------------------------------------------------------ exchanges --- */
.xch-list { display: grid; gap: var(--gap); grid-template-columns: 1fr; }

.xch {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 11px 12px;
    min-width: 0;
}

.xch-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.xch-name { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }

.xch-tag {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    text-transform: uppercase;
}

.xch-total { margin-left: auto; font-size: 15px; font-weight: 700; white-space: nowrap; }

.xch-stats {
    display: flex;
    gap: 2px 12px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 7px;
}

/* -------------------------------------------------------------- minichart -- */
.mini-wrap { position: relative; }
.mini-svg { display: block; width: 100%; height: auto; overflow: visible; }

.mini-col { cursor: pointer; }
.mini-col .mini-hit { fill: transparent; }
.mini-col:hover .mini-hit, .mini-col[data-active="1"] .mini-hit { fill: var(--accent-soft); }

.mini-range { stroke: var(--text-faint); stroke-width: 1.5; }
.mini-ask { stroke: var(--negative); stroke-width: 2.5; stroke-linecap: round; }
.mini-bid { stroke: var(--positive); stroke-width: 2.5; stroke-linecap: round; }

.mini-ref { stroke-dasharray: 4 4; stroke-width: 1; opacity: 0.65; }
.mini-ref-bid { stroke: var(--positive); }
.mini-ref-ask { stroke: var(--negative); }

.mini-name {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    fill: var(--text-muted);
    text-anchor: middle;
}

.mini-col[data-active="1"] .mini-name { fill: var(--accent); }

.mini-axis { font-size: 8.5px; fill: var(--text-faint); font-family: var(--font-num); }

.mini-readout {
    display: flex;
    align-items: center;
    gap: 4px 12px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-muted);
    min-height: 20px;
}

.mini-readout b { color: var(--text); font-weight: 650; font-family: var(--font-num); }
.mini-readout .k { font-size: 9.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-faint); }

.market-controls { display: flex; gap: 8px; margin-bottom: 9px; }

.market-controls input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 11px;
    /* 16px keeps iOS from zooming the viewport on focus. */
    font-size: 16px;
    font-family: var(--font-num);
    color: var(--text);
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
}

.market-controls input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
    height: 36px;
    padding: 0 13px;
    border-radius: var(--radius-sm);
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); color: #fff; filter: brightness(1.08); }
.btn-danger:hover { background: var(--negative-soft); color: var(--negative); border-color: var(--negative); }

/* --------------------------------------------------------------- system --- */
.meter-row {
    display: grid;
    grid-template-columns: 38px 1fr 46px;
    align-items: center;
    gap: 9px;
    font-size: 11.5px;
    margin-bottom: 7px;
}

.meter-row:last-of-type { margin-bottom: 0; }
.meter-label { font-weight: 700; letter-spacing: 0.07em; color: var(--text-muted); }
.meter { height: 7px; border-radius: var(--radius-pill); background: var(--bg-sunken); overflow: hidden; }

.meter-fill {
    height: 100%;
    width: 0;
    border-radius: var(--radius-pill);
    background: var(--positive);
    transition: width 0.4s ease, background 0.4s ease;
}

.meter-val { text-align: right; color: var(--text-muted); font-weight: 600; }

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- sheet --- */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(6, 8, 14, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.sheet-backdrop[data-open="1"] { opacity: 1; pointer-events: auto; }

.sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-elevated);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 18px var(--pad) calc(18px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 88vh;
    overflow-y: auto;
}

.sheet-backdrop[data-open="1"] .sheet { transform: translateY(0); }
.sheet h2 { margin: 0 0 3px; font-size: 16px; font-weight: 700; }
.sheet p { margin: 0 0 16px; font-size: 12.5px; color: var(--text-muted); }

.field { margin-bottom: 13px; }

.field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 5px;
}

.field input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    font-size: 16px;
    font-family: var(--font-num);
    color: var(--text);
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
}

.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.sheet-actions { display: flex; gap: 8px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; height: 42px; }

/* ---------------------------------------------------------------- toast --- */
.toasts {
    position: fixed;
    left: var(--pad);
    right: var(--pad);
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 500;
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    font-weight: 500;
    animation: toast-in 0.24s cubic-bezier(0.32, 0.72, 0, 1);
}

.toast[data-kind="error"] { border-color: var(--negative); color: var(--negative); }
.toast[data-kind="ok"] { border-color: var(--positive); color: var(--positive); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------- skeleton --- */
body[data-loading="1"] .skeleton {
    color: transparent !important;
    background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 37%, var(--bg-sunken) 63%);
    background-size: 400% 100%;
    border-radius: 5px;
    animation: shimmer 1.3s ease-in-out infinite;
}

@keyframes shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

.flash { animation: flash 0.7s ease-out; }

@keyframes flash {
    from { background-color: var(--accent-soft); }
    to { background-color: transparent; }
}

/* ============================================================== breakpoints */
/* Large phones and small tablets: pairing things up two-across cuts a lot of
   scrolling before the real multi-column layout kicks in. */
@media (min-width: 480px) {
    .delta-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .xch-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 600px) {
    :root { --pad: 16px; --gap: 12px; }
}

/* Two columns. The page reads as three bands: hero + mini chart, the exchange
   grid, then hedge + system - so nothing sits in a full-width row on its own. */
@media (min-width: 900px) {
    .page { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
    .span-all { grid-column: 1 / -1; }
    .xch-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
    .page { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    /* The two content-heavy cards take two thirds; their compact partner
       takes the last third and the row is only as tall as the taller card. */
    .hero, .hedge-card { grid-column: span 2; }

    .xch-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .delta-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1600px) {
    .xch-list { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Centred dialog instead of a bottom sheet once there is room. */
@media (min-width: 600px) {
    .sheet {
        position: relative;
        margin: 8vh auto 0;
        max-width: 420px;
        border-radius: var(--radius);
        transform: translateY(18px) scale(0.97);
        opacity: 0;
        transition: transform 0.22s ease, opacity 0.22s ease;
    }

    .sheet-backdrop[data-open="1"] .sheet { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
