/* ============================================================
   mathe.zhl-ubt.de — Main Stylesheet
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
    --accent: #0d9488;
    --accent-dk: #0f766e;
    --success: #248a3d;
    --warning: #e47911;
    --danger: #d70015;
    --text: #1d1d1f;
    --muted: #86868b;
    --bg: #f5f5f7;
    --white: #ffffff;
    --border: rgba(0,0,0,.08);
    --radius: 12px;
    --shadow: 0 1px 4px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.03);
    --shadow-lg: 0 8px 40px rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.04);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────── */
.page-wrap { max-width: 1100px; margin: 0 auto; padding: 5.5rem 1.5rem 2rem; }
.page-wrap-narrow { max-width: 760px; margin: 0 auto; padding: 5.5rem 1.5rem 2rem; }
.page-title { font-size: 1.5rem; margin-bottom: 1.5rem; font-weight: 700; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header .page-title { margin-bottom: 0; }
.section-title { font-size: 1.1rem; margin: 2rem 0 1rem; color: var(--muted); font-weight: 600; }
.subsection-title { font-size: .95rem; margin-bottom: .75rem; font-weight: 600; }
.back-link { color: var(--muted); font-size: .85rem; }
.back-link:hover { color: var(--accent); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card-header {
    padding: .75rem 1.25rem;
    font-weight: 600;
    font-size: .9rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    align-items: center;
}
.card-body { padding: 1.25rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1.1rem; font-size: .88rem; font-weight: 500;
    border: 1px solid transparent; border-radius: 8px; cursor: pointer;
    text-decoration: none; transition: all .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn-secondary { background: rgba(0,0,0,.04); color: var(--text); border-color: rgba(0,0,0,.1); }
.btn-secondary:hover { background: rgba(0,0,0,.07); border-color: rgba(0,0,0,.15); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; border-radius: 6px; }
.btn-block { display: flex; width: 100%; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; color: var(--text); }
.form-control {
    display: block; width: 100%;
    padding: .55rem .75rem; font-size: .88rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--white); color: var(--text);
    transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-control-sm { padding: .35rem .55rem; font-size: .82rem; }
textarea.form-control { resize: vertical; min-height: 80px; }
textarea.resizable { resize: both; }
.form-hint { display: block; margin-top: .25rem; font-size: .78rem; color: var(--muted); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-actions { display: flex; gap: .5rem; margin-top: 1.5rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .88rem; }
select.form-control { appearance: auto; }
.mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: .82rem; }
.divider { margin: 1.25rem 0; border: none; border-top: 1px solid var(--border); }

/* ── Data Tables ──────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: .6rem .75rem; text-align: left;
    font-size: .78rem; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .03em;
    background: #f8fafc; border-bottom: 1px solid var(--border);
}
.data-table td { padding: .6rem .75rem; border-bottom: 1px solid #f1f5f9; font-size: .88rem; }
.data-table tbody tr:hover { background: #f8fafc; }
.sortable-col { cursor: pointer; user-select: none; }
.sortable-col:hover { color: var(--accent); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: .15rem .5rem;
    font-size: .72rem; font-weight: 600; border-radius: 4px;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.badge-draft { background: #dbeafe; color: #1e40af; }

/* ── Flash Messages ───────────────────────────────────────── */
.flash {
    padding: .65rem 1rem; border-radius: 8px;
    font-size: .88rem; margin-bottom: 1rem;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.5); align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 1.5rem;
    width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { margin-bottom: 1rem; font-size: 1.1rem; }
.modal-lg { max-width: 720px; }

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem; text-align: center;
    box-shadow: var(--shadow);
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.stat-sub { font-size: .72rem; color: var(--muted); }

/* ── Menu Grid ────────────────────────────────────────────── */
.menu-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.menu-card {
    display: block; background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    box-shadow: var(--shadow); transition: all .15s;
    text-decoration: none; color: var(--text);
}
.menu-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }
.menu-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.menu-title { font-weight: 600; font-size: .95rem; margin-bottom: .25rem; }
.menu-desc { font-size: .8rem; color: var(--muted); }

/* ── Admin Nav ────────────────────────────────────────────── */
.admin-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: rgba(30, 41, 59, .95); backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,.1);
    height: 52px;
}
.admin-nav-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; height: 100%;
    padding: 0 1.5rem; gap: 1rem;
}
.nav-brand {
    display: flex; align-items: center; gap: .5rem;
    color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem;
    flex-shrink: 0;
}
.nav-brand-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; background: var(--accent); border-radius: 8px;
    font-size: 1rem; color: #fff;
}
.nav-brand-text { white-space: nowrap; }
.nav-links { display: flex; gap: .15rem; flex: 1; overflow-x: auto; }
.nav-link {
    padding: .35rem .65rem; color: rgba(255,255,255,.7);
    font-size: .82rem; border-radius: 6px; white-space: nowrap;
    text-decoration: none; transition: all .1s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }
.nav-link.active { color: #fff; background: rgba(59,130,246,.3); }
.nav-right { display: flex; align-items: center; gap: .75rem; margin-left: auto; flex-shrink: 0; }
.nav-user { color: rgba(255,255,255,.6); font-size: .8rem; }
.nav-logout { color: rgba(255,255,255,.5) !important; }
.nav-logout:hover { color: #fff !important; }

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(160deg, #f5f5f7 0%, #e8e8ed 100%);
}
.login-card {
    background: var(--white); border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
    padding: 2.5rem; width: 100%; max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 1.75rem; }
.login-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 60px; height: 60px; background: linear-gradient(135deg, #0071e3, #0058b0);
    border-radius: 18px; color: #fff; font-size: 1.8rem; margin-bottom: .75rem;
}
.login-brand h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.login-brand p { color: var(--muted); font-size: .88rem; }
.login-footer { text-align: center; margin-top: 1.25rem; }
.login-footer a { color: var(--muted); font-size: .82rem; }
.token-input {
    text-align: center; font-size: 1.4rem !important; font-weight: 700;
    letter-spacing: .15em; text-transform: uppercase;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.token-display {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .88rem; font-weight: 700; letter-spacing: .1em;
}

/* ── Code Blocks ──────────────────────────────────────────── */
.code-block {
    background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
    padding: 1rem; font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .82rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
    overflow-x: auto;
}

/* ── Version Rows ─────────────────────────────────────────── */
.version-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: .5rem .75rem; border-bottom: 1px solid #f1f5f9;
}
.version-row:last-child { border-bottom: none; }
.version-current { background: #eff6ff; border-radius: 6px; }

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar { display: flex; gap: .35rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

/* ── Bulk Actions ─────────────────────────────────────────── */
.bulk-actions { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }

/* ── Evaluation Colors ────────────────────────────────────── */
.eval-good { color: var(--success); font-weight: 600; }
.eval-mid { color: var(--warning); font-weight: 600; }
.eval-poor { color: var(--danger); font-weight: 600; }

/* ── Chat History (Admin Analysis) ────────────────────────── */
.chat-history .chat-msg { max-width: 85%; margin-bottom: .5rem; }
.chat-msg-label { font-size: .72rem; font-weight: 600; color: var(--muted); margin-bottom: .15rem; text-transform: uppercase; letter-spacing: .03em; }
.chat-msg-content { font-size: .88rem; line-height: 1.55; }
.chat-msg-user .chat-msg-content { background: var(--accent); color: #fff; padding: .5rem .75rem; border-radius: 12px 12px 4px 12px; }
.chat-msg-assistant .chat-msg-content { background: var(--white); border: 1px solid var(--border); padding: .5rem .75rem; border-radius: 12px 12px 12px 4px; }

/* ── Accent Background ───────────────────────────────────── */
:root { --accent-bg: #eff6ff; }

/* ── Rate Limit Bar ──────────────────────────────────────── */
.rate-limit-bar {
    display: flex; align-items: center; justify-content: center;
    padding: .3rem .75rem; font-size: .78rem; font-weight: 500;
    border-radius: 6px; margin-bottom: .5rem;
}
.rate-limit-low { background: #fef3c7; color: #92400e; }
.rate-limit-empty { background: #fee2e2; color: #991b1b; }

/* ── Log Viewer ──────────────────────────────────────────── */
.log-viewer {
    font-family: 'SF Mono', 'Fira Code', monospace; font-size: .78rem;
    line-height: 1.45; margin: 0; padding: .75rem 1rem; white-space: pre-wrap; word-break: break-all;
}
.log-line { display: block; padding: .1rem 0; border-bottom: 1px solid #f8fafc; }
.log-error { color: var(--danger); background: #fef2f2; }
.log-warning { color: #92400e; background: #fffbeb; }

/* ── Streaming ────────────────────────────────────────────── */
.chat-bubble.streaming { white-space: pre-wrap; }
.streaming-cursor {
    display: inline-block; width: 2px; height: 1em;
    background: var(--accent); margin-left: 2px;
    animation: blink .6s infinite;
    vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── KaTeX render containers ──────────────────────────────── */
.katex-render { /* initial state: preserve whitespace until KaTeX runs */ }
.katex-display { margin: .5em 0; }

/* ── Text Utilities ───────────────────────────────────────── */
.text-muted { color: var(--muted); }

/* ── OCR Link in Chat ─────────────────────────────────────── */
.ocr-show-link { color: var(--accent); font-weight: 500; cursor: pointer; }
.ocr-show-link:hover { text-decoration: underline; }

/* ── Prompt Card ──────────────────────────────────────────── */
.prompt-card .card-header { font-size: .85rem; }

/* ============================================================
   STUDENT APP — Apple-inspired Design
   ============================================================ */
.app-page {
    display: flex; height: 100vh; overflow: hidden;
    background: #1c1c1e;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 290px; flex-shrink: 0; display: flex; flex-direction: column;
    background: linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%);
    color: #f5f5f7; height: 100vh;
    border-right: 1px solid rgba(255,255,255,.08);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.sidebar-header {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.1rem 1.25rem;
    background: rgba(255,255,255,.04);
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-toggle {
    background: none; border: none; color: #f5f5f7;
    font-size: 1.15rem; cursor: pointer; padding: .25rem; display: none;
    border-radius: 6px; transition: background .15s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.08); }
.sidebar-title {
    font-weight: 700; font-size: 1rem; letter-spacing: -.02em;
    color: #f5f5f7;
}
.sidebar-content {
    flex: 1; overflow-y: auto; padding: .85rem .75rem;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent;
}
.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    color: rgba(255,255,255,.35); margin-bottom: .5rem; padding-left: .4rem;
    font-weight: 600;
}
.sidebar-footer {
    padding: .85rem 1rem; border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-footer .btn {
    background: rgba(255,255,255,.06); color: rgba(255,255,255,.6);
    border-color: rgba(255,255,255,.1);
}
.sidebar-footer .btn:hover {
    background: rgba(255,255,255,.1); color: #fff;
}

/* Nickname form */
.nickname-form { display: flex; gap: .35rem; }
.nickname-form .form-control {
    background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.1);
    color: #f5f5f7; border-radius: 10px; font-size: .82rem;
}
.nickname-form .form-control:focus {
    background: rgba(255,255,255,.12); border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13,148,136,.25);
}
.nickname-form .form-control::placeholder { color: rgba(255,255,255,.3); }
.nickname-form .btn {
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.7);
    border-color: rgba(255,255,255,.1);
}

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 3px; }
.task-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: .6rem .85rem; border-radius: 10px; cursor: pointer;
    color: rgba(255,255,255,.75); font-size: .85rem; text-decoration: none;
    transition: all .2s ease;
}
.task-item:hover {
    background: rgba(255,255,255,.06); text-decoration: none;
    color: #fff;
}
.task-item.active {
    background: linear-gradient(135deg, #0d9488, #2dd4bf);
    color: #fff;
    box-shadow: 0 4px 16px rgba(13,148,136,.35);
}
.task-item.task-inactive { opacity: .4; }
.task-badge {
    font-size: .62rem; background: rgba(255,255,255,.1);
    padding: .12rem .4rem; border-radius: 5px; font-weight: 500;
    color: rgba(255,255,255,.5);
}
.task-item.active .task-badge {
    background: rgba(255,255,255,.2); color: #fff;
}
.task-empty { color: rgba(255,255,255,.25); font-size: .82rem; padding: .5rem .35rem; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    flex: 1; display: flex; flex-direction: column;
    min-width: 0; height: 100vh;
    background: #000;
    border-radius: 16px 0 0 16px;
    overflow: hidden;
    margin: 0;
}

/* Task header */
.task-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.5rem;
    background: rgba(28,28,30,.92);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
}
.task-header h2 {
    font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em;
    color: #f5f5f7;
}
.task-header .btn {
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.7);
    border-color: rgba(255,255,255,.12);
}
.task-header .btn:hover {
    background: rgba(255,255,255,.14); color: #fff;
}

/* Assignment panel (expandable) */
.assignment-panel {
    max-height: 0; overflow: hidden;
    background: linear-gradient(180deg, rgba(13,148,136,.12) 0%, rgba(13,148,136,.05) 100%);
    border-bottom: 1px solid rgba(13,148,136,.2); position: relative;
    transition: max-height .35s cubic-bezier(.32,.72,0,1);
}
.assignment-panel.expanded { max-height: 400px; overflow-y: auto; }
.assignment-content {
    padding: 1.5rem; font-size: .92rem; line-height: 1.75;
    color: rgba(255,255,255,.85);
}
.assignment-close {
    position: absolute; top: .65rem; right: .85rem;
    background: rgba(255,255,255,.1); border: none; font-size: 1rem;
    cursor: pointer; color: rgba(255,255,255,.5); line-height: 1;
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.assignment-close:hover { background: rgba(255,255,255,.2); }

/* Empty state */
.empty-state {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: rgba(255,255,255,.35);
    background: #000;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 1.25rem; opacity: .5; }
.empty-state h2 {
    font-size: 1.5rem; color: #f5f5f7; margin-bottom: .5rem;
    font-weight: 600; letter-spacing: -.03em;
}
.empty-state p { font-size: .92rem; }

/* ── Chat ─────────────────────────────────────────────────── */
.chat-container {
    flex: 1; overflow-y: auto; padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1rem;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
    background: #000;
}
.chat-welcome {
    flex: 1; display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,.3); font-size: .92rem;
}
.chat-msg {
    display: flex; flex-direction: column; max-width: 72%;
    animation: msgAppear .3s cubic-bezier(.32,.72,0,1);
}
@keyframes msgAppear {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-msg-user { align-self: flex-end; align-items: flex-end; }
.chat-msg-assistant { align-self: flex-start; align-items: flex-start; }
.chat-msg-system { align-self: center; }

.chat-bubble {
    padding: .75rem 1.1rem; border-radius: 20px;
    font-size: .9rem; line-height: 1.6; word-wrap: break-word;
}
.chat-msg-user .chat-bubble {
    background: linear-gradient(135deg, #0d9488, #2dd4bf);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 12px rgba(13,148,136,.3);
}
.chat-msg-assistant .chat-bubble {
    background: #1c1c1e;
    color: rgba(255,255,255,.88);
    border: 1px solid rgba(255,255,255,.08);
    border-bottom-left-radius: 6px;
}
.chat-msg-system .chat-bubble {
    background: rgba(255,204,0,.12); color: #ffd60a; font-size: .82rem;
    border-radius: 12px; border: 1px solid rgba(255,204,0,.15);
}
.chat-meta {
    font-size: .66rem; color: rgba(255,255,255,.25);
    margin-top: .3rem; padding: 0 .3rem;
}

/* Typing indicator */
.typing { display: flex; gap: .3rem; padding: .7rem 1rem; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.3);
    animation: typing .8s infinite alternate;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { to { opacity: .15; transform: translateY(-3px); } }

/* File + OCR in chat */
.chat-file {
    display: flex; align-items: center; gap: .5rem;
    padding: .15rem 0; font-size: .88rem;
}
.chat-ocr-link a { color: #0d9488; font-weight: 500; }

/* ── Chat Input ───────────────────────────────────────────── */
.chat-input-area {
    padding: .85rem 1.25rem 1rem;
    background: rgba(28,28,30,.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0;
}
.chat-input-row {
    display: flex; align-items: flex-end; gap: .6rem;
}
.chat-textarea {
    flex: 1; resize: none;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 22px; padding: .65rem 1.1rem; font-size: .9rem;
    max-height: 150px; min-height: 42px; font-family: inherit;
    line-height: 1.45;
    background: rgba(255,255,255,.06);
    color: #f5f5f7;
    transition: all .2s ease;
}
.chat-textarea::placeholder { color: rgba(255,255,255,.3); }
.chat-textarea:focus {
    outline: none; border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13,148,136,.2);
    background: rgba(255,255,255,.09);
}
.chat-upload-btn, .chat-mic-btn, .chat-send-btn {
    background: none; border: none; font-size: 1.2rem;
    cursor: pointer; padding: .4rem; color: rgba(255,255,255,.35);
    border-radius: 50%; line-height: 1; flex-shrink: 0;
    transition: all .15s ease;
}
.chat-upload-btn:hover, .chat-mic-btn:hover {
    color: #0d9488; background: rgba(13,148,136,.12);
}
.chat-send-btn {
    font-size: 1.2rem;
    background: linear-gradient(135deg, #0d9488, #2dd4bf);
    color: #fff; border-radius: 50%;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px rgba(13,148,136,.3);
    transition: all .2s ease;
}
.chat-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 18px rgba(13,148,136,.45);
}

.chat-disabled {
    text-align: center; color: rgba(255,255,255,.3); font-size: .85rem;
    background: rgba(255,255,255,.03);
}

/* ── OCR Panel ────────────────────────────────────────────── */
.ocr-panel {
    width: 0; flex-shrink: 0; background: #1c1c1e;
    border-left: 1px solid rgba(255,255,255,.06); overflow: hidden;
    transition: width .3s cubic-bezier(.32,.72,0,1);
    height: 100vh; display: flex; flex-direction: column;
}
.ocr-panel.open { width: 380px; }
.ocr-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .95rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.06); flex-shrink: 0;
}
.ocr-header h3 { font-size: 1rem; font-weight: 600; color: #f5f5f7; }
.ocr-close {
    background: rgba(255,255,255,.08); border: none; font-size: .9rem;
    cursor: pointer; color: rgba(255,255,255,.5); line-height: 1;
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.ocr-close:hover { background: rgba(255,255,255,.15); }
.ocr-content {
    flex: 1; overflow-y: auto; padding: 1.25rem; font-size: .9rem;
    color: rgba(255,255,255,.75);
}

/* Sidebar backdrop (mobile overlay) */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 49;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Modal (Apple style) ─────────────────────────────────── */
.app-page .modal-overlay {
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.app-page .modal-box {
    background: #2c2c2e; color: #f5f5f7;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.08);
}
.app-page .modal-box h3 { color: #f5f5f7; }
.app-page .modal-box .btn-secondary {
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.7);
    border-color: rgba(255,255,255,.12);
}
.app-page .modal-box .btn-secondary:hover {
    background: rgba(255,255,255,.14); color: #fff;
}

/* ── Login Page ──────────────────────────────────────────── */
.login-page {
    background: #000;
    background-image: radial-gradient(ellipse at 30% 20%, rgba(13,148,136,.15) 0%, transparent 50%),
                      radial-gradient(ellipse at 70% 80%, rgba(45,212,191,.1) 0%, transparent 50%);
}
.login-card {
    background: rgba(44,44,46,.8);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
    color: #f5f5f7;
}
.login-brand h1 { color: #f5f5f7; }
.login-brand p { color: rgba(255,255,255,.45); }
.login-icon {
    background: linear-gradient(135deg, #0d9488, #2dd4bf);
    border-radius: 22px;
    box-shadow: 0 4px 20px rgba(13,148,136,.35);
}
.login-card .form-control {
    background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1);
    color: #f5f5f7;
}
.login-card .form-control:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13,148,136,.25);
    background: rgba(255,255,255,.1);
}
.login-card .form-control::placeholder { color: rgba(255,255,255,.3); }
.login-card .form-hint { color: rgba(255,255,255,.35); }
.login-card .btn-primary {
    background: linear-gradient(135deg, #0d9488, #2dd4bf);
    border: none;
    box-shadow: 0 2px 12px rgba(13,148,136,.35);
}
.login-card .btn-primary:hover {
    box-shadow: 0 4px 20px rgba(13,148,136,.5);
    transform: translateY(-1px);
}
.login-card .btn-secondary {
    background: rgba(255,255,255,.07); color: rgba(255,255,255,.5);
    border-color: rgba(255,255,255,.1);
}
.login-card .btn-secondary:hover {
    background: rgba(255,255,255,.12); color: rgba(255,255,255,.8);
}
.login-footer a { color: rgba(255,255,255,.35); }
.login-footer a:hover { color: #0d9488; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .page-wrap, .page-wrap-narrow { padding-top: 4.5rem; padding-left: 1rem; padding-right: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .menu-grid { grid-template-columns: 1fr; }
    .nav-brand-text { display: none; }
    .nav-links { gap: 0; }
    .nav-link { font-size: .75rem; padding: .3rem .45rem; }

    /* Student app responsive */
    .sidebar {
        position: fixed; top: 0; left: 0; z-index: 50;
        transform: translateX(-100%);
        width: 100vw; max-width: 320px;
        box-shadow: 12px 0 40px rgba(0,0,0,.12);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-backdrop { display: block; }
    .sidebar-toggle { display: block; }

    .ocr-panel.open { position: fixed; top: 0; right: 0; z-index: 50; width: 100vw; }

    .chat-msg { max-width: 88%; }
    .chat-container { padding: 1rem; }
    .form-row { flex-direction: column; }
}

@media (max-width: 480px) {
    .login-card { margin: 1rem; padding: 1.5rem; }
    .admin-nav-inner { padding: 0 .75rem; }
}
