[data-theme="dark"] {
    --primary: #7fb2f0;
    --primary-panel: #0a376f;
    --secondary: #5f9fe8;
    --secondary-soft: #123f73;
    --secondary-strong: #9fc8f6;
    --accent: #67c7d4;
    --on-accent: #041b32;
    --bg: #07111f;
    --sidebar-bg: #04152a;
    --chat-bg: #07111f;
    --card: #0b1b2e;
    --composer-bg: #0d2138;
    --hover-bg: #102b4b;
    --border: #234363;
    --outline: #315778;
    --surface: #091827;
    --surface-lowest: #061321;
    --surface-low: #0c2036;
    --surface-high: #153452;
    --surface-soft: #0b1d31;
    --text: #edf5ff;
    --muted: #a9bdd1;
    --sidebar-text: #edf5ff;
    --sidebar-muted: #9eb4ca;
    --tooltip-bg: #eaf3fc;
    --tooltip-text: #061321;
    --shadow: 0 24px 64px rgba(0, 8, 20, 0.42);
}

[data-theme="dark"] body,
[data-theme="dark"] .chat-page {
    background:
        radial-gradient(circle at 72% 12%, rgba(28, 92, 157, 0.13), transparent 31rem),
        var(--chat-bg);
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #062b5c 0%, #041d3d 45%, #03152c 100%);
    border-right: 1px solid rgba(127, 178, 240, 0.16);
    box-shadow: 12px 0 40px rgba(0, 7, 17, 0.18);
}

[data-theme="dark"] .brand-title { color: #ffffff; }
[data-theme="dark"] .nav-item { color: var(--sidebar-muted); }
[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item:focus-visible,
[data-theme="dark"] .nav-item.active {
    background: rgba(127, 178, 240, 0.12);
    color: #ffffff;
}
[data-theme="dark"] .new-chat-action {
    border: 1px solid rgba(159, 200, 246, 0.24) !important;
    background: rgba(7, 34, 70, 0.52) !important;
}
[data-theme="dark"] .new-chat-action:hover,
[data-theme="dark"] .new-chat-action:focus-visible {
    border-color: rgba(159, 200, 246, 0.55) !important;
    background: rgba(127, 178, 240, 0.16) !important;
}
[data-theme="dark"] .conversation-item.active {
    background: rgba(127, 178, 240, 0.17);
    box-shadow: inset 3px 0 0 #7fb2f0;
}
[data-theme="dark"] .conversation-group-label {
    color: #7fb2f0;
    letter-spacing: .06em;
    text-transform: uppercase;
}
[data-theme="dark"] .sidebar-toggle:hover,
[data-theme="dark"] .sidebar-toggle:focus-visible,
[data-theme="dark"] .profile-card:hover,
[data-theme="dark"] .profile-card:focus-visible { background: rgba(127, 178, 240, 0.12); }

[data-theme="dark"].sidebar-collapsed .nav-item::after,
[data-theme="dark"].sidebar-collapsed .profile-card::after,
[data-theme="dark"].sidebar-collapsed .sidebar-toggle-tooltip {
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
}

[data-theme="dark"] .student-context-bar {
    min-height: 64px;
    border-bottom: 1px solid rgba(127, 178, 240, 0.11);
    background: rgba(7, 17, 31, 0.82);
    backdrop-filter: blur(18px);
}
[data-theme="dark"] .context-kicker,
[data-theme="dark"] .knowledge-status { display: flex; }
[data-theme="dark"] .context-kicker {
    color: #7fb2f0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}
[data-theme="dark"] .student-context-bar strong { color: #f4f8fd; }
[data-theme="dark"] .knowledge-status {
    align-items: center;
    gap: 8px;
    color: #b6c8d9;
    font-size: 12px;
}
[data-theme="dark"] .knowledge-status i {
    background: #67c7d4;
    box-shadow: 0 0 0 4px rgba(103, 199, 212, 0.12), 0 0 14px rgba(103, 199, 212, 0.35);
}

[data-theme="dark"] .welcome-panel {
    position: relative;
    gap: 14px;
    margin-bottom: 24px;
    padding: 28px 30px;
    overflow: hidden;
    border: 1px solid rgba(127, 178, 240, 0.2);
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(15, 51, 87, 0.9), rgba(8, 28, 49, 0.82));
    box-shadow: 0 24px 60px rgba(0, 8, 20, 0.26);
}
[data-theme="dark"] .welcome-panel::after {
    position: absolute;
    width: 230px;
    height: 230px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(95, 159, 232, 0.22), transparent 68%);
    content: "";
    top: -130px;
    right: -55px;
    pointer-events: none;
}
[data-theme="dark"] .welcome-eyebrow {
    color: #7fcbd4;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}
[data-theme="dark"] .welcome-panel h1 {
    max-width: 650px;
    color: #f5f9ff;
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 650;
    line-height: 1.08;
    letter-spacing: -.035em;
}
[data-theme="dark"] .welcome-panel p {
    display: block;
    max-width: 590px;
    margin: 0;
    color: #b9cadb;
    font-size: 14px;
    line-height: 1.65;
}

[data-theme="dark"] .suggested-questions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}
[data-theme="dark"] .suggestion-pill {
    justify-content: flex-start;
    min-height: 64px;
    padding: 12px 14px;
    border: 1px solid rgba(127, 178, 240, 0.16);
    border-radius: 13px;
    background: rgba(10, 31, 53, 0.72);
    color: #bfd0e0;
    line-height: 1.35;
    text-align: left;
}
[data-theme="dark"] .suggestion-pill .material-symbols-outlined { color: #7fb2f0; }
[data-theme="dark"] .suggestion-pill:hover,
[data-theme="dark"] .suggestion-pill:focus-visible {
    border-color: rgba(127, 178, 240, 0.45);
    background: #102b49;
    color: #ffffff;
    transform: translateY(-2px);
}

[data-theme="dark"] .composer {
    border: 1px solid rgba(127, 178, 240, 0.24);
    border-radius: 18px;
    background: linear-gradient(180deg, #102842, #0c2036);
    box-shadow: 0 18px 48px rgba(0, 7, 18, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
[data-theme="dark"] .composer:hover { border-color: rgba(127, 178, 240, 0.38); }
[data-theme="dark"] .composer:focus-within {
    border-color: #5f9fe8;
    box-shadow: 0 0 0 3px rgba(95, 159, 232, 0.13), 0 18px 48px rgba(0, 7, 18, 0.4);
}
[data-theme="dark"] .composer textarea { color: var(--text); }
[data-theme="dark"] .composer textarea::placeholder { color: #8fa6bb; }
[data-theme="dark"] .voice-input-button:hover { background: rgba(127, 178, 240, 0.12); color: #b9d7fa; }
[data-theme="dark"] .voice-input-button:focus-visible { outline-color: #7fb2f0; }
[data-theme="dark"] .voice-input-button.listening {
    background: #e5484d;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.42);
}
[data-theme="dark"] .send-button,
[data-theme="dark"] .icon-button {
    background: #2d6daf;
    color: #ffffff;
}
[data-theme="dark"] .send-button:hover,
[data-theme="dark"] .send-button:focus-visible,
[data-theme="dark"] .icon-button:hover,
[data-theme="dark"] .icon-button:focus-visible { background: #4385c9; }

[data-theme="dark"] .message-row.user .message-bubble {
    border: 1px solid rgba(127, 178, 240, 0.22);
    background: linear-gradient(135deg, #123f73, #0d315c);
    color: #f4f8fd;
    box-shadow: 0 8px 24px rgba(0, 9, 24, 0.2);
}
[data-theme="dark"] .message-row.ai .message-bubble {
    width: fit-content;
    max-width: min(82%, 680px);
    padding: 11px 16px;
    border: 1px solid rgba(127, 178, 240, 0.13);
    border-left: 3px solid #4f8fd3;
    border-radius: 22px;
    background: rgba(10, 28, 47, 0.72);
    color: #dfeaf5;
}
[data-theme="dark"] .sources {
    width: fit-content;
    margin-top: 8px;
    padding: 7px 11px;
    border: 1px solid rgba(103, 199, 212, 0.2);
    border-radius: 999px;
    background: rgba(103, 199, 212, 0.08);
    color: #92dbe3;
}
[data-theme="dark"] .thinking { color: #91b7df; }
[data-theme="dark"] .thinking span { background: #67c7d4; }
[data-theme="dark"] .status-line {
    border-top: 1px solid rgba(127, 178, 240, 0.1);
    background: rgba(7, 17, 31, 0.92);
    color: #8fa6bb;
}

[data-theme="dark"] .conversation-menu,
[data-theme="dark"] .confirm-dialog {
    border-color: #284b6d;
    background: #0c2036;
    color: var(--text);
    box-shadow: var(--shadow);
}
[data-theme="dark"] .conversation-menu button { color: var(--text); }
[data-theme="dark"] .conversation-menu button:hover { background: #153452; }
[data-theme="dark"] .rename-field input { border-color: #315778; background: #071523; color: var(--text); }
[data-theme="dark"] .sidebar-overlay { background: rgba(0, 7, 18, 0.72); }
[data-theme="dark"] .mobile-header {
    border-bottom-color: rgba(127, 178, 240, 0.18);
    background: rgba(4, 21, 42, 0.94);
    backdrop-filter: blur(16px);
}

[data-theme="dark"] .login-shell { background: radial-gradient(circle at 70% 10%, #123f73 0%, #071a31 34%, #04101f 100%); }
[data-theme="dark"] .login-card {
    border-color: rgba(127, 178, 240, 0.22);
    background: rgba(8, 28, 49, 0.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
[data-theme="dark"] .login-brand h1 { color: var(--text); }
[data-theme="dark"] .login-logo-mark { background: transparent; }
[data-theme="dark"] .login-logo-light { display: none; }
[data-theme="dark"] .login-logo-dark { display: block; }
[data-theme="dark"] .google-login-button { border-color: #284b6d; background: #0a1c30; }
[data-theme="dark"] .google-login-button:hover,
[data-theme="dark"] .google-login-button:focus-visible {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(95, 159, 232, 0.15);
}

@media (max-width: 760px) {
    [data-theme="dark"] .student-context-bar { min-height: 54px; }
    [data-theme="dark"] .context-kicker,
    [data-theme="dark"] .knowledge-status { display: none; }
    [data-theme="dark"] .welcome-panel { padding: 22px 20px; border-radius: 18px; }
    [data-theme="dark"] .welcome-panel h1 { font-size: 27px; }
    [data-theme="dark"] .welcome-panel p { font-size: 13px; }
    [data-theme="dark"] .suggested-questions { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    [data-theme="dark"] .suggestion-pill { transition: none; }
}

[data-theme="dark"] .message-row.ai .message-bubble {
    width: auto;
    max-width: min(90%, 760px);
    padding: 0;
    border: 0;
    border-left: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
[data-theme="dark"] .chat-divider { background: #234363; }

/* Dark-theme prompt parity - final cascade */
[data-theme="dark"] .suggested-questions { display: grid; grid-template-columns: 1fr; gap: 2px; margin-top: 14px; }
[data-theme="dark"] .suggestion-pill {
    justify-content: flex-start;
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-align: left;
}
[data-theme="dark"] .suggestion-pill:hover,
[data-theme="dark"] .suggestion-pill:focus-visible { border: 0; background: var(--surface-low); color: var(--text); transform: none; }
@media (max-width: 640px) {
    [data-theme="dark"] .welcome-panel h1 { width: 100%; text-align: center; }
    [data-theme="dark"] .suggested-questions { margin: 6px 0 10px; }
    [data-theme="dark"] .suggestion-pill { min-height: 38px; padding: 7px 8px; }
}

[data-theme="dark"] .suggested-questions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    margin-top: 14px;
}
[data-theme="dark"] .suggestion-pill {
    justify-content: flex-start;
    min-height: 40px;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-align: left;
}
[data-theme="dark"] .suggestion-pill:hover,
[data-theme="dark"] .suggestion-pill:focus-visible { border: 0; background: var(--surface-low); color: var(--text); transform: none; }
@media (max-width: 640px) {
    [data-theme="dark"] .welcome-panel h1 { text-align: center; }
    [data-theme="dark"] .suggested-questions { margin: 6px 0 10px; }
    [data-theme="dark"] .suggestion-pill { min-height: 38px; padding: 7px 8px; }
}

/* Theme parity: dark mode keeps the same minimal structure as light mode. */
[data-theme="dark"] .sidebar {
    background: #062b5c;
    border-right: 0;
    box-shadow: 1px 0 0 rgba(2, 25, 58, 0.22);
}
[data-theme="dark"] .new-chat-action { border: 0 !important; background: transparent !important; }
[data-theme="dark"] .conversation-item.active {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: none;
}
[data-theme="dark"] .conversation-group-label {
    color: var(--sidebar-text);
    letter-spacing: 0;
    text-transform: none;
}
[data-theme="dark"] .student-context-bar { min-height: 52px; border-bottom: 0; }
[data-theme="dark"] .context-kicker,
[data-theme="dark"] .knowledge-status { display: none; }
[data-theme="dark"] .welcome-panel {
    gap: 12px;
    margin-bottom: 28px;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
[data-theme="dark"] .welcome-panel::after { display: none; }
[data-theme="dark"] .welcome-panel h1 {
    max-width: 700px;
    font-size: clamp(23px, 3vw, 30px);
    font-weight: 500;
    line-height: normal;
}
[data-theme="dark"] .welcome-panel p { max-width: 620px; font-size: inherit; line-height: inherit; }
[data-theme="dark"] .suggested-questions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    margin-top: 14px;
}
[data-theme="dark"] .suggestion-pill {
    justify-content: flex-start;
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-align: left;
}
[data-theme="dark"] .suggestion-pill:hover,
[data-theme="dark"] .suggestion-pill:focus-visible {
    border: 0;
    background: var(--surface-low);
    color: var(--text);
    transform: none;
}
@media (max-width: 640px) {
    [data-theme="dark"] .welcome-panel h1 { width: 100%; text-align: center; }
    [data-theme="dark"] .suggested-questions { margin: 6px 0 10px; }
    [data-theme="dark"] .suggestion-pill { min-height: 38px; padding: 7px 8px; }
}
[data-theme="dark"] .composer {
    border: 0;
    border-radius: 28px;
    background: var(--composer-bg);
    box-shadow: 0 0 0 1px var(--border);
}
[data-theme="dark"] .composer:hover,
[data-theme="dark"] .composer:focus-within { border: 0; box-shadow: 0 0 0 1px var(--outline); }

[data-theme="dark"] .message-row.ai .message-bubble {
    width: auto;
    max-width: min(90%, 760px);
    padding: 0;
    border: 0;
    border-left: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
[data-theme="dark"] .chat-divider { background: #234363; }
