:root {
    --exchange-bg: #f8fafc;
    --exchange-panel: rgba(255, 255, 255, 0.84);
    --exchange-surface: #ffffff;
    --exchange-soft: #f7f9fc;
    --exchange-line: rgba(219, 227, 239, 0.92);
    --exchange-ink: #101828;
    --exchange-muted: #667085;
    --exchange-faint: #98a2b3;
    --exchange-primary: #7c9fea;
    --exchange-primary-strong: #5f84d8;
    --exchange-primary-soft: #edf3ff;
    --exchange-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

html.portal-dark {
    --exchange-bg: #070b13;
    --exchange-panel: rgba(12, 17, 28, 0.9);
    --exchange-surface: #0d1422;
    --exchange-soft: #111a2b;
    --exchange-line: rgba(148, 163, 184, 0.18);
    --exchange-ink: #f8fafc;
    --exchange-muted: #a6b0c0;
    --exchange-faint: #718096;
    --exchange-primary: #8aa9ee;
    --exchange-primary-strong: #9bb6f1;
    --exchange-primary-soft: rgba(124, 159, 234, 0.12);
    --exchange-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

* { box-sizing: border-box; }

body.recharge-page.exchange-page {
    display: block;
    min-height: 100vh;
    margin: 0;
    color: var(--exchange-ink);
    background:
        linear-gradient(rgba(15, 23, 42, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.025) 1px, transparent 1px),
        linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(240, 253, 250, 0.5) 48%, rgba(248, 250, 252, 0.98)),
        var(--exchange-bg);
    background-size: 64px 64px, 64px 64px, auto, auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

html.portal-dark body.recharge-page.exchange-page {
    background:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(180deg, #070b13, #0a1220 48%, #070b13),
        var(--exchange-bg);
    background-size: 64px 64px, 64px 64px, auto, auto;
}

.page-shell {
    width: min(884px, calc(100% - 32px));
    margin: 0 auto;
    padding: 26px 0 48px;
    animation: none;
}

.exchange-shell {
    padding: 24px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-panel);
    box-shadow: var(--exchange-shadow);
    backdrop-filter: blur(18px);
}

.exchange-header {
    min-height: 82px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.exchange-title-block {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.exchange-brand-mark {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: transparent;
    filter: drop-shadow(0 6px 10px rgba(37, 99, 235, 0.20));
}

.exchange-brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.exchange-title-copy { min-width: 0; }
.exchange-eyebrow {
    display: block;
    margin-bottom: 2px;
    color: #0f766e;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}
html.portal-dark .exchange-eyebrow { color: #5eead4; }
.exchange-title-copy h1 {
    margin: 0;
    color: var(--exchange-ink);
    font-size: 24px;
    line-height: 1.45;
    letter-spacing: -0.02em;
}
.exchange-title-copy p {
    margin: 0;
    color: var(--exchange-muted);
    font-size: 13px;
    line-height: 1.7;
}

.exchange-tools { display: flex; align-items: center; gap: 8px; }
.exchange-tool-btn,
.exchange-tool-link {
    min-width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    color: var(--exchange-muted);
    background: var(--exchange-surface);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}
.exchange-tool-btn:hover,
.exchange-tool-link:hover { color: var(--exchange-primary-strong); border-color: var(--exchange-primary); }
.exchange-tool-btn svg { width: 18px; height: 18px; }

.exchange-switchboard {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.exchange-tabs {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: min(520px, 100%);
    height: 50px;
    margin: 0;
    padding: 5px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-soft);
}

.exchange-tab,
.exchange-tabs .tab-btn {
    position: relative;
    min-width: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    color: var(--exchange-muted);
    background: transparent;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.exchange-tab:hover,
.exchange-tabs .tab-btn:hover { color: var(--exchange-ink); background: rgba(255, 255, 255, 0.58); }
.exchange-tabs button:focus { outline: none; }
.exchange-tabs button:focus-visible { outline: 2px solid var(--exchange-primary); outline-offset: -2px; }
html.portal-dark .exchange-tab:hover,
html.portal-dark .exchange-tabs .tab-btn:hover { background: rgba(255,255,255,.05); }
.exchange-tabs .tab-btn.active,
body[data-portal-view="subscription"] .exchange-tab[data-view="subscription"],
body[data-portal-view="replace"] .exchange-tab[data-view="replace"],
body[data-portal-view="cancel"] .exchange-tab[data-view="cancel"],
body[data-portal-view="tools"] .exchange-tab[data-view="tools"] {
    color: #315fc2;
    background: var(--exchange-surface);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}
html.portal-dark .exchange-tabs .tab-btn.active,
html.portal-dark body[data-portal-view="subscription"] .exchange-tab[data-view="subscription"],
html.portal-dark body[data-portal-view="replace"] .exchange-tab[data-view="replace"],
html.portal-dark body[data-portal-view="cancel"] .exchange-tab[data-view="cancel"],
html.portal-dark body[data-portal-view="tools"] .exchange-tab[data-view="tools"] { color: #aac1f4; }
.exchange-tabs .tab-btn.active::after { display: none; }

.exchange-queue-bar {
    min-width: 238px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    color: var(--exchange-muted);
    background: var(--exchange-soft);
    font-size: 11px;
    white-space: nowrap;
}
.exchange-queue-dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.exchange-queue-bar strong { color: #315fc2; font-size: 14px; }
#compactQueueState { margin-left: auto; color: var(--exchange-faint); }

.recharge-card {
    max-width: none;
    margin: 20px 0 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.recharge-card::before { display: none; }

.stepper {
    min-height: 64px;
    display: flex;
    align-items: center;
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-panel);
    box-shadow: var(--exchange-shadow);
}
.step-item { flex: 0 0 auto; gap: 10px; color: var(--exchange-muted); font-size: 12px; }
.step-num {
    width: 34px;
    height: 34px;
    color: var(--exchange-muted);
    background: var(--exchange-surface);
    border: 1px solid var(--exchange-line);
}
.step-item.active .step-num { color: #315fc2; background: #e8f0ff; border-color: #d7e4ff; }
.step-item.done .step-num { color: #fff; background: #10b981; border-color: #10b981; }
.step-item.active,
.step-item.done { color: var(--exchange-ink); }
.step-line { flex: 1 1 auto; width: auto; min-width: 40px; height: 2px; margin: 0 12px; background: var(--exchange-line); }

#redeemSection,
#querySection,
.operation-section {
    padding: 30px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-panel);
    box-shadow: var(--exchange-shadow);
    backdrop-filter: blur(18px);
}

.query-heading { margin-bottom: 14px; }
.query-heading h2 { margin: 0 0 5px; color: var(--exchange-ink); font-size: 15px; }
.query-heading p { margin: 0; color: var(--exchange-muted); font-size: 11px; line-height: 1.7; }
#queryInput { min-height: 118px; resize: vertical; }
.query-input-meta { min-height: 28px; display: flex; align-items: center; color: #315fc2; font-size: 10px; font-weight: 650; }
html.portal-dark .query-input-meta { color: #aac1f4; }
.query-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.query-actions .btn-primary,
.query-actions .btn-secondary { width: 100%; min-height: 48px; }

.query-batch-summary,
.query-batch-results { margin-top: 16px; }
.query-batch-summary {
    padding: 16px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-surface);
}
.query-summary-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.query-summary-title strong { font-size: 13px; }
.query-summary-title span { color: var(--exchange-muted); font-size: 10px; }
.query-stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.query-stat-grid > div { padding: 10px 7px; text-align: center; border-radius: 6px; background: var(--exchange-soft); }
.query-stat-grid strong,
.query-stat-grid span { display: block; }
.query-stat-grid strong { color: var(--exchange-ink); font-size: 17px; }
.query-stat-grid span { margin-top: 2px; color: var(--exchange-muted); font-size: 9px; }

.query-task-detail {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--exchange-surface);
}
.query-result-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 126px;
    padding: 20px 22px;
    border: 1px solid var(--exchange-line);
    border-left: 4px solid var(--exchange-primary);
    border-radius: 8px;
    background: var(--exchange-primary-soft);
}
.tone-completed .query-result-banner { border-color: rgba(16,185,129,.34); border-left-color: #10b981; background: rgba(16,185,129,.08); }
.tone-processing .query-result-banner { border-color: rgba(37,99,235,.3); border-left-color: #2563eb; background: rgba(37,99,235,.07); }
.tone-failed .query-result-banner,
.tone-missing .query-result-banner { border-color: rgba(239,68,68,.28); border-left-color: #ef4444; background: rgba(239,68,68,.07); }
.tone-unused .query-result-banner { border-color: rgba(148,163,184,.35); border-left-color: #94a3b8; background: var(--exchange-soft); }
.tone-waiting .query-result-banner { border-color: rgba(245,158,11,.3); border-left-color: #f59e0b; background: rgba(245,158,11,.07); }
.query-result-banner small { display: block; color: var(--exchange-muted); font-size: 11px; font-weight: 650; }
.query-result-banner h3 { margin: 5px 0 6px; color: var(--exchange-ink); font-size: 23px; }
.query-result-banner p { margin: 0; color: var(--exchange-muted); font-size: 12px; }
.query-status-badge { flex-shrink: 0; padding: 7px 12px; border-radius: 999px; color: var(--exchange-muted); background: var(--exchange-surface); font-size: 11px; font-weight: 700; }
.tone-completed .query-status-badge { color: #047857; background: #ecfdf5; }
.tone-processing .query-status-badge { color: #1d4ed8; background: #eff6ff; }
.tone-failed .query-status-badge,
.tone-missing .query-status-badge { color: #b91c1c; background: #fef2f2; }
.query-refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 13px;
    padding: 7px 11px;
    border: 1px solid rgba(37, 99, 235, .2);
    border-radius: 999px;
    color: #2563eb;
    background: rgba(37, 99, 235, .08);
    font-size: 10px;
}
.query-refresh-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
    animation: query-refresh-pulse 1.5s ease-in-out infinite;
}
@keyframes query-refresh-pulse { 50% { opacity: .35; transform: scale(.78); } }

.query-detail-grid { display: grid; grid-template-columns: 1fr 1fr; margin-top: 14px; border: 1px solid var(--exchange-line); border-radius: 6px; overflow: hidden; }
.query-detail-field { min-width: 0; min-height: 82px; padding: 16px 18px; border-bottom: 1px solid var(--exchange-line); }
.query-detail-field:nth-child(odd) { border-right: 1px solid var(--exchange-line); }
.query-detail-field:last-child { border-bottom: 0; }
.query-detail-field.is-wide { grid-column: 1 / -1; border-right: 0; }
.query-detail-field span,
.query-detail-field strong { display: block; }
.query-detail-field span { color: var(--exchange-muted); font-size: 11px; font-weight: 650; }
.query-detail-field strong { margin-top: 7px; overflow-wrap: anywhere; color: var(--exchange-ink); font-size: 13px; }
.query-detail-field .plan-pill {
    display: inline-flex;
    width: auto;
    padding: 7px 13px;
    border: 1px solid rgba(16, 185, 129, .28);
    border-radius: 999px;
    color: #047857;
    background: rgba(16, 185, 129, .08);
}
.query-detail-field .plan-pill::before { content: '＋'; margin-right: 5px; }
.query-detail-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--exchange-line); }
.query-detail-actions .btn-secondary { width: auto; min-height: 40px; padding: 8px 14px; font-size: 10px; }
.query-task-id { display: flex; align-items: baseline; gap: 7px; min-width: 0; margin-left: auto; color: var(--exchange-muted); font-size: 10px; }
.query-task-id code { max-width: 280px; overflow: hidden; color: var(--exchange-muted); text-overflow: ellipsis; white-space: nowrap; }

.query-result-layout { display: grid; grid-template-columns: minmax(210px, .7fr) minmax(0, 1.3fr); gap: 12px; align-items: start; }
.query-result-list { display: grid; gap: 7px; max-height: 520px; overflow: auto; }
.query-result-item { width: 100%; min-width: 0; padding: 11px 12px; text-align: left; border: 1px solid var(--exchange-line); border-radius: 7px; color: var(--exchange-ink); background: var(--exchange-surface); }
.query-result-item:hover,
.query-result-item.active { border-color: var(--exchange-primary); background: var(--exchange-primary-soft); }
.query-result-item strong,
.query-result-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.query-result-item strong { font: 600 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.query-result-item span { margin-top: 3px; color: var(--exchange-muted); font-size: 9px; }

.field-label {
    margin-bottom: 8px;
    color: var(--exchange-ink);
    font-size: 13px;
    font-weight: 700;
}

.input-group { display: flex; flex-direction: column; gap: 14px; }
.recharge-page input,
.recharge-page textarea,
.tool-card textarea {
    width: 100%;
    color: var(--exchange-ink) !important;
    background: var(--exchange-surface) !important;
    border: 1px solid var(--exchange-line) !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}
.recharge-page input { height: 52px; padding: 0 14px; }
.recharge-page textarea { padding: 13px 14px; line-height: 1.65; }
.recharge-page input:focus,
.recharge-page textarea:focus { border-color: var(--exchange-primary) !important; box-shadow: 0 0 0 3px rgba(124,159,234,.14) !important; }

.recharge-page .btn-primary {
    width: 100%;
    min-height: 50px;
    border-radius: 6px;
    color: #fff;
    background: linear-gradient(135deg, #3478ef, #2563d9);
    box-shadow: 0 8px 18px rgba(37, 99, 217, 0.24);
    font-size: 13px;
    font-weight: 700;
}
.recharge-page .btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #2563eb, #1d4fc1); transform: none; }
.recharge-page .btn-primary:disabled {
    color: #fff;
    background: #aeb8c8;
    box-shadow: none;
    opacity: .72;
}
.recharge-page .btn-secondary {
    min-height: 44px;
    border-color: var(--exchange-line);
    border-radius: 6px;
    color: var(--exchange-muted);
    background: var(--exchange-surface);
}
.textarea-wrapper { width: 100%; }
.get-token-btn-floating { color: #315fc2; background: var(--exchange-primary-soft); }
.field-hint { color: var(--exchange-muted); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.operation-section { display: none; }
.operation-section .field-label { display: block; }
.operation-hint { margin: 12px 0 20px; font-size: 12px; line-height: 1.8; }
.operation-result { margin-top: 16px; padding: 14px; border: 1px solid var(--exchange-line); border-radius: 7px; color: var(--exchange-muted); background: var(--exchange-soft); font-size: 12px; line-height: 1.7; }
.operation-result.success { border-color: rgba(16,185,129,.3); color: #047857; background: rgba(16,185,129,.08); }
.operation-result.error { border-color: rgba(239,68,68,.28); color: #b91c1c; background: rgba(239,68,68,.07); }
.operation-result code { display: block; margin: 8px 0; overflow-wrap: anywhere; color: var(--exchange-ink); font: 700 15px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.operation-result .btn-secondary { margin-top: 8px; padding: 8px 12px; font-size: 11px; }

.cdk-confirmed,
.plan-confirmed,
.task-progress,
.status-message { border-radius: 6px; }
.task-progress { margin-top: 16px; background: var(--exchange-panel); border: 1px solid var(--exchange-line); }

.confirm-modal[hidden] { display: none; }
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 24px;
}
.confirm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .52);
    backdrop-filter: blur(3px);
}
.confirm-modal__dialog {
    position: relative;
    width: min(680px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 32px;
    border: 1px solid var(--exchange-line);
    border-radius: 12px;
    background: var(--exchange-surface);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}
.confirm-modal__dialog h2 {
    margin: 0 40px 24px 0;
    color: #2457b7;
    font-size: 24px;
}
.confirm-modal__close {
    position: absolute;
    top: 18px;
    right: 20px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--exchange-muted);
    background: transparent;
    font-size: 28px;
    line-height: 1;
}
.confirm-modal__close:hover { background: var(--exchange-soft); color: var(--exchange-ink); }
.confirm-summary {
    border: 1px solid var(--exchange-line);
    border-radius: 9px;
    overflow: hidden;
}
.confirm-summary__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 66px;
    padding: 14px 20px;
    color: var(--exchange-muted);
}
.confirm-summary__row + .confirm-summary__row { border-top: 1px solid var(--exchange-line); }
.confirm-summary__row strong {
    color: var(--exchange-ink);
    text-align: right;
    overflow-wrap: anywhere;
}
.confirm-summary__code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }
.confirm-summary__plan {
    padding: 7px 14px;
    border: 1px solid rgba(16, 185, 129, .3);
    border-radius: 999px;
    color: #047857 !important;
    background: rgba(16, 185, 129, .08);
    text-transform: lowercase;
}
.confirm-summary__status { color: #059669 !important; }
.confirm-modal__hint { margin: 18px 0; color: var(--exchange-muted); font-size: 13px; }
.confirm-modal__actions { display: flex; justify-content: flex-end; gap: 12px; }
.confirm-modal__actions button { width: auto; min-width: 120px; }
body.confirm-modal-open { overflow: hidden; }

.submission-result[hidden] { display: none; }
.submission-result {
    padding: 28px 40px 38px;
}
.submission-result > h2 {
    margin: 0 0 24px;
    color: #2457b7;
    font-size: 24px;
}
.submission-review {
    overflow: hidden;
    border: 1px solid var(--exchange-line);
    border-radius: 9px;
    background: var(--exchange-surface);
}
.submission-review__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 62px;
    padding: 13px 20px;
    color: var(--exchange-muted);
}
.submission-review__row + .submission-review__row { border-top: 1px solid var(--exchange-line); }
.submission-review__row strong {
    color: var(--exchange-ink);
    text-align: right;
    overflow-wrap: anywhere;
}
.submission-result__body {
    padding-top: 38px;
    text-align: center;
}
.submission-result__icon {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    border: 2px solid rgba(5, 150, 105, .55);
    border-radius: 10px;
    color: #059669;
    background: rgba(16, 185, 129, .08);
    font-size: 36px;
    line-height: 1;
}
.submission-result__body h3 {
    margin: 0;
    color: var(--exchange-ink);
    font-size: 25px;
}
.submission-result__body > p {
    margin: 10px 0 22px;
    color: var(--exchange-muted);
    font-size: 14px;
}
.submission-result__task {
    display: grid;
    gap: 8px;
    width: min(520px, 100%);
    margin: 0 auto 24px;
    padding: 16px 20px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-soft);
}
.submission-result__task span { color: var(--exchange-muted); font-size: 13px; }
.submission-result__task code {
    color: var(--exchange-ink);
    font: 700 15px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow-wrap: anywhere;
}
.submission-result__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.submission-result__actions button { min-height: 48px; }

@media (max-width: 560px) {
    .confirm-modal { padding: 14px; }
    .confirm-modal__dialog { padding: 24px 18px 20px; }
    .confirm-summary__row { align-items: flex-start; flex-direction: column; gap: 7px; min-height: 0; }
    .confirm-summary__row strong { text-align: left; }
    .confirm-modal__actions { flex-direction: column-reverse; }
    .confirm-modal__actions button { width: 100%; }
    .submission-result { padding: 22px 16px 28px; }
    .submission-review__row { align-items: flex-start; flex-direction: column; gap: 7px; min-height: 0; }
    .submission-review__row strong { text-align: left; }
    .submission-result__actions { grid-template-columns: 1fr; }
}

.power-tools {
    display: none;
    margin-top: 20px;
    padding: 30px;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-panel);
    box-shadow: var(--exchange-shadow);
}
.subscription-embed {
    display: none;
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid var(--exchange-line);
    border-radius: 8px;
    background: var(--exchange-surface);
    box-shadow: var(--exchange-shadow);
}
.subscription-embed iframe {
    display: block;
    width: 100%;
    min-height: 680px;
    border: 0;
    background: transparent;
}
body[data-portal-view="subscription"] .recharge-card,
body[data-portal-view="subscription"] .power-tools { display: none; }
body[data-portal-view="subscription"] .subscription-embed { display: block; }
body[data-portal-view="tools"] .recharge-card { display: none; }
body[data-portal-view="tools"] .power-tools { display: block; }
body[data-portal-view="query"] .stepper { display: none; }
body[data-portal-view="replace"] .stepper,
body[data-portal-view="cancel"] .stepper,
body[data-portal-view="replace"] #redeemSection,
body[data-portal-view="cancel"] #redeemSection,
body[data-portal-view="replace"] #querySection,
body[data-portal-view="cancel"] #querySection,
body[data-portal-view="replace"] #taskProgress,
body[data-portal-view="cancel"] #taskProgress,
body[data-portal-view="replace"] #statusMessage,
body[data-portal-view="cancel"] #statusMessage { display: none !important; }
body[data-portal-view="replace"] #replaceSection,
body[data-portal-view="cancel"] #cancelSection { display: block; }
body[data-portal-view="subscription"] .exchange-tabs .tab-btn.active,
body[data-portal-view="replace"] .exchange-tabs .tab-btn.active,
body[data-portal-view="cancel"] .exchange-tabs .tab-btn.active,
body[data-portal-view="tools"] .exchange-tabs .tab-btn.active { color: var(--exchange-muted); background: transparent; box-shadow: none; }
.tool-panel-title { margin-bottom: 18px; }
.tool-panel-title h2 { margin: 0 0 4px; color: var(--exchange-ink); font-size: 18px; }
.tool-panel-title p { margin: 0; color: var(--exchange-muted); font-size: 12px; }
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tool-card { padding: 18px; border: 1px solid var(--exchange-line); border-radius: 8px; background: var(--exchange-surface); box-shadow: none; }
.tool-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tool-title > div { flex: 1; }
.tool-title strong,
.tool-title small { display: block; }
.tool-title strong { color: var(--exchange-ink); font-size: 13px; }
.tool-title small { color: var(--exchange-muted); font-size: 10px; margin-top: 2px; }
.tool-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; color: #315fc2; background: var(--exchange-primary-soft); }
.tool-icon svg { width: 16px; height: 16px; }
.local-badge { padding: 3px 7px; border-radius: 999px; color: #315fc2; background: var(--exchange-primary-soft); font-size: 9px; }
.tool-card textarea { min-height: 104px; padding: 11px 12px; resize: vertical; font-size: 11px; }
.tool-actions { display: flex; gap: 8px; margin-top: 10px; }
.tool-actions .btn-primary,
.tool-actions .btn-secondary { min-height: 40px; padding: 8px 12px; font-size: 11px; }
.batch-summary,
.inspector-result { margin-top: 10px; padding: 10px; border-radius: 6px; color: var(--exchange-muted); background: var(--exchange-soft); font-size: 11px; }
.batch-results { max-height: 260px; overflow: auto; margin-top: 10px; border: 1px solid var(--exchange-line); border-radius: 6px; }
.batch-result-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--exchange-line); font-size: 10px; }
.batch-result-row:last-child { border-bottom: 0; }
.batch-result-row code { overflow: hidden; color: var(--exchange-muted); text-overflow: ellipsis; }
.batch-result-row .ok { color: #059669; }
.batch-result-row .busy { color: #d97706; }
.batch-result-row .fail { color: #dc2626; }

@media (max-width: 760px) {
    .page-shell { width: min(100% - 20px, 884px); padding-top: 10px; }
    .exchange-shell { padding: 16px; }
    .exchange-header { min-height: auto; }
    .exchange-title-copy h1 { font-size: 20px; }
    .exchange-title-copy p { font-size: 11px; }
    .exchange-brand-mark { width: 40px; height: 40px; flex-basis: 40px; }
    .exchange-tool-link { display: none; }
    .exchange-switchboard { align-items: stretch; flex-direction: column; margin-top: 14px; }
    .exchange-tabs { width: 100%; grid-template-columns: repeat(6, minmax(80px, 1fr)); overflow-x: auto; }
    .exchange-queue-bar { width: 100%; min-width: 0; justify-content: flex-start; }
    #redeemSection,
    #querySection,
    #replaceSection,
    #cancelSection,
    .subscription-embed,
    .power-tools { padding: 20px 16px; }
    .subscription-embed iframe { min-height: 720px; }
    .tools-grid { grid-template-columns: 1fr; }
    .query-stat-grid { grid-template-columns: repeat(3, 1fr); }
    .query-result-layout { grid-template-columns: 1fr; }
    .query-result-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 240px; }
}

@media (max-width: 520px) {
    .exchange-eyebrow { font-size: 8px; }
    .exchange-title-copy h1 { font-size: 18px; }
    .exchange-title-copy p { max-width: 210px; }
    .exchange-tools { gap: 4px; }
    .exchange-tool-btn { min-width: 38px; height: 38px; }
    .step-label { font-size: 10px; }
    .step-num { width: 28px; height: 28px; }
    .step-line { min-width: 10px; margin: 0 6px; }
    .query-actions { grid-template-columns: 1fr; }
    .query-detail-grid { grid-template-columns: 1fr; }
    .query-detail-field:nth-child(odd) { border-right: 0; }
    .query-detail-field:nth-last-child(-n+2) { border-bottom: 1px solid var(--exchange-line); }
    .query-detail-field:last-child { border-bottom: 0; }
    .query-result-banner { align-items: flex-start; min-height: 0; padding: 17px; }
    .query-result-banner h3 { font-size: 20px; }
    .query-status-badge { padding: 6px 9px; }
    .query-detail-actions { flex-wrap: wrap; }
    .query-task-id { width: 100%; margin: 6px 0 0; }
    .query-task-id code { max-width: calc(100% - 52px); }
    .query-result-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
