/* ==========================================================================
   Study Sanctuary theme — calm paper desk, sage focus accents
   Default: soft light study mode. Add .dark-theme for evening focus.
   ========================================================================== */
:root {
    --bg:            #f4f0e6;
    --bg-warm:       #ebe4d4;
    --surface:       #fffdf8;
    --surface-2:     #f0ebe0;
    --surface-3:     #e4ddd0;
    --primary:       #2f6f5e;
    --primary-hover: #255a4c;
    --primary-dim:   rgba(47, 111, 94, 0.12);
    --accent:        #3d8b74;
    --accent-soft:   #d7ebe3;
    --google:        #3d8b74;
    --bing:          #5b7c99;
    --active-pulse:  #c46b4a;
    --success:       #2f6f5e;
    --success-dim:   rgba(47, 111, 94, 0.14);
    --warn:          #c4923a;
    --text:          #1c2a24;
    --text-muted:    #5c6b63;
    --line:          #ddd4c4;
    --line-light:    #cfc5b3;
    --shadow:        0 8px 28px -8px rgba(48, 42, 30, 0.12), 0 2px 8px rgba(48, 42, 30, 0.05);
    --shadow-lg:     0 18px 40px -12px rgba(48, 42, 30, 0.16), 0 6px 14px rgba(48, 42, 30, 0.06);
    --radius:        18px;
    --radius-sm:     12px;
    --font-ui:       'DM Sans', 'Segoe UI', system-ui, sans-serif;
    --font-display:  'Literata', 'Georgia', 'Times New Roman', serif;
    --font-mono:     'IBM Plex Mono', 'Consolas', monospace;
    --heat-1:        #e3f0ea;
    --heat-2:        #b9dccf;
    --heat-3:        #6fb89a;
    --heat-4:        #2f6f5e;
    --heat-text-dark:#1c2a24;
    --heat-text-light:#f7fff9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-ui);
    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;
    overflow-x: hidden;
    transition: background-color 0.35s ease, color 0.35s ease;
    background-image:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(61, 139, 116, 0.13), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(196, 146, 58, 0.10), transparent 50%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
    background-size: 160% 160%, 170% 170%, 100% 100%;
    background-attachment: fixed;
    animation: ambient-color-shift 22s ease-in-out infinite alternate;
}

/* Soft study-desk wash — no cyber neon */
body::before, body::after {
    content: '';
    position: fixed;
    z-index: 0;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(72px);
    opacity: 0.55;
    will-change: transform, border-radius;
}
body::before {
    width: min(54vw, 720px);
    height: min(50vw, 650px);
    top: -12%;
    left: -10%;
    background: radial-gradient(circle at 30% 35%, rgba(61, 139, 116, 0.28), rgba(126, 185, 157, 0.12) 48%, transparent 72%);
    animation: liquid-drift-one 18s ease-in-out infinite alternate;
}
body::after {
    width: min(48vw, 640px);
    height: min(46vw, 600px);
    bottom: -10%;
    right: -10%;
    background: radial-gradient(circle at 60% 42%, rgba(196, 146, 58, 0.24), rgba(225, 179, 100, 0.10) 50%, transparent 72%);
    animation: liquid-drift-two 23s ease-in-out infinite alternate;
}

/* Fine grain prevents broad color washes from feeling flat. */
html::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.85'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 180px 180px;
}

@keyframes ambient-color-shift {
    0% { background-position: 0% 0%, 100% 0%, 0 0; }
    50% { background-position: 42% 18%, 55% 30%, 0 0; }
    100% { background-position: 18% 45%, 92% 62%, 0 0; }
}
@keyframes liquid-drift-one {
    0% { transform: translate3d(0, 0, 0) scale(1); border-radius: 48% 52% 58% 42% / 45% 46% 54% 55%; }
    50% { transform: translate3d(14vw, 9vh, 0) scale(1.12); border-radius: 58% 42% 44% 56% / 56% 58% 42% 44%; }
    100% { transform: translate3d(6vw, 18vh, 0) scale(0.94); border-radius: 42% 58% 54% 46% / 46% 42% 58% 54%; }
}
@keyframes liquid-drift-two {
    0% { transform: translate3d(0, 0, 0) scale(1); border-radius: 56% 44% 42% 58% / 49% 57% 43% 51%; }
    50% { transform: translate3d(-13vw, -14vh, 0) scale(1.1); border-radius: 44% 56% 58% 42% / 58% 45% 55% 42%; }
    100% { transform: translate3d(-5vw, -5vh, 0) scale(0.95); border-radius: 54% 46% 48% 52% / 43% 56% 44% 57%; }
}

/* Evening focus mode (title click toggles this) */
body.dark-theme {
    --bg:            #121a17;
    --bg-warm:       #0e1512;
    --surface:       #1a2621;
    --surface-2:     #24332d;
    --surface-3:     #2f4139;
    --primary:       #6fbfa5;
    --primary-hover: #8fd0bb;
    --primary-dim:   rgba(111, 191, 165, 0.14);
    --accent:        #7ec9b0;
    --accent-soft:   #1e3a32;
    --google:        #6fbfa5;
    --bing:          #8aabcc;
    --active-pulse:  #e08a6a;
    --success:       #6fbfa5;
    --success-dim:   rgba(111, 191, 165, 0.16);
    --warn:          #d4a85a;
    --text:          #e8f0ec;
    --text-muted:    #9aafa5;
    --line:          #2f4139;
    --line-light:    #3d5349;
    --shadow:        0 10px 28px -8px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg:     0 20px 40px -12px rgba(0, 0, 0, 0.55);
    --heat-1:        #1e332c;
    --heat-2:        #2a4d40;
    --heat-3:        #3d7a64;
    --heat-4:        #6fbfa5;
    --heat-text-dark:#e8f0ec;
    --heat-text-light:#0e1512;
    background-image:
        radial-gradient(ellipse 70% 45% at 15% 0%, rgba(111, 191, 165, 0.14), transparent 55%),
        radial-gradient(ellipse 50% 38% at 96% 90%, rgba(205, 160, 90, 0.10), transparent 60%),
        linear-gradient(180deg, #121a17 0%, #0e1512 100%);
    background-size: 160% 160%, 170% 170%, 100% 100%;
}

body.dark-theme::before {
    background: radial-gradient(circle at 30% 35%, rgba(111, 191, 165, 0.24), rgba(74, 126, 108, 0.10) 48%, transparent 72%);
}
body.dark-theme::after {
    background: radial-gradient(circle at 60% 42%, rgba(212, 168, 90, 0.18), rgba(108, 83, 47, 0.08) 50%, transparent 72%);
}

/* Legacy class: light-theme was old light; map to default (no-op) for saved prefs */
body.light-theme {
    /* default study desk is already light */
}

/* Soft surfaces use theme tokens — no neon glass overlays */
.panel::after,
.intake::after,
.record-card::after {
    opacity: 0 !important;
    display: none !important;
}

.scanlines-overlay {
    display: none !important;
}

#particle-canvas {
    display: none !important;
}

.mono { font-family: var(--font-mono); }
.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: var(--surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    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: var(--accent);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}
.time-widget.open {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

/* 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: var(--font-mono);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

.time-widget__day {
    font-family: var(--font-ui);
    font-weight: 600;
    color: var(--accent);
    font-size: 0.78rem;
    padding-left: 8px;
    border-left: 1px solid var(--line);
    text-transform: capitalize;
}

/* Mini Month Calendar Popup */
.time-widget-popup {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    z-index: 200;
    width: 320px;
    max-width: min(320px, calc(100vw - 2rem));
    padding: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    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 ease, transform 0.22s ease, 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.95rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-display);
}

.mini-cal-nav {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--primary);
    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(--primary);
    color: #fff;
    border-color: var(--primary);
}

.mini-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    text-align: center;
    margin-bottom: 6px;
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.mini-cal-empty {
    min-height: 34px;
}

.mini-cal-day {
    min-height: 34px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid transparent;
    transition: all 0.15s ease;
    cursor: pointer;
    padding: 3px 0 4px;
    position: relative;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    line-height: 1.1;
}
.mini-cal-day:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.mini-cal-day.is-today {
    box-shadow: inset 0 0 0 2px var(--warn);
    font-weight: 700;
}
.mini-cal-day.is-selected {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
.mini-cal-day.heat-0 { background: var(--surface-2); color: var(--text-muted); }
.mini-cal-day.heat-1 { background: var(--heat-1); color: var(--heat-text-dark); }
.mini-cal-day.heat-2 { background: var(--heat-2); color: var(--heat-text-dark); }
.mini-cal-day.heat-3 { background: var(--heat-3); color: var(--heat-text-light); font-weight: 600; }
.mini-cal-day.heat-4 { background: var(--heat-4); color: var(--heat-text-light); font-weight: 700; }
.mini-cal-day-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.75;
}
.mini-cal-day.heat-0 .mini-cal-day-dot { opacity: 0; }

.mini-cal-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 0.75rem;
    font-size: 0.68rem;
    color: var(--text-muted);
}
.mini-cal-legend-label { margin: 0 2px; }
.mini-cal-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid var(--line);
}
.mini-cal-legend-swatch.heat-0 { background: var(--surface-2); }
.mini-cal-legend-swatch.heat-1 { background: var(--heat-1); }
.mini-cal-legend-swatch.heat-2 { background: var(--heat-2); }
.mini-cal-legend-swatch.heat-3 { background: var(--heat-3); }
.mini-cal-legend-swatch.heat-4 { background: var(--heat-4); }

.mini-cal-day-detail {
    margin-top: 0.85rem;
    padding: 0.75rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--line);
    text-align: left;
    max-height: 180px;
    overflow-y: auto;
}
.mini-cal-day-detail__date {
    font-family: var(--font-display);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
}
.mini-cal-day-detail__total {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.55rem;
}
.mini-cal-day-detail__empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.mini-cal-day-detail__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.mini-cal-day-detail__item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.74rem;
    padding: 0.35rem 0.45rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
}
.mini-cal-day-detail__item-title {
    color: var(--text);
    font-weight: 550;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}
.mini-cal-day-detail__item-time {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    white-space: nowrap;
}
.mini-cal-day-detail__item.is-completed .mini-cal-day-detail__item-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.mini-cal-footer {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--line);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    font-family: var(--font-ui);
}

/* ============ 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: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    transition: all 0.25s ease;
}
.title-icon-wrapper:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.title-text {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: unset;
    color: var(--text);
    filter: none;
    font-family: var(--font-display);
}

.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: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    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: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    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: var(--primary); border-color: var(--line); background: var(--primary-dim); }
.btn-session-plan:hover { background: var(--accent-soft); border-color: var(--primary); }
.session-plan-panel {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 120;
    width: min(365px, calc(100vw - 3rem)); padding: 1rem;
    background: var(--surface); border: 1px solid var(--line); color: var(--text);
    border-radius: 12px; box-shadow: var(--shadow-lg); backdrop-filter: none;
    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: var(--primary); }
.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 var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); 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 var(--line); border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.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); border-radius: 14px; background: var(--surface-2); }
.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-fit, minmax(min(100%, 460px), 1fr));
    gap: 1.25rem;
    width: 100%;
    max-width: 1380px;
    position: relative;
    z-index: 1;
}

.record-card {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 16px;
    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(--primary); }
.panel::after, .intake::after, .record-card::after {
    content: none;
    display: none;
}
.record-card--active { border-color: var(--active-pulse); box-shadow: 0 0 0 2px rgba(196, 107, 74, 0.22), var(--shadow); }
.record-card--complete { opacity: 0.88; border-color: rgba(47, 111, 94, 0.35); background: var(--surface-2); }
.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 var(--primary-dim), var(--shadow); }

.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; }

.duck-ai-btn {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(124, 58, 237, 0.30);
    border-radius: 8px;
    color: #6d28d9;
    background: linear-gradient(135deg, rgba(237, 233, 254, 0.82), rgba(219, 234, 254, 0.70));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
    cursor: pointer;
    transition: transform 180ms ease, color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.duck-ai-btn:hover,
.duck-ai-btn:focus-visible {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, #8b5cf6, #2563eb);
    box-shadow: 0 8px 16px -9px rgba(91, 73, 206, 0.9);
    transform: translateY(-1px);
}
.duck-ai-btn.is-copied {
    color: #fff;
    background: linear-gradient(135deg, #0f766e, #16a34a);
    animation: duck-ai-confirm 600ms ease;
}
body.dark-theme .duck-ai-btn {
    color: #ddd6fe;
    border-color: rgba(196, 181, 253, 0.28);
    background: linear-gradient(135deg, rgba(91, 55, 145, 0.48), rgba(39, 80, 141, 0.42));
}
@keyframes duck-ai-confirm {
    50% { transform: scale(1.16); }
}

/* 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, 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;
    }
}

/* ==========================================================================
   Study Sanctuary � surface & component overrides (calm desk aesthetic)
   ========================================================================== */
.masthead::before {
    background: radial-gradient(circle, rgba(47, 111, 94, 0.18) 0%, rgba(196, 146, 58, 0.08) 45%, transparent 75%);
    filter: blur(28px);
}
h1 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: clamp(2rem, 4vw, 2.85rem);
}
.title-icon-wrapper {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.title-icon-wrapper:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}
.title-text {
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    color: var(--text);
    filter: none;
    font-family: var(--font-display);
}

.panel,
.intake,
.study-queue-widget {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    box-shadow: var(--shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.panel__title {
    font-family: var(--font-display);
    font-weight: 700;
}
.stat__value {
    font-family: var(--font-mono);
}
.progress-bar-container {
    background: var(--surface-2) !important;
}
.progress-bar-fill {
    background: linear-gradient(90deg, var(--primary), var(--accent)) !important;
    box-shadow: none !important;
}

.record-card {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    box-shadow: var(--shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-radius: 16px !important;
}
.record-card:hover {
    border-color: var(--primary) !important;
}
.record-card--active {
    border-color: var(--active-pulse) !important;
    box-shadow: 0 0 0 2px rgba(196, 107, 74, 0.22), var(--shadow) !important;
}
.record-card--complete {
    background: var(--surface-2) !important;
    border-color: rgba(47, 111, 94, 0.35) !important;
    opacity: 0.88;
}
.record-card--flagged {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--primary-dim), var(--shadow) !important;
}
.record-card--study-flagged {
    border-color: var(--warn) !important;
    box-shadow: 0 0 0 2px rgba(196, 146, 58, 0.18), var(--shadow) !important;
}
.record-card__title {
    font-family: var(--font-display);
    font-weight: 650;
}

/* ============ Glass surfaces ============ */
/* Translucent layers reveal the ambient background while retaining a calm reading contrast. */
.panel,
.intake,
.study-queue-widget,
.record-card {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.74) 0%, rgba(255, 253, 248, 0.52) 42%, rgba(230, 241, 234, 0.40) 100%) !important;
    border-color: rgba(255, 255, 255, 0.68) !important;
    box-shadow: 0 18px 48px -24px rgba(48, 42, 30, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.78) !important;
    backdrop-filter: blur(18px) saturate(125%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(125%) !important;
}
.panel,
.intake,
.study-queue-widget {
    overflow: hidden;
}
.panel::after,
.intake::after,
.record-card::after {
    content: '' !important;
    display: block !important;
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1 !important;
    border-radius: inherit;
    background: linear-gradient(118deg, rgba(255, 255, 255, 0.48), transparent 28%, transparent 70%, rgba(255, 255, 255, 0.12));
}
.panel > *,
.intake > *,
.record-card > *,
.study-queue-widget > * {
    position: relative;
    z-index: 1;
}
.stat,
.study-queue__items,
.study-queue__estimate {
    background: rgba(255, 253, 248, 0.46) !important;
    border-color: rgba(255, 255, 255, 0.52) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.52);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.time-widget,
.time-widget-popup {
    background: rgba(255, 253, 248, 0.68);
    border-color: rgba(255, 255, 255, 0.72);
    box-shadow: 0 16px 38px -22px rgba(48, 42, 30, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

body.dark-theme .panel,
body.dark-theme .intake,
body.dark-theme .study-queue-widget,
body.dark-theme .record-card {
    background:
        linear-gradient(135deg, rgba(39, 61, 52, 0.76) 0%, rgba(24, 43, 35, 0.60) 45%, rgba(47, 60, 42, 0.46) 100%) !important;
    border-color: rgba(179, 223, 204, 0.22) !important;
    box-shadow: 0 20px 50px -26px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(220, 255, 239, 0.12) !important;
}
body.dark-theme .panel::after,
body.dark-theme .intake::after,
body.dark-theme .record-card::after {
    background: linear-gradient(118deg, rgba(208, 247, 226, 0.13), transparent 30%, transparent 70%, rgba(232, 191, 119, 0.06));
}
body.dark-theme .stat,
body.dark-theme .study-queue__items,
body.dark-theme .study-queue__estimate {
    background: rgba(19, 38, 31, 0.44) !important;
    border-color: rgba(179, 223, 204, 0.14) !important;
    box-shadow: inset 0 1px 0 rgba(220, 255, 239, 0.08);
}
body.dark-theme .time-widget,
body.dark-theme .time-widget-popup {
    background: rgba(26, 45, 37, 0.72);
    border-color: rgba(179, 223, 204, 0.20);
}

.study-queue__icon {
    color: var(--warn) !important;
    background: rgba(196, 146, 58, 0.12) !important;
    border-color: rgba(196, 146, 58, 0.28) !important;
}
.study-queue__eyebrow {
    color: var(--warn) !important;
    font-family: var(--font-ui) !important;
    letter-spacing: 0.08em !important;
}
.study-queue__items {
    background: var(--surface-2) !important;
    border-color: var(--line) !important;
}
.study-queue-chip {
    background: var(--surface) !important;
    border-color: rgba(196, 146, 58, 0.3) !important;
}
.study-queue-chip__time,
.study-queue__estimate strong,
.study-preview-stat strong,
.study-session-field output {
    color: var(--warn) !important;
    font-family: var(--font-mono) !important;
}
.study-queue__estimate {
    background: var(--surface-2) !important;
}
.study-session-launch, .study-session-start {
    border-color: transparent !important;
    color: #fff !important;
    background: linear-gradient(135deg, var(--primary), var(--accent)) !important;
}
.study-preview-stat {
    background: var(--surface-2) !important;
}
.study-flag-btn.is-flagged {
    color: #fff !important;
    border-color: var(--warn) !important;
    background: var(--warn) !important;
}
.study-session-field input[type="range"] {
    accent-color: var(--primary) !important;
}

.btn-primary {
    background: var(--primary) !important;
    border-color: transparent !important;
    color: #fff !important;
}
.btn-primary:hover { background: var(--primary-hover) !important; }
.btn-success {
    background: var(--success) !important;
    border-color: transparent !important;
    color: #fff !important;
}
.search-pill--google {
    background: var(--primary-dim) !important;
    border-color: rgba(47, 111, 94, 0.35) !important;
    color: var(--primary) !important;
}
.search-pill--bing {
    background: rgba(91, 124, 153, 0.12) !important;
    border-color: rgba(91, 124, 153, 0.3) !important;
    color: var(--bing) !important;
}

.search-filter-box input,
.add-card-input {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
    font-family: var(--font-ui) !important;
}
.learning-time-box {
    background: var(--surface-2) !important;
    border-color: var(--line) !important;
}
.time-stats-footer {
    background: var(--surface-3) !important;
    color: var(--text-muted) !important;
}
.time-stats-footer strong { color: var(--text) !important; }
.check-btn--start.is-active {
    background: var(--active-pulse) !important;
    border-color: transparent !important;
    color: #fff !important;
}
.check-btn--final.is-complete {
    background: var(--success) !important;
    border-color: transparent !important;
    color: #fff !important;
}

.schedule-modal-card,
.shortcuts-modal-card {
    background: var(--surface) !important;
    border-color: var(--line) !important;
    color: var(--text) !important;
    box-shadow: var(--shadow-lg) !important;
}
.schedule-modal-title,
.shortcuts-modal-card .schedule-modal-title {
    font-family: var(--font-display) !important;
}
.schedule-modal-kicker {
    color: var(--primary) !important;
}
.shortcut-row {
    background: var(--surface-2) !important;
    border-color: var(--line) !important;
}
.shortcut-row:hover {
    border-color: var(--primary) !important;
    background: var(--accent-soft) !important;
}
.kbd {
    background: var(--surface) !important;
    border-color: var(--line) !important;
    color: var(--primary) !important;
    font-family: var(--font-mono) !important;
}
.session-plan-panel {
    background: var(--surface) !important;
    border-color: var(--line) !important;
    color: var(--text) !important;
}
.variance-metric-card {
    background: var(--surface-2) !important;
    border-color: var(--line) !important;
}
.chart-bar--current {
    background: linear-gradient(180deg, var(--accent) 0%, var(--primary) 100%) !important;
    box-shadow: none !important;
}
.chart-bar--prev {
    background: var(--surface-3) !important;
}
.badge {
    background: var(--primary-dim) !important;
    color: var(--primary) !important;
    border-color: transparent !important;
}
.badge.is-active {
    background: rgba(196, 107, 74, 0.15) !important;
    color: var(--active-pulse) !important;
}
.badge.is-complete {
    background: var(--success-dim) !important;
    color: var(--success) !important;
}
.shortcuts-fab {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    color: var(--primary) !important;
    box-shadow: var(--shadow) !important;
}
.mobile-nav-bar {
    background: var(--surface) !important;
    border-color: var(--line) !important;
}
.mobile-nav-btn.active {
    color: var(--primary) !important;
}
.pwa-install-banner {
    background: var(--surface) !important;
    border-color: var(--line) !important;
}
.network-toast {
    background: var(--surface) !important;
    border-color: var(--line) !important;
    color: var(--text) !important;
}
.live-timer {
    color: var(--active-pulse) !important;
}
.glitch-active,
.glitch-active::before,
.glitch-active::after {
    animation: none !important;
}
.glitch-active::before,
.glitch-active::after {
    display: none !important;
}
body.dark-theme .title-text {
    color: var(--text);
}
body.dark-theme .study-session-launch,
body.dark-theme .study-session-start {
    color: #0e1512 !important;
}

/* A restrained light sweep gives each glass card a tactile, premium response. */
.record-card {
    overflow: hidden;
}
.record-card::before {
    content: '';
    position: absolute;
    z-index: 2;
    top: -30%;
    left: -65%;
    width: 42%;
    height: 160%;
    pointer-events: none;
    opacity: 0;
    transform: skewX(-18deg);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
}
.record-card:hover::before {
    animation: card-light-sweep 800ms ease-out;
}
@keyframes card-light-sweep {
    0% { left: -65%; opacity: 0; }
    20% { opacity: 1; }
    100% { left: 125%; opacity: 0; }
}

/* The destructive action is explicit, compact, and visually separate from card controls. */
.record-card > .delete-card-btn {
    display: none;
}
.delete-card-action {
    position: static;
    align-self: flex-end;
    order: 10;
    margin-top: 0.2rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 36px;
    padding: 0 0.8rem;
    border: 1px solid rgba(220, 38, 38, 0.18);
    border-radius: 999px;
    color: #b91c1c;
    background: rgba(255, 247, 247, 0.48);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    cursor: pointer;
    font: 700 0.75rem var(--font-ui);
    letter-spacing: 0.025em;
    opacity: 0.88;
    transition: transform 180ms ease, color 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}
.delete-card-action:hover,
.delete-card-action:focus-visible {
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #c81e3a);
    border-color: transparent;
    box-shadow: 0 8px 18px -10px rgba(185, 28, 28, 0.9);
    opacity: 1;
    transform: translateY(-1px);
}
.delete-card-action:active {
    transform: translateY(0) scale(0.96);
}
body.dark-theme .delete-card-action {
    color: #fecaca;
    border-color: rgba(252, 165, 165, 0.22);
    background: rgba(92, 32, 38, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 220, 220, 0.08);
}

@media (prefers-reduced-motion: reduce) {
    .record-card:hover::before { animation: none; }
}
