/* ===== CSS Variables & Themes ===== */
:root {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: rgba(255,255,255,0.85);
    --bg-card-hover: rgba(255,255,255,0.95);
    --bg-input: #f1f5f9;
    --bg-glass: rgba(255,255,255,0.6);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;

    --border-color: rgba(226,232,240,0.8);
    --border-light: rgba(241,245,249,0.8);

    --accent-primary: #3b82f6;
    --accent-secondary: #6366f1;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #6366f1 100%);
    --accent-gradient-hover: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #4f46e5 100%);
    --accent-glow: rgba(59,130,246,0.25);

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #06b6d4;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 4px 10px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px -8px rgba(0, 0, 0, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --transition: 0.3s cubic-bezier(0.4,0,0.2,1);
    --transition-bounce: 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

[data-theme="dark"] {
    --bg-primary: #080c16;
    --bg-secondary: #0f1629;
    --bg-tertiary: #182038;
    --bg-card: rgba(15,22,41,0.85);
    --bg-card-hover: rgba(24,32,56,0.95);
    --bg-input: #182038;
    --bg-glass: rgba(15,22,41,0.7);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;

    --border-color: rgba(30,41,59,0.9);
    --border-light: rgba(51,65,85,0.6);

    --accent-glow: rgba(99,102,241,0.2);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px -8px rgba(0, 0, 0, 0.6);
}

/* ===== Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition), color var(--transition);
}

[data-theme="dark"] body {
    background-image:
        radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99,102,241,0.08), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(59,130,246,0.06), transparent);
}

.hidden { display: none !important; }

/* ===== Animations ===== */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 0 8px transparent; }
}

/* ===== Header ===== */
.header {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent-gradient);
    opacity: 0.4;
}

.header .container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.header-content { display: flex; justify-content: space-between; align-items: center; height: 64px; }
.header-left { display: flex; align-items: center; gap: 16px; }

.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-tertiary); text-decoration: none; font-size: 0.85rem; font-weight: 500;
    padding: 6px 12px; border-radius: var(--radius-md); transition: all var(--transition);
}
.back-link:hover { color: var(--accent-primary); background: rgba(59,130,246,0.1); }
.back-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.home-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius-md);
    color: var(--text-tertiary); text-decoration: none; transition: all var(--transition);
}
.home-link:hover { color: var(--accent-primary); background: rgba(59,130,246,0.1); }
.home-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 32px; height: 32px; color: var(--accent-primary); }
.logo h1 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1.35rem; 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: 12px; }

.theme-toggle {
    width: 40px; height: 40px; border-radius: 50%;
    border: 1px 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-primary); transform: rotate(15deg); }
.theme-toggle svg { width: 20px; height: 20px; color: var(--text-secondary); }
[data-theme="light"] .moon-icon, [data-theme="dark"] .sun-icon { display: none; }

/* ===== Container & Main ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.main { padding: 32px 0 16px; }

/* ===== Privacy Notice ===== */
.privacy-notice {
    background: var(--bg-card); backdrop-filter: blur(12px);
    border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 14px 20px; display: flex; align-items: center; gap: 12px;
    margin-bottom: 24px; font-size: 0.9rem; color: var(--text-secondary);
    box-shadow: var(--shadow-sm); animation: fadeSlideUp 0.4s ease;
}
.privacy-icon { font-size: 1.1rem; flex-shrink: 0; }
.privacy-notice .close-btn {
    margin-left: auto; background: none; border: none; font-size: 1.4rem;
    cursor: pointer; color: var(--text-muted); padding: 0 4px; transition: color var(--transition);
}
.privacy-notice .close-btn:hover { color: var(--text-primary); }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 36px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    animation: fadeSlideUp 0.5s ease both;
    transition: box-shadow var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}
.card:hover::before { opacity: 1; }

.card-title {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1.6rem; font-weight: 700; margin-bottom: 6px;
    background: var(--accent-gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.card-subtitle { color: var(--text-tertiary); font-size: 0.9rem; margin-bottom: 24px; }

/* ===== Handle Input ===== */
.search-form { display: flex; gap: 12px; }
.input-wrapper { flex: 1; position: relative; }

.search-icon {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--text-muted); pointer-events: none;
    transition: color var(--transition);
}

.input-wrapper input {
    width: 100%; padding: 14px 14px 14px 46px; font-size: 1rem;
    border: 2px solid var(--border-color); border-radius: var(--radius-lg);
    background: var(--bg-input); color: var(--text-primary);
    transition: all var(--transition); font-family: inherit;
}
.input-wrapper input:focus {
    outline: none; border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-glow);
}
.input-wrapper input:focus ~ .search-icon,
.input-wrapper input:focus + .search-icon { color: var(--accent-primary); }
.input-wrapper input::placeholder { color: var(--text-muted); }

/* ===== Buttons ===== */
.btn-gradient {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 28px; font-size: 1rem; font-weight: 600; color: white;
    background: var(--accent-gradient); border: none; border-radius: var(--radius-lg);
    cursor: pointer; transition: all var(--transition); font-family: inherit; white-space: nowrap;
    position: relative; overflow: hidden;
}
.btn-gradient::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0; transition: opacity var(--transition);
    pointer-events: none;
}
.btn-gradient:hover::before { opacity: 1; }
.btn-gradient:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px var(--accent-glow); }
.btn-gradient:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-gradient svg { width: 18px; height: 18px; }
.btn-gradient.btn-sm { padding: 8px 16px; font-size: 0.85rem; border-radius: var(--radius-md); }
.btn-gradient.btn-lg { padding: 16px 32px; font-size: 1.05rem; width: 100%; border-radius: var(--radius-lg); }

.btn-practice {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 16px 32px; font-size: 1.1rem; font-weight: 700; color: white;
    background: linear-gradient(135deg, #10b981, #059669, #047857);
    border: none; border-radius: var(--radius-lg); cursor: pointer;
    transition: all var(--transition); font-family: inherit; width: 100%;
    position: relative; overflow: hidden;
    animation: pulseGlow 2s ease infinite;
    --accent-glow: rgba(16,185,129,0.3);
}
.btn-practice:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(16,185,129,0.35); }
.btn-practice svg { width: 22px; height: 22px; }

.btn-outline {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary); background: transparent;
    border: 1.5px solid var(--border-color); border-radius: var(--radius-md);
    cursor: pointer; transition: all var(--transition); font-family: inherit; white-space: nowrap;
}
.btn-outline:hover:not(:disabled) { border-color: var(--accent-primary); color: var(--accent-primary); background: rgba(59,130,246,0.05); }
.btn-outline.active { border-color: var(--accent-primary); color: var(--accent-primary); background: rgba(59,130,246,0.1); }
.btn-outline.btn-lg { padding: 14px 24px; font-size: 0.95rem; flex: 1; }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; font-size: 0.8rem; font-weight: 500;
    color: var(--text-tertiary); background: transparent; border: none;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); font-family: inherit;
}
.btn-ghost:hover { color: var(--accent-primary); background: rgba(59,130,246,0.1); }

.btn-danger-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0; font-size: 1.1rem; font-weight: 500;
    color: var(--text-muted); background: transparent;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition);
}
.btn-danger-ghost:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.btn-danger-ghost:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== Spinner ===== */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* ===== Cache Info ===== */
.cache-info { margin-top: 12px; font-size: 0.85rem; color: var(--text-muted); }
.cache-info.fresh { color: var(--success); }

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
    z-index: 1000; animation: fadeIn 0.2s ease;
}
.loading-content {
    background: var(--bg-card); backdrop-filter: blur(20px);
    padding: 40px 48px; border-radius: var(--radius-xl); text-align: center;
    min-width: 320px; box-shadow: var(--shadow-xl); border: 1px solid var(--border-color);
}
.loading-spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--border-color); border-top-color: var(--accent-primary);
    border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 20px;
}
.loading-content p { color: var(--text-secondary); font-weight: 500; }
.progress-bar { height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; margin-top: 16px; }
.progress-fill { height: 100%; background: var(--accent-gradient); width: 0%; transition: width 0.3s ease; border-radius: 3px; }

/* ===== Message Area ===== */
.message-area { margin-bottom: 20px; animation: fadeSlideUp 0.3s ease; }
.message { padding: 14px 20px; border-radius: var(--radius-md); font-size: 0.95rem; font-weight: 500; }
.message.error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.message.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.message.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.message.info { background: rgba(59,130,246,0.1); color: var(--accent-primary); border: 1px solid rgba(59,130,246,0.3); }

/* ===== Stats Bar ===== */
.stats-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }

.stat-card {
    background: var(--bg-card); backdrop-filter: blur(12px);
    padding: 24px 20px; border-radius: var(--radius-lg); text-align: center;
    border: 1px solid var(--border-color);
    transition: all var(--transition-bounce); position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
    opacity: 0.7; transition: opacity var(--transition);
}
.stat-card:first-child::after { background: var(--accent-gradient); }
.stat-card:nth-child(2)::after { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card:nth-child(3)::after { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-card:hover::after { opacity: 1; }

.stat-value {
    display: block; font-family: 'JetBrains Mono', 'Space Grotesk', monospace;
    font-size: 2.2rem; font-weight: 700; color: var(--accent-primary); line-height: 1.2;
}
.stat-card:nth-child(2) .stat-value { color: var(--success); }
.stat-card:nth-child(3) .stat-value { color: var(--warning); }
.stat-label { font-size: 0.82rem; color: var(--text-tertiary); font-weight: 500; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== Form Sections ===== */
.form-section { margin-bottom: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--border-color); }
.form-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem; font-weight: 600; color: var(--text-primary); margin: 0; }

/* ===== Segments ===== */
.segments-container { display: flex; flex-direction: column; gap: 10px; }

.segment-row {
    display: flex; gap: 10px; align-items: center;
    padding: 14px 18px; background: var(--bg-tertiary); border-radius: var(--radius-md);
    border: 1px solid var(--border-color); transition: all var(--transition);
}
.segment-row:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); transform: translateX(2px); }

.segment-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent-gradient); color: white;
    font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.segment-inputs { display: flex; align-items: center; gap: 8px; flex: 1; }
.segment-inputs span { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }

.seg-input {
    width: 90px; padding: 10px 12px;
    border: 1.5px solid var(--border-color); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: 'JetBrains Mono', monospace;
    background: var(--bg-card); color: var(--text-primary);
    text-align: center; transition: all var(--transition);
    -moz-appearance: textfield;
}
.seg-input::-webkit-outer-spin-button, .seg-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.seg-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }

.seg-count-group { display: flex; align-items: center; gap: 6px; }
.seg-count-group label { font-size: 0.85rem; color: var(--text-tertiary); font-weight: 500; }

.seg-count-input {
    width: 60px; padding: 10px;
    border: 1.5px solid var(--border-color); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: 'JetBrains Mono', monospace;
    background: var(--bg-card); color: var(--text-primary);
    text-align: center; transition: all var(--transition);
    -moz-appearance: textfield;
}
.seg-count-input::-webkit-outer-spin-button, .seg-count-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.seg-count-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }

.segment-available {
    font-size: 0.78rem; color: var(--text-muted); background: var(--bg-card);
    padding: 4px 12px; border-radius: 20px; white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}
.segment-presets { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.segment-presets-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }

/* ===== Tag Filters ===== */
.tag-filter-section { margin-top: 0; }
.filter-hint { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 16px 0; }
.tag-search-row { display: flex; gap: 12px; margin-bottom: 16px; }

.tag-search-input {
    flex: 1; padding: 10px 14px 10px 38px; font-size: 0.9rem;
    border: 1.5px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-input); color: var(--text-primary);
    font-family: inherit; transition: all var(--transition);
}
.tag-search-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.tag-search-input::placeholder { color: var(--text-muted); }

.tag-search-wrapper { position: relative; flex: 1; }
.tag-search-wrapper svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }

.tag-filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.tag-filter-box {
    background: var(--bg-tertiary); border-radius: var(--radius-lg);
    padding: 20px; border: 1px solid var(--border-color);
}
.tag-filter-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tag-filter-title { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.tag-filter-count { color: var(--text-muted); font-size: 0.78rem; background: var(--bg-card); padding: 2px 10px; border-radius: 20px; font-family: 'JetBrains Mono', monospace; }
.tag-filter-desc { color: var(--text-muted); font-size: 0.8rem; margin: 0 0 12px 0; }

.tag-checkbox-container { max-height: 220px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; }
.tag-checkbox-container::-webkit-scrollbar { width: 5px; }
.tag-checkbox-container::-webkit-scrollbar-track { background: transparent; }
.tag-checkbox-container::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.tag-checkbox-item {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; background: var(--bg-card);
    border: 1.5px solid var(--border-color); border-radius: 20px;
    cursor: pointer; transition: all 0.2s ease;
    font-size: 0.82rem; font-weight: 500; user-select: none; color: var(--text-secondary);
}
.tag-checkbox-item:hover { border-color: var(--accent-primary); color: var(--accent-primary); transform: scale(1.02); }
.tag-checkbox-item.selected { background: var(--accent-primary); color: white; border-color: var(--accent-primary); transform: scale(1.05); }
.tag-checkbox-item.selected.exclude { background: var(--danger); border-color: var(--danger); }
.tag-checkbox-item .tag-check-icon { display: none; font-size: 0.7rem; font-weight: 700; }
.tag-checkbox-item.selected .tag-check-icon { display: inline; }
.tag-checkbox-item.tag-hidden { display: none; }

/* ===== Options Row ===== */
.options-row { display: flex; gap: 24px; flex-wrap: wrap; }

.checkbox-label {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; font-size: 0.9rem; color: var(--text-secondary); font-weight: 500;
}
.checkbox-label input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 20px; height: 20px; border: 2px solid var(--border-color);
    border-radius: 6px; background: var(--bg-input); cursor: pointer;
    position: relative; transition: all var(--transition); flex-shrink: 0;
}
.checkbox-label input[type="checkbox"]:checked { background: var(--accent-primary); border-color: var(--accent-primary); }
.checkbox-label input[type="checkbox"]:checked::after {
    content: ''; position: absolute; left: 6px; top: 2px;
    width: 5px; height: 10px; border: solid white; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.checkbox-label input[type="checkbox"]:focus { box-shadow: 0 0 0 3px var(--accent-glow); }

/* ===== Results ===== */
.results-summary {
    background: var(--bg-tertiary); padding: 20px;
    border-radius: var(--radius-lg); margin-bottom: 24px; border: 1px solid var(--border-color);
}
.results-summary h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; }
.results-summary div { padding: 4px 0; color: var(--text-secondary); font-size: 0.9rem; }

.results-problems { margin-bottom: 24px; }
.results-problems h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; }
.problem-count { color: var(--text-muted); font-weight: 500; }

.problems-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.problem-tag {
    background: var(--accent-gradient); color: white;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.88rem; font-weight: 600;
    transition: all var(--transition-bounce);
    position: relative; overflow: hidden;
}
.problem-tag::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    opacity: 0; transition: opacity var(--transition);
    pointer-events: none;
}
.problem-tag:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 6px 20px var(--accent-glow); }
.problem-tag:hover::before { opacity: 1; }
.problem-tag a { color: white; text-decoration: none; }
.problem-tag a:hover { text-decoration: underline; }

/* ===== Tags Chart ===== */
.results-tags { margin-bottom: 24px; }
.results-tags h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }
.tags-chart { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

.tag-bar { display: flex; align-items: center; gap: 14px; }
.tag-bar-label { min-width: 140px; font-size: 0.85rem; text-align: right; font-weight: 500; color: var(--text-secondary); }
.tag-bar-track { flex: 1; height: 28px; background: var(--bg-tertiary); border-radius: var(--radius-sm); overflow: hidden; }
.tag-bar-fill {
    height: 100%; background: var(--accent-gradient); border-radius: var(--radius-sm);
    display: flex; align-items: center; padding-left: 10px;
    color: white; font-size: 0.8rem; font-weight: 600; min-width: fit-content;
    transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

/* ===== Tags Table ===== */
.tags-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tags-table th, .tags-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
.tags-table th {
    background: var(--bg-tertiary); font-weight: 600; color: var(--text-secondary);
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.tags-table td { color: var(--text-secondary); }
.tags-table tr { transition: background var(--transition); }
.tags-table tbody tr:hover td { background: var(--bg-tertiary); }

/* ===== Virtual Contest / Practice Section ===== */
.virtual-contest-section {
    margin: 28px 0 20px; display: flex; flex-direction: column; align-items: center; gap: 14px;
    padding: 28px; border: 1.5px solid var(--border-color);
    border-radius: var(--radius-xl); background: var(--bg-card);
    backdrop-filter: blur(12px); transition: all var(--transition);
    box-shadow: var(--shadow-md);
}
.virtual-contest-section:hover { border-color: var(--accent-primary); box-shadow: var(--shadow-lg); }

.action-buttons-row { display: flex; gap: 12px; width: 100%; }

.contest-btn-meta {
    font-size: 0.75rem; opacity: 0.8; font-weight: 400; margin-left: 4px;
    background: rgba(255,255,255,0.18); border-radius: 20px; padding: 2px 10px;
}
.contest-btn-hint { font-size: 0.82rem; color: var(--text-muted); margin: 0; text-align: center; line-height: 1.5; }

/* ===== Export ===== */
.export-section { margin-bottom: 24px; }
.export-section h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 600; margin-bottom: 14px; }
.export-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.copy-feedback {
    margin-top: 12px; padding: 12px; background: var(--success);
    color: white; border-radius: var(--radius-md); text-align: center; font-weight: 600;
    animation: fadeSlideUp 0.3s ease;
}

/* ===== Extra Options ===== */
.extra-options { padding-top: 16px; border-top: 1px solid var(--border-color); }

/* ===== Upsolve Dashboard ===== */
.upsolve-dashboard {
    padding: 0 0 24px;
}
.upsolve-dashboard .container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}
.upsolve-cards {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

.upsolve-card {
    display: flex; align-items: center; gap: 16px;
    padding: 20px 24px; background: var(--bg-card);
    backdrop-filter: blur(12px); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); text-decoration: none;
    transition: all var(--transition-bounce); cursor: pointer;
    box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.upsolve-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    transition: width var(--transition);
}
.upsolve-card.upsolve-todo::before { background: linear-gradient(180deg, #f59e0b, #d97706); }
.upsolve-card.upsolve-done::before { background: linear-gradient(180deg, #10b981, #059669); }
.upsolve-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.upsolve-card:hover::before { width: 6px; }

.upsolve-card-icon { flex-shrink: 0; }
.upsolve-card.upsolve-todo .upsolve-card-icon { color: var(--warning); }
.upsolve-card.upsolve-done .upsolve-card-icon { color: var(--success); }

.upsolve-card-info { flex: 1; }
.upsolve-card-info h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.upsolve-card-info p { font-size: 0.82rem; color: var(--text-tertiary); margin: 0; }

.upsolve-count {
    font-family: 'JetBrains Mono', monospace; font-size: 1.5rem; font-weight: 700;
    color: var(--warning); flex-shrink: 0;
}
.upsolve-count.done { color: var(--success); }

/* ===== Practice History Summary ===== */
.practice-history-summary {
    margin-top: 12px;
}
.practice-history-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition);
    box-shadow: var(--shadow-md);
}
.practice-history-link:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}
.practice-history-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.12);
    color: var(--accent-primary);
    flex-shrink: 0;
}
.practice-history-text {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 500;
}
.practice-history-link svg:last-child {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-glass); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    padding: 24px 0; text-align: center; color: var(--text-muted); font-size: 0.85rem;
}
.footer a { color: var(--accent-primary); text-decoration: none; font-weight: 500; }
.footer a:hover { text-decoration: underline; }
.footer-note { font-size: 0.8rem; margin-top: 6px; }

/* ===== Modal ===== */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
    z-index: 2000; animation: fadeIn 0.2s ease;
}
.modal-content {
    background: var(--bg-card); backdrop-filter: blur(20px);
    padding: 32px; border-radius: var(--radius-xl); max-width: 500px; margin: 20px;
    box-shadow: var(--shadow-xl); border: 1px solid var(--border-color);
    animation: fadeSlideUp 0.3s ease;
}
.modal-content h2 { margin: 0 0 16px; color: var(--danger); font-family: 'Space Grotesk', sans-serif; font-size: 1.3rem; }
.modal-content p { color: var(--text-secondary); margin-bottom: 16px; }
.modal-content ul { margin: 16px 0; padding-left: 20px; color: var(--text-secondary); }
.modal-content li { margin-bottom: 8px; }
.modal-content .btn-gradient { margin-right: 12px; margin-top: 8px; }
.modal-content .btn-outline { margin-top: 8px; }

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

/* ===== Preset Buttons ===== */
.btn-preset {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    letter-spacing: 0.3px;
}
.btn-preset:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== Rating Level Progress ===== */
.rl-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.rl-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.rl-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1.5px dashed var(--border-color);
    border-radius: var(--radius-lg);
}

.rl-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    overflow: hidden;
    text-align: left;
    font-family: inherit;
    color: inherit;
}
.rl-card:hover {
    border-color: var(--border-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.rl-card.rl-complete {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.05);
}

.rl-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.rl-rating {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
}
.rl-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

.rl-bar-track {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
}
.rl-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}
.rl-bar-complete {
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.rl-pct {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    line-height: 1;
}

.rl-lightning {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.9rem;
    animation: rlLightningPulse 1.5s ease infinite;
    filter: drop-shadow(0 0 4px rgba(255, 200, 0, 0.6));
}
@keyframes rlLightningPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.15); }
}

/* ===== Rating Level Modal ===== */
.rl-modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 36px 40px;
    border-radius: var(--radius-xl);
    max-width: 460px;
    width: calc(100% - 40px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    animation: fadeSlideUp 0.3s ease;
    position: relative;
}

.rl-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    line-height: 1;
}
.rl-modal-close:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-bg);
}

.rl-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.rl-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
    flex-shrink: 0;
}
.rl-modal-header h2 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.rl-modal-range {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    margin: 2px 0 0;
}

.rl-modal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.rl-modal-stat {
    text-align: center;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.rl-modal-stat-value {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.2;
}
.rl-modal-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    display: block;
}

.rl-modal-progress {
    margin-bottom: 24px;
}
.rl-modal-bar-track {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}
.rl-modal-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.rl-modal-form {
    margin-bottom: 24px;
}
.rl-modal-label {
    display: block;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.rl-modal-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.rl-modal-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 1.1rem;
    font-family: 'JetBrains Mono', monospace;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    text-align: center;
    font-weight: 600;
    transition: all var(--transition);
    -moz-appearance: textfield;
}
.rl-modal-input::-webkit-outer-spin-button,
.rl-modal-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.rl-modal-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-glow);
}
.rl-modal-max-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}

.rl-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rl-modal-actions .btn-practice {
    animation: none;
}
.rl-modal-actions .btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

/* ===== Rating Colors ===== */
.rating-color-800, .rating-color-900 { color: #808080; }
.rating-color-1000, .rating-color-1100 { color: #008000; }
.rating-color-1200, .rating-color-1300 { color: #03a89e; }
.rating-color-1400, .rating-color-1500 { color: #0000ff; }
.rating-color-1600, .rating-color-1700, .rating-color-1800 { color: #aa00aa; }
.rating-color-1900, .rating-color-2000 { color: #ff8c00; }
.rating-color-2100, .rating-color-2200, .rating-color-2300, .rating-color-2400 { color: #ff0000; }

/* ===== Active Practice Banner ===== */
.active-practice-banner {
    margin-bottom: 24px;
    animation: fadeSlideUp 0.5s ease;
}
.active-practice-content {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(59,130,246,0.06));
    border: 1.5px solid rgba(16,185,129,0.35);
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 20px rgba(16,185,129,0.1);
    position: relative;
    overflow: hidden;
}
.active-practice-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #10b981, #34d399, #10b981);
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
}
.active-practice-pulse {
    position: absolute;
    top: 18px; left: 18px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #10b981;
    animation: activePulse 2s infinite;
}
@keyframes activePulse {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
    70% { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.active-practice-icon {
    color: var(--success);
    flex-shrink: 0;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(16,185,129,0.15);
    border-radius: 50%;
    margin-left: 14px;
}
.active-practice-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.active-practice-info strong {
    font-size: 0.95rem;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-primary);
}
.active-practice-info span {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
}
.active-practice-resume {
    flex-shrink: 0;
    background: linear-gradient(135deg, #10b981, #059669) !important;
    text-decoration: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-content { height: 56px; }
    .header-left { gap: 8px; }
    .back-link { padding: 4px 6px; font-size: 0; gap: 0; }
    .back-link svg { width: 18px; height: 18px; }
    .home-link { width: 30px; height: 30px; }
    .logo h1 { font-size: 1.15rem; }
    .card { padding: 24px; border-radius: var(--radius-lg); }
    .card-title { font-size: 1.3rem; }
    .search-form { flex-direction: column; }
    .stats-bar { grid-template-columns: 1fr; gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.6rem; }
    .segment-row { flex-wrap: wrap; }
    .segment-inputs { flex-wrap: wrap; }
    .tag-filter-row { grid-template-columns: 1fr; }
    .options-row { flex-direction: column; gap: 14px; }
    .segment-presets { flex-wrap: wrap; justify-content: center; }
    .export-buttons { flex-direction: column; }
    .export-buttons .btn-outline { width: 100%; }
    .container { padding: 0 16px; }
    .header .container { padding: 0 16px; }
    .upsolve-cards { grid-template-columns: 1fr; }
    .action-buttons-row { flex-direction: column; }
    .btn-outline.btn-lg { width: 100%; }
    .active-practice-content { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
    .active-practice-icon { margin-left: 10px; }
    .active-practice-resume { width: 100%; text-align: center; }
    .rl-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .rl-modal-content { padding: 28px 24px; }
    .rl-modal-actions { flex-direction: column; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .header .container { padding: 0 12px; }
    .header-content { height: 50px; }
    .logo h1 { font-size: 1rem; }
    .logo-icon { width: 22px; height: 22px; }
    .card { padding: 16px; }
    .card-title { font-size: 1.15rem; }
    .segment-row { padding: 10px 12px; }
    .seg-input { width: 70px; }
    .tag-bar-label { min-width: 100px; font-size: 0.8rem; }
    .privacy-notice { font-size: 0.8rem; padding: 10px 14px; }
    .btn-gradient.btn-lg { padding: 14px 24px; font-size: 0.95rem; }
    .upsolve-cards { grid-template-columns: 1fr; }
    .practice-history-link { padding: 12px 16px; }
    .practice-history-text { font-size: 0.82rem; }
    .rl-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .rl-card { padding: 10px 12px; }
    .rl-rating { font-size: 0.9rem; }
    .rl-modal-content { padding: 22px 18px; }
    .rl-modal-header h2 { font-size: 1.25rem; }
    .rl-modal-stat-value { font-size: 1.3rem; }
}

/* ===== Activity Calendar ===== */
.cal-container {
    margin-top: 8px;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 0 4px;
}

.cal-nav-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.cal-nav-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(59,130,246,0.08);
    transform: scale(1.1);
}

.cal-nav-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.cal-nav-center h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cal-today-btn {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cal-today-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(59,130,246,0.08);
}

/* Calendar Grid */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    max-width: 600px;
    margin: 0 auto;
}

.cal-header-cell {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Space Grotesk', sans-serif;
}

.cal-day {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: default;
    transition: all 0.2s ease;
    position: relative;
    border: 1.5px solid transparent;
}
.cal-day:not(.cal-empty):hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: var(--shadow-md);
}
.cal-day.cal-empty {
    background: transparent;
    pointer-events: none;
}

.cal-day-num {
    font-size: 0.92rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}
.cal-day-count {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
    padding: 1px 6px;
    border-radius: 8px;
}

/* Calendar Color Classes */
.cal-day.cal-red {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.22);
}
.cal-day.cal-red .cal-day-num { color: #ef4444; }

.cal-day.cal-yellow {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.25);
}
.cal-day.cal-yellow .cal-day-num { color: #f59e0b; }
.cal-day.cal-yellow .cal-day-count { color: #b45309; background: rgba(245,158,11,0.18); }

.cal-day.cal-green {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.25);
}
.cal-day.cal-green .cal-day-num { color: #10b981; }
.cal-day.cal-green .cal-day-count { color: #047857; background: rgba(16,185,129,0.18); }

.cal-day.cal-cyan {
    background: rgba(6, 182, 212, 0.16);
    border-color: rgba(6, 182, 212, 0.3);
}
.cal-day.cal-cyan .cal-day-num { color: #06b6d4; }
.cal-day.cal-cyan .cal-day-count { color: #0e7490; background: rgba(6,182,212,0.18); }

.cal-day.cal-future {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    opacity: 0.4;
}
.cal-day.cal-future .cal-day-num { color: var(--text-muted); }

/* Dark theme calendar adjustments */
[data-theme="dark"] .cal-day.cal-yellow .cal-day-count { color: #fbbf24; }
[data-theme="dark"] .cal-day.cal-green .cal-day-count { color: #34d399; }
[data-theme="dark"] .cal-day.cal-cyan .cal-day-count { color: #22d3ee; }

/* Today highlight */
.cal-day.cal-today {
    border-width: 2.5px;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px var(--accent-glow);
    animation: calTodayPulse 2.5s ease infinite;
}
@keyframes calTodayPulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--accent-glow); }
    50% { box-shadow: 0 0 0 6px transparent; }
}

/* Grid animation */
@keyframes calFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.cal-grid-animate {
    animation: calFadeIn 0.3s ease;
}

/* Calendar Stats */
.cal-stats {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.cal-stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

.cal-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    transition: all var(--transition);
}
.cal-stat-item:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.cal-stat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-dot-red { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.cal-dot-yellow { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.cal-dot-green { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,0.4); }
.cal-dot-cyan { background: #06b6d4; box-shadow: 0 0 6px rgba(6,182,212,0.4); }
.cal-dot-future { background: var(--text-muted); }

.cal-stat-label {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    font-weight: 500;
}
.cal-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cal-total {
    text-align: center;
    padding: 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.cal-total-label {
    color: var(--text-tertiary);
    font-size: 0.88rem;
    font-weight: 500;
}
.cal-total-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-left: 8px;
}

/* Calendar Responsive */
@media (max-width: 768px) {
    .cal-grid { gap: 4px; max-width: 100%; }
    .cal-day-num { font-size: 0.78rem; }
    .cal-day-count { font-size: 0.58rem; padding: 1px 4px; }
    .cal-header-cell { font-size: 0.68rem; padding: 4px 0 8px; }
    .cal-nav { margin-bottom: 16px; }
    .cal-nav-center h3 { font-size: 1.1rem; }
    .cal-nav-btn { width: 36px; height: 36px; }
    .cal-stat-item { padding: 6px 12px; gap: 6px; }
    .cal-stat-label { font-size: 0.75rem; }
    .cal-stat-value { font-size: 0.75rem; }
}

@media (max-width: 480px) {
    .cal-grid { gap: 3px; }
    .cal-day { border-radius: 6px; gap: 1px; border-width: 1px; }
    .cal-day-num { font-size: 0.7rem; }
    .cal-day-count { font-size: 0.5rem; padding: 0 3px; }
    .cal-header-cell { font-size: 0.6rem; letter-spacing: 0; }
    .cal-nav-center h3 { font-size: 1rem; }
    .cal-today-btn { font-size: 0.65rem; padding: 2px 10px; }
    .cal-stat-row { gap: 6px; }
    .cal-stat-item { padding: 5px 8px; }
    .cal-stat-label { font-size: 0.7rem; }
    .cal-stat-value { font-size: 0.7rem; }
    .cal-stat-dot { width: 8px; height: 8px; }
    .cal-total-value { font-size: 0.95rem; }
}
