/* P3 Spy · Midnight Editorial — Monitor / Operate shell adapter.
   Opt-in only: every rule is scoped under body.p3-spy and styles page chrome.
   The DOM cards keep their approved design, their own stylesheets and the
   dom.css type scale: this file must never style a .coin-* node, an order row
   or the card grid, and it never redefines a legacy theme variable that cards
   inherit. See docs/p3-spy-midnight-editorial.md. */

.p3-spy {
    --p3-bg: #050505;
    --p3-surface: #0b0b0b;
    --p3-lift: #101010;
    --p3-ink: #f4f2ec;
    --p3-dim: #b9b6ad;
    --p3-muted: #8a877f;
    --p3-rule: rgba(244, 242, 236, 0.14);
    --p3-rule-strong: rgba(244, 242, 236, 0.30);
    --p3-cyan: #67e8f9;
    --p3-cyan-deep: #22d3ee;
    --p3-cyan-soft: rgba(103, 232, 249, 0.12);
    --p3-radius: 4px;
    --p3-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --p3-display: 'Sora', 'Inter', sans-serif;
    --p3-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;
    background: var(--p3-bg);
}

/* Flat paper instead of a blurred, pulsing gradient: operational surface. */
.p3-spy .bg-particles {
    display: none;
}

/* --- header: one compact row ---------------------------------------------- */

.p3-spy .header-bar {
    box-sizing: border-box;
    position: relative;
    display: block;
    height: auto;
    min-height: 0;
    padding: 6px 14px;
    background: var(--p3-bg);
    border-bottom: 1px solid var(--p3-rule-strong);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 100;
}

.p3-spy .header-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px 10px;
    width: 100%;
    max-width: 1600px;
    min-width: 0;
    margin: 0 auto;
    padding: 0;
}

.p3-spy .p3-spy-brand {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 30px;
    order: 0;
}

.p3-spy .p3-spy-logo {
    display: inline-flex;
    align-items: baseline;
    flex: none;
    gap: 7px;
    white-space: nowrap;
}

.p3-spy .p3-spy-logo-mark {
    font: 800 20px/1 var(--p3-display);
    letter-spacing: -0.07em;
    color: var(--p3-ink);
}

.p3-spy .p3-spy-logo-product {
    font: 600 16px/1.1 var(--p3-display);
    letter-spacing: -0.04em;
    color: var(--p3-dim);
}

.p3-spy .p3-spy-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.p3-spy .p3-spy-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 32px;
    padding: 6px 10px;
    font: 500 12px/1.2 var(--p3-font);
    color: var(--p3-dim);
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--p3-radius);
    transition: color .15s, border-color .15s, background-color .15s;
}

.p3-spy .p3-spy-nav-link:hover {
    color: var(--p3-ink);
    background: var(--p3-lift);
}

.p3-spy .p3-spy-nav-link.active {
    color: var(--p3-cyan);
    background: var(--p3-cyan-soft);
    border-color: var(--p3-rule-strong);
    text-decoration: underline;
    text-underline-offset: 5px;
}

.p3-spy .p3-spy-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    margin-left: auto;
    min-width: 0;
    order: 0;
}

.p3-spy .header-bar .status-section {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    margin: 0;
    font: 500 11px/1 var(--p3-mono);
    letter-spacing: 0.02em;
    color: var(--p3-dim);
    white-space: nowrap;
}

.p3-spy .header-bar .status-dot {
    flex: none;
}

/* Existing header icon buttons keep their hitboxes; only the paint changes. */
.p3-spy .header-bar .icon-action-btn {
    box-sizing: border-box;
    min-width: 34px;
    min-height: 32px;
    padding: 6px;
    color: var(--p3-dim);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--p3-radius);
}

.p3-spy .header-bar .icon-action-btn:hover {
    color: var(--p3-ink);
    background: var(--p3-lift);
    border-color: var(--p3-rule);
}

.p3-spy .header-bar .icon-action-btn.active {
    color: var(--p3-cyan);
    border-color: var(--p3-rule-strong);
    background: var(--p3-cyan-soft);
}

.p3-spy .header-bar .p3-account-entry {
    box-sizing: border-box;
    min-height: 32px;
    min-width: 44px;
    padding: 6px 12px;
    font: 500 12px/1.1 var(--p3-font);
    color: var(--p3-ink);
    white-space: nowrap;
    text-decoration: none;
    border: 1px solid var(--p3-rule-strong);
    border-radius: var(--p3-radius);
    background: transparent;
    box-shadow: none;
    transition: background-color .15s, border-color .15s, color .15s;
}

.p3-spy .header-bar .p3-account-entry:hover {
    color: var(--p3-ink);
    background: var(--p3-lift);
    border-color: var(--p3-ink);
}

/* Phone-only filter disclosure. It stays hidden until the shell script is
   ready, so a no-JS browser simply keeps the whole toolbar visible. */
.p3-spy .p3-spy-filters-toggle {
    display: none;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    font: 600 11px/1 var(--p3-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--p3-ink);
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule-strong);
    border-radius: var(--p3-radius);
    cursor: pointer;
}

/* --- shared toolbar ------------------------------------------------------- */

.p3-spy .controls-section {
    display: flex;
    flex: 1 0 100%;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px 8px;
    min-width: 0;
    padding: 4px 0 0;
    overflow: visible;
    border-top: 1px solid var(--p3-rule);
    order: 1;
}

.p3-spy .controls-section .control-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* The labels stay in the DOM and in the accessibility tree; a mono caption on
   every group made a one-row 1440px header impossible. Expanded on a phone,
   where the panel is the only thing on screen, they come back as visual
   captions. Inputs without a label association carry their own aria-label. */
.p3-spy .controls-section .control-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.p3-spy .controls-section .slider-container {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 2px 7px;
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
}

.p3-spy .controls-section .slider {
    width: 56px;
    height: 3px;
    border-radius: 2px;
    background: rgba(244, 242, 236, 0.16);
}

.p3-spy .controls-section .slider::-webkit-slider-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: none;
}

.p3-spy .controls-section .slider-value {
    font: 500 11px/1.2 var(--p3-mono);
    font-variant-numeric: tabular-nums;
    min-width: 34px;
    text-align: right;
    color: var(--p3-ink);
}

.p3-spy .controls-section .token-filter-compact {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 2px 6px;
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
    transition: border-color .15s;
}

.p3-spy .controls-section .token-filter-compact:focus-within {
    border-color: var(--p3-cyan-deep);
    background: var(--p3-surface);
}

.p3-spy .controls-section .token-input-compact {
    width: 96px;
    padding: 4px 0;
    font: 400 11px/1.2 var(--p3-font);
    color: var(--p3-ink);
    background: transparent;
    border: none;
    outline: none;
}

.p3-spy .controls-section .token-input-compact::placeholder {
    color: var(--p3-muted);
    opacity: 1;
}

.p3-spy .controls-section .token-clear-compact {
    color: var(--p3-muted);
    background: transparent;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.p3-spy .controls-section .token-clear-compact:hover {
    color: var(--p3-ink);
}

.p3-spy .controls-section .sort-wrapper {
    min-width: 0;
    max-width: 100%;
}

.p3-spy .controls-section .toolbar-select {
    box-sizing: border-box;
    min-height: 28px;
    width: 132px;
    max-width: 100%;
    padding: 3px 8px;
    font: 400 11px/1.2 var(--p3-font);
    color: var(--p3-ink);
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
    text-overflow: ellipsis;
}

.p3-spy .controls-section .market-filter {
    display: flex;
    gap: 4px;
}

.p3-spy .controls-section .market-filter-btn {
    box-sizing: border-box;
    width: 30px;
    height: 28px;
    font: 600 11px/1 var(--p3-mono);
    color: var(--p3-dim);
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
}

.p3-spy .controls-section .market-filter-btn:hover {
    color: var(--p3-ink);
    border-color: var(--p3-rule-strong);
    background: var(--p3-lift);
}

.p3-spy .controls-section .market-filter-btn.active {
    color: var(--p3-cyan);
    border-color: var(--p3-rule-strong);
    background: var(--p3-cyan-soft);
}

.p3-spy .controls-section .ex-filter-btn {
    box-sizing: border-box;
    min-height: 28px;
    padding: 3px 10px;
    font: 400 11px/1.2 var(--p3-font);
    color: var(--p3-dim);
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
}

.p3-spy .controls-section .ex-filter-btn:hover {
    color: var(--p3-ink);
    border-color: var(--p3-rule-strong);
}

.p3-spy .controls-section .favorite-search-btn {
    box-sizing: border-box;
    min-height: 28px;
    padding: 3px 12px;
    font: 500 11px/1.2 var(--p3-font);
    color: var(--p3-ink);
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
}

.p3-spy .controls-section .favorite-search-btn:hover {
    background: var(--p3-lift);
    border-color: var(--p3-rule-strong);
}

.p3-spy .controls-section .control-pair {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 14px;
    min-width: 0;
}

/* Scanner-only toolbar pieces. */
.p3-spy .controls-section .toggle-group {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
}

.p3-spy .controls-section .toggle-btn {
    padding: 3px 10px;
    font: 500 11px/1.2 var(--p3-font);
    color: var(--p3-dim);
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: color .15s, background-color .15s;
}

.p3-spy .controls-section .toggle-btn:hover {
    color: var(--p3-ink);
}

.p3-spy .controls-section .toggle-btn.active {
    color: var(--p3-ink);
    background: var(--p3-lift);
    box-shadow: inset 0 0 0 1px var(--p3-rule);
}

.p3-spy .controls-section .toggle-btn.bid-btn.active {
    color: #00e676;
    background: rgba(0, 230, 118, 0.14);
    box-shadow: inset 0 0 0 1px rgba(0, 230, 118, 0.4);
}

.p3-spy .controls-section .toggle-btn.ask-btn.active {
    color: #ff1744;
    background: rgba(255, 23, 68, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 23, 68, 0.4);
}

.p3-spy .controls-section .exchanges-group {
    flex: 1 1 420px;
    min-width: 0;
}

.p3-spy .controls-section .exchange-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.p3-spy .controls-section .exchange-chip {
    padding: 2px 8px;
    font: 500 10px/1.3 var(--p3-mono);
    letter-spacing: 0.02em;
    color: var(--p3-dim);
    background: transparent;
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
    cursor: pointer;
    transition: color .15s, border-color .15s, background-color .15s;
}

.p3-spy .controls-section .exchange-chip:hover {
    color: var(--p3-ink);
    border-color: var(--p3-rule-strong);
}

.p3-spy .controls-section .exchange-chip.active {
    color: var(--p3-ink);
    background: var(--p3-lift);
    border-color: var(--chip-color, var(--p3-rule-strong));
    box-shadow: none;
}

/* --- stat strips ---------------------------------------------------------- */

.p3-spy .stats-bar,
.p3-spy .stats-bar-dom {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px 22px;
    padding: 6px 14px;
    background: var(--p3-bg);
    border-bottom: 1px solid var(--p3-rule);
    font: 500 11px/1.4 var(--p3-mono);
    color: var(--p3-muted);
    flex-shrink: 0;
    overflow: visible;
}

.p3-spy .stats-bar .stat-item,
.p3-spy .stats-bar-dom .stat-item {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    color: var(--p3-muted);
    white-space: nowrap;
}

.p3-spy .stats-bar .stat-label,
.p3-spy .stats-bar-dom .stat-label {
    font: 500 10px/1.4 var(--p3-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--p3-muted);
}

.p3-spy .stats-bar .stat-value,
.p3-spy .stats-bar-dom .stat-value {
    font: 600 12px/1.4 var(--p3-mono);
    font-variant-numeric: tabular-nums;
    color: var(--p3-ink);
    text-shadow: none;
}

.p3-spy .stats-bar .whale-value {
    color: var(--p3-ink);
    text-shadow: none;
}

.p3-spy .stats-bar .big-value {
    color: var(--p3-cyan);
    text-shadow: none;
}

/* --- scanner panel chrome (table interior keeps its own semantics) -------- */

.p3-spy .glass-panel {
    background: var(--p3-surface);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.p3-spy .table-header {
    padding: 10px 14px;
    gap: 10px;
    border-bottom: 1px solid var(--p3-rule);
}

.p3-spy .table-title {
    gap: 10px;
    font: 600 13px/1.2 var(--p3-display);
    letter-spacing: -0.02em;
    color: var(--p3-ink);
}

.p3-spy .table-title .title-glow {
    color: var(--p3-ink);
    background: none;
    -webkit-text-fill-color: currentColor;
    text-shadow: none;
}

.p3-spy .table-title .dom-link-glow {
    padding: 2px 8px;
    font: 500 10px/1.3 var(--p3-mono);
    letter-spacing: 0.06em;
    color: var(--p3-cyan);
    background: var(--p3-cyan-soft);
    border: 1px solid var(--p3-rule-strong);
    border-radius: var(--p3-radius);
    box-shadow: none;
    transform: none;
}

.p3-spy .table-title .dom-link-glow:hover {
    color: var(--p3-ink);
    background: var(--p3-lift);
    box-shadow: none;
    transform: none;
}

.p3-spy .table-title .order-count-badge {
    padding: 2px 7px;
    font: 500 10px/1.3 var(--p3-mono);
    color: var(--p3-dim);
    background: var(--p3-lift);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
}

.p3-spy .table-actions .sort-btn {
    padding: 4px 10px;
    font: 500 11px/1.2 var(--p3-font);
    color: var(--p3-dim);
    background: transparent;
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
    cursor: pointer;
    transition: color .15s, border-color .15s, background-color .15s;
}

.p3-spy .table-actions .sort-btn:hover {
    color: var(--p3-ink);
    background: var(--p3-lift);
}

.p3-spy .table-actions .sort-btn.active {
    color: var(--p3-ink);
    background: var(--p3-lift);
    border-color: var(--p3-rule-strong);
}

.p3-spy .token-chips-row .token-chip {
    font: 500 10px/1.3 var(--p3-mono);
    color: var(--p3-dim);
    background: var(--p3-lift);
    border: 1px solid var(--p3-rule);
    border-radius: var(--p3-radius);
}

/* Column labels only: the cells, side colours and size emphasis stay as they
   are, because they carry the data semantics of the table. */
.p3-spy .orders-table th {
    padding: 8px 12px;
    font: 500 9px/1.3 var(--p3-mono);
    letter-spacing: 0.08em;
    color: var(--p3-muted);
    background: var(--p3-surface);
    border-bottom: 1px solid var(--p3-rule);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* --- quiet footer --------------------------------------------------------- */

.p3-spy .p3-spy-footer {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    padding: 4px 14px;
    font: 400 11px/1.35 var(--p3-mono);
    color: var(--p3-muted);
    background: var(--p3-bg);
    border-top: 1px solid var(--p3-rule);
}

.p3-spy .p3-spy-footer-free {
    color: var(--p3-dim);
}

.p3-spy .p3-spy-footer-sep {
    color: var(--p3-rule-strong);
}

.p3-spy .p3-spy-footer-note {
    color: var(--p3-muted);
}

.p3-spy .p3-spy-footer-link {
    color: var(--p3-dim);
    text-decoration: none;
    border-bottom: 1px solid var(--p3-rule);
}

.p3-spy .p3-spy-footer-link:hover {
    color: var(--p3-ink);
    border-bottom-color: var(--p3-rule-strong);
}

.p3-spy .p3-spy-footer .disclaimer-btn {
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--p3-dim);
    font: inherit;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px solid var(--p3-rule);
}

.p3-spy .p3-spy-footer .disclaimer-btn:hover {
    color: var(--p3-ink);
    border-bottom-color: var(--p3-rule-strong);
}

.p3-spy .p3-spy-footer .p3-spy-about {
    color: var(--p3-muted);
}

.p3-spy .p3-spy-footer .p3-spy-about > summary {
    cursor: pointer;
    color: var(--p3-dim);
    border-bottom: 1px solid var(--p3-rule);
    list-style: none;
}

.p3-spy .p3-spy-footer .p3-spy-about > summary::-webkit-details-marker {
    display: none;
}

.p3-spy .p3-spy-footer .p3-spy-about[open] > summary {
    color: var(--p3-ink);
}

.p3-spy .p3-spy-footer .p3-spy-about p {
    max-width: 78ch;
    margin: 6px 0 0;
    color: var(--p3-dim);
    line-height: 1.6;
}

.p3-spy .p3-spy-footer .p3-spy-about a {
    color: var(--p3-cyan);
    text-decoration: none;
    border-bottom: 1px solid var(--p3-rule);
}

/* --- DOM settings: About sits above the last technical block -------------- */

.p3-spy .spy-about > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font: 500 10px/1.4 var(--p3-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--p3-dim);
    list-style: none;
}

.p3-spy .spy-about > summary::-webkit-details-marker {
    display: none;
}

.p3-spy .spy-about > summary:hover {
    color: var(--p3-ink);
}

.p3-spy .spy-about[open] > summary {
    color: var(--p3-ink);
    margin-bottom: 8px;
}

.p3-spy .spy-about p {
    margin: 0 0 8px;
    font: 400 12px/1.6 var(--p3-font);
    color: var(--p3-dim);
}

.p3-spy .spy-about p:last-child {
    margin-bottom: 0;
}

.p3-spy .spy-about a {
    color: var(--p3-cyan);
    text-decoration: none;
}

/* --- focus, motion, embed ------------------------------------------------- */

.p3-spy .header-bar :is(input, select, button):focus-visible,
.p3-spy .p3-spy-nav-link:focus-visible,
.p3-spy .p3-spy-filters-toggle:focus-visible,
.p3-spy .header-bar .p3-account-entry:focus-visible,
.p3-spy .p3-spy-footer-link:focus-visible,
.p3-spy .p3-spy-footer .disclaimer-btn:focus-visible,
.p3-spy .p3-spy-footer .p3-spy-about > summary:focus-visible,
.p3-spy .spy-about > summary:focus-visible {
    outline: 2px solid var(--p3-cyan);
    outline-offset: 2px;
    border-radius: var(--p3-radius);
}

/* Embed mode is explicit here even though dom.css already forces the header
   away: the adapter must not reintroduce either band inside an iframe. */
.p3-spy.embed-mode .header-bar,
.p3-spy.embed-mode .p3-spy-footer {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .p3-spy .p3-spy-nav-link {
        transition: none;
    }

    .p3-spy .header-bar .p3-account-entry {
        transition: none;
    }

    .p3-spy .controls-section .slider::-webkit-slider-thumb {
        transition: none;
    }
}

/* --- responsive ----------------------------------------------------------- */

/* Tablet: branding and actions share a row, the toolbar owns the next one. */
@media (min-width: 861px) {
    .p3-spy .p3-spy-actions {
        order: 1;
    }

    .p3-spy .controls-section {
        order: 2;
    }

    .p3-spy .p3-spy-filters-toggle {
        display: none;
    }
}

/* Wide desktop DOM: brand, every filter and the actions in one <=60px row. */
@media (min-width: 1281px) {
    .p3-spy--dom .header-content {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .p3-spy--dom .controls-section {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        padding: 0;
        border-top: 0;
        order: 1;
    }

    .p3-spy--dom .controls-section .control-group {
        flex: 0 0 auto;
    }

    .p3-spy--dom .p3-spy-actions {
        order: 2;
    }

    .p3-spy--scanner .p3-spy-actions {
        order: 1;
    }

    .p3-spy--scanner .controls-section {
        order: 2;
    }
}

/* Phone: two 44px rows, filters behind one accessible disclosure. */
@media (max-width: 860px) {
    .p3-spy .header-bar {
        padding: 4px 8px;
    }

    .p3-spy .header-content {
        gap: 4px 6px;
    }

    /* The logo, navigation and actions become header-content items so the
       navigation can sit beside the toggle instead of squeezing the brand. */
    .p3-spy .p3-spy-brand {
        display: contents;
    }

    .p3-spy .p3-spy-logo {
        order: 1;
        min-height: 44px;
    }

    .p3-spy .p3-spy-nav {
        order: 3;
        gap: 0;
    }

    .p3-spy .p3-spy-nav-link {
        min-height: 44px;
        padding: 0 8px;
        font-size: 11px;
    }

    .p3-spy .p3-spy-actions {
        order: 2;
        gap: 4px;
    }

    .p3-spy .header-bar .status-section {
        font-size: 10px;
    }

    .p3-spy .header-bar .icon-action-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0;
    }

    .p3-spy .header-bar .p3-account-entry {
        min-width: 44px;
        min-height: 44px;
        padding: 0 10px;
        font-size: 11px;
    }

    .p3-spy .header-bar .p3-account-entry .p3-account-label {
        display: none;
    }

    /* The guest avatar is intentionally empty; keep its compact link visible. */
    .p3-spy .header-bar .p3-account-entry[data-p3-account-state="signed_out"]::before {
        content: "";
        display: block;
        width: 18px;
        height: 18px;
        flex: 0 0 18px;
        pointer-events: none;
        background: currentColor;
        --p3-guest-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='3.5' fill='none' stroke='white' stroke-width='2'/%3E%3Cpath d='M5 21v-2a7 7 0 0 1 14 0v2' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E");
        -webkit-mask: var(--p3-guest-icon) center / contain no-repeat;
        mask: var(--p3-guest-icon) center / contain no-repeat;
    }

    .p3-spy--filters-ready .p3-spy-filters-toggle {
        display: inline-flex;
        order: 4;
        margin-left: auto;
    }

    .p3-spy--filters-ready .controls-section {
        order: 5;
        flex: 1 0 100%;
        display: none;
    }

    .p3-spy--filters-ready .controls-section.is-open {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px 8px;
        padding: 6px 0 2px;
        border-top: 1px solid var(--p3-rule);
    }

    /* Without the script the toggle cannot work, so it stays hidden and the
       whole toolbar remains visible as a wrapping block. */
    .p3-spy:not(.p3-spy--filters-ready) .controls-section {
        display: flex;
        flex-wrap: wrap;
        flex: 1 0 100%;
        padding: 4px 0 2px;
    }

    .p3-spy .controls-section .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
        min-height: 44px;
    }

    .p3-spy .controls-section .control-label {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        overflow: visible;
        clip: auto;
        clip-path: none;
        font: 500 9px/1.2 var(--p3-mono);
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--p3-muted);
    }

    .p3-spy .controls-section .token-filter-compact {
        min-height: 44px;
        padding: 4px 8px;
    }

    .p3-spy .controls-section .token-input-compact {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        font-size: 13px;
    }

    .p3-spy .controls-section .token-clear-compact {
        min-width: 44px;
        min-height: 44px;
        font-size: 18px;
    }

    .p3-spy .controls-section .toolbar-select {
        width: 100%;
        min-height: 44px;
        font-size: 12px;
        padding: 0 8px;
    }

    .p3-spy .controls-section .favorite-search-btn,
    .p3-spy .controls-section .ex-filter-btn {
        width: 100%;
        min-height: 44px;
        padding: 0 10px;
        font-size: 12px;
    }

    .p3-spy .controls-section .ex-filter-wrap {
        width: 100%;
    }

    .p3-spy .controls-section .market-filter {
        gap: 6px;
    }

    .p3-spy .controls-section .market-filter-btn {
        width: 44px;
        height: 44px;
    }

    .p3-spy .controls-section .control-pair {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 8px;
    }

    /* dom.css hides Scale at <=768px; the expanded panel is allowed to offer
       every original control, so the shell restores it there only. */
    .p3-spy .controls-section #scaleGroup {
        display: flex;
    }

    .p3-spy .controls-section .slider-container {
        min-height: 44px;
        gap: 8px;
        padding: 0 8px;
    }

    /* 44px transparent element, 3px painted track: easy to grab without a
       visually heavy control. */
    .p3-spy .controls-section .slider {
        width: 100%;
        height: 44px;
        background: transparent;
        -webkit-appearance: none;
        appearance: none;
    }

    .p3-spy .controls-section .slider::-webkit-slider-runnable-track {
        height: 3px;
        border-radius: 2px;
        background: rgba(244, 242, 236, 0.16);
    }

    .p3-spy .controls-section .slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 18px;
        height: 18px;
        margin-top: -7.5px;
        border-radius: 50%;
        background: var(--p3-cyan);
    }

    .p3-spy .controls-section .slider::-moz-range-track {
        height: 3px;
        border-radius: 2px;
        background: rgba(244, 242, 236, 0.16);
    }

    .p3-spy .controls-section .slider::-moz-range-thumb {
        width: 18px;
        height: 18px;
        border: 0;
        border-radius: 50%;
        background: var(--p3-cyan);
    }

    .p3-spy .controls-section .slider-value {
        min-width: 40px;
        font-size: 11px;
    }

    .p3-spy .controls-section .toggle-group {
        min-height: 44px;
        align-items: center;
    }

    .p3-spy .controls-section .toggle-btn {
        min-height: 44px;
        padding: 0 10px;
        font-size: 12px;
    }

    .p3-spy .controls-section .exchanges-group {
        grid-column: 1 / -1;
    }

    .p3-spy .controls-section .exchange-chip {
        min-height: 44px;
        padding: 0 10px;
        font-size: 10px;
    }

    /* A read-only stat strip keeps its original single scrolling line on a
       phone: six readouts cannot be labelled legibly in 390px. */
    .p3-spy .stats-bar,
    .p3-spy .stats-bar-dom {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 6px 16px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .p3-spy .p3-spy-footer {
        flex-wrap: wrap;
        gap: 0 6px;
        min-height: 52px;
        padding: 2px 8px;
        overflow: visible;
    }

    .p3-spy .p3-spy-footer > * {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        flex: 0 0 auto;
    }

    /* The desktop-only sentence is redundant here: the visible About / risk
       trigger opens the same warning in full. */
    .p3-spy .p3-spy-footer .p3-spy-footer-note {
        display: none;
    }

    .p3-spy .p3-spy-footer .p3-spy-about {
        display: inline-flex;
        align-items: center;
    }

    /* An open notice owns the next row; never widen the phone footer. */
    .p3-spy .p3-spy-footer .p3-spy-about[open] {
        display: block;
        flex: 1 1 100%;
        min-width: 0;
        max-width: 100%;
    }

    .p3-spy .p3-spy-footer .p3-spy-about[open] p {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .p3-spy .p3-spy-footer .p3-spy-about > summary {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

@media (max-width: 360px) {
    .p3-spy .p3-spy-nav-link {
        padding: 0 6px;
        font-size: 10px;
    }

    /* Below 360px the header cannot hold the logo, three icon actions, the
       navigation and the toggle without a third row. The home icon is a
       duplicate of the visible Scanner navigation link, so it is the one
       redundant action that yields; nothing unique disappears. */
    .p3-spy--dom .header-bar .icon-action-btn[href="/"] {
        display: none;
    }

    .p3-spy .p3-spy-filters-toggle {
        padding: 0 10px;
    }

    .p3-spy--filters-ready .controls-section.is-open {
        grid-template-columns: minmax(0, 1fr);
    }

    .p3-spy .controls-section .control-pair {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
}

