@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ============================
   A2OJ Ladder - Styles v2
   Matching analysis/ page design
   ============================ */

/* ===== Variables ===== */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.78);
    --bg-card-hover: #f8fafc;
    --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.35);
    --focus-ring-offset: 0 0 0 1px rgba(59, 130, 246, 0.15);
    --shadow-card-hover: 0 22px 44px -12px rgba(59, 130, 246, 0.18), 0 12px 24px -10px rgba(0, 0, 0, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --accent: #3b82f6;
    --accent-2: #6366f1;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --shadow-sm: 0 1px 2px 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);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --transition: 0.3s ease;
}

[data-theme="dark"] {
    --bg-primary: #080c16;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-glass: rgba(8, 12, 22, 0.72);
    --bg-card-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 10px 10px -5px rgba(0,0,0,0.4);
    --shadow-card-hover: 0 28px 56px -12px rgba(59, 130, 246, 0.32), 0 16px 32px -12px rgba(0, 0, 0, 0.5);
    --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.45);
    --focus-ring-offset: 0 0 0 1px rgba(59, 130, 246, 0.22);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}
[data-theme="dark"] body {
    background:
        radial-gradient(ellipse 100% 58% at 50% -14%, rgba(59, 130, 246, 0.13), transparent 52%),
        radial-gradient(ellipse 68% 42% at 100% 28%, rgba(99, 102, 241, 0.09), transparent 48%),
        radial-gradient(ellipse 52% 38% at 0% 68%, rgba(6, 182, 212, 0.055), transparent 44%),
        var(--bg-primary);
}

h1, h2, h3 {
    font-family: 'Space Grotesk', sans-serif;
}
.container { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
.hidden { display: none !important; }
.mt-16 { margin-top: 16px; }
.flex-1 { flex: 1; min-width: 200px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-tertiary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== HEADER ===== */
.header {
    background: var(--bg-glass);
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 55%, transparent);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    pointer-events: none;
    box-shadow: 0 6px 28px 2px rgba(59, 130, 246, 0.26), 0 12px 48px 6px rgba(99, 102, 241, 0.12);
}
.header-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-secondary);
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
}
.back-link:hover {
    background: color-mix(in srgb, var(--bg-tertiary) 85%, var(--accent));
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.18);
}
.back-link:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }

.home-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-secondary);
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
}
.home-link:hover {
    background: color-mix(in srgb, var(--bg-tertiary) 85%, var(--accent));
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.18);
}
.home-link:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { width: 32px; height: 32px; color: var(--accent); }
.logo h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions { display: flex; align-items: center; gap: 16px; }

/* CF Input */
.cf-section { display: flex; align-items: center; }
.cf-input-group { display: flex; align-items: center; gap: 8px; }
.input-wrapper-sm {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}
.input-wrapper-sm:focus-within {
    border-color: var(--accent);
    box-shadow: var(--focus-ring-offset), 0 0 0 4px rgba(59, 130, 246, 0.2), 0 8px 24px rgba(59, 130, 246, 0.12);
}
.input-wrapper-sm svg { color: var(--text-muted); flex-shrink: 0; }
.input-wrapper-sm input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    width: 130px;
    font-family: inherit;
}
.input-wrapper-sm input::placeholder { color: var(--text-muted); }

.btn-connect {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-connect:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 24px rgba(59, 130, 246, 0.25);
}
.btn-connect:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(99,102,241,0.1));
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--radius-full);
}
.user-name { font-weight: 600; font-size: 0.9rem; color: var(--accent-2); }
.btn-refresh, .btn-logout {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-refresh:hover { background: var(--bg-tertiary); color: var(--accent); }
.btn-logout:hover { background: rgba(239,68,68,0.1); color: var(--danger); }

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.theme-toggle:hover {
    border-color: var(--accent);
    transform: rotate(15deg) translateY(-2px) scale(1.05);
    box-shadow: 0 8px 22px rgba(59, 130, 246, 0.26);
}
.theme-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }
.theme-toggle svg { width: 22px; height: 22px; color: var(--text-secondary); }
[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }

/* Spinner */
.spinner { width: 16px; height: 16px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite; }
.spinner-lg { width: 40px; height: 40px; border: 3px solid var(--border-color); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== NAV BAR ===== */
.nav-bar {
    background: color-mix(in srgb, var(--bg-glass) 88%, var(--bg-secondary));
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 55%, transparent);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
}
.nav-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.nav-tabs::-webkit-scrollbar { height: 0; }

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
}
.tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.tab:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); border-radius: var(--radius-md); }
.tab.active {
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(99,102,241,0.1));
    color: var(--accent);
    font-weight: 600;
}

/* ===== MAIN ===== */
.main { padding: 32px 0; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp 0.3s ease; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== SECTION HEADERS ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}
.section-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.section-subtitle { color: var(--text-tertiary); font-size: 0.95rem; }

/* ===== BUTTONS ===== */
.btn-gradient {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-gradient:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}
.btn-gradient:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), color var(--transition);
    font-family: inherit;
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.12);
}
.btn-outline:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }

.btn-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), color var(--transition);
    flex-shrink: 0;
}
.btn-back:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(59, 130, 246, 0.15);
}
.btn-back:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }

/* ===== STAT CARDS ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: color-mix(in srgb, var(--bg-card) 72%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    animation: fadeSlideUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.stats-row .stat-card:nth-child(1) { animation-delay: 0.04s; }
.stats-row .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-row .stat-card:nth-child(3) { animation-delay: 0.16s; }
.stats-row .stat-card:nth-child(4) { animation-delay: 0.22s; }
.stat-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-card-hover);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border-color));
    background: color-mix(in srgb, var(--bg-card) 82%, transparent);
}
.stat-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}
.icon-purple { background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(139,92,246,0.25)); color: #a78bfa; }
.icon-yellow { background: linear-gradient(135deg, rgba(245,158,11,0.25), rgba(217,119,6,0.25)); color: #fbbf24; }
.icon-blue { background: linear-gradient(135deg, rgba(59,130,246,0.25), rgba(6,182,212,0.25)); color: #60a5fa; }
.icon-green { background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(5,150,105,0.25)); color: #34d399; }
[data-theme="light"] .icon-purple { color: #7c3aed; }
[data-theme="light"] .icon-yellow { color: #d97706; }
[data-theme="light"] .icon-blue { color: #2563eb; }
[data-theme="light"] .icon-green { color: #059669; }
.stat-value {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-label { display: block; font-size: 0.85rem; color: var(--text-tertiary); margin-top: 2px; }

/* ===== SECTION CARDS ===== */
.section-card {
    background: color-mix(in srgb, var(--bg-card) 72%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    animation: fadeSlideUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: 0.06s;
}
.section-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.section-card-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.progress-label {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    padding: 6px 16px;
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(99,102,241,0.1));
    border-radius: var(--radius-full);
}

/* Progress Bars */
.progress-bar-xl {
    width: 100%;
    height: 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-fill-gradient {
    height: 100%;
    background: linear-gradient(135deg, #22c55e 0%, #3b82f6 50%, #6366f1 100%);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
    min-width: 0;
}
.progress-bar-sm {
    width: 160px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-inline-lg {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-tertiary);
}

/* Connect Card */
.connect-card { text-align: center; }
.connect-content { padding: 24px 0; }
.connect-content svg { color: var(--text-muted); margin-bottom: 16px; }
.connect-content h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    margin-bottom: 8px;
}
.connect-content p { color: var(--text-tertiary); max-width: 500px; margin: 0 auto; }

/* ===== CATEGORY PROGRESS GRID ===== */
.cat-progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.cat-progress-item {
    padding: 16px 20px;
    background: color-mix(in srgb, var(--bg-tertiary) 78%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 45%, transparent);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    animation: fadeSlideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.cat-progress-grid .cat-progress-item:nth-child(1) { animation-delay: 0.02s; }
.cat-progress-grid .cat-progress-item:nth-child(2) { animation-delay: 0.05s; }
.cat-progress-grid .cat-progress-item:nth-child(3) { animation-delay: 0.08s; }
.cat-progress-grid .cat-progress-item:nth-child(4) { animation-delay: 0.11s; }
.cat-progress-grid .cat-progress-item:nth-child(5) { animation-delay: 0.14s; }
.cat-progress-grid .cat-progress-item:nth-child(6) { animation-delay: 0.17s; }
.cat-progress-item:hover {
    background: color-mix(in srgb, var(--bg-card-hover) 88%, transparent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border-color));
}
.cat-progress-item .cp-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; }
.cat-progress-item .cp-stats {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.cat-progress-item .cp-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-primary);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.cat-progress-item .cp-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

/* ===== CATEGORIES GRID ===== */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}
.category-card {
    padding: 24px;
    background: color-mix(in srgb, var(--bg-card) 72%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    animation: fadeSlideUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.category-card:hover {
    border-color: var(--accent);
    transform: translateY(-6px);
    box-shadow: var(--shadow-card-hover);
    background: color-mix(in srgb, var(--bg-card) 82%, transparent);
}
.category-card .cc-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.category-card .cc-badge {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    padding: 4px 12px;
    background: var(--accent-gradient);
    color: #fff;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
}
.category-card .cc-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 12px 0 8px;
}
.category-card .cc-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.category-card .cc-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

/* ===== SEARCH BOX ===== */
.search-box-lg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    min-width: 260px;
}
.search-box-lg:focus-within {
    border-color: var(--accent);
    box-shadow: var(--focus-ring-offset), 0 0 0 4px rgba(59, 130, 246, 0.2), 0 8px 24px rgba(59, 130, 246, 0.1);
}
.search-box-lg svg { color: var(--text-muted); flex-shrink: 0; }
.search-box-lg input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    width: 100%;
    font-family: inherit;
}
.search-box-lg input::placeholder { color: var(--text-muted); }

/* ===== FILTERS ===== */
.filters-card {
    background: color-mix(in srgb, var(--bg-card) 75%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    animation: fadeSlideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.04s backwards;
}
.filters-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-select {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: all var(--transition);
}
.filter-select:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring-offset), 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.filter-select:focus-visible { outline: none; }

.platform-toggle-row {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.toggle-label input { display: none; }
.toggle-track {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    transition: all var(--transition);
    flex-shrink: 0;
    border: 2px solid var(--border-color);
}
.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition);
}
.toggle-label input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-label input:checked + .toggle-track .toggle-thumb { left: 22px; background: white; }

/* ===== PROBLEMS HEADER ===== */
.problems-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}
.problems-title-row { display: flex; align-items: center; gap: 16px; }
.problems-title-row h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

/* ===== TABLE ===== */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--bg-card) 75%, transparent);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    animation: fadeSlideUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.08s backwards;
}
.problems-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.problems-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    user-select: none;
}
.problems-table th.sortable { cursor: pointer; }
.problems-table th.sortable:hover { color: var(--accent); }

.problems-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.problems-table tbody tr { transition: background var(--transition); }
.problems-table tbody tr:hover { background: var(--bg-card-hover); }

.col-num {
    width: 50px;
    text-align: center;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.col-status { width: 70px; text-align: center; }
.col-name { min-width: 220px; }
.col-platform { width: 110px; }
.col-diff { width: 60px; text-align: center; }
.col-contest { min-width: 160px; max-width: 260px; }
.col-actions { width: 110px; text-align: center; }
.col-failed { width: 80px; text-align: center; }

/* Problem link */
.problem-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}
.problem-link:hover { color: var(--accent); }

/* Status dots */
.status-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-solved { background: #22c55e; box-shadow: 0 0 10px rgba(34,197,94,0.6), 0 0 4px rgba(34,197,94,0.8); }
.status-attempted { background: #f59e0b; box-shadow: 0 0 10px rgba(245,158,11,0.6), 0 0 4px rgba(245,158,11,0.8); }
.status-unsolved { background: transparent; border: 2px solid var(--text-muted); }

/* Row highlights */
.row-solved { background: rgba(34,197,94,0.12) !important; border-left: 3px solid #22c55e; }
.row-attempted { background: rgba(245,158,11,0.12) !important; border-left: 3px solid #f59e0b; }
[data-theme="light"] .row-solved { background: rgba(34,197,94,0.08) !important; }
[data-theme="light"] .row-attempted { background: rgba(245,158,11,0.08) !important; }

/* Platform badges */
.platform-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.platform-codeforces { background: #3b82f6; color: #fff; }
.platform-spoj { background: #059669; color: #fff; }
.platform-uva { background: #9333ea; color: #fff; }
.platform-uri { background: #0891b2; color: #fff; }
.platform-other { background: var(--text-muted); color: #fff; }
[data-theme="light"] .platform-codeforces { background: #2563eb; }
[data-theme="light"] .platform-spoj { background: #047857; }
[data-theme="light"] .platform-uva { background: #7c3aed; }
[data-theme="light"] .platform-uri { background: #0e7490; }
[data-theme="light"] .platform-other { background: #6b7280; }

/* Difficulty */
.diff-badge {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
}
.diff-1 { background: #059669; color: #fff; }
.diff-2 { background: #2563eb; color: #fff; }
.diff-3 { background: #d97706; color: #fff; }
.diff-4 { background: #dc2626; color: #fff; }
.diff-5 { background: #7c3aed; color: #fff; }

/* Action buttons */
.action-btns { display: flex; gap: 4px; justify-content: center; }
.action-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), color var(--transition), filter var(--transition);
}
.action-btn:hover { background: var(--bg-tertiary); color: var(--accent); transform: translateY(-1px); }
.action-btn:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); border-radius: var(--radius-sm); }
.action-btn.bookmarked { color: #f59e0b; filter: drop-shadow(0 0 4px rgba(245,158,11,0.4)); }
.action-btn.has-notes { color: #22c55e; filter: drop-shadow(0 0 4px rgba(34,197,94,0.4)); }

/* Failed mark */
.failed-mark { color: #ef4444; font-size: 1.3rem; font-weight: 800; text-shadow: 0 0 8px rgba(239,68,68,0.5); }

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.page-btn {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--bg-card) 88%, transparent);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), color var(--transition), background var(--transition);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.15);
}
.page-btn:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), var(--focus-ring); }
.page-btn.active { background: var(--accent-gradient); color: white; border-color: transparent; }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* ===== ATTEMPTED TAB ===== */
.attempted-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}
.attempted-count {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--warning);
}
.attempted-label { font-size: 0.9rem; color: var(--text-tertiary); }

.attempted-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: color-mix(in srgb, var(--bg-card) 75%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    transition: transform var(--transition), box-shadow var(--transition), border-left-color var(--transition), background var(--transition);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    animation: fadeSlideUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.attempted-card:hover {
    box-shadow: var(--shadow-md);
    border-left-color: #ef4444;
    background: color-mix(in srgb, rgba(245, 158, 11, 0.08) 70%, var(--bg-card));
    transform: translateX(4px);
}
.attempted-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.attempted-name {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}
.attempted-name:hover { color: var(--accent); }
.attempted-meta { font-size: 0.8rem; color: var(--text-muted); }
.attempted-actions { display: flex; gap: 8px; align-items: center; }

/* ===== PLAYLISTS & BOOKMARKS ===== */
.playlists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}
.playlist-card {
    padding: 24px;
    background: color-mix(in srgb, var(--bg-card) 72%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    animation: fadeSlideUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.playlist-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-4px);
    background: color-mix(in srgb, var(--bg-card) 82%, transparent);
}
.playlist-card .pl-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.playlist-card .pl-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
}
.playlist-card .pl-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.playlist-card .pl-count { font-size: 0.8rem; color: var(--text-tertiary); }
.playlist-card .pl-actions { display: flex; gap: 8px; margin-top: 16px; }

.bookmark-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: color-mix(in srgb, var(--bg-card) 75%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
}
.bookmark-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    background: color-mix(in srgb, var(--bg-card) 85%, transparent);
}
.bookmark-info { display: flex; flex-direction: column; gap: 4px; }
.bookmark-name { color: var(--text-primary); text-decoration: none; font-weight: 600; }
.bookmark-name:hover { color: var(--accent); }
.bookmark-meta { font-size: 0.8rem; color: var(--text-muted); }

/* ===== EMPTY STATES ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
    grid-column: 1 / -1;
}
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.empty-state p { font-size: 0.9rem; max-width: 360px; }

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    padding: 20px;
    animation: fadeUp 0.2s ease;
}
.modal {
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    background: color-mix(in srgb, var(--bg-card) 88%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: auto;
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.modal-sm { max-width: 380px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
}
.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--danger); color: white; }
.modal-close:focus-visible { outline: none; box-shadow: var(--focus-ring-offset), 0 0 0 2px rgba(239, 68, 68, 0.45); }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring-offset), 0 0 0 4px rgba(59, 130, 246, 0.2), 0 8px 22px rgba(59, 130, 246, 0.1);
}
.form-input:focus-visible { outline: none; }

#notesTextarea {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    transition: all var(--transition);
}
#notesTextarea:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring-offset), 0 0 0 3px rgba(59, 130, 246, 0.18);
}
#notesTextarea:focus-visible { outline: none; }

.playlist-option {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
    gap: 12px;
    font-weight: 500;
}
.playlist-option:hover { background: var(--bg-tertiary); }

/* ===== TOASTS ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
}
.loading-box {
    text-align: center;
    padding: 40px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
}
.loading-box p { margin-top: 16px; color: var(--text-secondary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .categories-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 768px) {
    .header-content { height: 60px; }
    .header-left { gap: 8px; }
    .back-link, .home-link { width: 34px; height: 34px; }
    .logo h1 { font-size: 1.2rem; }
    .logo-icon { width: 26px; height: 26px; }
    .header-actions { gap: 8px; }
    .input-wrapper-sm input { width: 90px; }
    .input-wrapper-sm { padding: 6px 10px; gap: 6px; }
    .btn-connect { padding: 6px 12px; font-size: 0.8rem; }
    .theme-toggle { width: 36px; height: 36px; }
    .theme-toggle svg { width: 18px; height: 18px; }
    .tab span { display: none; }
    .tab { padding: 10px 12px; }
    .main { padding: 20px 0; }
    .container { padding: 0 16px; }
    .section-header h2 { font-size: 1.4rem; }
    .problems-title-row h2 { font-size: 1.4rem; }
    .filters-row { flex-direction: column; }
    .flex-1 { min-width: 100%; }
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-value { font-size: 1.5rem; }
    .section-card { padding: 20px; border-radius: var(--radius-lg); }
    .col-contest { display: none; }
    .problems-table td:nth-child(6) { display: none; }
    .cat-progress-grid { grid-template-columns: 1fr; }
    .search-box-lg { min-width: 100%; }
    .user-badge { gap: 6px; }
    .user-name { font-size: 0.8rem; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .header-content { height: 52px; }
    .header-left { gap: 4px; }
    .back-link, .home-link { width: 30px; height: 30px; }
    .back-link svg, .home-link svg { width: 16px; height: 16px; }
    .logo { gap: 6px; }
    .logo h1 { font-size: 1rem; }
    .logo-icon { width: 22px; height: 22px; }
    .header-actions { gap: 6px; }
    .input-wrapper-sm input { width: 70px; font-size: 0.8rem; }
    .input-wrapper-sm { padding: 5px 8px; }
    .btn-connect { padding: 5px 10px; font-size: 0.75rem; }
    .theme-toggle { width: 32px; height: 32px; }
    .stat-card { flex-direction: column; text-align: center; }
    .categories-grid { grid-template-columns: 1fr; }
    .playlists-grid { grid-template-columns: 1fr; }
    .cf-input-group { flex-wrap: wrap; }
    .section-header h2 { font-size: 1.2rem; }
    .tabs { gap: 4px; }
    .tab { padding: 8px 10px; font-size: 0.85rem; }
    .problems-table th, .problems-table td { padding: 10px 8px; font-size: 0.8rem; }
    .col-name { min-width: 160px; }
}
