/* ========================================================================= */
/* FORTE CARD VIEWER - ENHANCED CSS STRUCTURE                            */
/* ========================================================================= */
/* This file provides an organized structure for the CSS, separating        */
/* concerns and making maintenance easier.                                 */
/* ========================================================================= */

/* --- 1. VARIABLES (Theme Configuration) --- */
:root {
    /* Main Theme Colors - Consolidated color palette */
    --color-primary: #f87171;       /* Red accent */
    --color-primary-light: #fca5a5; /* Lighter shade of primary */
    --color-primary-dark: #ef4444;  /* Darker shade of primary */
    
    --color-secondary: #5a0866;     /* Deep purple */
    --color-secondary-light: #7e1f8e;
    --color-secondary-dark: #3d0545;
    --color-secondary-rgb: 90,8,102; /* RGB values for rgba() */
    
    --color-background: #0f172a;     /* Dark Blue/Slate bg */
    --color-background-alt: #1e293b; /* Slightly lighter background */
    --color-background-panel: rgba(23, 37, 59, 0.97); /* Panel background */
    --color-background-input: rgba(30, 41, 59, 0.9);  /* Input background */
    
    --color-text-primary: #f1f5f9;   /* Light text (Tailwind slate-100) */
    --color-text-secondary: #94a3b8; /* Dimmer text (Tailwind slate-400) */
    --color-text-placeholder: #64748b; /* Placeholder text (Tailwind slate-500) */
    
    --color-border: rgba(51, 65, 85, 0.7);   /* Border color (Tailwind slate-600 alpha) */
    --color-border-light: rgba(71, 85, 105, 0.5); /* Lighter border (Tailwind slate-500 alpha) */
    
    --color-accent: #fbbf24;        /* Accent color (Tailwind amber-400) */
    --color-accent-light: #fcd34d;  /* Lighter accent (Tailwind amber-300) */
    --color-accent-dark: #f59e0b;   /* Darker accent (Tailwind amber-500) */
    
    --color-error: #ef4444;         /* Error color (Tailwind red-500) */
    --color-success: #22c55e;       /* Success color (Tailwind green-500) */
    --color-info: #3b82f6;          /* Info color (Tailwind blue-500) */
    --color-warning: #f97316;       /* Warning color (Tailwind orange-500) */
    
    --color-focus-ring: rgba(99, 102, 241, 0.5); /* Focus ring (Tailwind indigo-500 alpha) */
    --color-overlay: rgba(0, 0, 0, 0.75); /* Dark overlay for modals */
    
    /* Spacing Scale (based on 4px increments) */
    --space-1: 0.25rem;  /* 4px */
    --space-2: 0.5rem;   /* 8px */
    --space-3: 0.75rem;  /* 12px */
    --space-4: 1rem;     /* 16px */
    --space-5: 1.25rem;  /* 20px */
    --space-6: 1.5rem;   /* 24px */
    --space-8: 2rem;     /* 32px */
    --space-10: 2.5rem;  /* 40px */
    --space-12: 3rem;    /* 48px */
    
    /* Border Radius */
    --radius-sm: 0.125rem;  /* 2px */
    --radius-md: 0.375rem;  /* 6px */
    --radius-lg: 0.5rem;    /* 8px */
    --radius-xl: 0.75rem;   /* 12px */
    --radius-full: 9999px;  /* For pills and circles */
    
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: 'Pirata One', cursive;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    
    /* Font Sizes */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    
    /* Animation Timings */
    --transition-fast: 150ms;
    --transition-normal: 250ms;
    --transition-slow: 400ms;
    
    /* Z-index Scale */
    --z-base: 1;
    --z-dropdown: 10;
    --z-sticky: 100;
    --z-fixed: 1000;
    --z-modal: 1100;
    --z-popover: 1200;
    --z-toast: 1300;
    --z-tooltip: 1400;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* --- 2. RESETS & BASE STYLES --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: var(--font-sans);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    display: flex;
    flex-direction: column;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Button Reset */
button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    outline: inherit;
    color: inherit;
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(17, 24, 39, 0.3);
    border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-secondary-light);
}

/* --- 3. LAYOUT & STRUCTURE --- */
.app-header {
    flex-shrink: 0;
    background-color: var(--color-background-panel);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-sticky);
    border-bottom: 1px solid var(--color-border);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-6);
    max-width: 1400px;
    margin: 0 auto;
}

.brand-area {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo {
    max-height: 40px;
    width: auto;
    filter: drop-shadow(0 0 5px rgba(248,113,113,0.5));
}

.title-glow {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    color: var(--color-primary);
    text-shadow: 0 0 4px var(--color-primary), 0 0 8px var(--color-primary);
}

.app-set-navigation {
    flex-shrink: 0;
    background-color: rgba(17, 24, 39, 0.9);
    padding: var(--space-2) var(--space-4);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 90;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    position: relative;
}

.app-main-content {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
}

.app-sidebar {
    width: 280px;
    flex-shrink: 0;
    background-color: var(--color-background-panel);
    padding: var(--space-4);
    overflow-y: auto;
    border-right: 1px solid var(--color-border);
}

.app-gallery-area {
    flex-grow: 1;
    padding: var(--space-4);
    overflow-y: auto;
}

/* Responsive Layout Adjustments */
@media (max-width: 1023px) {
    .app-main-content {
        flex-direction: column;
    }
    
    .app-sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
}

/* --- 4. NAVIGATION & TABS --- */
#tab-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: var(--space-1);
    max-width: 100%;
    padding-bottom: var(--space-1);
}

.tab {
    background-color: transparent;
    color: var(--color-text-secondary);
    border: 1px solid transparent;
    border-bottom: 3px solid transparent;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    white-space: nowrap;
    position: relative;
}

.tab:hover {
    background-color: rgba(255,255,255,0.03);
    color: var(--color-text-primary);
    border-bottom-color: rgba(255,255,255,0.1);
}

.tab.active {
    background-color: var(--tab-active-bg-color, rgba(90, 8, 102, 0.15));
    color: var(--tab-active-text-color, var(--color-primary));
    border-color: var(--color-border-light);
    border-bottom-color: var(--tab-active-border-color, var(--color-primary));
    font-weight: 600;
}

/* Tab Numbering for Keyboard Shortcuts */
.tab[data-key-num]::after {
    content: attr(data-key-num);
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    color: var(--color-text-secondary);
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-full);
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.tab.active[data-key-num]::after {
    color: var(--color-text-primary);
    background-color: rgba(0, 0, 0, 0.4);
    opacity: 0.8;
}

/* --- 5. FILTER CONTROLS --- */
.filter-group {
    margin-bottom: var(--space-5);
}

.filter-label {
    display: block;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}

.filter-select {
    width: 100%;
    background-color: var(--color-background-input);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    transition: all var(--transition-fast) ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.filter-select:hover:not(:disabled) {
    border-color: var(--color-border-light);
}

.filter-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: rgba(15, 23, 42, 0.7);
}

/* --- 6. GALLERY & THUMBNAILS --- */
#item-gallery {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    padding-bottom: var(--space-4);
}

.thumbnail {
    position: relative;
    background-color: rgba(30, 41, 59, 0.8);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 2.5 / 3.5;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast) ease-out, 
                box-shadow var(--transition-fast) ease-out;
    will-change: transform, box-shadow;
}

.thumbnail:hover, 
.thumbnail:focus-visible {
    transform: translateY(-4px) scale(1.03);
    box-shadow: var(--shadow-xl);
    outline: none;
}

.thumbnail:focus-visible {
    border: 2px solid var(--color-accent);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity var(--transition-normal) ease-in-out;
}

.thumbnail img.loaded {
    opacity: 1;
}

.forte-indicator {
    position: absolute;
    top: var(--space-1);
    left: var(--space-1);
    background: linear-gradient(135deg, #7c3aed 0%, #1e1b4b 100%);
    color: white;
    border-radius: var(--radius-full);
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    z-index: 5;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.forte-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #7c3aed 0%, #1e1b4b 100%);
    color: white;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.3);
}

#empty-folder-message {
    text-align: center;
    padding: var(--space-8);
    color: var(--color-text-secondary);
    font-size: var(--text-base);
}

/* Gallery Size Classes */
.gallery-size-s {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-2);
}

.gallery-size-m {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-4);
}

.gallery-size-l {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-5);
}

/* --- 7. LOADING STATES --- */
#page-loading-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--color-background);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition-slow) ease-out, 
                visibility 0s linear var(--transition-slow);
}

#page-loading-overlay.loaded {
    opacity: 0;
    visibility: hidden;
    transition-delay: 0s;
}

.loader {
    border: 4px solid rgba(229, 231, 235, 0.2);
    border-top-color: var(--color-primary);
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

#loading-text {
    margin-top: var(--space-4);
    color: var(--color-primary);
    font-weight: 500;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- 8. LIGHTBOX / CARD VIEWER --- */
#fancy-lightbox {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.92);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    transition: opacity var(--transition-normal) ease-in-out;
}

#fancy-lightbox.visible {
    display: flex;
    opacity: 1;
}

.fancy-lightbox-content {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl), 0 0 20px rgba(90, 8, 102, 0.3);
    width: 90vw;
    max-width: 1000px;
    height: 90vh;
    max-height: 750px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.fancy-lightbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    background-color: var(--color-background-panel);
}

.fancy-lightbox-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.fancy-lightbox-close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-1);
    line-height: 1;
    transition: color var(--transition-fast) ease, 
                transform var(--transition-fast) ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
}

.fancy-lightbox-close:hover {
    color: var(--color-primary);
    transform: rotate(90deg) scale(1.1);
    background-color: rgba(0, 0, 0, 0.2);
}

.fancy-lightbox-body {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
}

.fancy-card-image-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    overflow: hidden;
    position: relative;
    background-color: rgba(0, 0, 0, 0.2);
}

#fancy-card-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    opacity: 0;
    transition: opacity var(--transition-normal) ease-in-out;
    box-shadow: var(--shadow-xl);
}

#fancy-card-image.loaded {
    opacity: 1;
}

#fancy-spinner {
    border-width: 3px;
    width: 30px;
    height: 30px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.fancy-card-info {
    width: 300px;
    flex-shrink: 0;
    padding: var(--space-4);
    overflow-y: auto;
    border-left: 1px solid var(--color-border);
    background-color: var(--color-background-panel);
}

.card-detail-section {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
}

.card-detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.info-section-title {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
}

.info-section-title i {
    margin-right: var(--space-2);
    color: var(--color-accent);
    font-size: 0.9rem;
}

.info-item {
    margin-bottom: var(--space-2);
}

.info-label {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    display: block;
    margin-bottom: var(--space-1);
}

.info-value {
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    word-break: break-word;
}

.card-types {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-1);
}

.card-type-badge {
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

/* --- 9. LIGHTBOX ACTIONS & NAVIGATION --- */
.fancy-card-actions {
    position: absolute;
    right: var(--space-4);
    bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: var(--z-popover);
}

.fancy-action-button {
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    width: 2.5rem;
    height: 2.5rem;
    font-size: var(--text-base);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    box-shadow: var(--shadow-md);
}

.fancy-action-button:hover {
    background-color: var(--color-secondary);
    transform: scale(1.1);
    border-color: var(--color-primary);
}

.fancy-action-button:active {
    transform: scale(0.95);
}

.fancy-action-button.success {
    background-color: var(--color-success) !important;
}

.fancy-action-button.error {
    background-color: var(--color-error) !important;
}

.fancy-nav-controls {
    position: absolute;
    top: 50%;
    left: var(--space-2);
    right: var(--space-2);
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: var(--z-dropdown);
}

.fancy-nav-button {
    background: rgba(0, 0, 0, 0.35);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color var(--transition-fast) ease,
                transform var(--transition-fast) ease;
    opacity: 0.7;
}

.fancy-nav-button:hover:not(:disabled) {
    opacity: 1;
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.05);
}

.fancy-nav-button:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    transform: none;
}

/* Copy tooltip */
.copy-tooltip {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    z-index: var(--z-toast);
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* --- 10. UTILITY BUTTONS --- */
.key-info-button,
.settings-button,
.access-button {
    background-color: rgba(107, 114, 128, 0.2);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.6rem;
    font-size: var(--text-sm);
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition-fast) ease-in-out;
    margin-left: var(--space-2);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.key-info-button:hover,
.settings-button:hover,
.access-button:hover {
    background-color: rgba(107, 114, 128, 0.4);
    color: var(--color-text-primary);
    border-color: var(--color-accent);
}

.key-info-button i,
.settings-button i,
.access-button i {
    font-size: 0.9em;
}

/* --- 11. LEGEND POPUP & SETTINGS MODAL --- */
.key-popup-overlay,
.settings-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--color-overlay);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    transition: opacity var(--transition-normal) ease-in-out;
}

.key-popup-overlay.visible,
.settings-modal-overlay.visible {
    display: flex;
    opacity: 1;
}

.key-popup-content,
.settings-content {
    background-color: var(--color-background-alt);
    color: var(--color-text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    border: 1px solid var(--color-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.key-popup-header,
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    background-color: rgba(0, 0, 0, 0.2);
}

.key-popup-title,
.settings-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-accent);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.key-popup-close,
.settings-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: var(--space-1);
    line-height: 1;
    transition: color var(--transition-fast) ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key-popup-close:hover,
.settings-close:hover {
    color: var(--color-text-primary);
}

.key-popup-body,
.settings-body {
    padding: var(--space-4);
    font-size: var(--text-sm);
    overflow-y: auto;
    flex-grow: 1;
}

.key-popup-body h4,
.settings-section h4 {
    font-weight: 600;
    margin-top: var(--space-4);
    margin-bottom: var(--space-2);
    color: var(--color-accent);
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: var(--space-1);
    font-size: var(--text-base);
}

.key-popup-body h4:first-child {
    margin-top: 0;
}

.key-popup-body ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: var(--space-4);
}

.key-popup-body li {
    margin-bottom: var(--space-1);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.key-popup-body kbd {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.1em 0.4em;
    font-family: var(--font-mono);
    font-size: 0.85em;
    box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
    margin: 0 0.1em;
    color: var(--color-text-primary);
    white-space: nowrap;
}

.key-popup-body i {
    display: inline-block;
    width: 1.2em;
    text-align: center;
    color: var(--color-accent);
    margin-right: var(--space-1);
}

.key-popup-body .note {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px dashed var(--color-border);
}

/* Settings specific styles */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    padding: var(--space-1) 0;
}

.setting-item label {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin-right: var(--space-4);
}

.setting-item .description {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: calc(-1 * var(--space-2));
    flex-basis: 100%;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--color-accent);
}

input:focus + .toggle-slider {
    box-shadow: 0 0 1px var(--color-accent);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.settings-slider {
    width: 100px;
    height: 8px;
    background: #555;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
    border-radius: 4px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    margin-left: auto;
}

.settings-slider:hover {
    opacity: 1;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
}

.settings-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.settings-button-action {
    background-color: var(--color-error);
    color: white;
    border: none;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    margin-left: auto;
}

.settings-button-action:hover {
    background-color: #b91c1c;
}

.settings-placeholder {
    color: var(--color-text-secondary);
    font-style: italic;
    font-size: var(--text-sm);
}

/* --- 12. RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 768px) {
    .app-sidebar {
        max-height: 50vh;
    }
    
    .fancy-lightbox-content {
        flex-direction: column;
        width: 95vw;
        height: 95vh;
        max-height: 95vh;
    }
    
    .fancy-card-info {
        width: 100%;
        max-height: 45%;
        border-left: none;
        border-top: 1px solid var(--color-border);
        order: 2;
    }
    
    .fancy-card-image-container {
        order: 1;
        padding: var(--space-2);
    }
    
    .fancy-nav-controls {
        left: var(--space-1);
        right: var(--space-1);
    }
    
    .fancy-nav-button {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .header-content {
        padding: var(--space-2) var(--space-3);
    }
    
    .title-glow {
        font-size: var(--text-xl);
    }
    
    .key-info-button,
    .settings-button,
    .access-button {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .key-info-button span,
    .settings-button span {
        display: none; /* Hide text, show only icons on small screens */
    }
    
    #tab-container {
        justify-content: flex-start;
        gap: var(--space-1);
    }
    
    .tab {
        padding: var(--space-1) var(--space-2);
        font-size: 0.8rem;
    }
}

/* --- 13. ANIMATIONS & TRANSITIONS --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.fade-in {
    animation: fadeIn var(--transition-normal) ease-out forwards;
}

.slide-in {
    animation: slideIn var(--transition-normal) ease-out forwards;
}

/* --- 14. UTILITY CLASSES --- */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

/* --- 15. POKEMON TYPE COLORS --- */
/* Type badge colors for consistent styling */
.type-grass { background-color: #78C850 !important; color: white !important; }
.type-fire { background-color: #F08030 !important; color: white !important; }
.type-water { background-color: #6890F0 !important; color: white !important; }
.type-lightning { background-color: #F8D030 !important; color: #333 !important; }
.type-fighting { background-color: #C03028 !important; color: white !important; }
.type-psychic { background-color: #F85888 !important; color: white !important; }
.type-colorless { background-color: #A8A878 !important; color: white !important; }
.type-darkness { background-color: #705848 !important; color: white !important; }
.type-metal { background-color: #B8B8D0 !important; color: #333 !important; }
.type-dragon { background-color: #7038F8 !important; color: white !important; }
.type-fairy { background-color: #EE99AC !important; color: #333 !important; }
.type-trainer { background-color: #A0A0A0 !important; color: #333 !important; }
.type-energy { background-color: #E0E0E0 !important; color: #333 !important; }

/* Energy Symbol Colors - match badge colors for consistency */
.energy-grass { background-color: #78C850; }
.energy-fire { background-color: #F08030; }
.energy-water { background-color: #6890F0; }
.energy-lightning { background-color: #F8D030; color: #333; }
.energy-fighting { background-color: #C03028; }
.energy-psychic { background-color: #F85888; }
.energy-colorless { background-color: #A8A878; }
.energy-darkness { background-color: #705848; }
.energy-metal { background-color: #B8B8D0; color: #333; }
.energy-dragon { background-color: #7038F8; }
.energy-fairy { background-color: #EE99AC; color: #333; }