:root {
    --bg:          #0f172a;   /* Dark slate background */
    --surface:     #1e293b;   /* Slate card surface */
    --surface-2:   #334155;   /* Slightly lighter slate for inset panels */
    --surface-3:   #475569;
    --primary:     #6366f1;   /* Modern Indigo */
    --primary-hover:#4f46e5;
    --primary-dim: rgba(99, 102, 241, 0.15);
    --accent:      #38bdf8;   /* Sky blue */
    --google:      #22c55e;   /* Light Green Accent */
    --bing:        #0ea5e9;   /* Light Blue Accent */
    --active-pulse:#ef4444;   /* Active learning red pulse */
    --success:     #10b981;   /* Emerald Green */
    --success-dim: rgba(16, 185, 129, 0.15);
    --text:        #f8fafc;   /* Crisp white text */
    --text-muted:  #94a3b8;   /* Muted slate text */
    --line:        #334155;   /* Borders */
    --line-light:  #475569;
    --shadow:      0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-lg:   0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius:      16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    padding: 2.5rem 1.5rem 5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    position: relative;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Volumetric glass field — sits behind the UI and gives each blurred surface depth. */
body::before, body::after {
    content: ''; position: fixed; inset: -20vmax; z-index: 0; pointer-events: none;
    filter: blur(42px); opacity: .58; transform: translate3d(0, 0, 0);
}
body::before {
    background: radial-gradient(circle at 20% 20%, rgba(56, 189, 248, .19), transparent 26%), radial-gradient(circle at 76% 34%, rgba(168, 85, 247, .17), transparent 24%), radial-gradient(circle at 48% 82%, rgba(236, 72, 153, .12), transparent 27%);
    animation: volumetric-drift 18s ease-in-out infinite alternate;
}
body::after {
    background: radial-gradient(circle at 72% 75%, rgba(16, 185, 129, .11), transparent 22%), radial-gradient(circle at 32% 56%, rgba(99, 102, 241, .14), transparent 26%);
    animation: volumetric-drift 24s ease-in-out -7s infinite alternate-reverse;
}
@keyframes volumetric-drift {
    from { transform: translate3d(-2%, -1%, 0) scale(1); }
    to { transform: translate3d(3%, 2%, 0) scale(1.06); }
}


/* ============ Consolidated Light Color Scheme Overrides ============ */
body.light-theme {
    --bg:          #f1f5f9;   /* Soft crisp background */
    --surface:     rgba(255, 255, 255, 0.95);
    --surface-2:   #e2e8f0;   /* Light slate inset */
    --surface-3:   #cbd5e1;
    --primary:     #4f46e5;   /* Indigo */
    --primary-hover:#4338ca;
    --primary-dim: rgba(79, 70, 229, 0.12);
    --accent:      #0284c7;   /* Sky blue */
    --google:      #16a34a;
    --bing:        #0284c7;
    --success:     #059669;
    --success-dim: rgba(5, 150, 105, 0.15);
    --text:        #0f172a;   /* Dark slate text */
    --text-muted:  #475569;   /* Muted slate */
    --line:        #cbd5e1;   /* Clean light borders */
    --line-light:  #94a3b8;
    --shadow:      0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-lg:   0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 10px 10px -5px rgba(15, 23, 42, 0.06);
}

body.light-theme .panel,
body.light-theme .intake,
body.light-theme .record-card,
body.light-theme .study-queue-widget {
    background: rgba(255, 255, 255, 0.95);
    border-color: #cbd5e1;
    box-shadow: var(--shadow);
}

body.light-theme .study-queue__icon { background: #fef3c7; color: #b45309; }
body.light-theme .study-queue__items { background: #f8fafc; border-color: #cbd5e1; }
body.light-theme .study-queue-chip { background: #fff; border-color: #cbd5e1; }
body.light-theme .study-session-field select { background: #fff; color: #0f172a; border-color: #cbd5e1; }

/* Light Theme Completed Cards Override */
body.light-theme .record-card--complete {
    background: rgba(241, 245, 249, 0.95);
    border-color: rgba(16, 185, 129, 0.4);
}

/* Disable screen blend mode overlay in light theme */
body.light-theme .panel::after,
body.light-theme .intake::after,
body.light-theme .record-card::after {
    opacity: 0;
}

body.light-theme .search-filter-box input,
body.light-theme .add-card-input {
    background: #ffffff;
    color: #0f172a;
    border-color: #cbd5e1;
}

body.light-theme .title-text {
    background: linear-gradient(135deg, #1d4ed8 0%, #7e22ce 50%, #be185d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .scanlines-overlay {
    opacity: 0.15;
}

body.light-theme .learning-time-box {
    background: #f8fafc;
    border-color: #cbd5e1;
}

body.light-theme .time-stats-footer {
    background: #e2e8f0;
    color: #475569;
}
body.light-theme .time-stats-footer strong {
    color: #0f172a;
}

/* Light Mode Overrides for Panels and Modals */
body.light-theme .session-plan-panel {
    background: rgba(255, 255, 255, 0.98);
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.15);
}
body.light-theme .session-plan-option-summary,
body.light-theme .session-calendar {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
body.light-theme .schedule-modal-card,
body.light-theme .shortcuts-modal-card {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}
body.light-theme .schedule-modal-summary div,
body.light-theme .shortcut-row {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
body.light-theme .shortcut-row:hover {
    background: #e2e8f0;
    border-color: #0284c7;
}
body.light-theme .schedule-modal-item {
    background: #f8fafc;
}
body.light-theme .schedule-modal-kicker,
body.light-theme .session-plan-title b,
body.light-theme .session-plan-range {
    color: #d97706;
}
body.light-theme .kbd {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #0284c7;
}

.mono { font-family: 'Fira Code', monospace; }
.hidden { display: none !important; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============ Top-Left Live Time & Date Mini Widget ============ */
.time-widget {
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.88) 0%, rgba(15, 23, 42, 0.92) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 8px 25px -4px rgba(0, 0, 0, 0.4), 0 0 15px rgba(56, 189, 248, 0.15);
    transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    user-select: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}
.time-widget:hover {
    border-color: rgba(56, 189, 248, 0.7);
    box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.3);
    transform: translateY(-1px);
}
.time-widget.open {
    border-color: #38bdf8;
    box-shadow: 0 12px 35px -4px rgba(56, 189, 248, 0.35);
}

/* Hide widgets helper class for 'H' shortcut */
.time-widget.widgets-hidden,
.shortcuts-fab.widgets-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.85) translateY(10px) !important;
}

.time-widget__icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-widget__content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.time-widget__time {
    font-family: 'Fira Code', monospace;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.02em;
}

.time-widget__day {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: #38bdf8;
    font-size: 0.78rem;
    padding-left: 8px;
    border-left: 1px solid var(--line-light);
    text-transform: capitalize;
}

/* Mini Month Calendar Popup */
.time-widget-popup {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    z-index: 200;
    width: 290px;
    padding: 1.1rem;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(56, 189, 248, 0.45);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(56, 189, 248, 0.2);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.22s;
}

.time-widget.open .time-widget-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Calendar popup — backdrop overlay (mobile only, activated by JS open class) */
.time-widget-backdrop {
    display: none;
}

.mini-cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.mini-cal-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    font-family: 'Inter', sans-serif;
}

.mini-cal-nav {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--line-light);
    background: var(--surface-2);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    line-height: 1;
    transition: all 0.2s ease;
}
.mini-cal-nav:hover {
    background: var(--surface-3);
    color: #ffffff;
    border-color: var(--accent);
}

.mini-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    text-align: center;
    margin-bottom: 6px;
    font-family: 'Fira Code', monospace;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 700;
}

.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.mini-cal-empty {
    min-height: 30px;
}

.mini-cal-day {
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    color: var(--text);
    background: rgba(51, 65, 85, 0.25);
    border: 1px solid transparent;
    transition: all 0.15s ease;
}
.mini-cal-day:hover {
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.18);
    color: #ffffff;
}
.mini-cal-day.is-today {
    background: #f59e0b;
    color: #0f172a;
    font-weight: 800;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.6);
    border-color: #fde68a;
}

.mini-cal-footer {
    margin-top: 0.9rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--line);
    font-size: 0.73rem;
    color: var(--text-muted);
    text-align: center;
    font-family: 'Fira Code', monospace;
}

/* Light Mode Overrides for Time Widget & Popup */
body.light-theme .time-widget {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%);
    border-color: #cbd5e1;
    box-shadow: 0 8px 25px -4px rgba(15, 23, 42, 0.1), 0 0 15px rgba(79, 70, 229, 0.1);
}
body.light-theme .time-widget__time {
    color: #0f172a;
}
body.light-theme .time-widget__day {
    color: #0284c7;
    border-left-color: #cbd5e1;
}

body.light-theme .time-widget-popup {
    background: rgba(255, 255, 255, 0.98);
    border-color: #cbd5e1;
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.2);
}
body.light-theme .mini-cal-title {
    color: #0f172a;
}
body.light-theme .mini-cal-day {
    background: #f1f5f9;
    color: #0f172a;
}
body.light-theme .mini-cal-day.is-today {
    background: #d97706;
    color: #ffffff;
}

/* ============ Header ============ */
.masthead {
    width: 100%;
    max-width: 1100px;
    text-align: center;
    margin-bottom: 2.25rem;
    position: relative;
    z-index: 1;
    padding: 0.5rem 1rem 0;
}

.masthead::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 360px;
    height: 120px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.3) 0%, rgba(56, 189, 248, 0.15) 45%, transparent 75%);
    filter: blur(35px);
    z-index: 0;
    pointer-events: none;
}

h1 {
    position: relative;
    z-index: 1;
    font-size: 3.2rem;
    font-weight: 800;
    letter-spacing: -0.035em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.title-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1.5px solid rgba(129, 140, 248, 0.4);
    border-radius: 22px;
    box-shadow: 0 12px 30px -5px rgba(99, 102, 241, 0.35), 0 0 20px rgba(56, 189, 248, 0.25);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.title-icon-wrapper:hover {
    transform: translateY(-4px) scale(1.04);
    border-color: rgba(56, 189, 248, 0.7);
    box-shadow: 0 18px 35px -5px rgba(99, 102, 241, 0.45), 0 0 30px rgba(56, 189, 248, 0.4);
}

.title-text {
    background: linear-gradient(135deg, #60a5fa 0%, #c084fc 45%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 15px rgba(192, 132, 252, 0.25));
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-top: 0.5rem;
}

/* ============ Dashboard Metrics Panel ============ */
.panel {
    width: 100%;
    max-width: 1100px;
    margin-bottom: 2rem;
    padding: 1.75rem 2rem;
    background: linear-gradient(135deg, rgba(51, 65, 85, .72), rgba(30, 41, 59, .82) 48%, rgba(15, 23, 42, .76));
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    z-index: 1;
}

.panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel__title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    font-family: 'Fira Code', monospace;
    background-color: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.badge.is-active {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}
.badge.is-complete {
    background-color: var(--success-dim);
    color: var(--success);
    border-color: var(--success);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
}

/* Progress bar */
.progress-bar-container {
    width: 100%;
    height: 10px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--line);
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 999px;
    width: 0%;
    transition: width 0.4s ease;
}

.panel__grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 1.25rem; 
}

.stat {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--line);
    transition: transform 0.2s ease;
}
.stat:hover { transform: translateY(-2px); }
.stat__label { 
    font-size: 0.75rem; 
    font-weight: 600; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    display: block; 
    margin-bottom: 6px; 
}
.stat__value { 
    font-family: 'Fira Code', monospace; 
    font-size: 1.5rem; 
    font-weight: 700; 
    color: var(--text); 
}
.stat__value--highlight { color: #f59e0b; }
.stat__value--success { color: var(--success); }
.stat__value--accent { color: var(--accent); }

/* ============ Intake & Action Bar ============ */
.intake {
    width: 100%;
    max-width: 1100px;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(51, 65, 85, .7), rgba(30, 41, 59, .82) 52%, rgba(15, 23, 42, .75));
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    z-index: 1;
}
.intake.session-plan-active { z-index: 20; }

.intake__top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-filter-box {
    position: relative;
    flex: 1;
    min-width: 260px;
}

.search-filter-box input {
    width: 100%;
    padding: 10px 38px 10px 42px;
    border-radius: 10px;
    border: 1px solid var(--line-light);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s ease;
}
.search-filter-box input:focus {
    border-color: var(--accent);
    background: #1e293b;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
.search-filter-box svg.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    display: none;
    transition: all 0.2s ease;
}
.search-clear-btn:hover {
    color: var(--text);
    background: var(--surface-3);
}
.search-filter-box.has-text .search-clear-btn {
    display: block;
}

.intake__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Accessible file input styling fix */
input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
label[for="file-upload"]:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Standard Buttons */
.btn {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line-light);
    background: var(--surface-2);
    color: var(--text);
    transition: all 0.2s ease;
    font-family: inherit;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-muted); }

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-success {
    background: #059669;
    color: white;
    border: none;
}
.btn-success:hover { background: #047857; transform: translateY(-1px); }

.btn-danger { color: #f87171; border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.1); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; }

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text-muted);
}
.btn-ghost:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--line-light);
}

/* Session planner */
.session-plan { position: relative; }
.btn-session-plan { color: #fef3c7; border-color: rgba(251, 191, 36, 0.48); background: rgba(245, 158, 11, 0.14); }
.btn-session-plan:hover { background: rgba(245, 158, 11, 0.24); border-color: #fbbf24; }
.session-plan-panel {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 120;
    width: min(365px, calc(100vw - 3rem)); padding: 1rem;
    background: rgba(15, 23, 42, 0.98); border: 1px solid rgba(251, 191, 36, 0.42);
    border-radius: 12px; box-shadow: var(--shadow-lg); backdrop-filter: blur(16px);
    opacity: 0; visibility: hidden; transform: translateY(-6px); pointer-events: none;
    max-height: calc(100vh - 2rem); overflow-y: auto;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.session-plan.open .session-plan-panel { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; }
.session-plan-title { font-size: .84rem; color: var(--text); }
.session-plan-title b, .session-plan-range { color: #fcd34d; }
.session-plan-title span, .session-plan-note { color: var(--text-muted); font-size: .76rem; }
.session-plan-range { margin: .45rem 0 .7rem; font-family: 'Fira Code', monospace; font-size: .9rem; font-weight: 700; }
.session-plan-options { display: grid; gap: .45rem; }
.session-plan-option-summary { padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(51, 65, 85, .45); }
.session-plan-option-summary strong { display: block; color: var(--accent); font-size: .78rem; }
.session-plan-option-summary span { color: var(--text-muted); font-size: .73rem; }
.session-plan-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .45rem; margin-top: .7rem; }
.session-plan-action { padding: .55rem; border: 1px solid rgba(251, 191, 36, .45); border-radius: 7px; color: #fef3c7; background: rgba(245, 158, 11, .12); cursor: pointer; font: 600 .72rem 'Inter', sans-serif; transition: .18s ease; }
.session-plan-action:hover { color: #422006; background: #fcd34d; border-color: #fde68a; }
.session-plan-extend { display: flex; align-items: center; gap: .45rem; margin-top: .7rem; color: #fed7aa; font-size: .73rem; cursor: pointer; }
.session-plan-extend input { accent-color: #f59e0b; }
.session-plan-schedule { display: grid; gap: .3rem; margin-top: .7rem; padding: .65rem .7rem; border-left: 2px solid #f59e0b; border-radius: 6px; background: rgba(245, 158, 11, .07); color: var(--text-muted); font: .72rem 'Fira Code', monospace; }
.session-plan-schedule > span { color: #fcd34d; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; }
.session-plan-schedule b { color: var(--text); }
.session-calendar { margin-top: .75rem; padding: .7rem; border: 1px solid var(--line); border-radius: 9px; background: rgba(51, 65, 85, .32); }
.session-calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .55rem; color: var(--text); font-size: .78rem; font-weight: 700; }
.session-calendar-nav { width: 24px; height: 24px; border: 1px solid var(--line-light); border-radius: 6px; color: var(--accent); background: var(--surface-2); cursor: pointer; line-height: 1; }
.session-calendar-weekdays, .session-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.session-calendar-weekdays { margin-bottom: 3px; color: var(--text-muted); font: .6rem 'Fira Code', monospace; }
.session-calendar-day { min-height: 26px; border: 1px solid transparent; border-radius: 6px; color: var(--text-muted); background: transparent; cursor: pointer; font: .67rem 'Fira Code', monospace; }
.session-calendar-day:not(:disabled):hover { color: var(--text); border-color: var(--accent); background: var(--primary-dim); }
.session-calendar-day.is-today { color: #fcd34d; border-color: rgba(251, 191, 36, .42); }
.session-calendar-day.is-selected { color: #172033; background: #fcd34d; border-color: #fde68a; font-weight: 700; }
.session-calendar-day:disabled { opacity: .25; cursor: not-allowed; }
.session-calendar-empty { min-height: 26px; }
.session-calendar-caption { display: block; margin-top: .55rem; color: var(--text-muted); font-size: .68rem; }

/* Modals */
.schedule-modal, .shortcuts-modal { position: fixed; inset: 0; z-index: 500; display: none; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(2, 6, 23, .7); backdrop-filter: blur(7px); }
.schedule-modal.is-open, .shortcuts-modal.is-open { display: flex; animation: schedule-fade .18s ease; }
.schedule-modal-card, .shortcuts-modal-card { width: min(560px, 100%); max-height: min(720px, calc(100vh - 3rem)); overflow: auto; padding: 1.35rem; border: 1px solid rgba(251, 191, 36, .48); border-radius: 18px; background: linear-gradient(145deg, rgba(30, 41, 59, .99), rgba(15, 23, 42, .99)); box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 35px rgba(245, 158, 11, .12); animation: schedule-rise .22s ease; }
.schedule-modal-card:focus, .shortcuts-modal-card:focus { outline: none; box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 45px rgba(245, 158, 11, .28); }
.shortcuts-modal-card { border-color: rgba(56, 189, 248, 0.4); box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 35px rgba(56, 189, 248, .12); }
.schedule-modal-modes { display: flex; gap: 0.6rem; margin-top: 0.85rem; margin-bottom: 0.85rem; }
.schedule-modal-mode-btn { flex: 1; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.3rem; padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(51, 65, 85, .35); color: var(--text-muted); cursor: pointer; transition: all 0.2s ease; text-align: left; }
.schedule-modal-mode-btn strong { font-size: 0.92rem; color: var(--text); }
.schedule-mode-time-info { font-size: 0.75rem; color: #fcd34d; font-family: 'Fira Code', monospace; }
.schedule-mode-desc { font-size: 0.7rem; color: var(--text-muted); }
.schedule-modal-mode-btn:hover { border-color: #fbbf24; background: rgba(245, 158, 11, 0.12); }
.schedule-modal-mode-btn.is-active { border-color: #fbbf24; background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(251, 191, 36, 0.08)); color: #fef3c7; box-shadow: 0 0 16px rgba(245, 158, 11, 0.2); }
.schedule-modal-mode-btn.is-active strong { color: #fbbf24; }
.schedule-modal-mode-btn.is-recommended { border-color: rgba(52, 211, 153, 0.5); }
.schedule-modal-mode-btn.is-recommended.is-active { border-color: #34d399; box-shadow: 0 0 20px rgba(52, 211, 153, 0.3); }
.schedule-recommend-banner { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.95rem; margin-top: 0.9rem; margin-bottom: 0.5rem; border: 1px solid rgba(52, 211, 153, 0.4); border-radius: 12px; background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(52, 211, 153, 0.05)); color: #a7f3d0; }
.schedule-recommend-banner strong { display: block; color: #34d399; font-size: 0.85rem; }
.schedule-recommend-banner p { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--text-muted); }
.schedule-recommend-badge { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #10b981; background: rgba(16, 185, 129, 0.22); border: 1px solid rgba(52, 211, 153, 0.45); padding: 0.18rem 0.5rem; border-radius: 999px; }
.schedule-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.schedule-modal-kicker { color: #fcd34d; font: .68rem 'Fira Code', monospace; letter-spacing: .12em; text-transform: uppercase; }
.schedule-modal-title { margin-top: .25rem; color: var(--text); font-size: 1.3rem; }
.schedule-modal-close { width: 32px; height: 32px; flex: 0 0 auto; border: 1px solid var(--line-light); border-radius: 8px; color: var(--text-muted); background: var(--surface-2); cursor: pointer; font-size: 1.2rem; }
.schedule-modal-close:hover { color: #fef3c7; border-color: #fbbf24; }
.schedule-modal-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin: 1rem 0; }
.schedule-modal-summary div { padding: .7rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(51, 65, 85, .45); }
.schedule-modal-summary span { display: block; color: var(--text-muted); font-size: .66rem; text-transform: uppercase; }
.schedule-modal-summary strong { display: block; margin-top: .18rem; color: var(--text); font: .82rem 'Fira Code', monospace; }
.schedule-modal-list { display: grid; gap: .55rem; }
.schedule-modal-item { display: grid; grid-template-columns: 92px 1fr auto; gap: .75rem; align-items: center; padding: .75rem; border-left: 3px solid var(--accent); border-radius: 8px; background: rgba(56, 189, 248, .06); }
.schedule-modal-item time { color: #fcd34d; font: .72rem 'Fira Code', monospace; }
.schedule-modal-item strong { color: var(--text); font-size: .82rem; }
.schedule-modal-item span { color: var(--text-muted); font-size: .72rem; }
.schedule-modal-item.is-break { border-left-color: #34d399; background: linear-gradient(135deg, rgba(16, 185, 129, .34), rgba(34, 197, 94, .12)); }
.schedule-modal-item.is-break time, .schedule-modal-item.is-break strong { color: #bbf7d0; }
.schedule-modal-item.is-break span { color: #d1fae5; }
.schedule-modal-item.is-next-day { border-left-color: #a78bfa; background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(167, 139, 250, 0.08)); box-shadow: inset 0 0 12px rgba(167, 139, 250, 0.15); }
.schedule-modal-item.is-next-day time { color: #c4b5fd; font-weight: 700; }
.schedule-modal-item.is-next-day strong { color: #f3e8ff; }
.next-day-divider { display: flex; align-items: center; justify-content: center; margin: 0.75rem 0 0.4rem 0; position: relative; }
.next-day-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: linear-gradient(90deg, transparent, rgba(167, 139, 250, 0.45), transparent); }
.next-day-divider span { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 3px 12px; border-radius: 999px; background: #1e293b; border: 1px solid rgba(167, 139, 250, 0.5); color: #c4b5fd; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; font-family: 'Fira Code', monospace; box-shadow: 0 0 12px rgba(139, 92, 246, 0.25); }
.next-day-tag { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 2px 7px; border-radius: 6px; background: rgba(167, 139, 250, 0.22); color: #ddd6fe; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.03em; border: 1px solid rgba(167, 139, 250, 0.45); vertical-align: middle; }
.session-plan-schedule .is-break { color: #bbf7d0; padding: .3rem .4rem; border-radius: 5px; background: linear-gradient(135deg, rgba(16, 185, 129, .32), rgba(34, 197, 94, .1)); }
.session-plan-schedule .is-next-day { color: #c4b5fd; padding: .3rem .4rem; border-radius: 5px; background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(167, 139, 250, 0.1)); border-left: 2px solid #a78bfa; }
.next-day-chip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 1px 6px; border-radius: 5px; background: rgba(167, 139, 250, 0.22); color: #ddd6fe; font-size: 0.62rem; font-weight: 700; border: 1px solid rgba(167, 139, 250, 0.4); vertical-align: middle; }
.schedule-modal-footer { margin-top: 1rem; color: var(--text-muted); font-size: .74rem; text-align: center; }

/* Shortcuts Grid */
.shortcuts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; margin: 1.25rem 0; }
.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    background: rgba(51, 65, 85, .3);
    border: 1px solid var(--line);
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    user-select: none;
}
.shortcut-row:hover {
    background: rgba(56, 189, 248, 0.18);
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.shortcut-row:active {
    transform: translateY(0);
}
.shortcut-row:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.shortcut-label { font-size: 0.8rem; color: var(--text-muted); }
.kbd { font-family: 'Fira Code', monospace; background: var(--surface-2); border: 1px solid var(--line-light); color: var(--accent); padding: 2px 7px; border-radius: 5px; font-size: 0.78rem; font-weight: 700; box-shadow: 0 2px 0 var(--line); pointer-events: none; }

.shortcuts-modal-footer {
    margin-top: 1.1rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.shortcuts-modal-footer strong {
    color: #4ade80;
    font-family: 'Fira Code', monospace;
    font-weight: 700;
}
body.light-theme .shortcuts-modal-footer {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: #334155;
}
body.light-theme .shortcuts-modal-footer strong {
    color: #16a34a;
}

/* Floating Keyboard Shortcuts FAB in bottom right corner */
.shortcuts-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.92) 0%, rgba(15, 23, 42, 0.95) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 0 15px rgba(56, 189, 248, 0.25);
    transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.shortcuts-fab:hover {
    transform: translateY(-3px) scale(1.08);
    border-color: rgba(56, 189, 248, 0.8);
    color: #ffffff;
    box-shadow: 0 15px 30px -5px rgba(99, 102, 241, 0.5), 0 0 25px rgba(56, 189, 248, 0.4);
}
.shortcuts-fab:active {
    transform: translateY(0) scale(0.95);
}

body.light-theme .shortcuts-fab {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%);
    border-color: #cbd5e1;
    color: var(--primary);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 0 15px rgba(79, 70, 229, 0.15);
}
body.light-theme .shortcuts-fab:hover {
    border-color: var(--primary);
    color: var(--primary-hover);
    box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.25);
}

@keyframes schedule-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes schedule-rise { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Search Pills */
.search-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--line-light);
    background: var(--surface-2);
    font-family: inherit;
}

.search-pill--google {
    color: #4ade80;
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
}
.search-pill--google:hover {
    background: rgba(34, 197, 94, 0.25);
    border-color: #4ade80;
    transform: translateY(-1px);
}

.search-pill--bing {
    color: #38bdf8;
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.3);
}
.search-pill--bing:hover {
    background: rgba(14, 165, 233, 0.25);
    border-color: #38bdf8;
    transform: translateY(-1px);
}

.count-chip {
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

/* Add Card Form Row */
.add-card-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}
.add-card-input {
    padding: 9px 14px;
    border-radius: 8px;
    border: 1px solid var(--line-light);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
}
.add-card-input:focus { border-color: var(--accent); outline: none; }
.add-card-input--topic { flex: 2; min-width: 200px; }
.add-card-input--tags { flex: 1.5; min-width: 150px; }
.add-card-input--time { width: 90px; text-align: center; }

/* Icon Links */
.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--line-light);
    transition: all 0.2s ease;
    text-decoration: none;
    cursor: pointer;
}
.icon-link--google { background: rgba(34, 197, 94, 0.1); color: #4ade80; border-color: rgba(34, 197, 94, 0.3); }
.icon-link--google:hover { background: rgba(34, 197, 94, 0.25); color: #4ade80; }
.icon-link--bing { background: rgba(14, 165, 233, 0.1); color: #38bdf8; border-color: rgba(14, 165, 233, 0.3); }
.icon-link--bing:hover { background: rgba(14, 165, 233, 0.25); color: #38bdf8; }
.icon-link--edit { background: rgba(251, 191, 36, 0.1); color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
.icon-link--edit:hover { background: rgba(251, 191, 36, 0.25); color: #fef3c7; }

/* Edit Card Form */
.edit-form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1rem; }
.edit-form-group label { font-size: 0.76rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.edit-modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ============ Record Cards Grid ============ */
.study-queue-widget {
    width: 100%; max-width: 1380px; min-height: 184px; margin-bottom: 1.75rem; padding: 1.65rem 1.75rem;
    display: grid; grid-template-columns: minmax(220px, .65fr) minmax(520px, 2.35fr) minmax(170px, auto);
    gap: 1.6rem; align-items: stretch; position: relative; z-index: 2;
    border: 1px solid rgba(245, 158, 11, .42); border-radius: 20px;
    background: linear-gradient(135deg, rgba(30, 41, 59, .94), rgba(51, 65, 85, .66));
    box-shadow: 0 18px 45px rgba(0, 0, 0, .24), 0 0 28px rgba(245, 158, 11, .07);
}
.study-queue__summary { display: flex; gap: 1rem; align-items: center; min-width: 0; }
.study-queue__icon { flex: 0 0 auto; width: 60px; height: 60px; display: grid; place-items: center; border-radius: 17px; color: #fbbf24; background: rgba(245, 158, 11, .13); border: 1px solid rgba(245, 158, 11, .3); }
.study-queue__icon svg { width: 28px; height: 28px; }
.study-queue__eyebrow { margin-bottom: .35rem; color: #fbbf24; font: 700 .72rem 'Fira Code', monospace; letter-spacing: .14em; text-transform: uppercase; }
.study-queue__summary h2 { font-size: 1.24rem; line-height: 1.3; }
.study-queue__summary p { margin-top: .45rem; color: var(--text-muted); font-size: .84rem; line-height: 1.5; }
.study-queue__items { width: 100%; min-width: 0; min-height: 130px; max-height: 154px; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: .6rem; padding: .9rem; border: 1px dashed var(--line-light); border-radius: 14px; background: rgba(15, 23, 42, .32); }
.study-queue__empty { align-self: center; margin: auto; color: var(--text-muted); font-size: .86rem; }
.study-queue-chip { max-width: 230px; display: inline-flex; align-items: center; gap: .48rem; padding: .48rem .55rem .48rem .78rem; border: 1px solid rgba(245, 158, 11, .25); border-radius: 999px; color: var(--text); background: rgba(245, 158, 11, .09); font-size: .8rem; }
.study-queue-chip__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.study-queue-chip__time { flex: 0 0 auto; color: #fbbf24; font-family: 'Fira Code', monospace; }
.study-queue-chip button { width: 24px; height: 24px; flex: 0 0 auto; border: 0; border-radius: 50%; color: var(--text-muted); background: transparent; cursor: pointer; }
.study-queue-chip button:hover { color: #fff; background: rgba(239, 68, 68, .6); }
.study-queue__actions { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 1rem; min-width: 184px; }
.study-queue__estimate { display: grid; text-align: center; padding: .7rem; border-radius: 12px; background: rgba(15, 23, 42, .24); }
.study-queue__estimate span, .study-queue__estimate small { color: var(--text-muted); font-size: .72rem; }
.study-queue__estimate strong { margin: .15rem 0; color: #fbbf24; font: 700 1.7rem 'Fira Code', monospace; }
.study-session-launch, .study-session-start { border-color: #f59e0b; color: #1c1917; background: linear-gradient(135deg, #fcd34d, #f59e0b); font-weight: 800; white-space: nowrap; }
.study-session-launch { min-height: 48px; justify-content: center; }
.study-session-launch:hover, .study-session-start:hover { filter: brightness(1.08); transform: translateY(-1px); }
.study-session-launch:disabled { opacity: .42; cursor: not-allowed; filter: grayscale(.35); transform: none; }

.record-card--study-flagged { border-color: rgba(245, 158, 11, .7); box-shadow: 0 0 0 2px rgba(245, 158, 11, .14), var(--shadow); }
.study-flag-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-light); border-radius: 8px; color: var(--text-muted); background: var(--surface-2); cursor: pointer; transition: .2s ease; }
.study-flag-btn:hover { color: #fbbf24; border-color: rgba(245, 158, 11, .7); transform: translateY(-1px); }
.study-flag-btn.is-flagged { color: #422006; border-color: #fbbf24; background: #fbbf24; }

.study-session-modal-card { width: min(620px, 100%); }
.study-session-form { display: grid; gap: 1.15rem; padding-top: 1rem; }
.study-session-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.study-preview-stat { padding: .85rem; border: 1px solid var(--line); border-radius: 11px; background: rgba(51, 65, 85, .32); }
.study-preview-stat span { display: block; color: var(--text-muted); font-size: .68rem; }
.study-preview-stat strong { display: block; margin-top: .25rem; color: #fbbf24; font: 700 .95rem 'Fira Code', monospace; }
.study-session-settings { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: .75rem; }
.study-session-field { display: grid; align-content: start; gap: .55rem; color: var(--text-muted); font-size: .74rem; font-weight: 600; }
.study-session-field > span { display: flex; justify-content: space-between; gap: .5rem; }
.study-session-field output { color: #fbbf24; font-family: 'Fira Code', monospace; }
.study-session-field input[type="range"] { width: 100%; accent-color: #f59e0b; }
.study-session-field select { width: 100%; min-height: 38px; padding: 0 .55rem; border: 1px solid var(--line-light); border-radius: 8px; color: var(--text); background: var(--surface-2); font: inherit; }
.study-session-start { justify-self: end; min-width: 180px; justify-content: center; }

#tasks-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 1100px;
    position: relative;
    z-index: 1;
}

.record-card {
    background: linear-gradient(145deg, rgba(51, 65, 85, .68), rgba(30, 41, 59, .84) 52%, rgba(15, 23, 42, .78));
    backdrop-filter: blur(18px) saturate(1.18);
    -webkit-backdrop-filter: blur(18px) saturate(1.18);
    border-radius: 14px;
    padding: 1rem;
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: .75rem;
    transition: all 0.25s ease;
    box-shadow: var(--shadow);
    position: relative;
}
.record-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-light); }
.panel::after, .intake::after, .record-card::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
    background: linear-gradient(120deg, rgba(255,255,255,.12), transparent 19%, transparent 72%, rgba(125,211,252,.05));
    opacity: .65; mix-blend-mode: screen;
}
.record-card--active { border-color: #ef4444; box-shadow: 0 0 15px rgba(239, 68, 68, 0.25); }
.record-card--complete { opacity: 0.8; border-color: rgba(16, 185, 129, 0.3); background: rgba(30, 41, 59, 0.7); }
.record-card--complete .record-card__title { text-decoration: line-through; color: var(--text-muted); }
.record-card--flagged { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3); }

.record-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }

.record-card__header { display: flex; align-items: flex-start; gap: 0.75rem; flex: 1; }

.record-card__title { padding-right: 1rem; font-size: .98rem; font-weight: 600; line-height: 1.35; color: var(--text); word-break: break-word; }
.record-card__title a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
.record-card__title a:hover { color: var(--accent); text-decoration: underline; }

.record-card__controls { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.record-card__controls .icon-link,
.record-card__controls .study-flag-btn { width: 28px; height: 28px; border-radius: 7px; }
.record-card__controls .variance-badge { padding: .16rem .4rem; font-size: .65rem; }

/* Selection checkbox accessible styling fix */
.select-label { cursor: pointer; display: flex; }
.select-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.select-mark {
    width: 28px; height: 28px;
    border-radius: 8px; border: 1px solid var(--line-light);
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-weight: 700; transition: all 0.2s ease;
}
.select-mark:hover { background: var(--surface-3); color: var(--text); }
.select-checkbox:checked + .select-mark { background: var(--accent); border-color: var(--accent); color: #0f172a; }
.select-checkbox:focus-visible + .select-mark {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.time-badge {
    background-color: var(--surface-2); border: 1px solid var(--line-light);
    padding: 3px 7px; border-radius: 6px; font-size: .7rem; font-weight: 600;
    color: var(--text-muted); font-family: 'Fira Code', monospace;
}

.tags-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.topic-tag {
    background: rgba(99, 102, 241, 0.15); border: 1px solid rgba(99, 102, 241, 0.3); color: #a5b4fc;
    padding: 2px 7px; border-radius: 999px; font-size: .68rem; font-weight: 600;
    text-decoration: none; transition: all 0.2s ease; word-break: break-word;
}
.topic-tag:hover { background: rgba(99, 102, 241, 0.3); color: #c7d2fe; border-color: #818cf8; }

/* Dual Check Learning Time Bar */
.learning-time-box {
    background: var(--surface-2);
    border: 1px solid var(--line-light);
    border-radius: 10px;
    padding: .7rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.checks-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .45rem;
}

.check-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 7px;
    border-radius: 8px;
    font-size: .72rem;
    font-weight: 600;
    border: 1px solid var(--line-light);
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    transition: all 0.2s ease;
    font-family: inherit;
}

/* Start Check Styling */
.check-btn--start {
    border-color: rgba(245, 158, 11, 0.4);
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.1);
}
.check-btn--start:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
}
.check-btn--start.is-active {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
    animation: pulse-button 1.5s infinite;
}
@keyframes pulse-button {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
}

/* Final Check Styling */
.check-btn--final {
    border-color: rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.1);
}
.check-btn--final:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
}
.check-btn--final.is-complete {
    background: var(--success);
    color: #0f172a;
    border-color: var(--success);
    font-weight: 700;
}

.time-stats-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .2rem .5rem;
    font-size: .68rem;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
    background: rgba(15, 23, 42, 0.5);
    padding: 5px 7px;
    border-radius: 6px;
}
.time-stats-footer strong { color: var(--text); }
.live-timer { color: #f87171; font-weight: 700; }

.delete-card-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.4;
    transition: all 0.2s ease;
    padding: 4px;
    border-radius: 4px;
}
.delete-card-btn:hover { opacity: 1; color: #ef4444; background: rgba(239, 68, 68, 0.1); }

.empty-state {
    grid-column: 1 / -1; text-align: center; padding: 4rem 2rem;
    background: var(--surface); border-radius: var(--radius); border: 2px dashed var(--line);
}
.empty-state h3 { font-size: 1.3rem; color: var(--text); margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 0.95rem; }

@media (max-width: 850px) {
    .study-queue-widget { min-height: 0; grid-template-columns: 1fr 1fr; padding: 1.35rem; }
    .study-queue__items { grid-column: 1 / -1; grid-row: 2; }
    .study-queue__actions { min-width: 0; justify-self: stretch; }
    .panel__grid { grid-template-columns: repeat(2, 1fr); }
    .intake__top-row { flex-direction: column; align-items: stretch; }
    .intake__actions { justify-content: flex-start; }
    .session-plan { width: 100%; }
    .session-plan .btn { width: 100%; justify-content: center; }
    .session-plan-panel { left: 0; right: 0; width: auto; }
    .schedule-modal-summary { grid-template-columns: 1fr; }
    .schedule-modal-item { grid-template-columns: 76px 1fr; }
    .schedule-modal-item span { grid-column: 2; }
    .shortcuts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .study-queue-widget { grid-template-columns: 1fr; padding: 1.15rem; }
    .study-queue__items { grid-column: auto; grid-row: auto; }
    .study-queue__actions { width: 100%; flex-direction: row; justify-self: stretch; justify-content: space-between; }
    .study-session-launch { flex: 1; }
    .study-session-preview, .study-session-settings { grid-template-columns: 1fr; }
    .study-session-start { width: 100%; }
    /* ── Mobile: top-center pill widget ── */
    .time-widget {
        top: calc(0.6rem + env(safe-area-inset-top));
        left: 50%;
        transform: translateX(-50%);
        padding: 10px 20px;
        gap: 12px;
        min-height: 52px;
        border-radius: 999px;
        /* slightly wider glow on mobile for better visibility */
        box-shadow: 0 6px 20px -4px rgba(0, 0, 0, 0.5),
                    0 0 18px rgba(56, 189, 248, 0.22);
    }
    .time-widget:hover {
        /* remove hover lift on touch screens — use :active instead */
        transform: translateX(-50%);
    }
    .time-widget:active {
        transform: translateX(-50%) scale(0.97);
    }
    .time-widget.open {
        transform: translateX(-50%);
    }
    .time-widget.widgets-hidden {
        transform: translateX(-50%) scale(0.85) translateY(10px) !important;
    }

    .time-widget__time {
        font-size: 0.92rem;
        letter-spacing: -0.01em;
    }
    .time-widget__day {
        font-size: 0.78rem;
        padding-left: 10px;
    }

    /* ── Mobile: bottom-sheet calendar popup ── */
    .time-widget-popup {
        /* override absolute positioning — become a fixed bottom sheet */
        position: fixed;
        top: auto !important;
        left: 0 !important;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 24px 24px 0 0;
        border: 1px solid rgba(56, 189, 248, 0.35);
        border-bottom: none;
        padding: 0 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
        z-index: 10500;
        /* override default dropdown transform */
        transform: translateY(100%);
        opacity: 1;
        visibility: hidden;
        scale: 1;
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                    visibility 0.32s;
    }

    .time-widget.open .time-widget-popup {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Drag handle at top of bottom sheet */
    .time-widget-popup::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 999px;
        background: rgba(148, 163, 184, 0.4);
        margin: 0.85rem auto 1rem;
    }

    /* Dimmed backdrop behind the sheet */
    .time-widget-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10499;
        background: rgba(2, 6, 23, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        pointer-events: none;
    }
    .time-widget.open ~ .time-widget-backdrop,
    .time-widget-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Bigger tap targets for calendar day cells */
    .mini-cal-day {
        min-height: 38px;
        font-size: 0.85rem;
        border-radius: 10px;
    }
    .mini-cal-nav {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    body { padding: 1.5rem 1rem 3rem; }
    h1 { font-size: 2.2rem; }
    .panel__grid { grid-template-columns: 1fr; }
    .add-card-row { flex-direction: column; align-items: stretch; }
    .add-card-input--time { width: 100%; text-align: left; }
    .checks-row { grid-template-columns: 1fr; }
    .shortcuts-fab {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 42px;
        height: 42px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before, body::after { animation: none; }
}

/* ============ CRT Scanlines Overlay & Cyber Glitch ============ */
.scanlines-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.18) 50%
    ), linear-gradient(
        90deg,
        rgba(255, 0, 0, 0.015),
        rgba(0, 255, 0, 0.005),
        rgba(0, 0, 255, 0.015)
    );
    background-size: 100% 3px, 6px 100%;
    opacity: 0.65;
}

/* RGB Channel Split Animation */
.glitch-active {
    position: relative;
    display: inline-block;
    animation: glitch-skew 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.glitch-active::before,
.glitch-active::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
}
.glitch-active::before {
    left: -3px;
    text-shadow: -2px 0 #ef4444;
    clip-path: inset(20% 0 30% 0);
    animation: glitch-anim-red 0.18s infinite linear alternate-reverse;
}
.glitch-active::after {
    left: 3px;
    text-shadow: 2px 0 #38bdf8;
    clip-path: inset(50% 0 10% 0);
    animation: glitch-anim-blue 0.18s infinite linear alternate-reverse;
}

@keyframes glitch-anim-red {
    0% { clip-path: inset(10% 0 60% 0); transform: translate(-3px, -1px); }
    50% { clip-path: inset(70% 0 5% 0); transform: translate(3px, 1px); }
    100% { clip-path: inset(30% 0 40% 0); transform: translate(-2px, 2px); }
}
@keyframes glitch-anim-blue {
    0% { clip-path: inset(60% 0 10% 0); transform: translate(3px, 1px); }
    50% { clip-path: inset(20% 0 50% 0); transform: translate(-3px, -1px); }
    100% { clip-path: inset(40% 0 25% 0); transform: translate(2px, -2px); }
}
@keyframes glitch-skew {
    0% { transform: skew(0deg); }
    20% { transform: skew(-4deg); }
    40% { transform: skew(3deg); }
    60% { transform: skew(-2deg); }
    100% { transform: skew(0deg); }
}

/* ==========================================================================
   PWA & Mobile Native App Compatibility System
   ========================================================================== */

/* PWA Body Padding & Touch Optimization */
body {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)) !important;
    padding-top: calc(1.5rem + env(safe-area-inset-top));
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Network Toast Banner */
.network-toast {
    position: fixed;
    top: calc(0.75rem + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 10001;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
    opacity: 0;
    pointer-events: none;
}
.network-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.network-toast--offline {
    background: rgba(225, 29, 72, 0.95);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(12px);
}
.network-toast--online {
    background: rgba(16, 185, 129, 0.95);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(12px);
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    top: calc(1rem + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    width: min(92%, 520px);
    z-index: 9998;
    background: rgba(30, 41, 59, 0.92);
    border: 1px solid rgba(56, 189, 248, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 18px;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(56, 189, 248, 0.15);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.pwa-install-banner.hidden {
    display: none !important;
}
.pwa-install-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.pwa-install-info div {
    display: flex;
    flex-direction: column;
}
.pwa-install-info strong {
    font-size: 0.95rem;
    color: var(--text);
}
.pwa-install-info span {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* iOS Instructions Body */
.ios-install-body {
    padding: 1.25rem 0.5rem 0.5rem;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
}
.ios-steps {
    margin-top: 1rem;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.ios-steps li {
    background: var(--surface-2);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
}

/* Mobile Bottom Navigation Bar */
.mobile-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9990;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.3);
}
body.light-theme .mobile-nav-bar {
    background: rgba(255, 255, 255, 0.92);
    border-top-color: #cbd5e1;
}

.mobile-nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.15s ease;
    min-width: 56px;
    min-height: 48px;
}
.mobile-nav-btn svg {
    transition: transform 0.2s ease, stroke 0.2s ease;
}
.mobile-nav-btn.active, .mobile-nav-btn:active {
    color: var(--accent);
}
.mobile-nav-btn.active svg {
    stroke: var(--accent);
    transform: translateY(-2px) scale(1.1);
}

@media (min-width: 769px) {
    .mobile-nav-bar {
        display: none !important;
    }
}

/* Comprehensive Responsive Styling for Mobile Devices */
@media (max-width: 768px) {
    body {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Masthead Header */
    .masthead {
        margin-top: 1rem;
        margin-bottom: 1.5rem;
    }
    .masthead h1 {
        font-size: 2rem;
    }

    /* Hide Time Widget on Mobile */
    .time-widget,
    .time-widget-backdrop,
    .time-widget-popup {
        display: none !important;
    }

    /* Prevent auto-zooming inputs on iOS by setting min 16px font-size */
    input, select, textarea, button {
        font-size: 16px !important;
    }

    /* Panel & Grid Layouts */
    .panel {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
    }
    .panel__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .stat {
        padding: 0.75rem;
    }
    .stat__value {
        font-size: 1.35rem;
    }

    /* Intake Section */
    .intake {
        padding: 1.25rem;
        gap: 1.25rem;
    }
    .intake__top-row {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .search-filter-box {
        width: 100%;
        max-width: none;
    }
    .intake__actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
        width: 100%;
    }
    .intake__actions > button, 
    .intake__actions > label,
    .intake__actions > .session-plan {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
    .intake__actions > .session-plan > .btn {
        width: 100%;
        height: 100%;
        justify-content: center;
        min-height: 44px;
    }
    .intake__actions > label[for="file-upload"],
    .intake__actions > .btn-danger {
        grid-column: span 2;
    }

    /* Add Card Row Layout */
    .add-card-row {
        flex-direction: column;
        gap: 0.75rem;
    }
    .add-card-input {
        width: 100% !important;
        min-height: 46px;
    }
    .add-card-row .btn-primary {
        width: 100%;
        min-height: 48px;
        font-weight: 700;
        font-size: 1rem !important;
    }

    /* Record Cards on Mobile */
    .record-card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }
    .record-card__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .record-card__actions {
        width: 100%;
        justify-content: space-between;
    }
    .record-card__actions .btn {
        min-height: 42px;
        padding: 0.5rem 1rem;
    }

    /* Mobile Sheet Transformation for Modals */
    .schedule-modal-card,
    .shortcuts-modal-card {
        width: 100%;
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        position: fixed;
        bottom: 0;
        margin: 0;
        max-height: 85vh;
        overflow-y: auto;
        animation: mobile-sheet-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes mobile-sheet-up {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* Adjust Floating Shortcuts FAB */
    .shortcuts-fab {
        bottom: calc(5.25rem + env(safe-area-inset-bottom));
        right: 1rem;
        width: 46px;
        height: 46px;
    }

    /* Hide shortcuts C and H in the mobile version */
    .shortcut-row[data-shortcut="c"],
    .shortcut-row[data-shortcut="h"] {
        display: none !important;
    }
}

/* ==========================================================================
   Time Variance Analytics & Per-Card Variance System
   ========================================================================== */

/* Per-Card Variance Badge */
.variance-badge {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: 'Fira Code', monospace;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.variance-badge--ahead {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}
.variance-badge--over {
    background: rgba(225, 29, 72, 0.15);
    color: #fb7185;
    border-color: rgba(251, 113, 133, 0.3);
}
.variance-badge--equal {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.25);
}

/* Time Variance Analytics Panel */
.panel--variance {
    margin-bottom: 1.75rem;
    border: 1px solid rgba(56, 189, 248, 0.25);
    background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.06), transparent 40%), var(--surface);
}

.panel__subtitle {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.4rem;
}

/* Period Tabs */
.variance-period-selector {
    display: flex;
    background: var(--surface-2);
    padding: 0.25rem;
    border-radius: 10px;
    gap: 0.25rem;
    border: 1px solid var(--line);
}
.variance-period-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.variance-period-btn.active, .variance-period-btn:hover {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Variance Hero Row */
.variance-hero-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 1.25rem;
}
.variance-metric-card {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.variance-metric-card:hover {
    border-color: var(--line-light);
    transform: translateY(-2px);
}

.variance-metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.variance-metric-value {
    font-size: 1.45rem;
    font-weight: 800;
    font-family: 'Fira Code', monospace;
    color: var(--text);
}
.variance-metric-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Metric Colors */
.variance-metric-card.is-ahead .variance-metric-value {
    color: #34d399;
}
.variance-metric-card.is-ahead .variance-metric-sub {
    color: #34d399;
}
.variance-metric-card.is-over .variance-metric-value {
    color: #fb7185;
}
.variance-metric-card.is-over .variance-metric-sub {
    color: #fb7185;
}

/* Period Table Breakdown */
.variance-table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.4);
}
body.light-theme .variance-table-container {
    background: rgba(241, 245, 249, 0.6);
}

.variance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
    text-align: left;
}
.variance-table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 700;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
}
.variance-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}
.variance-table tr:last-child td {
    border-bottom: none;
}
.variance-table tr.active-row {
    background: rgba(99, 102, 241, 0.08);
}

/* Mobile Adjustments for Variance Widget */
@media (max-width: 768px) {
    .variance-hero-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .panel__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
    }
    .variance-period-selector {
        width: 100%;
        justify-content: space-between;
    }
    .variance-period-btn {
        flex: 1;
        text-align: center;
    }
}

/* ==========================================================================
   Weekly Study Comparison Widget & Visual Bar Chart System
   ========================================================================== */

.panel--weekly {
    margin-bottom: 1.75rem;
    border: 1px solid rgba(168, 85, 247, 0.25);
    background: radial-gradient(circle at top left, rgba(168, 85, 247, 0.06), transparent 40%), var(--surface);
}

/* Trend Badges */
.badge.trend-badge--up {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}
.badge.trend-badge--down {
    background: rgba(225, 29, 72, 0.15);
    color: #fb7185;
    border-color: rgba(251, 113, 133, 0.3);
}
.badge.trend-badge--flat {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.25);
}

/* Weekly Bar Chart */
.weekly-chart-box {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--line);
    border-radius: 14px;
}
body.light-theme .weekly-chart-box {
    background: rgba(241, 245, 249, 0.6);
}

.weekly-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.weekly-chart-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.weekly-chart-legend {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}
.legend-dot--current {
    background: linear-gradient(135deg, #38bdf8, #6366f1);
}
.legend-dot--prev {
    background: var(--surface-3);
    border: 1px solid var(--line-light);
}

/* Bar Chart Container & Pairs */
.weekly-bar-chart {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
    align-items: flex-end;
    min-height: 180px;
    padding-top: 1.5rem;
}

.chart-day-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    height: 100%;
    justify-content: flex-end;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    width: 100%;
    max-width: 48px;
    height: 140px;
    position: relative;
}

.chart-bar-wrapper {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
}

.chart-bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
    transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    min-height: 3px;
}

.chart-bar--current {
    background: linear-gradient(180deg, #38bdf8 0%, #6366f1 100%);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.chart-bar--prev {
    background: var(--surface-3);
    opacity: 0.65;
}

.chart-bar-wrapper:hover .chart-bar {
    opacity: 0.9;
    filter: brightness(1.2);
}

.chart-day-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}
.chart-day-group.is-today .chart-day-label {
    color: var(--accent);
    font-weight: 800;
}

.chart-val-label {
    font-size: 0.65rem;
    font-family: 'Fira Code', monospace;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2px;
}

@media (max-width: 600px) {
    .weekly-bar-chart {
        gap: 0.35rem;
    }
    .chart-bars {
        max-width: 32px;
        gap: 2px;
    }
    .chart-val-label {
        font-size: 0.58rem;
    }
}
