/* ============================================
   My Collection — Portfolio Dashboard
   Pairs with the unified app chrome (top-header + pill-nav)
   loaded from app-chrome.css. All theme-aware.
   ============================================ */

:root {
    --font-display: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mc-success-500: #059669;
    --mc-success-400: #10b981;
    --mc-success-bg: rgba(16, 185, 129, 0.10);
    --mc-danger-500: #dc2626;
    --mc-danger-bg: rgba(239, 68, 68, 0.10);
    --mc-folder-inset: rgba(0, 0, 0, 0.025);
    --mc-chart-line: var(--blue-500);
    --mc-chart-fill-top: rgba(59, 130, 246, 0.22);
    --mc-chart-fill-bottom: rgba(59, 130, 246, 0);
    --mc-card-surface: var(--bg-secondary);
}

[data-theme="dark"] {
    --mc-folder-inset: rgba(255, 255, 255, 0.03);
    --mc-chart-fill-top: rgba(56, 189, 248, 0.26);
    --mc-chart-line: var(--sky-400);
}

/* ============================================
   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;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; border: 0; background: none; color: inherit; cursor: pointer; }

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    line-height: 1;
    user-select: none;
    vertical-align: middle;
}

.hidden { display: none !important; }

/* ============================================
   Portfolio Hero
   ============================================ */
.portfolio-hero {
    display: grid;
    grid-template-areas:
        "label  action"
        "value  action"
        "growth action";
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-8);
    padding-top: var(--space-4);
}

.portfolio-hero-label {
    grid-area: label;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--blue-600);
}
[data-theme="dark"] .portfolio-hero-label { color: var(--sky-400); }

.portfolio-hero-value {
    grid-area: value;
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 8vw, 3.75rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1;
    color: var(--text-primary);
    margin: 0;
}

.portfolio-hero-growth {
    grid-area: growth;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--mc-success-bg);
    color: var(--mc-success-500);
    font-size: 0.8125rem;
    font-weight: 700;
    width: max-content;
}
.portfolio-hero-growth .pill-period {
    color: var(--text-tertiary);
    font-weight: 500;
    margin-left: 4px;
}
.portfolio-hero-growth.negative {
    background: var(--mc-danger-bg);
    color: var(--mc-danger-500);
}
.portfolio-hero-growth .material-symbols-outlined { font-size: 18px; }

.btn-add-card {
    grid-area: action;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: var(--gradient-primary);
    color: #ffffff;
    border-radius: var(--radius-full);
    border: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.005em;
    box-shadow: 0 10px 24px rgba(59, 130, 246, 0.28);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    text-decoration: none;
}
.btn-add-card:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(59, 130, 246, 0.35); }
.btn-add-card:active { transform: scale(0.97); }
.btn-add-card .material-symbols-outlined { font-size: 22px; }

/* ============================================
   Performance Chart
   ============================================ */
.perf-chart {
    position: relative;
    background: var(--mc-card-surface);
    border-radius: var(--radius-2xl);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border-primary);
}

.perf-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.perf-chart-preview-badge {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue-600);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
[data-theme="dark"] .perf-chart-preview-badge {
    color: var(--sky-400);
    background: rgba(56, 189, 248, 0.12);
}
.perf-chart-preview-badge .material-symbols-outlined { font-size: 14px; }
.perf-chart.is-preview .perf-chart-preview-badge { display: inline-flex; }
.perf-chart.is-preview .perf-chart-canvas { opacity: 0.72; }
.perf-chart.is-preview .perf-chart-note { display: block; }

.perf-chart-note {
    display: none;
    margin: var(--space-3) 0 0;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.4;
    text-align: center;
}

.chart-range-tabs {
    display: inline-flex;
    gap: 2px;
    background: var(--mc-folder-inset);
    padding: 4px;
    border-radius: var(--radius-full);
}
.chart-range-tab {
    padding: 6px 14px;
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}
.chart-range-tab:hover { color: var(--text-primary); }
.chart-range-tab.active {
    background: #ffffff;
    color: var(--blue-600);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
[data-theme="dark"] .chart-range-tab.active {
    background: var(--bg-tertiary);
    color: var(--sky-400);
}

.perf-chart-canvas { position: relative; width: 100%; height: 180px; }
.perf-chart-canvas svg { width: 100%; height: 100%; display: block; overflow: visible; }

.perf-chart-xaxis {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-3);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-tertiary);
    text-transform: uppercase;
}


/* ============================================
   Folders Bento (Public / Private)
   ============================================ */
.folders-bento {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.folder-card {
    position: relative;
    overflow: hidden;
    background: var(--mc-card-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-6);
    text-align: left;
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-4);
    width: 100%;
}
.folder-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
.folder-card.active {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 2px var(--blue-500), 0 10px 30px rgba(59, 130, 246, 0.14);
}

.folder-icon {
    position: absolute;
    top: var(--space-5);
    right: var(--space-5);
    font-size: 52px;
    opacity: 0.10;
    color: var(--text-primary);
    pointer-events: none;
}

.folder-top { display: grid; gap: 4px; }
.folder-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}
.folder-subtitle { font-size: 0.875rem; color: var(--text-tertiary); }

.folder-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}
.folder-value {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.growth-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--mc-success-bg);
    color: var(--mc-success-500);
    font-size: 0.8125rem;
    font-weight: 700;
}
.growth-pill.negative { background: var(--mc-danger-bg); color: var(--mc-danger-500); }
.growth-pill .material-symbols-outlined { font-size: 15px; }

/* ============================================
   Cards Section
   ============================================ */
.cards-section { margin-bottom: var(--space-8); }

.cards-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    gap: var(--space-3);
}
.cards-section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
}

.cards-section-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 4px 12px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue-600);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 700;
}
[data-theme="dark"] .cards-section-filter { color: var(--sky-400); background: rgba(56, 189, 248, 0.12); }
.filter-clear {
    background: none;
    border: 0;
    color: inherit;
    display: inline-grid;
    place-items: center;
    padding: 2px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s ease;
}
.filter-clear:hover { background: rgba(59, 130, 246, 0.18); }
.filter-clear .material-symbols-outlined { font-size: 18px; }

.toolbar-lite {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.search-wrapper {
    flex: 1;
    min-width: 180px;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--mc-card-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    padding: 0 var(--space-4);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-wrapper:focus-within {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}
.search-wrapper .material-symbols-outlined {
    color: var(--text-tertiary);
    font-size: 20px;
    pointer-events: none;
}
.search-input {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9375rem;
    padding: 12px 10px;
    outline: none;
    font-family: inherit;
}
.search-input::placeholder { color: var(--text-tertiary); }

.sort-select {
    background: var(--mc-card-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}
.sort-select:focus { border-color: var(--blue-500); }

/* ============================================
   Cards Grid + Tiles
   ============================================ */
.cards-grid-v2 {
    display: grid;
    gap: var(--space-6);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-tile {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    cursor: pointer;
    text-align: center;
    background: none;
    border: 0;
    font: inherit;
    color: inherit;
    padding: 0;
    transition: transform 0.2s ease;
}
.card-tile:hover { transform: translateY(-4px); }

.card-tile-image {
    aspect-ratio: 5 / 7;
    /* No grey backing — the card art fills the frame edge-to-edge. Radius
       matches .card-tile-image-inner so the rounded corners (and shadow) hug
       the card; the inner still shows its pocket surface for empty slots. */
    border-radius: calc(var(--radius-xl) - 6px);
    overflow: hidden;
    position: relative;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    transition: box-shadow 0.2s ease;
}
.card-tile:hover .card-tile-image {
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(59, 130, 246, 0.18);
}
.card-tile-image-inner {
    width: 100%;
    height: 100%;
    background: var(--mc-folder-inset);
    border-radius: calc(var(--radius-xl) - 6px);
    display: grid;
    place-items: center;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.08);
}
[data-theme="dark"] .card-tile-image-inner {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.card-tile-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-tile-silhouette {
    font-size: 48px;
    color: var(--text-muted);
    opacity: 0.45;
}

.card-tile-name {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 var(--space-1);
}
.card-tile-set {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 var(--space-1);
}

.card-tile-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--mc-success-400);
    box-shadow: 0 0 0 2px var(--mc-card-surface), 0 0 12px rgba(16, 185, 129, 0.5);
    pointer-events: none;
}

.card-tile-add {
    display: grid;
    place-items: center;
    gap: var(--space-2);
    aspect-ratio: 5 / 7;
    background: transparent;
    border: 2px dashed var(--border-primary);
    border-radius: var(--radius-xl);
    color: var(--text-tertiary);
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
    text-decoration: none;
    cursor: pointer;
}
.card-tile-add:hover {
    border-color: var(--blue-500);
    color: var(--blue-600);
    background: rgba(59, 130, 246, 0.04);
}
[data-theme="dark"] .card-tile-add:hover { color: var(--sky-400); }
.card-tile-add .material-symbols-outlined { font-size: 36px; }
.card-tile-add-label { font-size: 0.8125rem; font-weight: 700; letter-spacing: -0.005em; }

/* Focus styles for keyboard users */
.card-tile:focus-visible,
.folder-card:focus-visible,
.chart-range-tab:focus-visible,
.btn-add-card:focus-visible,
.card-tile-add:focus-visible,
.filter-clear:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 3px;
}

/* ============================================
   Empty State (preserved)
   ============================================ */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
}
.empty-state-ghosts {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.ghost-card {
    width: 80px;
    height: 112px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    animation: ghostFloat 3s ease-in-out infinite;
}
[data-theme="light"] .ghost-card { border-color: rgba(0, 0, 0, 0.1); }
.ghost-card:nth-child(2) { animation-delay: 0.3s; }
.ghost-card:nth-child(3) { animation-delay: 0.6s; }
@keyframes ghostFloat {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}
.empty-state-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}
.empty-state-text {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-6);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}
.empty-state-cta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--gradient-primary);
    color: #fff;
    border: 0;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.empty-state-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(59, 130, 246, 0.28); }

/* ============================================
   Loading State
   ============================================ */
.loading-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--sky-400);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-4);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-tertiary); font-size: 0.875rem; }

/* ============================================
   Toast Notification
   ============================================ */
.toast-notification {
    position: fixed;
    bottom: calc(var(--home-pill-height, 64px) + var(--home-pill-offset, 1.5rem) + var(--space-3));
    right: var(--space-6);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-3) var(--space-5);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}
.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   Spotlight Overlay (kept for large-card zoom)
   ============================================ */
.spotlight-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    animation: spotlightIn 0.3s ease;
    cursor: pointer;
}
@keyframes spotlightIn { from { opacity: 0; } to { opacity: 1; } }

.spotlight-card {
    max-width: 360px;
    width: 100%;
    border-radius: var(--radius-xl);
    overflow: hidden;
    cursor: default;
    animation: spotlightCardIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
@keyframes spotlightCardIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}
.spotlight-card img { width: 100%; height: auto; display: block; }
.spotlight-info { text-align: center; margin-top: var(--space-6); cursor: default; }
.spotlight-name { font-size: 1.5rem; font-weight: 800; color: #fff; margin-bottom: var(--space-2); }
.spotlight-meta { color: rgba(255, 255, 255, 0.6); font-size: 0.875rem; }
.spotlight-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: rgba(255, 255, 255, 0.1);
    border: 0;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.2s;
}
.spotlight-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ============================================
   Modals (Edit Card)
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: none;
}
.modal-overlay.active { display: block; }

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-6);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 501;
    display: none;
}
.modal.active { display: block; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}
.modal-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.modal-close {
    background: none;
    border: 0;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-1);
    transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }

.modal-field { margin-bottom: var(--space-4); }
.modal-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}
.modal-field input,
.modal-field select,
.modal-field textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
}
.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus { border-color: var(--sky-500); }

.modal-field .checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
}
.modal-field .checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--sky-500);
}

.grading-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.edit-photo-slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-top: var(--space-2);
}
.edit-photo-slot {
    aspect-ratio: 3 / 4;
    border: 2px dashed var(--border-primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
}
.edit-photo-slot:hover { border-color: var(--sky-400); }
.edit-photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-tertiary);
    font-size: 0.75rem;
}
.edit-photo-preview { width: 100%; height: 100%; object-fit: cover; }
.edit-photo-change {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    text-align: center;
    padding: var(--space-1);
    font-size: 0.6875rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
}
.edit-photo-slot:hover .edit-photo-change { opacity: 1; }

.field-hint {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}

/* Shared button styles used in modal */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--gradient-primary);
    color: #fff;
    border: 0;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    font-family: inherit;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(59, 130, 246, 0.28); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    font-family: inherit;
}
.btn-secondary:hover { background: var(--bg-tertiary); border-color: var(--text-tertiary); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: #ef4444;
    color: #fff;
    border: 0;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.btn-danger:hover { background: #dc2626; }

/* ============================================
   Confirm Dialog
   ============================================ */
.confirm-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    /* Above the selection bar (1500) and toast (2000) so confirmations are
       always the topmost, fully-modal layer. */
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.confirm-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-6);
    max-width: 400px;
    width: 90%;
}
.confirm-dialog h3 {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-3);
}
.confirm-dialog p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0 0 var(--space-5);
    line-height: 1.5;
}
.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 641px) {
    .cards-grid-v2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .folders-bento { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 768px) {
    .cards-grid-v2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    .cards-grid-v2 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .perf-chart-canvas { height: 220px; }
    .folder-value { font-size: 2.25rem; }
}
@media (max-width: 640px) {
    /* Value (left) + Add Card (right) share one row; label spans above and
       growth spans below. Scale the value font down a touch so large amounts
       still fit beside the button (columns stay 1fr auto from the base rule). */
    .portfolio-hero {
        grid-template-areas:
            "label  label"
            "value  action"
            "growth growth";
    }
    .portfolio-hero-value { font-size: clamp(1.875rem, 8vw, 2.75rem); }
    .toolbar-lite { flex-direction: column; align-items: stretch; }
    .sort-select { width: 100%; }
    .spotlight-card { max-width: 280px; }
}

/* ============================================
   Section actions: Select toggle, multi-select,
   hover-delete, bulk-action bar
   ============================================ */

/* Base .cards-section-filter sets display:inline-flex which overrides the
   [hidden] UA rule — so the filter chip never actually hid and looked
   un-clearable. Make the attribute authoritative again. */
.cards-section-filter[hidden] { display: none !important; }

.cards-section-header { flex-wrap: wrap; row-gap: var(--space-2); }
.cards-section-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Give the filter clear (X) a comfortable touch target */
.filter-clear { width: 28px; height: 28px; }

.btn-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-primary);
    background: var(--mc-card-surface);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}
.btn-select .material-symbols-outlined { font-size: 18px; }
.btn-select:hover { border-color: var(--text-tertiary); color: var(--text-primary); }
.btn-select.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: var(--blue-500);
    color: var(--blue-600);
}
[data-theme="dark"] .btn-select.active { color: var(--sky-400); background: rgba(56, 189, 248, 0.12); }
.btn-select:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 3px; }

/* Per-tile delete button — hover on desktop, always shown on touch */
.card-tile-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 0;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.62);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.card-tile-delete .material-symbols-outlined { font-size: 18px; }
.card-tile:hover .card-tile-delete,
.card-tile:focus-within .card-tile-delete { opacity: 1; transform: scale(1); }
.card-tile-delete:hover { background: var(--mc-danger-500); }
.card-tile-delete:focus-visible { opacity: 1; transform: scale(1); outline: 2px solid #fff; outline-offset: 1px; }
@media (hover: none) {
    .card-tile-delete { opacity: 1; transform: scale(1); background: rgba(15, 23, 42, 0.5); }
}
.cards-grid-v2.select-mode .card-tile-delete { display: none; }

/* Selection check overlay (only in select mode) */
.card-tile-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    place-items: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.card-tile-check .material-symbols-outlined {
    font-size: 16px;
    color: #fff;
    opacity: 0;
    font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 24;
}
.cards-grid-v2.select-mode .card-tile-check { display: grid; }
.cards-grid-v2.select-mode .card-tile { cursor: pointer; }
.cards-grid-v2.select-mode .card-tile:hover { transform: none; }
.cards-grid-v2.select-mode .card-tile-add { display: none; }
.cards-grid-v2.select-mode .card-tile-badge { display: none; }
.card-tile.selected .card-tile-check { background: var(--blue-500); border-color: #fff; }
.card-tile.selected .card-tile-check .material-symbols-outlined { opacity: 1; }
.card-tile.selected .card-tile-image {
    box-shadow: 0 0 0 3px var(--blue-500), 0 12px 30px rgba(59, 130, 246, 0.22);
}

/* Bottom bulk-action bar — sits just above the pill-nav */
.selection-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--home-pill-height, 64px) + var(--home-pill-offset, 1.5rem) + var(--space-3));
    z-index: 1500;
    display: flex;
    justify-content: center;
    padding: 0 var(--space-4);
    pointer-events: none;
    animation: selBarIn 0.22s ease;
}
.selection-bar[hidden] { display: none; }
@keyframes selBarIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.selection-bar-inner {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    max-width: 560px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}
.sel-cancel {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.sel-cancel:hover { color: var(--text-primary); background: var(--border-primary); }
.sel-cancel .material-symbols-outlined { font-size: 20px; }
.sel-count { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.sel-count strong { color: var(--blue-600); }
[data-theme="dark"] .sel-count strong { color: var(--sky-400); }
.sel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.sel-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}
.sel-action .material-symbols-outlined { font-size: 18px; }
.sel-action:hover:not(:disabled) { border-color: var(--text-tertiary); }
.sel-action:active:not(:disabled) { transform: scale(0.96); }
.sel-action:disabled { opacity: 0.45; cursor: not-allowed; }
.sel-action-danger { color: #fff; background: var(--mc-danger-500); border-color: transparent; }
.sel-action-danger:hover:not(:disabled) { background: #b91c1c; }
.sel-action:focus-visible, .sel-cancel:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }

/* Keep the last row of cards clear of the fixed bar while selecting */
body.selection-active .app-page { padding-bottom: 110px; }

@media (max-width: 560px) {
    .selection-bar { padding: 0 var(--space-3); }
    .selection-bar-inner {
        flex-wrap: wrap;
        border-radius: var(--radius-2xl);
        padding: 10px;
        gap: var(--space-2);
    }
    .sel-cancel { order: 0; }
    .sel-count { order: 1; }
    .sel-actions {
        order: 2;
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }
    .sel-action { flex: 1; justify-content: center; padding: 11px 8px; }
}
@media (max-width: 380px) {
    .sel-action span:not(.material-symbols-outlined) { display: none; }
    .sel-action { padding: 11px; }
}

/* ============================================
   Collection / Traded tabs
   ============================================ */
.collection-tabs {
    display: inline-flex;
    gap: 2px;
    background: var(--mc-folder-inset);
    padding: 4px;
    border-radius: var(--radius-full);
}
.collection-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.collection-tab:hover { color: var(--text-primary); }
.collection-tab.active {
    background: #ffffff;
    color: var(--blue-600);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
[data-theme="dark"] .collection-tab.active {
    background: var(--bg-tertiary);
    color: var(--sky-400);
}
.collection-tab:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.collection-tab-count {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--mc-folder-inset);
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}
.collection-tab.active .collection-tab-count {
    background: rgba(59, 130, 246, 0.14);
    color: var(--blue-600);
}
[data-theme="dark"] .collection-tab.active .collection-tab-count { color: var(--sky-400); }

/* On the Traded tab the per-card actions don't apply */
.cards-section.traded-active .cards-section-actions { display: none; }

/* Traded (sold) tiles — read-only, dimmed, with a badge */
.card-tile-traded { cursor: pointer; }
.card-tile-traded .card-tile-image-inner { opacity: 0.55; filter: saturate(0.85); }
.card-tile-traded:hover { transform: translateY(-4px); }
.card-tile-traded-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 4px 8px;
    border-radius: var(--radius-full);
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.card-tile-traded-badge .material-symbols-outlined { font-size: 14px; }

.cards-empty-inline {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-12) var(--space-4);
    color: var(--text-tertiary);
}
.cards-empty-inline .material-symbols-outlined {
    font-size: 40px;
    opacity: 0.5;
    display: block;
    margin: 0 auto var(--space-3);
}
.cards-empty-inline-title {
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}
.cards-empty-inline-text { font-size: 0.875rem; }

@media (max-width: 480px) {
    .collection-tab { padding: 8px 12px; font-size: 0.875rem; }
}
