/* Persistent UI Styles - Always looks like "Default" */

.app-header {
    /* Aggressive Reset */
    background: #ffffff !important;
    border: 1px solid #d0d7de !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    margin: 0 0 2rem 0 !important;
    /* Reset top/left/right/bottom explicitly */
    padding: 1.25rem !important;
    color: #24292f !important;

    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
    font-weight: normal !important;
    text-shadow: none !important;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: #24292f !important;
    text-shadow: none !important;
    letter-spacing: normal !important;
}

/* Controls inside header */
/* --- Controls inside header --- */
.app-header .controls {
    display: flex !important;
    align-items: center !important;
    gap: 1rem !important;
}

/* UI Grouping */
.ui-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 6px 10px;
    background: #fff;
    min-width: 60px;
    /* Minimum width for stability */
}

.group-content {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    /* Match button height */
}

.ui-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #57606a;
    margin-top: 4px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

/* Ink Level Badge (next to Template label) */
.ink-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-left: 4px;
    padding-left: 5px;
    border-left: 1px solid #d0d7de;
    color: #2da44e; /* Default: green/light — overridden by JS */
    text-transform: uppercase;
    cursor: default;
    transition: color 0.2s ease;
}

/* 1. Generic Label (e.g. "Year:") */
.app-header .controls label {
    color: #24292f !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    margin-right: 8px !important;
    cursor: default !important;
}

/* New Theme Label Container */
.app-header .theme-label {
    margin-right: 10px !important;
    font-weight: 500 !important;
    color: #24292f !important;
    white-space: nowrap !important;
}

/* Bold the theme name only */
.app-header .theme-label strong {
    font-weight: 700 !important;
}

/* 2. Inputs & Selects (e.g. Year Input) */
.app-header input[type="number"],
.app-header input[type="text"],
.app-header select {
    background: #f6f8fa !important;
    border: 1px solid #d0d7de !important;
    color: #24292f !important;
    padding: 0 12px !important;
    /* Adjusted padding for fixed height */
    border-radius: 6px !important;
    font-size: 0.9rem !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-weight: normal !important;
    box-shadow: none !important;
    height: 36px !important;
    /* UNIFORM HEIGHT */
    line-height: 34px !important;
    /* Vertically center (height - border) */
    box-sizing: border-box !important;
    max-width: 100px !important;
    display: inline-block !important;
    margin: 0 !important;
    appearance: none !important;
    /* Remove browser native styling */
    -moz-appearance: textfield !important;
}

/* Toggle Switch - Default Look */
/* Toggle Switch - Strict Lockdown */
/* Strict Switch Container */
/* 4. Orientation Segmented Control (Toggle Buttons) */
.segmented-control {
    display: flex !important;
    background: #f0f0f0 !important;
    padding: 3px !important;
    /* Slightly more padding for the 'track' */
    border-radius: 6px !important;
    gap: 4px !important;
    /* Small gap between buttons looks nice in segmented too */
    border: 1px solid #d0d7de !important;
    height: 36px !important;
    /* Match other inputs */
    box-sizing: border-box !important;
    align-items: center !important;
}

.segment-btn {
    background: transparent !important;
    border: none !important;
    padding: 0 8px !important;
    height: 28px !important;
    /* Fit within 36px parent (36 - 3*2 padding = 30? let's safe 28) */
    border-radius: 4px !important;
    cursor: pointer !important;
    color: #888 !important;
    /* Inactive Icon Color */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    min-width: 32px !important;
    /* Ensure touch target size */
}

/* Hover state for inactive */
.segment-btn:not(.active):hover {
    color: #555 !important;
    background: rgba(0, 0, 0, 0.05) !important;
}

/* Active State */
.segment-btn.active {
    background: #000000 !important;
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.segment-btn.active:hover {
    background: #333333 !important;
}

/* Icon Sizing */
.segment-btn svg {
    display: block;
    fill: none;
    stroke: currentColor;
    /* Stroke width handled by SVG attribute typically, but we can override if needed */
}

/* Explicitly target ALL text containers in header to kill theme inheritance */
.app-header span,
.app-header label,
.app-header div,
.app-header p {
    color: #24292f !important;
}

/* 3. Buttons (Theme Picker & Admin) */
.app-header button {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    display: inline-block !important;
    height: 36px !important;
    /* UNIFORM HEIGHT */
    line-height: normal !important;
    box-sizing: border-box !important;
}

.app-header .btn-primary {
    background-color: #000 !important;
    color: #ffffff !important;
    border: 1px solid #000 !important;
    padding: 0 16px !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.app-header .btn-small {
    background-color: #f6f8fa !important;
    border: 1px solid #d0d7de !important;
    color: #24292f !important;
    padding: 0 12px !important;
    /* Standard padding */
    border-radius: 6px !important;
    font-size: 0.9rem !important;
    /* Match inputs */
    font-weight: 500 !important;
    box-shadow: 0 1px 0 rgba(27, 31, 35, 0.04) !important;
    cursor: pointer !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.app-header .btn-small:hover {
    background-color: #ebf0f4 !important;
    border-color: #d0d7de !important;
    text-decoration: none !important;
}

/* Icon Button Support */
.app-header .btn-small.has-icon {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding-left: 10px !important;
    padding-right: 12px !important;
}

/* Active State (Toggle ON) */
.app-header .btn-small.active {
    background-color: #e1e4e8 !important;
    border-color: #000 !important;
    font-weight: 700 !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.app-header .btn-small .icon {
    display: block !important;
    color: inherit !important;
}

.app-header #admin-toggle {
    background: transparent !important;
    border: none !important;
    color: #24292f !important;
    font-size: 1.2rem !important;
    padding: 0 5px !important;
    margin-left: 5px !important;
    opacity: 1 !important;
}

/* 5. Labels (Portrait / Landscape) */
/* 5. Orientation Icons (Replaces Text Labels) */
.app-header .toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888 !important;
    /* Inactive: Grey */
    cursor: pointer !important;
    transition: color 0.2s ease;
    padding: 4px;
    border-radius: 4px;
}

.app-header .toggle-icon:hover {
    color: #555 !important;
    background: rgba(0, 0, 0, 0.05);
}

.app-header .toggle-icon.active {
    color: #000 !important;
    /* Active: Black */
    /* Optional: background highlight? */
    /* background: #e1e4e8; */
}

/* Ensure SVG inherits color */
.app-header .toggle-icon svg {
    stroke: currentColor;
    fill: none;
}

/* If we want filled active state */
.app-header .toggle-icon.active svg {
    stroke-width: 2.5;
    /* fill: currentColor; -- maybe too heavy? sticky to stroke width increase for "Bold" feel */
}

/* Global Reset for Header Children */
.app-header * {
    -webkit-font-smoothing: antialiased;
    text-shadow: none !important;
}

@media print {
    .app-header {
        display: none;
    }
}

/* --- Theme Picker Modal Styles --- */

/* Buttons */
.btn-primary {
    background: #000;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    background: #eee;
    color: #333;
    border: 1px solid #ccc;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    margin-right: 10px;
}

.btn-secondary:hover {
    background: #ddd;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;

    /* INSULATION */
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
    color: #24292f !important;
    text-align: left !important;
}

/* Protect all text inside the modal from theme inheritance */
.modal-overlay * {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    /* Ensure inputs don't inherit giant fonts */
    font-size: inherit;
}

/* Specific fix for inputs/buttons to defined sizes */
.modal-overlay input,
.modal-overlay button,
.modal-overlay select {
    font-size: 14px !important;
}

/* Modal Content */
.modal-content {
    background: #fff;
    width: 800px;
    max-width: 95%;
    height: 600px;
    max-height: 90vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Modal Body - Split View */
.modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.theme-sidebar {
    width: 180px;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    background: #f9f9f9;
}

.theme-search-input {
    padding: 10px;
    border: none;
    border-bottom: 1px solid #eee;
    font-family: 'Inter', sans-serif;
    width: 100%;
    box-sizing: border-box;
}

.theme-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

.theme-list li {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.theme-list li:hover {
    background: #eee;
}

.theme-list li.active {
    background: #e0e0e0;
    font-weight: bold;
    border-left: 4px solid #000;
}

.theme-preview-pane {
    flex: 1;
    background: #ffffff;
    /* FORCE WHITE */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    /* NO PADDING */
    position: relative;
    overflow: hidden;
}

.preview-label {
    /* Floating label */
    position: absolute;
    top: 15px;
    right: 20px;
    /* Moved to right */
    left: auto;
    z-index: 10;
    font-size: 0.75rem;
    color: #888;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Wrapper now just fills the available space */
.preview-wrapper {
    width: 100%;
    height: 100%;
    background: white;
    box-shadow: none;
    overflow: hidden;
}

#preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        flex-shrink: 0;
    }

    .modal-body {
        flex-direction: column;
    }

    .theme-sidebar {
        width: 100%;
        height: 35%;
        min-height: 150px;
        border-right: none;
        border-bottom: 1px solid #eee;
        flex-shrink: 0;
    }

    .theme-preview-pane {
        width: 100%;
        height: 65%;
        padding: 0;
        justify-content: flex-start;
        background: #fff;
    }

    .preview-label {
        top: 10px;
        left: 10px;
    }

    .preview-wrapper {
        width: 100%;
        height: 100%;
    }
}

/* --- Year Picker Modal --- */
.year-modal-content {
    background: #fff;
    width: 400px;
    max-width: 90%;
    /* Auto height */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 20px;
}

.year-nav-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.year-nav-btn {
    background: none;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    cursor: pointer;
    padding: 5px 10px;
    font-size: 1.2rem;
}

.year-nav-btn:hover {
    background: #f0f0f0;
}

/* --- Print Options Modal --- */
.print-modal-content {
    background: #fff;
    width: 600px;
    max-width: 90%;
    /* Auto height based on content */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    /* No overflow hidden typically, unless we want scroll */
}

.print-option-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.print-option-card:hover {
    background: #fff;
    border-color: #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.print-option-card .option-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

/* Locked State */
.btn-locked {
    background-color: #f6f8fa !important;
    color: #57606a !important;
    border: 1px solid #d0d7de !important;
    cursor: not-allowed !important;
    opacity: 0.8;
}

.lock-icon {
    font-size: 1rem;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
}

/* --- Dropdown / Popover (v76) --- */
.dropdown-menu {
    position: absolute;
    top: 100%;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
    z-index: 1000;
    text-align: left;
}

.purchased-item {
    margin-bottom: 4px;
    color: #2da44e;
    cursor: pointer;
    padding: 2px 6px;
    margin-left: -6px;
    border-radius: 4px;
    transition: background 0.2s ease;
}
.purchased-item:hover {
    background: #f3f4f6;
}

.dropdown-menu::before {
    /* Triangle Pointer */
    content: '';
    position: absolute;
    top: -6px;
    right: 12px;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-top: 1px solid #d0d7de;
    border-left: 1px solid #d0d7de;
    transform: rotate(45deg);
}

.dropdown-menu button.btn-secondary:hover {
    border-color: #0969da;
    color: #0969da;
}

.print-option-card h3 {
    margin: 5px 0;
    font-size: 1.1rem;
    color: #24292f;
}

.print-option-card p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
}

#year-range-label {
    font-weight: 700;
    font-size: 1.1rem;
}

.year-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.year-option {
    padding: 10px;
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.2s;
}

.year-option:hover {
    background: #e0e0e0;
    border-color: #bbbbbb;
}

.year-option.selected {
    background: #000;
    color: #fff;
    border-color: #000;
    font-weight: 700;
}

/* --- Admin Panel Insulation --- */
#admin-panel {
    background: #ffffff !important;
    border: 1px solid #ccc !important;
    border-radius: 8px !important;
    color: #24292f !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 16px !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

#admin-panel h3,
#admin-panel h4 {
    color: #24292f !important;
    margin-top: 0 !important;
    margin-bottom: 10px !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    text-shadow: none !important;
    letter-spacing: normal !important;
    text-transform: none !important;
}

#admin-panel p,
#admin-panel li,
#admin-panel div {
    color: #24292f !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    text-shadow: none !important;
}

#admin-panel ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 10px 0 !important;
}

.admin-theme-item {
    transition: background-color 0.15s ease;
}

.admin-theme-item:hover {
    background-color: #e6e6e6 !important;
}

.admin-theme-item.dragging {
    background-color: #d0d0d0 !important;
    opacity: 0.8;
}

#admin-panel button {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    cursor: pointer !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {}

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Random Flash Effect (v84.1) */
@keyframes flash-invert {
    0% {
        filter: invert(1);
    }

    100% {
        filter: invert(0);
    }
}

.theme-flash {
    animation: flash-invert 0.5s ease-out;
}


.modal-overlay {
    animation: fadeIn 0.15s ease-out !important;
}

.modal-content,
.year-modal-content {
    animation: scaleIn 0.15s ease-out !important;
}

#admin-panel {
    animation: scaleIn 0.15s ease-out !important;
    transform-origin: top center;
}

/* --- Theme Dropdown (DEPRECATED - kept for fallback) --- */
.theme-dropdown-menu {
    display: none !important; /* Superseded by visual grid panel */
}

/* --- Visual Theme Grid Panel (v98) --- */
.theme-grid-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

.theme-grid-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px 0;
    flex-shrink: 0;
}

.theme-grid-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #24292f !important;
    letter-spacing: -0.02em;
}

.theme-grid-close {
    background: none;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 1.4rem;
    color: #57606a !important;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    line-height: 1;
}

.theme-grid-close:hover {
    background: #f3f4f6;
    color: #24292f !important;
    border-color: #aaa;
}

/* Filter tabs */
.theme-grid-filters {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 14px 28px 0;
    flex-shrink: 0;
    border-bottom: 1px solid #e1e4e8;
}

.theme-grid-filter-divider {
    width: 1px;
    height: 18px;
    background-color: #d0d7de;
    margin: 0 8px 8px 8px;
}

.theme-grid-filter-label {
    font-size: 0.65rem;
    color: #8c959f !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: -1px;
}

.theme-grid-filter-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #57606a !important;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    margin-bottom: -1px;
}

.theme-grid-filter-tab:hover {
    color: #24292f !important;
}

.theme-grid-filter-tab.active {
    color: #24292f !important;
    border-bottom-color: #000;
    font-weight: 600;
}

/* Card grid */
.theme-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    padding: 20px 28px 28px;
    overflow-y: auto;
    flex: 1;
    align-content: start;
}

.theme-grid-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #57606a !important;
    padding: 40px 20px;
    font-size: 0.95rem;
}

/* Individual card */
.theme-grid-card {
    cursor: pointer;
    border-radius: 8px;
    padding: 6px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
}

.theme-grid-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    background: #f6f8fa;
}

.theme-grid-card.active {
    background: #e8f0fe;
    box-shadow: 0 0 0 2px #0969da, 0 4px 12px rgba(9, 105, 218, 0.15);
    border-radius: 8px;
}

/* Swatch inside grid card — smaller than showcase */
.theme-grid-swatch {
    width: 130px;
    height: 150px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 10px 8px 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s;
    box-sizing: border-box;
}

.theme-grid-card:hover .theme-grid-swatch {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
}

.theme-grid-swatch-fallback {
    align-items: center;
    justify-content: center;
    background: #f6f8fa;
}

/* Card footer with name + fav */
.theme-grid-card-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 6px;
    width: 100%;
    padding: 0 2px;
}

.theme-grid-card-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: #57606a !important;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

.theme-grid-card.active .theme-grid-card-name {
    color: #0969da !important;
}

.theme-grid-fav-btn {
    background: none;
    border: none;
    font-size: 0.9rem;
    color: #d0d7de !important;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: all 0.2s;
    outline: none;
    flex-shrink: 0;
}

.theme-grid-fav-btn:hover {
    color: #bf8700 !important;
    transform: scale(1.15);
}

.theme-grid-fav-btn.active {
    color: #bf8700 !important;
}

/* Responsive: smaller screens get fewer columns */
@media (max-width: 768px) {
    .theme-grid-cards {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
        padding: 14px 14px 14px;
    }
    .theme-grid-swatch {
        width: 110px;
        height: 128px;
        padding: 8px 6px 5px;
    }
    .theme-grid-header {
        padding: 14px 14px 0;
    }
    .theme-grid-filters {
        padding: 10px 14px 0;
        overflow-x: auto;
    }
    .theme-grid-filter-tab {
        padding: 6px 10px;
        font-size: 0.78rem;
        white-space: nowrap;
    }
}

/* Old favorite button styles (still used by global fav button) */
.favorite-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #d0d7de; /* subtle gray */
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: all 0.2s;
    outline: none;
}

.favorite-btn:hover {
    color: #bf8700; /* gold */
    transform: scale(1.1);
}

.favorite-btn.active {
    color: #bf8700; /* gold */
}

/* --- FOOTER INSULATION (v92) --- */
/* Mirrors .app-header insulation: prevents theme styles from leaking into the footer */
.app-footer {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 0.9rem !important;
    color: #666 !important;
    background: transparent !important;
    text-shadow: none !important;
    letter-spacing: normal !important;
    font-weight: normal !important;
    line-height: 1.5 !important;
    border-top: 1px solid #ddd !important;
}

.app-footer .footer-link {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    color: #666 !important;
    font-size: 0.9rem !important;
    font-weight: normal !important;
    text-shadow: none !important;
    letter-spacing: normal !important;
    text-transform: none !important;
}

.app-footer .footer-link:hover {
    color: #000 !important;
}
/* =========================================================
   Mobile Responsiveness
   ========================================================= */
@media (max-width: 900px) {
    .app-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
        padding: 1rem !important;
    }

    .app-header .logo-box {
        margin-right: 0 !important;
        justify-content: center !important;
    }

    .app-header .controls {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 10px !important;
    }
    
    /* Ensure the auth section wraps nicely if present */
    .app-header #auth-section {
        margin-right: 0 !important;
        text-align: center;
    }
}
