/* ============================================
   Trading Page Styles
   ============================================ */

/* ============================================
   CSS Variables (page-specific)
   Note: Top-header, pill-nav and page chrome live in
   `/static/css/app-chrome.css` (loaded first in the
   <head>). We consume its `--home-*` tokens here and
   only add hub-specific additions.
   ============================================ */
:root {
    --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --hub-font-headline: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --hub-surface-tile: var(--bg-secondary);
    --hub-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
    --hub-card-shadow-hover: 0 18px 40px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(59, 130, 246, 0.25);
}

[data-theme="light"] {
    --hub-surface-tile: #ffffff;
    --hub-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --hub-card-shadow-hover: 0 18px 40px rgba(0, 0, 0, 0.10), 0 0 0 1px rgba(59, 130, 246, 0.15);
}

/* ============================================
   Base Styles
   ============================================ */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}

/* trade-history.css (loaded before this file for the embedded trade-history
   block) sets a global `html` background; pin it to the trading canvas so the
   overscroll area is unchanged in light theme. */
html { background: var(--bg-primary); }

a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* Prevent double-tap zoom on mobile */
@media (max-width: 1024px) {
    body, .app-page, .trading-card, .bundle-card,
    .card-action-btn, .bundle-action-btn, .view-tab,
    .btn-primary, .btn-secondary, .fab {
        touch-action: manipulation;
    }
}

/* ============================================
   Defensive pill-nav overrides
   The hub page's active pill must NOT show any
   badge or secondary indicator. Some legacy markup
   may still ship a badge element; belt-and-braces
   hide it unless explicitly marked visible.
   ============================================ */
.pill-nav-item.active .pill-nav-badge { display: none !important; }
.pill-nav-badge:not(.visible) { display: none !important; }
.pill-nav-badge:empty { display: none !important; }

/* ============================================
   TRADE HUB — sections
   ============================================ */
.trade-hub {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    animation: hubFadeIn 0.45s var(--home-transition) backwards;
}

@keyframes hubFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Embedded trade-history block: add clear separation from the Direct Trade /
   Find a Match CTA grid above it (the flex `gap` alone read too tight). The
   hairline divider visually delineates "build a trade" from "your trades". */
.th-embed {
    margin-top: var(--space-4);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-primary);
}
@media (min-width: 768px) {
    .th-embed {
        margin-top: var(--space-6);
        padding-top: var(--space-8);
    }
}

.hub-section { padding: 0 2px; }

.hub-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding: 0 2px;
}

.hub-heading {
    margin: 0;
    font-family: var(--hub-font-headline);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

@media (min-width: 1024px) {
    .hub-heading { font-size: 1.4rem; }
}

/* "See All" / "Find More" link — works for both <a> and <button> */
.hub-see-all {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    color: var(--blue-500);
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.hub-see-all:hover { text-decoration: underline; opacity: 0.85; }
.hub-see-all:active { opacity: 0.65; }
.hub-see-all:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Horizontal scroll carousels */
.hub-scroll {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding: 4px 2px 8px;
    margin: 0 -2px;
}
.hub-scroll::-webkit-scrollbar { display: none; }

.hub-skeleton-row { display: flex; gap: 14px; }
.hub-skeleton-card {
    flex: 0 0 260px;
    height: 132px;
    border-radius: var(--radius-3xl);
    background: linear-gradient(110deg, var(--bg-secondary) 30%, var(--bg-tertiary) 50%, var(--bg-secondary) 70%);
    background-size: 200% 100%;
    animation: hubShimmer 1.4s linear infinite;
}
@keyframes hubShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   TRADE MODE PICKER (Direct Trade / Find a Match)
   Card with a pill toggle, animated mode preview,
   and a primary "Trade" button.
   ============================================ */
.trade-picker {
    width: 100%;
    align-self: stretch;
    background: var(--hub-surface-tile);
    border: 1px solid var(--border-primary);
    border-radius: 28px;
    padding: 24px 20px 22px;
    box-shadow: var(--hub-card-shadow);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
}
@media (min-width: 768px) {
    .trade-picker {
        padding: 32px 32px 28px;
        gap: 22px;
    }
    /* Card spans the full page-content width on desktop; constrain the
       inner controls so the toggle/icon/button stay focal-sized centered. */
    .trade-picker > * {
        width: 100%;
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }
}

.trade-picker-head {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.trade-picker-title {
    font-family: var(--hub-font-headline);
    font-weight: 800;
    font-size: 1.375rem;
    letter-spacing: -0.015em;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}
@media (min-width: 768px) {
    .trade-picker-title { font-size: 1.5rem; }
}
.trade-picker-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* --- Pill toggle (sliding thumb) --- */
.trade-picker-toggle {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    width: 100%;
    padding: 4px;
    background: var(--bg-tertiary, rgba(148, 163, 184, 0.12));
    border: 1px solid var(--border-primary);
    border-radius: 999px;
    overflow: hidden;
}
.trade-picker-thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    background: var(--gradient-primary);
    border-radius: 999px;
    box-shadow: 0 8px 22px rgba(14, 165, 233, 0.35);
    transition: transform 0.32s var(--transition-bounce);
    z-index: 0;
    pointer-events: none;
}
.trade-picker-toggle[data-mode="match"] .trade-picker-thumb {
    transform: translateX(100%);
}
.trade-picker-tab {
    position: relative;
    z-index: 1;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--hub-font-headline);
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: -0.005em;
    padding: 12px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.2s ease;
    white-space: nowrap;
}
.trade-picker-tab.active {
    color: #ffffff;
}
.trade-picker-tab:focus-visible {
    outline: 2px solid var(--blue-400);
    outline-offset: 2px;
}
@media (min-width: 768px) {
    .trade-picker-tab { font-size: 1rem; padding: 14px 16px; }
}

/* --- Mode preview (icon disc + title + description) --- */
.trade-picker-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 6px 8px 2px;
    animation: tradePickerPreviewIn 0.35s var(--home-transition);
}
@keyframes tradePickerPreviewIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.trade-picker-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.12) 0%, rgba(59, 130, 246, 0.18) 100%);
    border: 1px solid rgba(59, 130, 246, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}
[data-theme="light"] .trade-picker-icon {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.10) 0%, rgba(59, 130, 246, 0.14) 100%);
}
.trade-picker-icon .material-symbols-outlined {
    color: var(--blue-500);
    font-size: 30px;
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.trade-picker-preview-title {
    font-family: var(--hub-font-headline);
    font-weight: 800;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0;
}
.trade-picker-preview-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
    max-width: 28ch;
}

/* --- Primary "Trade" CTA --- */
.trade-picker-cta {
    appearance: none;
    border: none;
    width: 100%;
    padding: 16px 24px;
    border-radius: 999px;
    background: var(--gradient-primary);
    color: #ffffff;
    font-family: var(--hub-font-headline);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.28);
    transition: transform 0.18s var(--home-transition), box-shadow 0.25s ease, filter 0.2s ease;
    position: relative;
    overflow: hidden;
}
.trade-picker-cta::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0) 70%);
    transform: translateX(-100%);
    transition: transform 0.65s var(--home-transition);
    pointer-events: none;
}
.trade-picker-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 38px rgba(37, 99, 235, 0.36);
    filter: brightness(1.05);
}
.trade-picker-cta:hover::before { transform: translateX(100%); }
.trade-picker-cta:active { transform: scale(0.985); }
.trade-picker-cta:focus-visible {
    outline: 2px solid var(--blue-400);
    outline-offset: 3px;
}

@media (max-width: 360px) {
    .trade-picker { padding: 20px 16px 18px; }
    .trade-picker-title { font-size: 1.25rem; }
    .trade-picker-icon { width: 56px; height: 56px; }
    .trade-picker-icon .material-symbols-outlined { font-size: 26px; }
    .trade-picker-cta { padding: 14px 20px; }
}

/* ============================================
   NEW OFFER CARD
   ============================================ */
.offer-card {
    flex: 0 0 260px;
    background: var(--hub-surface-tile);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-3xl);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--hub-card-shadow);
    scroll-snap-align: start;
    transition: transform 0.2s var(--home-transition), box-shadow 0.25s ease;
}
.offer-card:hover { transform: translateY(-3px); box-shadow: var(--hub-card-shadow-hover); }

.offer-card-head { display: flex; align-items: center; gap: 12px; }
.offer-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(14, 165, 233, 0.12);
    color: var(--blue-500);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.offer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.offer-avatar .material-symbols-outlined {
    font-size: 28px;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.offer-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.offer-meta-name {
    font-family: var(--hub-font-headline);
    font-weight: 800;
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.offer-meta-time {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.offer-card-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
}
.offer-card-thumb {
    width: 40px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    overflow: hidden;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--blue-500);
}
.offer-card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.offer-card-thumb .material-symbols-outlined {
    font-size: 22px;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.offer-card-text { flex: 1; min-width: 0; }
.offer-card-name {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.offer-card-context {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offer-view-btn {
    width: 100%;
    background: var(--gradient-primary);
    color: #ffffff;
    border: none;
    padding: 11px;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.15s ease;
}
.offer-view-btn:hover { filter: brightness(1.08); }
.offer-view-btn:active { transform: scale(0.98); }

/* Empty / placeholder state for carousels */
.hub-empty {
    flex: 1;
    padding: 28px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    border: 1px dashed var(--border-primary);
    border-radius: var(--radius-2xl);
    background: var(--bg-secondary);
}

/* ============================================
   ACTIVE CONVERSATIONS PANEL
   ============================================ */
.hub-panel {
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.06) 0%, transparent 100%);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-3xl);
    padding: 24px;
}
[data-theme="light"] .hub-panel {
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.05) 0%, #ffffff 100%);
}

.hub-panel-head {
    margin-bottom: 16px;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conv-loading,
.conv-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: 24px 0;
    font-size: 0.875rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 8px;
    border-radius: var(--radius-2xl);
    cursor: pointer;
    transition: background 0.18s ease;
    border-bottom: 1px solid var(--border-primary);
}
.conversation-item:last-child { border-bottom: none; }
.conversation-item:hover { background: var(--bg-tertiary); }

.conversation-avatar-wrap { position: relative; flex-shrink: 0; }
.conversation-avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    font-family: var(--hub-font-headline);
    font-weight: 800;
    font-size: 1rem;
    text-transform: uppercase;
}
.conversation-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conversation-item.unread .conversation-avatar {
    background: rgba(14, 165, 233, 0.15);
    color: var(--blue-500);
}
.conversation-status-dot {
    position: absolute;
    bottom: 0; right: 0;
    width: 14px; height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--hub-surface-tile);
    display: none;
}
.conversation-item.unread .conversation-status-dot { display: block; }

.conversation-body {
    flex: 1;
    min-width: 0;
}
.conversation-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
    gap: 8px;
}
.conversation-name {
    font-family: var(--hub-font-headline);
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-item.unread .conversation-name { color: var(--blue-500); font-weight: 800; }
.conversation-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
    flex-shrink: 0;
}
.conversation-item.unread .conversation-time { color: var(--blue-500); font-weight: 700; }

.conversation-preview {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-item.unread .conversation-preview { color: var(--blue-500); font-weight: 700; }
.conversation-preview .material-symbols-outlined {
    font-size: 16px;
    color: var(--text-tertiary);
}
.conversation-item.unread .conversation-preview .material-symbols-outlined {
    color: var(--blue-500);
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* ============================================
   TRADE HISTORY BUTTON
   ============================================ */
.history-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: var(--space-6);
    padding: 18px;
    background: var(--hub-surface-tile);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--hub-font-headline);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.history-btn:hover {
    background: var(--bg-tertiary);
    border-color: rgba(59, 130, 246, 0.3);
}
.history-btn:active { transform: scale(0.98); }
.history-btn .material-symbols-outlined {
    font-size: 22px;
    color: var(--text-secondary);
}

/* ============================================
   BUILDER VIEW WRAPPER
   ============================================ */
.trade-builder {
    animation: hubFadeIn 0.35s var(--home-transition) backwards;
}

.builder-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}
.builder-back:hover {
    background: var(--bg-tertiary);
    border-color: rgba(59, 130, 246, 0.3);
}
.builder-back:hover .material-symbols-outlined { transform: translateX(-3px); }
.builder-back:active { transform: scale(0.97); }
.builder-back .material-symbols-outlined {
    font-size: 20px;
    transition: transform 0.2s ease;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-md);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

/* Stats Hero */
.stats-hero {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    transition: all 0.3s var(--ease-out);
    position: relative;
}

.stat-card-clickable {
    cursor: pointer;
}

.stat-card-clickable:hover {
    border-color: var(--sky-500);
    background: rgba(14, 165, 233, 0.05);
}

.stat-card-clickable .stat-arrow {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    transition: all 0.2s var(--ease-out);
}

.stat-card-clickable:hover .stat-arrow {
    color: var(--sky-500);
    transform: translateY(-50%) translateX(4px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-cards {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
    color: var(--sky-400);
}

.stat-icon-bundles {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
    color: #a855f7;
}

.stat-icon-value {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(34, 197, 94, 0.2) 100%);
    color: #10b981;
}

.stat-icon-offers {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(251, 191, 36, 0.2) 100%);
    color: #f59e0b;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

@media (max-width: 1200px) {
    .stats-hero {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .stats-hero {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: var(--space-4);
    }

    .stat-value {
        font-size: 1.25rem;
    }
}

/* View Tabs */
.view-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: var(--space-2);
}

.view-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.view-tab:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.view-tab.active {
    color: var(--sky-400);
    background: rgba(14, 165, 233, 0.1);
}

.tab-count {
    background: var(--bg-tertiary);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.view-tab.active .tab-count {
    background: rgba(14, 165, 233, 0.2);
    color: var(--sky-400);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    flex: 1;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 300px;
    min-width: 200px;
}

.search-wrapper svg {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

.search-input {
    width: 100%;
    padding: var(--space-3) var(--space-3) var(--space-3) 42px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: all 0.2s var(--ease-out);
}

.search-input:focus {
    outline: none;
    border-color: var(--sky-500);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.filter-group {
    display: flex;
    gap: var(--space-2);
}

.filter-select,
.sort-select {
    padding: var(--space-3) var(--space-4);
    padding-right: var(--space-8);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.filter-select:focus,
.sort-select:focus {
    outline: none;
    border-color: var(--sky-500);
}

.grid-view-toggle {
    display: none;
    align-items: center;
    gap: var(--space-2);
}

.grid-view-toggle-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.grid-view-switch {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.grid-view-switch:hover {
    border-color: var(--sky-500);
}

.grid-view-icons {
    display: flex;
}

.grid-view-icon {
    padding: var(--space-1);
    color: var(--text-tertiary);
    transition: color 0.2s var(--ease-out);
}

.grid-view-icon.active {
    color: var(--sky-400);
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
    }

    .search-wrapper {
        max-width: none;
    }

    .filter-group {
        flex: 1;
    }

    .filter-select {
        flex: 1;
    }

    .grid-view-toggle {
        display: flex;
    }
}

/* Content Grid */
.content-grid {
    display: grid;
    gap: var(--space-4);
}

.card-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.bundle-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.content-grid.hidden {
    display: none;
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-grid.single-column {
        grid-template-columns: 1fr;
    }

    .bundle-grid {
        grid-template-columns: 1fr;
    }
}

/* Trading Card Item */
.trading-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all 0.3s var(--ease-out);
    position: relative;
}

.trading-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.4);
}

/* Rarity glow effects on hover */
.trading-card[data-rarity="common"]:hover {
    box-shadow: 0 0 30px rgba(156, 163, 175, 0.2);
}

.trading-card[data-rarity="uncommon"]:hover {
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.2);
}

.trading-card[data-rarity="rare"]:hover {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.25);
}

.trading-card[data-rarity="ultra-rare"]:hover,
.trading-card[data-rarity="secret"]:hover {
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.3);
}

.card-image-container {
    position: relative;
    aspect-ratio: 63 / 88;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: var(--bg-tertiary);
    padding: 6px;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: calc(var(--radius-xl) - 6px);
    background: var(--bg-secondary);
    transition: transform 0.3s var(--ease-out);
}

.card-image-placeholder {
    width: 100%;
    height: 100%;
    border-radius: calc(var(--radius-xl) - 6px);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image-placeholder svg {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.trading-card:hover .card-image {
    transform: scale(1.05);
}

/* Card Badges */
.card-badges {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    right: var(--space-2);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 2;
}

.condition-badge {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.condition-badge.nm {
    background: rgba(16, 185, 129, 0.9);
    color: white;
}

.condition-badge.lp {
    background: rgba(34, 197, 94, 0.9);
    color: white;
}

.condition-badge.mp {
    background: rgba(245, 158, 11, 0.9);
    color: white;
}

.condition-badge.hp {
    background: rgba(249, 115, 22, 0.9);
    color: white;
}

.condition-badge.dmg {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.grade-badge {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: 0.6875rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 4px;
}

.bundle-indicator {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-md);
    background: rgba(139, 92, 246, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bundle-indicator svg {
    width: 14px;
    height: 14px;
}

/* Card Details */
.card-details {
    padding: var(--space-3);
}

.card-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-1) 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-2);
}

.card-set {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.card-number {
    flex-shrink: 0;
}

.card-value-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.adjustment-tag {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
}

.adjustment-tag.positive {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.adjustment-tag.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Card Actions Overlay */
.card-actions-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    opacity: 0;
    transition: opacity 0.2s var(--ease-out);
    z-index: 5;
}

.trading-card:hover .card-actions-overlay {
    opacity: 1;
}

.card-action-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.card-action-btn:hover {
    transform: scale(1.1);
}

.card-action-btn.edit:hover {
    background: var(--sky-500);
    border-color: var(--sky-500);
    color: white;
}

.card-action-btn.move:hover {
    background: #8b5cf6;
    border-color: #8b5cf6;
    color: white;
}

.card-action-btn.remove:hover {
    background: #f59e0b;
    border-color: #f59e0b;
    color: white;
}

.card-action-btn.delete:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

/* Touch devices - always show actions */
@media (hover: none) {
    .card-actions-overlay {
        opacity: 0;
        pointer-events: none;
    }

    .trading-card.show-actions .card-actions-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Bundle Card Item */
.bundle-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all 0.3s var(--ease-out);
    position: relative;
}

.bundle-card:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 12px 40px -12px rgba(139, 92, 246, 0.3);
}

/* Trainer card style top bar */
.bundle-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b5cf6 0%, #a855f7 50%, #8b5cf6 100%);
    z-index: 2;
}

.bundle-image-container {
    position: relative;
    height: 180px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(168, 85, 247, 0.05) 100%);
}

/* Stacked card visual effect */
.bundle-stack {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 140px;
}

.bundle-stack-card {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    overflow: hidden;
    transition: all 0.3s var(--ease-out);
}

.bundle-stack-card:nth-child(1) {
    transform: rotate(-8deg) translateX(-15px);
    z-index: 1;
}

.bundle-stack-card:nth-child(2) {
    transform: rotate(4deg) translateX(10px);
    z-index: 2;
}

.bundle-stack-card:nth-child(3) {
    transform: rotate(0deg);
    z-index: 3;
}

.bundle-card:hover .bundle-stack-card:nth-child(1) {
    transform: rotate(-12deg) translateX(-20px) translateY(-5px);
}

.bundle-card:hover .bundle-stack-card:nth-child(2) {
    transform: rotate(8deg) translateX(15px) translateY(-5px);
}

.bundle-stack-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bundle-count-badge {
    position: absolute;
    bottom: var(--space-3);
    right: var(--space-3);
    background: rgba(0, 0, 0, 0.8);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    z-index: 5;
}

.bundle-count-badge svg {
    width: 14px;
    height: 14px;
}

.bundle-preview-strip {
    position: absolute;
    bottom: var(--space-3);
    left: var(--space-3);
    display: flex;
    gap: 4px;
    z-index: 5;
}

.bundle-preview-card {
    width: 28px;
    height: 39px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    overflow: hidden;
}

.bundle-preview-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bundle-details {
    padding: var(--space-4);
}

.bundle-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.bundle-icon {
    font-size: 1.25rem;
}

.bundle-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.bundle-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0 0 var(--space-3) 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bundle-cards-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}

.bundle-card-tag {
    padding: var(--space-1) var(--space-2);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.6875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bundle-value-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-primary);
}

.bundle-value-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.bundle-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Bundle Actions Overlay */
.bundle-actions-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    opacity: 0;
    transition: opacity 0.2s var(--ease-out);
    z-index: 10;
}

.bundle-card:hover .bundle-actions-overlay {
    opacity: 1;
}

.bundle-action-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.bundle-action-btn:hover {
    transform: scale(1.1);
}

.bundle-action-btn.edit:hover {
    background: var(--sky-500);
    border-color: var(--sky-500);
    color: white;
}

.bundle-action-btn.add:hover {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.bundle-action-btn.delete:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-state-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-6);
}

.empty-state-icon svg {
    color: var(--text-tertiary);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-2) 0;
}

.empty-state-text {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0 0 var(--space-6) 0;
    max-width: 400px;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
}

.loading-state.hidden {
    display: none;
}

/* Pokeball Spinner */
.pokeball-spinner {
    width: 60px;
    height: 60px;
    position: relative;
    animation: pokeball-bounce 0.8s ease-in-out infinite;
}

.pokeball-top {
    position: absolute;
    top: 0;
    width: 100%;
    height: 50%;
    background: #ef4444;
    border-radius: 60px 60px 0 0;
    border: 4px solid #1a1a1a;
    border-bottom: none;
}

.pokeball-bottom {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 50%;
    background: white;
    border-radius: 0 0 60px 60px;
    border: 4px solid #1a1a1a;
    border-top: none;
}

.pokeball-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: white;
    border: 4px solid #1a1a1a;
    border-radius: 50%;
    z-index: 2;
}

.pokeball-center::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: #1a1a1a;
    border-radius: 50%;
}

@keyframes pokeball-bounce {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
    }
}

.loading-text {
    margin-top: var(--space-6);
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* Floating Action Button */
.fab {
    display: none;
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4);
    z-index: 100;
    transition: all 0.2s var(--ease-out);
}

.fab:hover {
    transform: scale(1.1);
}

.fab:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .fab {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================
   Modal Styles
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    width: 90%;
    max-width: 500px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    z-index: 1001;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-primary);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease-out);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-content {
    flex: 1;
    padding: var(--space-5);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5);
    border-top: 1px solid var(--border-primary);
}

/* Mobile modal - bottom sheet */
@media (max-width: 768px) {
    .modal {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(100%);
        max-width: none;
        width: 100%;
        max-height: 85vh;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    }

    .modal.active {
        transform: translateY(0);
    }

    .card-editor-modal {
        max-height: 92vh;
    }
}

/* Card Editor Modal */
.card-editor-modal {
    max-width: 620px;
}

.card-editor-modal .modal-content {
    max-height: none;
}

.card-editor-preview {
    display: flex;
    gap: var(--space-4);
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: var(--space-5);
}

.card-preview-image {
    width: 100px;
    height: 140px;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    overflow: hidden;
    flex-shrink: 0;
}

.card-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card-preview-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-preview-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-1) 0;
}

.card-preview-set {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.editor-section {
    margin-bottom: var(--space-5);
}

.editor-section:last-child {
    margin-bottom: 0;
}

.editor-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.condition-pills {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.condition-pill {
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.condition-pill:hover {
    border-color: var(--sky-500);
    color: var(--text-primary);
}

.condition-pill.active {
    background: var(--sky-500);
    border-color: var(--sky-500);
    color: white;
}

/* Grading Toggle */
.grading-toggle {
    margin-bottom: var(--space-3);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    position: relative;
    transition: all 0.2s var(--ease-out);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.2s var(--ease-out);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--sky-500);
}

.toggle-label input:checked + .toggle-switch::after {
    left: 22px;
    background: white;
}

.toggle-text {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.grading-inputs {
    display: flex;
    gap: var(--space-3);
}

.grading-inputs.hidden {
    display: none;
}

.grading-company {
    flex: 1;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.grading-score {
    width: 80px;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    text-align: center;
}

.grading-company:focus,
.grading-score:focus {
    outline: none;
    border-color: var(--sky-500);
}

/* Value Adjustment */
.value-adjustment {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.adjustment-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.market-price {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.market-price span {
    color: var(--text-primary);
    font-weight: 500;
}

.adjustment-badge {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.adjustment-badge.positive {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.adjustment-badge.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.final-price {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.final-price span {
    color: #10b981;
    font-weight: 600;
}

.adjustment-slider-wrapper {
    margin-bottom: var(--space-4);
}

.adjustment-slider {
    width: 100%;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    appearance: none;
    cursor: pointer;
}

.adjustment-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gradient-primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}

.adjustment-markers {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.adjustment-presets {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.preset-btn {
    flex: 1;
    min-width: 60px;
    padding: var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.preset-btn:hover {
    border-color: var(--sky-500);
    color: var(--text-primary);
}

.preset-btn.active {
    background: var(--sky-500);
    border-color: var(--sky-500);
    color: white;
}

/* Bundle Modal */
.bundle-modal {
    max-width: 600px;
}

.bundle-form {
    margin-bottom: var(--space-5);
}

.form-group {
    position: relative;
    margin-bottom: var(--space-4);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: all 0.2s var(--ease-out);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--sky-500);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
}

.char-count {
    position: absolute;
    right: var(--space-3);
    bottom: var(--space-3);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.bundle-cards-section {
    margin-bottom: var(--space-5);
}

.bundle-cards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.bundle-cards-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.btn-add-cards {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid var(--sky-500);
    border-radius: var(--radius-full);
    color: var(--sky-400);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.btn-add-cards:hover {
    background: rgba(14, 165, 233, 0.1);
}

.bundle-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    min-height: 120px;
}

.bundle-cards-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.bundle-cards-empty p {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin: 0;
}

.bundle-card-item {
    position: relative;
    aspect-ratio: 63 / 88;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
}

.bundle-card-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.bundle-card-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s var(--ease-out);
}

.bundle-card-item:hover .remove-btn {
    opacity: 1;
}

.bundle-card-item .remove-btn svg {
    width: 12px;
    height: 12px;
}

.bundle-summary {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-row:not(:last-child) {
    margin-bottom: var(--space-2);
}

.summary-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.summary-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.summary-value-price {
    color: #10b981;
}

/* Card Selector Panel */
.card-selector-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 450px;
    max-width: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s var(--ease-out);
    z-index: 1002;
}

.card-selector-panel.active {
    transform: translateX(0);
}

.card-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-primary);
}

.card-selector-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-selector-search {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-primary);
    position: relative;
}

.card-selector-search svg {
    position: absolute;
    left: calc(var(--space-4) + var(--space-3));
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

.selector-search-input {
    width: 100%;
    padding: var(--space-3) var(--space-3) var(--space-3) 42px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.selector-search-input:focus {
    outline: none;
    border-color: var(--sky-500);
}

.card-selector-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    padding: var(--space-4);
    overflow-y: auto;
    align-content: start;
}

.selector-card {
    position: relative;
    aspect-ratio: 63 / 88;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s var(--ease-out);
}

.selector-card:hover {
    transform: scale(1.05);
}

.selector-card.selected {
    border-color: var(--sky-500);
}

.selector-card.selected::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(14, 165, 233, 0.2);
}

.selector-card .check-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--sky-500);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.selector-card.selected .check-icon {
    display: flex;
}

.selector-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.selector-card-placeholder {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.selector-card-placeholder svg {
    width: 32px;
    height: 32px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.card-selector-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.selected-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.selected-count strong {
    color: var(--sky-400);
}

@media (max-width: 768px) {
    .card-selector-panel {
        width: 100%;
        top: auto;
        height: 85vh;
        border-left: none;
        border-top: 1px solid var(--border-primary);
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        transform: translateY(100%);
    }

    .card-selector-panel.active {
        transform: translateY(0);
    }

    .card-selector-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Move to Bundle Panel */
.move-bundle-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    width: 90%;
    max-width: 400px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    z-index: 1001;
}

.move-bundle-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.move-bundle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-primary);
}

.move-bundle-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.move-bundle-content {
    padding: var(--space-4);
    overflow-y: auto;
}

.current-bundle-section {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-primary);
}

.current-bundle-section.hidden {
    display: none;
}

.section-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
}

.current-bundle-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
}

.current-bundle-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.current-bundle-icon {
    font-size: 1.25rem;
}

.current-bundle-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.btn-remove-from-bundle {
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-full);
    color: #ef4444;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.btn-remove-from-bundle:hover {
    background: rgba(239, 68, 68, 0.1);
}

.available-bundles-section .section-label {
    margin-bottom: var(--space-3);
}

.bundle-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.bundle-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.bundle-option:hover {
    border-color: var(--sky-500);
    background: rgba(14, 165, 233, 0.05);
}

.bundle-option-icon {
    font-size: 1.25rem;
}

.bundle-option-info {
    flex: 1;
}

.bundle-option-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    display: block;
}

.bundle-option-count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.btn-create-bundle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: transparent;
    border: 1px dashed var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.btn-create-bundle:hover {
    border-color: var(--sky-500);
    color: var(--sky-400);
}

@media (max-width: 768px) {
    .move-bundle-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(100%);
        max-width: none;
        width: 100%;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    }

    .move-bundle-panel.active {
        transform: translateY(0);
    }
}

/* Confirmation Modal */
.confirm-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    z-index: 2000;
}

.confirm-modal.active {
    opacity: 1;
    visibility: visible;
}

.confirm-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-6);
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.3s var(--ease-out);
}

.confirm-modal.active .confirm-content {
    transform: scale(1);
}

.confirm-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
}

.confirm-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.confirm-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-2) 0;
}

.confirm-message {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0 0 var(--space-6) 0;
}

.confirm-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

.confirm-actions button {
    flex: 1;
    max-width: 140px;
}

/* Toast Notification — sits above the floating pill nav */
.toast-notification {
    position: fixed;
    bottom: calc(var(--home-pill-height) + var(--home-pill-offset) + var(--space-4) + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
    padding: var(--space-4) var(--space-5);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    z-index: 3000;
    transition: transform 0.3s var(--ease-out), opacity 0.3s var(--ease-out);
    max-width: 90%;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}

.toast-notification:empty {
    display: none;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.toast-notification.success {
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.toast-notification.error {
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.toast-notification.warning {
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.toast-notification.hub-notification {
    border-color: rgba(59, 130, 246, 0.35);
    color: var(--text-primary);
    background: var(--bg-secondary);
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(59, 130, 246, 0.22);
}
.toast-notification.hub-notification .toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blue-500);
    color: #ffffff;
    flex-shrink: 0;
}
.toast-notification.hub-notification .toast-icon .material-symbols-outlined {
    font-size: 18px;
}
.toast-notification.hub-notification .toast-text {
    font-weight: 600;
    letter-spacing: -0.005em;
}
.toast-notification.hub-notification:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 14px 32px rgba(59, 130, 246, 0.28);
}
.toast-notification.hub-notification.show:hover {
    transform: translateX(-50%) translateY(-2px);
}

/* Toast visible alias (JS uses .toast-visible) */
.toast-notification.toast-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   Trading Page Components
   ============================================ */

/* --- Mode Selector Tabs --- */
.mode-selector {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-6);
}

.mode-tab {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    text-align: center;
}

.mode-tab:hover {
    color: var(--text-primary);
}

.mode-tab.active {
    color: #fff;
    background: var(--gradient-primary);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

/* --- Trade Mode Container --- */
.trade-mode {
    display: block;
}

/* --- Direct Trade Entry State --- */
.dt-entry {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: 0 0 var(--space-4);
}

#directTradeMode.user-selected .dt-entry {
    display: none;
}

/* Card sections only appear once a trade partner is chosen
   (mirrors the old behavior where the split-screen was hidden until then). */
#directTradeMode:not(.user-selected) .fm-section {
    display: none;
}

.dt-entry-head {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-2) 0 var(--space-6);
}

.dt-back {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--blue-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.dt-back:hover { background: var(--bg-tertiary); }
.dt-back:active { transform: scale(0.92); }
.dt-back .material-symbols-outlined { font-size: 26px; }

.dt-title-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
    min-width: 0;
}

.dt-title {
    margin: 0;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    line-height: 1.15;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    white-space: nowrap;
}

.dt-subtitle {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-tertiary);
    line-height: 1.3;
}
.dt-subtitle:empty { display: none; }

.dt-head-spacer { width: 44px; height: 44px; display: block; }

/* --- Search Frame --- */
.dt-search-frame {
    position: relative;
    background: var(--border-primary);
    padding: 1.5px;
    border-radius: var(--radius-xl);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background 0.2s ease, box-shadow 0.25s ease, transform 0.2s ease;
}
.dt-search-frame:focus-within {
    background: var(--text-tertiary);
}

.dt-search-inner {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: calc(var(--radius-xl) - 1.5px);
    overflow: visible;
}

.search-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    z-index: 1;
    font-size: 22px;
}

.user-search-input {
    width: 100%;
    padding: 14px var(--space-4) 14px 46px;
    background: transparent;
    border: none;
    border-radius: inherit;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
}

.user-search-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 500;
}

/* --- Recommended Traders Section --- */
.dt-recommend {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.dt-recommend-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
}

.dt-recommend-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.dt-recommend-title {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

.dt-recommend-subtitle {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-tertiary);
    line-height: 1.35;
}

.dt-see-all {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 6px 4px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--blue-500);
    cursor: pointer;
    transition: opacity 0.15s ease;
    font-family: inherit;
}
.dt-see-all:hover { opacity: 0.75; }
.dt-see-all[hidden] { display: none; }

/* --- Trader List & Cards --- */
.dt-trader-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dt-trader-card {
    display: grid;
    grid-template-columns: 56px 1fr 48px;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--bg-secondary);
    border-radius: var(--radius-2xl);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: box-shadow 0.25s ease, transform 0.2s ease, background 0.25s ease;
    font-family: inherit;
    border: none;
    text-align: left;
    width: 100%;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    .dt-trader-card:hover {
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
        transform: translateY(-2px);
    }
}
.dt-trader-card:active { transform: scale(0.99); }
.dt-trader-card:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
}

.dt-trader-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    overflow: hidden;
    flex-shrink: 0;
}
.dt-trader-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.dt-trader-avatar .material-symbols-outlined {
    font-size: 32px;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.dt-trader-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.dt-trader-name {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dt-trader-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Inter', sans-serif;
    color: var(--blue-500);
    line-height: 1;
}
.dt-trader-rating .material-symbols-outlined {
    font-size: 16px;
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}
.dt-trader-rating-value {
    font-weight: 800;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.dt-trader-trade-count {
    margin-left: 2px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0;
}
.dt-trader-rating-empty {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dt-trader-location {
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Skeleton loader (shown before fetch resolves) */
.dt-trader-skeleton {
    height: 88px;
    border-radius: var(--radius-2xl);
    background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-tertiary) 50%, var(--bg-secondary) 100%);
    background-size: 200% 100%;
    animation: dtShimmer 1.6s linear infinite;
}
@keyframes dtShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dt-trader-empty {
    padding: var(--space-6);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    background: var(--bg-secondary);
    border-radius: var(--radius-2xl);
}

/* Desktop adaptation — center the entry column, slightly larger type */
@media (min-width: 768px) {
    .dt-entry-head { margin: var(--space-2) 0 var(--space-8); }
    .dt-entry {
        max-width: 48rem;
        margin-inline: auto;
        width: 100%;
        gap: var(--space-8);
    }
    .dt-title { font-size: 2.25rem; }
    .dt-recommend-title { font-size: 1.75rem; }
    .dt-recommend-subtitle { font-size: 0.9375rem; }
    .dt-trader-name { font-size: 1.0625rem; }
    .dt-trader-rating-value { font-size: 0.875rem; }
    .dt-trader-trade-count { font-size: 0.75rem; }
    .dt-trader-location { font-size: 0.75rem; }
    .dt-trader-card { padding: var(--space-5) var(--space-6); }
}

/* --- Autocomplete Dropdown --- */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

[data-theme="light"] .autocomplete-dropdown {
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);
}

.autocomplete-dropdown:empty {
    display: none;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: background 0.15s ease;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
}

.dropdown-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.dropdown-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dropdown-username {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.dropdown-empty {
    padding: var(--space-4);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* --- Selected User Banner --- */
.selected-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-4);
    margin-left: 0;
    margin-right: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background 0.18s ease, box-shadow 0.18s ease;
}

.selected-user:hover {
    background: var(--bg-tertiary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.selected-user-avatar,
.selected-user-name {
    cursor: pointer;
}

.selected-user:hover .selected-user-name {
    color: var(--sky-400);
}

[data-theme="light"] .selected-user {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
}

.selected-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.selected-user-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.selected-user-clear {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.15s ease;
    font-family: inherit;
}

.selected-user-clear:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Card browsing grid — used by the Direct Trade and Find-a-Match
   card-select picker modals (.panel-card-grid.card-select-grid).

   Desktop: fixed 180px tracks, cards don't stretch.
   Mobile (≤768px, via media query below): 2 equal columns stretched to fill.

   Touch-scroll is explicitly enabled so the grid scrolls inside the
   Find-a-Match modal — without this, the modal was squeezing all cards
   into one viewport height on mobile. */
.panel-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 180px);
    gap: var(--space-3);
    padding: var(--space-4);
    min-height: 200px;
    max-height: min(640px, 70vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    flex: 1;
    scroll-behavior: smooth;
    justify-content: start;
}

.panel-card-grid .selectable-card {
    width: 180px;
    max-width: 180px;
}

.panel-card-grid::-webkit-scrollbar {
    width: 8px;
}

.panel-card-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.panel-card-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.panel-card-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
    background-clip: content-box;
}

.panel-empty {
    /* Span the whole grid row so the message isn't jammed into a single card slot,
       then center both axes inside that row so it looks intentional in any panel
       width (Direct Trade or Find-a-Match modal). */
    grid-column: 1 / -1;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-8) var(--space-4);
    margin: 0;
    color: var(--text-tertiary);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
}

.panel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-10);
    grid-column: 1 / -1;
}

.panel-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--sky-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Selectable Cards --- */
.selectable-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .selectable-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 20px rgba(14, 165, 233, 0.12);
        transform: translateY(-3px) scale(1.02);
    }
}
.selectable-card:active { transform: scale(0.98); }

.selectable-card.card-selected {
    box-shadow: 0 0 0 2px var(--sky-400), 0 0 24px rgba(14, 165, 233, 0.25), 0 4px 16px rgba(0, 0, 0, 0.2);
}

@media (hover: hover) {
    .selectable-card.card-selected:hover {
        transform: translateY(-2px);
        box-shadow: 0 0 0 2px var(--sky-400), 0 0 32px rgba(14, 165, 233, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
    }
}

/* Wrapper that enforces the card's 63:88 aspect-ratio. When the JS renders tiles
   through renderSelectableCardTile(), every <img> sits inside this wrapper. */
.selectable-card-img {
    position: relative;
    aspect-ratio: 63 / 88;
    background: #0d1117;
    overflow: hidden;
}
.selectable-card-img > img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Safety net: if a stale cached build renders <img> as a DIRECT child of
   .selectable-card (no wrapper), enforce the 63:88 aspect-ratio here too so
   tiles don't collapse to tiny pills. Scoped with `:not()` so it never fights
   the wrapper rule above. */
.selectable-card > img:not(.wrapped) {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 63 / 88;
    object-fit: contain;
    background: #0d1117;
}

.card-check-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(14, 165, 233, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    backdrop-filter: brightness(1.1);
}

.card-check-overlay svg {
    width: 32px;
    height: 32px;
    color: #fff;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.card-info-bar {
    padding: var(--space-3) var(--space-2) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    background: rgba(0, 0, 0, 0.22);
}

.card-name-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.card-price {
    font-family: 'Inter', sans-serif;
    align-self: flex-start;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--sky-400);
    background: rgba(14, 165, 233, 0.14);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.01em;
}

/* --- Trade Summary Bar --- */
.trade-summary-bar {
    background: linear-gradient(135deg, rgba(15, 20, 32, 0.95), rgba(10, 14, 26, 0.95));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-6);
    margin-top: var(--space-5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.summary-values {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
}

.summary-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    min-width: 140px;
    flex-shrink: 0;
    padding: var(--space-3) var(--space-4);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.summary-side.your-side {
    border-color: rgba(14, 165, 233, 0.12);
}

.summary-side.their-side {
    border-color: rgba(139, 92, 246, 0.12);
}

.summary-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.summary-amount {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fairness-container {
    flex: 1;
    max-width: 280px;
    min-width: 120px;
}

/* --- Fairness Meter (copied from trade.css to avoid loading that file) --- */
.fairness-meter {
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    /* Override conflicting styles from styles.css which sets height:12px and overflow:hidden
       for a different simpler fairness bar used on other pages */
    height: auto;
    overflow: visible;
    margin-bottom: 0;
}

.fairness-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.fairness-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    /* Override conflicting styles from styles.css */
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0;
}

.fairness-status {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.75rem;
    font-weight: 600;
}

.fairness-status.fair {
    color: #10b981;
}

.fairness-status.warning {
    color: #f59e0b;
}

.fairness-status.unfair {
    color: #ef4444;
}

.fairness-status svg {
    width: 14px;
    height: 14px;
}

/* Bar wrapper - holds both the track and the pointer */
.fairness-bar-wrapper {
    position: relative;
    height: 20px;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
}

/* Bar track - clipped container for the fill and center marker */
.fairness-bar-track {
    position: relative;
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.fairness-bar-fill {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: var(--radius-full);
    transition: all 0.3s ease;
}

.fairness-bar-fill.fair {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.fairness-bar-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.fairness-bar-fill.unfair {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Center marker */
.fairness-center-marker {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-tertiary);
    transform: translateX(-50%);
    opacity: 0.5;
}

/* Pointer - sits on top of the wrapper, NOT inside the clipped track */
.fairness-pointer {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: white;
    border-radius: var(--radius-full);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: left 0.3s ease;
    z-index: 2;
}

/* Value Comparison */
.fairness-values {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    gap: var(--space-2);
}

.fairness-values > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.fairness-val-left,
.fairness-val-right {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.fairness-difference {
    text-align: center;
    font-weight: 700;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.fairness-difference.positive {
    color: #10b981;
}

.fairness-difference.negative {
    color: #ef4444;
}

.summary-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.message-input {
    flex: 1;
    min-width: 200px;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.message-input:focus {
    border-color: var(--sky-500);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.12);
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

/* ============================================================
   Find a Match (Make a Trade mode) — fm-* components
   ============================================================ */

/* Trade-entry flag hides mode tabs when user arrived via a hub CTA */
.trade-builder[data-trade-entry="match"] .mode-selector,
.trade-builder[data-trade-entry="direct"] .mode-selector,
.trade-builder[data-trade-entry="match"] .builder-back,
.trade-builder[data-trade-entry="direct"] .builder-back {
    display: none;
}

.find-match-view {
    max-width: 45rem;
    margin: 0 auto;
    padding: 0 var(--space-4) var(--space-10);
}

/* Sub-header (back + title) */
.fm-page-header {
    position: sticky;
    top: var(--home-header-height, 64px);
    z-index: 5;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    padding: var(--space-3) 0 var(--space-4);
    margin: 0 0 var(--space-2);
    background: var(--bg-primary);
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.fm-back {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--blue-500);
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.15s ease;
}

.fm-back:hover {
    background: color-mix(in srgb, var(--blue-500) 10%, transparent);
}

.fm-back:active {
    transform: scale(0.92);
}

.fm-back .material-symbols-outlined {
    font-size: 22px;
}

.fm-title {
    margin: 0;
    text-align: center;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, var(--blue-500) 0%, var(--sky-400) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.fm-header-spacer { width: 40px; height: 40px; }

/* Game filter tightening inside the view */
.fm-game-filter {
    margin: 0 0 var(--space-4);
}

/* Section container (Offering / Seeking) */
.fm-section {
    margin-bottom: 0;
}

.fm-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0 var(--space-1);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}

.fm-section-title-group {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    min-width: 0;
}

.fm-section-title {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.fm-value-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border: 1px solid color-mix(in srgb, var(--blue-400) 30%, transparent);
    border-radius: var(--radius-full);
    font-family: 'Manrope', sans-serif;
    font-size: 0.6875rem;
    font-weight: 800;
    color: var(--blue-400);
    white-space: nowrap;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-feature-settings: 'tnum' 1;
}

.fm-value-pill.is-bump {
    transform: translateY(-1px) scale(1.06);
}

.fm-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: color-mix(in srgb, var(--blue-500) 14%, transparent);
    border: none;
    border-radius: var(--radius-full);
    color: var(--blue-400);
    font-family: 'Inter', sans-serif;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.15s ease;
}

.fm-add-btn:hover {
    background: color-mix(in srgb, var(--blue-500) 22%, transparent);
}

.fm-add-btn:active {
    transform: scale(0.96);
}

.fm-add-btn .material-symbols-outlined {
    font-size: 14px;
}

/* Horizontal card scroll row */
.fm-card-scroll {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px var(--space-4) var(--space-3);
    margin: 0 calc(-1 * var(--space-4));
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.fm-card-scroll::-webkit-scrollbar {
    display: none;
}

/* Mini-card */
.fm-mini {
    position: relative;
    flex-shrink: 0;
    width: 112px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.32);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.fm-mini:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.48);
}

.fm-mini-img-wrap {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-tertiary);
    margin-bottom: 6px;
}

.fm-mini-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.fm-mini-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: color-mix(in srgb, var(--blue-500) 40%, transparent);
    font-size: 30px;
}

.fm-mini-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    background: color-mix(in srgb, var(--bg-secondary) 85%, transparent);
    border: 1px solid color-mix(in srgb, var(--blue-400) 25%, transparent);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: var(--blue-400);
    text-transform: uppercase;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.fm-mini-badge[data-tone="grade"] {
    background: color-mix(in srgb, var(--sky-400) 14%, var(--bg-secondary));
    border-color: color-mix(in srgb, var(--sky-400) 35%, transparent);
    color: var(--sky-400);
}

.fm-mini-badge[data-tone="rarity"] {
    background: color-mix(in srgb, #8b5cf6 18%, var(--bg-secondary));
    border-color: color-mix(in srgb, #8b5cf6 35%, transparent);
    color: #a78bfa;
}

.fm-mini-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
    border: 1px solid var(--border-primary);
    padding: 0;
    border-radius: 50%;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease, background-color 0.15s ease;
    z-index: 2;
}

.fm-mini:hover .fm-mini-remove,
.fm-mini:focus-within .fm-mini-remove {
    opacity: 1;
    transform: scale(1);
}

/* Touch devices — always show the remove X since hover isn't reliable */
@media (hover: none) {
    .fm-mini-remove {
        opacity: 1;
        transform: scale(1);
    }
}

.fm-mini-remove:hover {
    background: color-mix(in srgb, #ef4444 14%, var(--bg-secondary));
    color: #ef4444;
    border-color: color-mix(in srgb, #ef4444 40%, transparent);
}

.fm-mini-remove:active {
    transform: scale(0.92);
}

.fm-mini-remove .material-symbols-outlined {
    font-size: 14px;
}

.fm-mini-body {
    padding: 0 4px 4px;
}

.fm-mini-name {
    margin: 0 0 1px;
    font-family: 'Manrope', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fm-mini-num {
    margin: 0 0 2px;
    font-family: 'Inter', sans-serif;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--text-tertiary);
}

.fm-mini-price {
    font-family: 'Manrope', sans-serif;
    font-size: 0.8125rem;
    font-weight: 800;
    color: var(--blue-400);
}

/* Dashed "add more" tile */
.fm-mini--add {
    background: transparent;
    border: 2px dashed color-mix(in srgb, var(--blue-400) 30%, transparent);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: var(--blue-500);
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.fm-mini--add .fm-mini-add-inner {
    width: 100%;
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fm-mini--add:hover {
    background: color-mix(in srgb, var(--blue-500) 8%, transparent);
    border-color: color-mix(in srgb, var(--blue-400) 50%, transparent);
    transform: none;
    box-shadow: none;
}

.fm-mini--add .material-symbols-outlined {
    font-size: 28px;
}

/* Empty state inside a scroll (not used with dashed + tile, kept for safety) */
.fm-scroll-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    padding: var(--space-3);
}

/* Find Matches primary CTA */
.fm-cta-wrap {
    margin: var(--space-5) 0 var(--space-6);
}

.fm-find-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--blue-500) 0%, var(--sky-400) 100%);
    border: none;
    border-radius: var(--radius-full);
    color: #ffffff;
    font-family: 'Manrope', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow: 0 14px 36px -10px color-mix(in srgb, var(--blue-500) 55%, transparent),
                0 6px 14px -4px color-mix(in srgb, var(--blue-500) 30%, transparent);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.fm-find-btn:hover:not(:disabled) {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 18px 40px -8px color-mix(in srgb, var(--blue-500) 65%, transparent),
                0 8px 16px -4px color-mix(in srgb, var(--blue-500) 35%, transparent);
}

.fm-find-btn:active:not(:disabled) {
    transform: scale(0.985);
}

.fm-find-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.fm-find-btn .material-symbols-outlined {
    font-size: 20px;
}

/* ---------- Light-theme overrides for fm-* ---------- */
[data-theme="light"] .fm-page-header {
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
}

[data-theme="light"] .fm-back {
    color: var(--blue-500);
}

[data-theme="light"] .fm-title {
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-400) 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .fm-value-pill {
    background: var(--bg-primary);
    border-color: color-mix(in srgb, var(--blue-500) 22%, transparent);
    color: var(--blue-500);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .fm-add-btn {
    color: var(--blue-500);
    background: color-mix(in srgb, var(--blue-500) 12%, transparent);
}

[data-theme="light"] .fm-add-btn:hover {
    background: color-mix(in srgb, var(--blue-500) 20%, transparent);
}

[data-theme="light"] .fm-mini {
    background: var(--bg-primary);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .fm-mini:hover {
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12), 0 2px 4px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .fm-mini-badge {
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    color: var(--blue-500);
    border-color: color-mix(in srgb, var(--blue-500) 18%, transparent);
}

[data-theme="light"] .fm-mini-badge[data-tone="grade"] {
    color: var(--sky-600);
    background: color-mix(in srgb, var(--sky-400) 12%, var(--bg-primary));
    border-color: color-mix(in srgb, var(--sky-500) 32%, transparent);
}

[data-theme="light"] .fm-mini-badge[data-tone="rarity"] {
    color: #7c3aed;
    background: color-mix(in srgb, #8b5cf6 10%, var(--bg-primary));
    border-color: color-mix(in srgb, #8b5cf6 28%, transparent);
}

[data-theme="light"] .fm-mini-name {
    color: var(--text-primary);
}

[data-theme="light"] .fm-mini-price {
    color: var(--blue-500);
}

[data-theme="light"] .fm-mini-remove {
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
}

[data-theme="light"] .fm-mini-remove:hover {
    background: color-mix(in srgb, #ef4444 10%, var(--bg-primary));
}

[data-theme="light"] .fm-mini--add {
    border-color: color-mix(in srgb, var(--blue-500) 26%, transparent);
    color: var(--blue-500);
}

[data-theme="light"] .fm-mini--add:hover {
    background: color-mix(in srgb, var(--blue-500) 6%, transparent);
    border-color: color-mix(in srgb, var(--blue-500) 45%, transparent);
}

/* ---------- Light-theme overrides for direct-trade entry state ---------- */
[data-theme="light"] .dt-back { color: var(--blue-500); }
[data-theme="light"] .dt-back:hover { background: color-mix(in srgb, var(--blue-500) 10%, transparent); }

[data-theme="light"] .dt-title,
[data-theme="light"] .dt-recommend-title {
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-400) 100%);
    -webkit-background-clip: text;
    background-clip: text;
}
[data-theme="light"] .dt-recommend-title {
    background: none;
    -webkit-text-fill-color: initial;
    color: var(--text-primary);
}

[data-theme="light"] .dt-search-frame {
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .dt-trader-card {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.05);
    background: #ffffff;
}
@media (hover: hover) {
    [data-theme="light"] .dt-trader-card:hover {
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10), 0 3px 10px rgba(15, 23, 42, 0.06);
    }
}

[data-theme="light"] .dt-trader-empty {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .dt-trader-skeleton {
    background: linear-gradient(90deg, #f8fafc 0%, #eef2f7 50%, #f8fafc 100%);
    background-size: 200% 100%;
}

/* ---------- Responsive: mobile tuning + desktop upscale ---------- */
@media (max-width: 420px) {
    .find-match-view {
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .fm-card-scroll {
        margin: 0 calc(-1 * var(--space-3));
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .fm-mini {
        width: 108px;
    }

    .fm-section-title {
        font-size: 0.9375rem;
    }

    .fm-find-btn {
        font-size: 0.9375rem;
        padding: 13px 14px;
    }
}

@media (min-width: 960px) {
    .find-match-view {
        padding-left: var(--space-5);
        padding-right: var(--space-5);
    }

    .fm-section-title {
        font-size: 1.125rem;
    }

    .fm-value-pill {
        font-size: 0.75rem;
        padding: 4px 12px;
    }

    .fm-add-btn {
        font-size: 0.6875rem;
        padding: 7px 14px;
    }

    .fm-mini {
        width: 140px;
    }

    .fm-mini-badge {
        font-size: 0.625rem;
    }

    .fm-mini-name {
        font-size: 0.8125rem;
    }

    .fm-mini-price {
        font-size: 0.875rem;
    }

    .fm-find-btn {
        font-size: 1.0625rem;
        padding: 16px 20px;
    }
}

/* --- Match Results (shown in a modal) --- */
/* Desktop only: widen the results modal. On mobile (<=768px) it must keep the
   base .modal full-width bottom-sheet, so don't cap max-width there. */
@media (min-width: 769px) {
    .matches-modal {
        max-width: 600px;
    }
}

.matches-modal .modal-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.results-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 165, 233, 0.15);
    color: var(--sky-400);
    font-size: 0.75rem;
    font-weight: 600;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    min-width: 24px;
}

.match-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-3);
}

.match-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    transition: all 0.2s ease;
}

.match-card:hover {
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.match-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    min-width: 0;
}

.match-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.match-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.match-username {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-distance {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.match-count {
    font-size: 0.8125rem;
    color: var(--sky-400);
    font-weight: 600;
    white-space: nowrap;
}

/* Trader has every wanted card — emphasize the coverage tag */
.match-count.is-all {
    color: var(--accent-green);
    font-weight: 700;
}

/* --- Card Select Modal (Make a Trade popup) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Fullscreen Card Picker modal — shared by "Add Card" (offer) + "Add Card" (seek).
   Fills the entire viewport so we can have many cards at a FIXED size, scrollable. */
.card-select-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    background: var(--bg-primary);
    border: none;
    border-radius: 0;
    z-index: 210;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    overflow: hidden;
}

.card-select-modal.active {
    transform: translateY(0);
    pointer-events: auto;
}

/* Mobile defense: the generic `.modal` mobile rules (styles at ~line 1843) try to
   turn every modal into a bottom-sheet with `max-height: 85vh` and a border-radius.
   `.modal.card-select-modal` has higher specificity (0,2,0) than either `.modal`
   or `.card-select-modal` alone (0,1,0), so these overrides win at all widths. */
@media (max-width: 768px) {
    .modal.card-select-modal {
        position: fixed;
        inset: 0;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100dvh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        transform: translateY(100%);
    }
    .modal.card-select-modal.active {
        transform: translateY(0);
    }
}

/* Thin accent line below header — replaces old ::before bar which was overlapping the header */
.card-select-modal .modal-header {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--space-3);
    /* Account for iOS notch here instead of on the modal wrapper */
    padding: calc(var(--space-3) + env(safe-area-inset-top, 0)) var(--space-4) var(--space-3);
    flex-shrink: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    min-height: calc(56px + env(safe-area-inset-top, 0));
    /* Reset globals from styles.css so the close stays in-flow */
    margin-bottom: 0;
    text-align: left;
}

/* Optional hairline gradient accent below the header */
.card-select-modal .modal-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--sky-400), var(--blue-500), #8b5cf6);
    opacity: 0.22;
    pointer-events: none;
}

.card-select-modal .modal-title {
    font-family: 'Manrope', sans-serif;
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: var(--space-2);
}

/* Close button — 44×44 touch target, clear, no rotate-on-hover.
   IMPORTANT: override `position: absolute` + top/right from the global `.modal-close`
   in styles.css so the button participates in the header grid instead of floating
   over the title. */
.card-select-modal .modal-close {
    position: static;
    top: auto;
    right: auto;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-full);
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    justify-self: end;
}

.card-select-modal .modal-close .material-symbols-outlined {
    font-size: 22px;
    line-height: 1;
}

.card-select-modal .modal-close:hover {
    background: color-mix(in srgb, #ef4444 14%, var(--bg-tertiary));
    color: #ef4444;
    border-color: color-mix(in srgb, #ef4444 45%, transparent);
}

.card-select-modal .modal-close:active {
    transform: scale(0.94);
}

.card-select-modal .modal-close:focus-visible {
    outline: 2px solid var(--blue-400);
    outline-offset: 2px;
}

/* FULL reset against the generic .modal-content from styles.css (max-width 540px,
   heavy padding, gradient bg, border, shadow, animation). The reset also makes
   the modal-content THE scroll container: the grid inside has its own natural
   height (max-height: none), the grid items flow top-to-bottom as a normal grid,
   and the user scrolls vertically inside .modal-content to see more cards —
   same mental model as scrolling a web page. This is what Direct Trade does for
   its Your/Their panels (page-level scroll) — just scoped to the modal. */
.card-select-modal .modal-content {
    position: relative;
    width: 100%;
    max-width: none;
    max-height: none;
    background: transparent;
    backdrop-filter: none;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    animation: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    display: block;
}

.card-select-modal .form-input {
    width: calc(100% - var(--space-4) * 2);
    margin: var(--space-3) var(--space-4) 0;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.card-select-modal .form-input:focus {
    border-color: var(--sky-500);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sky-500) 18%, transparent);
}

.card-select-modal .form-input::placeholder {
    color: var(--text-tertiary);
}

/* Modal-specific overrides for the picker grid. The grid does NOT scroll
   itself — the .modal-content wrapper is the scroll container. The grid flows
   top-to-bottom with its natural height so ALL cards are laid out and the
   parent scrolls past them. This is why cards don't get squeezed anymore:
   there's no height constraint trying to cram them into one screen. */
.card-select-grid {
    flex: none;
    min-height: 0;
    max-height: none;
    overflow: visible;
    align-content: start;
}

.card-select-modal .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border-primary);
    flex-shrink: 0;
    background: var(--bg-primary);
}

/* Body scroll lock while the card picker is open. DO NOT add `touch-action: none`
   here — it propagates to all descendants and kills touch-scroll inside the modal,
   which makes the card grid crush every tile into one viewport height. Overflow
   hidden alone is enough to stop the underlying page from scrolling. */
body.modal-open {
    overflow: hidden;
}

.card-select-modal .modal-footer > span {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-select-modal .modal-footer .btn-primary {
    min-width: 140px;
    padding: var(--space-3) var(--space-5);
    font-size: 0.9375rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--blue-500) 0%, var(--sky-400) 100%);
    box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--blue-500) 55%, transparent);
}

.card-select-modal .modal-footer .btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* --- Small Button Variant --- */
.btn-sm {
    padding: var(--space-2) var(--space-3) !important;
    font-size: 0.8125rem !important;
}

/* ============================================
   Light Theme Overrides
   ============================================ */

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --border-primary: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .stat-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .trading-card,
[data-theme="light"] .bundle-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .trading-card:hover,
[data-theme="light"] .bundle-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .modal,
[data-theme="light"] .card-selector-panel,
[data-theme="light"] .move-bundle-panel {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .toast-notification {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .pokeball-top {
    border-color: #333;
}

[data-theme="light"] .pokeball-bottom {
    border-color: #333;
}

[data-theme="light"] .pokeball-center {
    border-color: #333;
}

[data-theme="light"] .selectable-card {
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .selectable-card:hover {
    border-color: rgba(14, 165, 233, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .selectable-card-img {
    background: #f0f0f0;
}

[data-theme="light"] .card-info-bar {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .trade-summary-bar {
    background: var(--bg-secondary);
    border-color: var(--border-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .card-select-modal {
    background: var(--bg-primary);
}

[data-theme="light"] .card-select-modal .modal-header,
[data-theme="light"] .card-select-modal .modal-footer {
    background: var(--bg-primary);
    border-color: var(--border-primary);
}

[data-theme="light"] .card-select-modal .modal-close {
    background: var(--bg-secondary);
    border-color: var(--border-primary);
    color: var(--text-primary);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .card-select-modal .modal-close:hover {
    background: color-mix(in srgb, #ef4444 10%, var(--bg-secondary));
    color: #dc2626;
    border-color: color-mix(in srgb, #ef4444 40%, transparent);
}

[data-theme="light"] .selectable-card-img {
    background: #f0f0f0;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

/* --- Tablet (1024px) --- */
@media (max-width: 1024px) {
    .trading-page {
        max-width: 100%;
    }
    .page-title {
        font-size: 1.5rem;
    }
}

/* --- Mobile (768px) --- */
@media (max-width: 768px) {
    .main-content {
        padding: calc(60px + var(--space-3)) var(--space-3) var(--space-3);
    }
    .page-header {
        margin-bottom: var(--space-3);
    }
    .page-title {
        font-size: 1.25rem;
    }
    .page-subtitle {
        font-size: 0.8125rem;
    }

    /* Mode selector */
    .mode-selector {
        margin-bottom: var(--space-4);
    }
    .mode-tab {
        padding: var(--space-2) var(--space-3);
        font-size: 0.875rem;
    }

    /* Mobile: 2 cards per row, stretched to fill the modal width
       (both card-select picker modals carry .panel-card-grid). */
    .panel-card-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: none;
        gap: var(--space-3);
        padding: var(--space-3);
    }
    .panel-card-grid .selectable-card {
        width: 100%;
        max-width: none;
    }

    /* Trade summary - stack vertically */
    .trade-summary-bar {
        padding: var(--space-4);
    }
    .summary-values {
        flex-direction: column;
        gap: var(--space-3);
    }
    .summary-side {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        min-width: auto;
        padding: var(--space-3);
    }
    .fairness-container {
        max-width: none;
        min-width: auto;
        width: 100%;
    }
    .summary-actions {
        flex-direction: column;
    }
    .message-input {
        min-width: auto;
        width: 100%;
    }
    .summary-actions .btn-primary {
        width: 100%;
    }

    /* Match results - single column */
    .match-results-grid {
        grid-template-columns: 1fr;
    }

    /* Card picker modal is already fullscreen at all sizes — no bottom-sheet override here. */

    /* Match cards - compact */
    .match-card {
        padding: var(--space-3);
        flex-wrap: wrap;
    }
    .match-card .btn-primary {
        width: 100%;
        margin-top: var(--space-2);
    }
    .match-user {
        flex: 1 1 100%;
    }
    .match-count {
        flex: 1 1 100%;
        text-align: center;
        padding: var(--space-1) 0;
    }
}

/* --- Small Mobile (480px) --- */
@media (max-width: 480px) {
    .main-content {
        padding: calc(60px + var(--space-2)) var(--space-2) var(--space-2);
    }
    .panel-card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
        padding: var(--space-2);
        max-height: none;
    }
    .panel-card-grid .selectable-card {
        width: 100%;
        max-width: none;
    }
    .card-info-bar {
        padding: var(--space-2);
    }
    .card-name-label {
        font-size: 0.8125rem;
    }
    .card-price {
        font-size: 0.75rem;
    }
    /* Card picker grid uses fixed-width columns globally — no 480px override */
    .trade-summary-bar {
        padding: var(--space-3);
    }
    .summary-side {
        padding: var(--space-2);
    }
    .summary-amount {
        font-size: 1.125rem;
    }
}

/* ============================================
   Game Type Filter Pills
   ============================================ */
.game-type-filter {
    padding: 0 0 var(--space-4);
}
.game-type-filter .mp-pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: center;
}
.game-type-filter .mp-mini-pill {
    height: 30px;
    padding: 0 var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}
.game-type-filter .mp-mini-pill:hover {
    border-color: var(--sky-500);
}
.game-type-filter .mp-mini-pill.active {
    background: rgba(14, 165, 233, 0.15);
    border-color: var(--sky-500);
    color: var(--sky-400);
}
.game-type-filter .mp-mini-pill[data-game-type="pokemon"].active {
    background: rgba(255, 107, 107, 0.15);
    border-color: #ff6b6b;
    color: #ff6b6b;
}
.game-type-filter .mp-mini-pill[data-game-type="onepiece"].active {
    background: rgba(78, 205, 196, 0.15);
    border-color: #4ecdc4;
    color: #4ecdc4;
}
.game-type-filter .mp-mini-pill[data-game-type="mtg"].active {
    background: rgba(155, 89, 182, 0.15);
    border-color: #9b59b6;
    color: #9b59b6;
}