/* CPT_S 421 VTA - Document RAG System
   Light, modern learning-platform design system.
   Shared by: login, student dashboard, VTA chat. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Fira+Code:wght@400;500;600&display=swap');

:root {
    /* Surfaces */
    --bg-page: #f5f7fb;
    --bg-surface: #ffffff;
    --bg-subtle: #f2f5fa;
    --bg-input: #f1f5fd;

    /* Brand */
    --primary: #2f6bed;
    --primary-hover: #1f57d0;
    --primary-active: #1a4cb8;
    --primary-soft: #eaf1ff;
    --primary-soft-strong: #dbe7ff;
    --primary-ring: rgba(47, 107, 237, 0.12);
    --primary-fade: rgba(47, 107, 237, 0.08);

    /* Text */
    --text-strong: #101828;
    --text-main: #344054;
    --text-dim: #667085;
    --text-faint: #98a2b3;

    /* Borders */
    --border-subtle: #e4e8f0;
    --border-active: #b6cdfb;

    /* Status */
    --success: #12b76a;
    --success-soft: #e7f8f0;
    --warning: #f79009;
    --warning-soft: #fef4e6;
    --danger: #f04438;
    --danger-soft: #fdeceb;
    --info: #2f6bed;
    --violet: #7a5af8;
    --violet-soft: #f1edfe;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;

    /* Shape */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.08);
    --shadow-primary: 0 4px 14px rgba(47, 107, 237, 0.24);

    /* Legacy aliases kept so existing markup keeps working */
    --bg-deep: var(--bg-page);
    --bg-main: var(--bg-page);
    --bg-card: var(--bg-surface);
    --bg-elevated: var(--bg-subtle);
    --bg-input-legacy: var(--bg-input);
    --accent-primary: var(--primary);
    --accent-secondary: #12b76a;
    --accent-tertiary: #f04438;
    --accent-glow: var(--primary-ring);
    --text-bright: var(--text-strong);
    --text-accent: var(--primary);
    --shadow-glow: var(--shadow-primary);
}

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

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

button {
    font-family: inherit;
}

::selection {
    background: var(--primary-soft-strong);
    color: var(--text-strong);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d7dde8;
    border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: #bcc5d4;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================================================================
   SHARED PRIMITIVES
   ================================================================ */

.card-surface {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.eyebrow {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-strong);
}

.section-sub {
    font-size: 13.5px;
    color: var(--text-dim);
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    padding: 11px 18px;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
}

.btn-primary:active {
    background: var(--primary-active);
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-ghost {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    color: var(--text-main);
    padding: 10px 16px;
}

.btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-fade);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 13px 20px;
    font-size: 15px;
    border-radius: var(--radius-md);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    cursor: pointer;
    padding: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
    color: var(--primary);
    background: var(--primary-fade);
}

.icon-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.icon-tile.violet {
    background: var(--violet-soft);
    color: var(--violet);
}

.icon-tile.green {
    background: var(--success-soft);
    color: var(--success);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 44px 24px;
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    margin-bottom: 18px;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-strong);
}

.empty-state-text {
    font-size: 13.5px;
    color: var(--text-dim);
    max-width: 420px;
    margin-top: 6px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-dim);
    transition: color 0.15s ease;
}

.back-link:hover {
    color: var(--primary);
}

.back-link svg {
    width: 14px;
    height: 14px;
}

/* ================================================================
   AUTH PAGE
   ================================================================ */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    background:
        radial-gradient(900px 480px at 50% -10%, #e9f0ff 0%, transparent 60%),
        var(--bg-page);
}

.auth-container {
    width: 100%;
    max-width: 430px;
    animation: fadeInUp 0.45s ease both;
}

.auth-brand {
    text-align: center;
    margin-bottom: 26px;
}

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
}

.brand-mark svg {
    width: 30px;
    height: 30px;
}

.auth-brand h1 {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-strong);
}

.auth-brand p {
    font-size: 14.5px;
    color: var(--text-dim);
    margin-top: 6px;
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

.auth-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 26px;
}

.auth-tab {
    flex: 1;
    padding: 9px 0;
    background: none;
    border: none;
    border-radius: 7px;
    color: var(--text-dim);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.auth-tab:hover {
    color: var(--text-strong);
}

.auth-tab.active {
    background: var(--bg-surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
}

.input-group {
    margin-bottom: 18px;
}

.input-label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.input-shell {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-shell:focus-within {
    background: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.input-shell .field-icon {
    display: flex;
    align-items: center;
    color: var(--text-faint);
    flex-shrink: 0;
}

.input-shell .field-icon svg {
    width: 18px;
    height: 18px;
}

.input-shell input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-strong);
    font-family: inherit;
    font-size: 14.5px;
}

.input-shell input::placeholder {
    color: var(--text-faint);
}

.input-shell .toggle-pw {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 2px;
    transition: color 0.15s ease;
}

.input-shell .toggle-pw:hover {
    color: var(--primary);
}

.input-shell .toggle-pw svg {
    width: 18px;
    height: 18px;
}

.role-group {
    margin-bottom: 18px;
}

.role-options {
    display: flex;
    gap: 10px;
}

.role-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.18s ease;
}

.role-option:hover {
    border-color: var(--border-active);
}

.role-option input[type="radio"] {
    display: none;
}

.role-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-fade);
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.role-option .role-icon {
    font-size: 16px;
}

.auth-submit {
    width: 100%;
    margin-top: 22px;
}

.auth-status {
    margin-top: 16px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    display: none;
    align-items: center;
    gap: 8px;
}

.auth-status.error {
    display: flex;
    background: var(--danger-soft);
    border: 1px solid #fbd5d2;
    color: var(--danger);
}

.auth-status.success {
    display: flex;
    background: var(--success-soft);
    border: 1px solid #c3ecd9;
    color: #067647;
}

.auth-status.loading {
    display: flex;
    background: var(--primary-fade);
    border: 1px solid var(--primary-soft-strong);
    color: var(--primary);
}

.status-prefix {
    font-weight: 700;
}

.auth-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 14px;
    color: var(--text-dim);
}

.auth-footer a {
    font-weight: 600;
}

.auth-back {
    display: flex;
    justify-content: center;
    margin-top: 26px;
}

.spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ================================================================
   STUDENT DASHBOARD
   ================================================================ */

.dash-page {
    min-height: 100vh;
    background: var(--bg-page);
    padding: 34px 28px 56px;
}

.dash-container {
    max-width: 1180px;
    margin: 0 auto;
}

.dash-title {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-strong);
    margin-top: 8px;
}

.dash-title .accent {
    color: var(--primary);
}

.dash-sub {
    font-size: 14.5px;
    color: var(--text-dim);
    margin-top: 6px;
}

.dash-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.dash-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.dash-user-chip .chip-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-strong);
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: 20px 22px 22px;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-active);
}

.stat-trend {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--primary);
    opacity: 0.7;
}

.stat-trend svg {
    width: 18px;
    height: 18px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-strong);
    line-height: 1;
    margin-top: 18px;
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-top: 12px;
}

.stat-hint {
    font-size: 12.5px;
    color: var(--text-faint);
    margin-top: 4px;
}

/* Analytics block */
.analytics-card {
    margin-top: 16px;
    padding: 22px;
}

.analytics-card canvas {
    max-width: 100%;
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 260px;
    margin-top: 18px;
}

/* Two column area */
.dash-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    margin-top: 16px;
    align-items: start;
}

.classroom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.classroom-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    cursor: pointer;
    text-align: left;
    transition: all 0.18s ease;
}

.classroom-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.classroom-card .classroom-body {
    flex: 1;
    min-width: 0;
}

.classroom-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.classroom-meta {
    display: block;
    font-size: 12.5px;
    color: var(--text-faint);
    margin-top: 3px;
}

.classroom-card .classroom-go {
    color: var(--text-faint);
    transition: color 0.18s ease, transform 0.18s ease;
}

.classroom-card:hover .classroom-go {
    color: var(--primary);
    transform: translateX(3px);
}

.dashed-panel {
    border: 1.5px dashed var(--border-subtle);
    border-radius: var(--radius-xl);
    background: var(--bg-surface);
}

/* Join class card */
.join-card {
    padding: 22px;
}

.join-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-strong);
}

.join-card .input-shell {
    margin-top: 16px;
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}

.join-card .input-shell:focus-within {
    border-color: var(--primary);
    background: var(--bg-surface);
}

.join-card .input-shell input {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.join-btn {
    width: 100%;
    margin-top: 14px;
    background: var(--primary);
    color: #fff;
    padding: 11px 18px;
    box-shadow: var(--shadow-primary);
}

.join-btn:hover {
    background: var(--primary-hover);
    color: #fff;
}

.join-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.dash-back {
    display: flex;
    justify-content: center;
    margin-top: 36px;
}

/* Toast */
.toast-stack {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1080;
}

.app-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--text-strong);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.2s ease both;
}

.app-toast.success {
    background: #067647;
}

.app-toast.error {
    background: var(--danger);
}

.app-toast svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Hidden File Input */
#fileInput {
    display: none;
}

/* ================================================================
   VTA CHAT
   ================================================================ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-page);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo {
    width: 36px;
    height: 36px;
    background: var(--primary-soft);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.logo svg {
    width: 20px;
    height: 20px;
}

.app-header h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header h1 span {
    color: var(--primary);
    font-weight: 600;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 12.5px;
    color: var(--text-dim);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 7px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.inactive {
    background: var(--warning);
}

.chat-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Welcome */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.welcome-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    margin-bottom: 22px;
}

.welcome-mark svg {
    width: 30px;
    height: 30px;
}

.welcome-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-strong);
}

.welcome-subtitle {
    font-size: 14.5px;
    color: var(--text-dim);
    margin-top: 8px;
    max-width: 520px;
}

.welcome-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 26px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.18s ease;
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.messages-container {
    max-width: 880px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeInUp 0.2s ease both;
}

.message-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    flex-shrink: 0;
    background: var(--primary-soft);
    color: var(--primary);
}

.message-avatar svg {
    width: 16px;
    height: 16px;
}

.message.user .message-avatar {
    background: var(--bg-subtle);
    color: var(--text-dim);
}

.message-content {
    flex: 1;
    min-width: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 14px 18px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text-main);
}

.message.user .message-content {
    background: var(--primary-soft);
    border-color: var(--primary-soft-strong);
}

.message-content code {
    font-family: var(--font-mono);
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 0.88em;
    color: var(--primary);
}

.message-content strong {
    color: var(--text-strong);
}

/* Citations */
.citations-container {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    white-space: normal;
}

.citations-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 10px;
}

.citation-item {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    white-space: normal;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.citation-item:hover {
    background: var(--primary-fade);
    border-left-color: var(--primary-hover);
}

.citation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
}

.citation-source,
.citation-link {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--primary);
}

.citation-link:hover {
    text-decoration: underline;
}

.citation-match {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--success);
    background: var(--success-soft);
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.citation-loc {
    font-size: 12.5px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.citation-text {
    font-size: 12.5px;
    color: var(--text-dim);
    font-style: italic;
}

.citation-type-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    margin-left: 8px;
}

.table-badge {
    background: var(--primary-soft);
    color: var(--primary);
}

.image-badge {
    background: var(--violet-soft);
    color: var(--violet);
}

.audio-badge {
    background: var(--warning-soft);
    color: #b54708;
}

.audio-citation .citation-audio-meta {
    font-size: 12.5px;
    color: var(--text-dim);
    margin-top: 4px;
    font-style: italic;
}

.table-citation .table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.table-citation .table-container table {
    border-collapse: collapse;
    width: 100%;
    margin: 0;
}

.table-citation .table-container th,
.table-citation .table-container td {
    border: 1px solid var(--border-subtle);
    padding: 6px 10px;
    text-align: left;
}

.table-citation .table-container th {
    background: var(--bg-subtle);
    color: var(--primary);
    font-weight: 600;
}

.table-citation .citation-description {
    font-size: 12.5px;
    color: var(--text-dim);
    margin: 8px 0 4px;
}

.image-citation .image-preview {
    margin-top: 10px;
    text-align: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px;
}

.image-citation .image-preview img {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.image-citation .citation-caption {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-main);
    line-height: 1.5;
}

.image-citation .citation-caption strong {
    color: var(--primary);
}

.image-citation .citation-ocr {
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--text-dim);
    background: var(--bg-subtle);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--violet);
}

.image-citation .citation-ocr strong {
    color: var(--violet);
}

/* Loading */
.loading-container {
    padding: 20px 24px;
    display: none;
}

.loading-container.active {
    display: block;
}

.cursor-line {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    color: var(--text-dim);
}

.cursor-line::after {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.25; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1); }
}

/* Input area */
.input-container {
    padding: 16px 24px 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
}

.input-wrapper {
    max-width: 880px;
    margin: 0 auto;
}

.command-line {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    padding: 10px 12px 10px 14px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.command-line:focus-within {
    background: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.prompt-symbol {
    display: flex;
    align-items: center;
    color: var(--primary);
    padding-bottom: 6px;
    user-select: none;
}

.prompt-symbol svg {
    width: 16px;
    height: 16px;
}

.input-area {
    flex: 1;
    min-width: 0;
}

#messageInput {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-strong);
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.55;
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 150px;
}

#messageInput::placeholder {
    color: var(--text-faint);
}

.attach-btn {
    background: var(--primary-soft);
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-btn:hover {
    background: var(--primary);
    color: #fff;
}

.attach-btn svg {
    width: 18px;
    height: 18px;
}

/* Attachments */
.files-bar {
    display: none;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.files-bar.active {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-main);
}

.file-tag .ext {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
}

.files-clear {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.files-clear:hover {
    background: var(--danger-soft);
}

.input-info {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 10px;
    text-align: center;
}

/* Inline toast used by the chat page */
.chat-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-strong);
    color: #fff;
    padding: 11px 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: fadeInUp 0.2s ease both;
}

/* Course buttons (used by student navigation lists) */
.course-btn {
    display: block;
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-strong);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.18s ease;
}

.course-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-fade);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1024px) {
    .dash-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .dash-page {
        padding: 24px 16px 40px;
    }

    .dash-title {
        font-size: 24px;
    }

    .auth-card {
        padding: 24px 20px;
    }

    .status-bar {
        display: none;
    }

    .chat-messages,
    .input-container {
        padding-left: 14px;
        padding-right: 14px;
    }
}
