/* ============================================
   УЧЕБЕН ЦЕНТЪР v2 — style.css
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

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

:root {
  --bg:       #f8f7f4;
  --surface:  #ffffff;
  --surface2: #f2f0eb;
  --border:   #e0ddd6;
  --border2:  #ccc9c0;
  --text:     #1a1916;
  --text2:    #6b6860;
  --text3:    #9c9a94;
  --accent:   #2563eb;
  --accent-bg:#eff6ff;
  --accent-b: #bfdbfe;
  --green:    #16a34a;
  --green-bg: #f0fdf4;
  --green-b:  #bbf7d0;
  --amber:    #d97706;
  --amber-bg: #fffbeb;
  --amber-b:  #fcd34d;
  --red:      #dc2626;
  --red-bg:   #fef2f2;
  --red-b:    #fca5a5;
  --r:        10px;
  --rl:       14px;
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }

/* ── AUTH ───────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-wrap { width: 100%; max-width: 400px; padding: 20px; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo-icon { font-size: 40px; }
.auth-logo h1 { font-size: 22px; font-weight: 600; margin-top: 8px; }
.auth-logo p  { color: var(--text3); font-size: 13px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); overflow: hidden; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); }
.auth-tab { flex: 1; padding: 14px; text-align: center; text-decoration: none; color: var(--text2);
            font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; transition: .15s; }
.auth-tab:hover  { color: var(--text); }
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-card form { padding: 22px; }
.auth-note { font-size: 12px; color: var(--text3); margin-top: 12px; text-align: center; }

/* ── ALERTS ─────────────────────────────── */
.alert { padding: 12px 16px; margin: 16px 16px 0; border-radius: var(--r); font-size: 13px; }
.alert-error   { background: var(--red-bg);   border: 1px solid var(--red-b);   color: var(--red);   }
.alert-success { background: var(--green-bg); border: 1px solid var(--green-b); color: var(--green); }

/* ── FORMS ──────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-group input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r);
                    font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
                    outline: none; transition: .15s; }
.form-group input:focus { border-color: var(--accent); }
.hint-text { font-size: 12px; color: var(--text3); font-weight: 400; }

/* ── BUTTONS ────────────────────────────── */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 10px 20px;
               border-radius: var(--r); font-size: 14px; font-weight: 500; cursor: pointer;
               font-family: inherit; transition: .15s; }
.btn-primary:hover { background: #1d4ed8; }
.btn-full { width: 100%; }
.btn-sm { padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--r);
          background: var(--surface2); color: var(--text2); font-size: 12px; cursor: pointer;
          font-family: inherit; transition: .15s; text-decoration: none; display: inline-block; }
.btn-sm:hover { background: var(--border); color: var(--text); }
.btn-sm.btn-danger { border-color: var(--red-b); color: var(--red); background: var(--red-bg); }
.btn-sm.btn-danger:hover { background: var(--red-b); }
.modal-select { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r);
                font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); outline: none; }

/* ── APP LAYOUT ─────────────────────────── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ────────────────────────────── */
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border);
           display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; }
.sidebar-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border);
                display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 20px; }
.logo-text { font-weight: 600; font-size: 14px; }
.sidebar-section-label { padding: 12px 14px 4px; font-size: 11px; font-weight: 600;
                          color: var(--text3); text-transform: uppercase; letter-spacing: .05em; }
.subject-nav { flex: 1; overflow-y: auto; padding: 4px 8px; }
.subject-link { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
                border-radius: var(--r); text-decoration: none; color: var(--text);
                font-size: 13px; margin-bottom: 2px; transition: .12s; }
.subject-link:hover  { background: var(--surface2); }
.subject-link.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; border: 1px solid var(--accent-b); }
.subject-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.add-subject-btn { margin: 8px; border: 1px dashed var(--border2); background: none;
                   cursor: pointer; color: var(--text2); font-size: 13px; padding: 8px;
                   border-radius: var(--r); font-family: inherit; transition: .12s; }
.add-subject-btn:hover { background: var(--surface2); color: var(--text); }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text2); }
.sidebar-footer-links { margin-top: 4px; }
.sidebar-footer-links a { color: var(--text3); text-decoration: none; font-size: 12px; }
.sidebar-footer-links a:hover { color: var(--accent); }

/* ── MAIN ───────────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; min-height: 0; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center;
               justify-content: center; color: var(--text2); padding: 40px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 18px; margin-bottom: 8px; }
#subjectView { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }
.subject-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex;
                   align-items: center; gap: 10px; background: var(--surface); flex-shrink: 0; }
.subject-header-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.subject-header h2  { font-size: 16px; font-weight: 600; }

/* ── TABS ───────────────────────────────── */
.tabs-bar { display: flex; border-bottom: 1px solid var(--border); background: var(--surface);
            flex-shrink: 0; padding: 0 16px; overflow-x: auto; }
.tab { padding: 11px 14px; font-size: 13px; cursor: pointer; background: none; border: none;
       color: var(--text2); border-bottom: 2px solid transparent; transition: .12s;
       font-weight: 500; font-family: inherit; white-space: nowrap; }
.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { flex: 1; overflow-y: auto; padding: 18px 20px; min-height: 0; -webkit-overflow-scrolling: touch; }
.tab-content.chat-tab { overflow: hidden; padding: 0; }
.tab-intro   { font-size: 13px; color: var(--text2); margin-bottom: 14px; }

/* ── UPLOAD ─────────────────────────────── */
.upload-zone { display: block; border: 1.5px dashed var(--border2); border-radius: var(--rl);
               padding: 24px; text-align: center; cursor: pointer; transition: .15s;
               margin-bottom: 16px; background: var(--surface); }
.upload-zone:hover { border-color: var(--accent); background: var(--accent-bg); }
.upload-zone input { display: none; }
.upload-icon { font-size: 24px; margin-bottom: 8px; }
.progress-bar-wrap  { background: var(--border); border-radius: 999px; height: 6px; overflow: hidden;
                       margin-bottom: 12px; }
.progress-bar-inner { height: 100%; background: var(--accent); transition: width .3s; border-radius: 999px; }

/* ── LECTURE ACTIONS ────────────────────── */
.lecture-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
                   padding: 10px 14px; background: var(--amber-bg); border: 1px solid var(--amber-b);
                   border-radius: var(--r); }
.btn-lecture  { padding: 7px 14px; border: 1px solid var(--amber-b); border-radius: var(--r);
                background: #fff; color: var(--amber); font-size: 13px; font-weight: 500;
                cursor: pointer; font-family: inherit; transition: .12s; white-space: nowrap; }
.btn-lecture:hover { background: var(--amber-bg); }
.lecture-hint { font-size: 12px; color: var(--amber); }
.materials-toolbar-wrap { position: sticky; top: -18px; z-index: 5;
                          background: linear-gradient(to bottom, rgba(248,247,244,.99), rgba(248,247,244,.95));
                          backdrop-filter: blur(10px); padding: 8px 0 12px; margin-bottom: 12px; }
.materials-toolbar { display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
                     margin-bottom: 10px; padding: 14px; border: 1px solid #e7ddd0; border-radius: 18px;
                     background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,248,243,.96));
                     box-shadow: 0 10px 30px rgba(26,25,22,.04); }
.materials-toolbar-main { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 0; }
.materials-toolbar-card { display: flex; flex-direction: column; justify-content: center; gap: 6px;
                          min-width: 150px; padding: 10px 12px; border: 1px solid #ebe4d9; border-radius: 14px;
                          background: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.7); }
.materials-toolbar-search { flex: 1 1 260px; min-width: 240px; }
.materials-toolbar-label { font-size: 11px; color: var(--text3); font-weight: 700; white-space: nowrap;
                           text-transform: uppercase; letter-spacing: .05em; }
.materials-toolbar-card select,
.materials-toolbar-card input { width: 100%; min-width: 0; padding: 0; border: none; background: transparent; color: var(--text);
                                font-size: 14px; font-family: inherit; outline: none; height: 22px; box-shadow: none;
                                -webkit-appearance: none; appearance: none; }
.materials-toolbar-card input[type="date"] { min-width: 150px; }
.materials-toolbar-card:focus-within { border-color: var(--accent-b); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.materials-clear-btn { align-self: center; height: 42px; padding: 0 16px; background: #fff; border-radius: 999px;
                       border-color: #ddd4c7; }
.materials-counts { display: flex; gap: 8px; flex-wrap: wrap; }
.count-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px;
               border: 1px solid var(--border); background: var(--surface); color: var(--text2);
               font-size: 12px; cursor: pointer; font-family: inherit; transition: .12s; }
.count-badge strong { color: var(--text); font-size: 12px; }
.count-badge:hover { border-color: var(--border2); color: var(--text); background: var(--surface2); }
.count-badge.active { border-color: var(--accent-b); background: var(--accent-bg); color: var(--accent); }
.count-badge.active strong { color: var(--accent); }

.material-group { margin-bottom: 18px; }
.material-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
                       margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.material-group-title { font-size: 12px; font-weight: 700; color: var(--text2); text-transform: uppercase;
                        letter-spacing: .04em; }
.material-group-count { font-size: 11px; color: var(--text3); background: var(--surface2);
                        border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* ── MATERIAL CARDS ─────────────────────── */
.mat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl);
            padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px;
            margin-bottom: 8px; transition: .12s; }
.mat-card:hover    { border-color: var(--border2); }
.mat-card.dragging { opacity: .4; }
.mat-card.drag-over { border-color: var(--accent); background: var(--accent-bg); }
.mat-card.drag-disabled .drag-handle { opacity: .35; cursor: default; }
.mat-select { display: inline-flex; align-items: center; justify-content: center; padding-top: 3px; }
.mat-select input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.drag-handle { cursor: grab; color: var(--text3); font-size: 16px; padding: 2px 4px; user-select: none; }
.mat-icon    { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.mat-info    { flex: 1; min-width: 0; }
.mat-name    { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mat-meta    { font-size: 12px; color: var(--text3); margin-top: 2px; }
.mat-summary { font-size: 13px; color: var(--text2); margin-top: 8px; line-height: 1.6;
               border-top: 1px solid var(--border); padding-top: 8px; white-space: pre-wrap; }
.mat-summary.muted { color: var(--text3); font-style: italic; }
.mat-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.semester-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.materials-bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px;
                      margin-bottom: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.materials-bulk-left,
.materials-bulk-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.materials-bulk-count { font-size: 12px; color: var(--text2); }

.type-badge           { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.type-badge.slide      { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.type-badge.pdf        { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.type-badge.docx       { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.type-badge.transcript { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.type-badge.notes      { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.type-badge.audio      { background: #fef9c3; color: #854d0e; border: 1px solid #fef08a; }
.empty-notice { text-align: center; padding: 30px; color: var(--text3); }

@media (max-width: 720px) {
  .materials-toolbar-wrap { top: -12px; }
  .materials-toolbar { flex-direction: column; padding: 10px; }
  .materials-toolbar-main { width: 100%; }
  .materials-toolbar-card,
  .materials-toolbar-search { flex: 1 1 100%; min-width: 0; width: 100%; }
  .materials-clear-btn { width: 100%; }
  .materials-bulk-bar { flex-direction: column; align-items: stretch; }
  .materials-bulk-left,
  .materials-bulk-right { width: 100%; }
  .materials-bulk-right .btn-primary,
  .materials-bulk-right .modal-select { width: 100%; }
  .mat-card { padding: 12px; gap: 8px; }
  .mat-actions > * { flex: 1 1 100%; text-align: center; }
}

/* ── CHAT ───────────────────────────────── */
.chat-layout { display: flex; gap: 0; height: 100%; min-height: 0; overflow: hidden; }
.chat-sessions-sidebar { width: 200px; flex-shrink: 0; display: flex; flex-direction: column;
                          border-right: 1px solid var(--border); padding: 12px 10px; gap: 10px;
                          overflow-y: auto; }
.new-session-btn { width: 100%; font-size: 13px; padding: 8px 10px; }
.sessions-list { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.no-sessions { font-size: 12px; color: var(--text3); text-align: center; padding: 10px 0; }
.session-item { display: flex; align-items: center; gap: 4px; border-radius: var(--r);
                padding: 6px 8px; cursor: pointer; transition: .12s; }
.session-item:hover { background: var(--surface2); }
.session-item.active { background: var(--surface2); border-left: 2px solid var(--accent); }
.session-title { flex: 1; font-size: 12px; color: var(--text2); line-height: 1.4;
                 overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.session-item.active .session-title { color: var(--text); font-weight: 500; }
.session-del { flex-shrink: 0; background: none; border: none; color: var(--text3); cursor: pointer;
               font-size: 11px; padding: 2px 4px; border-radius: 3px; line-height: 1; }
.session-del:hover { background: var(--red-bg); color: var(--red); }
.chat-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 18px 20px; overflow: hidden; }
.hint-bar  { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.hint-chip { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
             background: var(--surface); color: var(--text2); font-size: 12px;
             cursor: pointer; font-family: inherit; transition: .12s; }
.hint-chip:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }

.confidence-legend { display: flex; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.conf              { font-size: 11px; color: var(--text3); }

.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
                 padding-bottom: 8px; min-height: 150px; }
.chat-welcome  { text-align: center; padding: 30px 20px; color: var(--text2); font-size: 14px; line-height: 1.7; }

.msg           { max-width: 88%; }
.msg.user      { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg-label     { font-size: 11px; color: var(--text3); margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
.msg.user .msg-label { justify-content: flex-end; }
.bubble        { padding: 10px 14px; border-radius: var(--rl); font-size: 14px; line-height: 1.65;
                 border: 1px solid var(--border); white-space: pre-wrap; }
.msg.user .bubble      { background: var(--surface2); }
.msg.assistant .bubble { background: var(--surface); }
.bubble.typing         { color: var(--text3); font-style: italic; }
.msg.assistant .bubble { white-space: normal; }
.chat-md-h1, .chat-md-h2, .chat-md-h3 { font-weight: 700; color: var(--text); margin: 10px 0 6px; }
.chat-md-h1 { font-size: 18px; }
.chat-md-h2 { font-size: 16px; }
.chat-md-h3 { font-size: 15px; }
.chat-md-li { padding-left: 2px; margin: 3px 0; }
.error-inline          { color: var(--red); }

/* Confidence dots */
.conf-dot        { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.conf-dot.conf-high   { background: var(--green); }
.conf-dot.conf-medium { background: var(--amber); }
.conf-dot.conf-low    { background: var(--red); }

.chat-input-row { padding-top: 12px; border-top: 1px solid var(--border); margin-top: 12px;
                   display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }
.chat-input-row textarea { flex: 1; padding: 10px 12px; border: 1px solid var(--border);
                            border-radius: var(--r); font-size: 14px; font-family: inherit;
                            resize: none; background: var(--surface); color: var(--text);
                            outline: none; transition: .15s; }
.chat-input-row textarea:focus { border-color: var(--accent); }

/* ── EXAM ───────────────────────────────── */
.exam-box      { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); overflow: hidden; }
.exam-box-head { padding: 11px 14px; background: var(--surface2); border-bottom: 1px solid var(--border); font-weight: 500; }
.exam-semester-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: #fff; flex-wrap: wrap; }
.exam-semester-row select { min-width: 220px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; }
.exam-upload-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border);
                   background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,248,243,.96)); flex-wrap: wrap; }
.exam-upload-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px dashed var(--border2);
                   border-radius: 999px; background: #fff; cursor: pointer; color: var(--text); font-size: 13px; }
.exam-upload-btn:hover { border-color: var(--accent-b); background: var(--accent-bg); color: var(--accent); }
.exam-upload-btn input { display: none; }
.exam-upload-note { color: var(--text2); font-size: 12px; }
.exam-box textarea { width: 100%; padding: 12px 14px; border: none; background: var(--surface);
                     color: var(--text); font-size: 14px; font-family: inherit; resize: none;
                     outline: none; line-height: 1.6; }
.exam-box-foot { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.exam-dev-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); padding: 16px; margin-top: 16px; }
.exam-dev-head { font-weight: 600; margin-bottom: 12px; }
.exam-dev-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.exam-dev-controls select { min-width: 220px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
                            background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; }
.exam-dev-note { margin-top: 10px; color: var(--text2); font-size: 12px; }
.exam-dev-download { margin-bottom: 12px; }
.result-card   { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl);
                 padding: 16px; margin-top: 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.7; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); overflow: hidden; }
.info-card-head { padding: 11px 14px; background: var(--surface2); border-bottom: 1px solid var(--border); font-weight: 500; }
.info-card textarea { width: 100%; min-height: 220px; padding: 14px; border: none; resize: vertical; background: var(--surface);
                      color: var(--text); font-size: 14px; font-family: inherit; outline: none; line-height: 1.7; }
.info-actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.info-status { color: var(--text2); font-size: 13px; }
.section-divider { font-size: 12px; font-weight: 600; color: var(--text3); text-transform: uppercase;
                    letter-spacing: .05em; margin-bottom: 10px; padding-bottom: 6px;
                    border-bottom: 1px solid var(--border); }

/* Exam history cards */
.history-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
                margin-bottom: 8px; overflow: hidden; }
.history-head { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px;
                transition: .12s; }
.history-head:hover { background: var(--surface2); }
.history-date    { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.history-preview { font-size: 13px; color: var(--text2); flex: 1; overflow: hidden;
                    text-overflow: ellipsis; white-space: nowrap; }
.history-toggle  { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.history-body    { padding: 12px 14px; border-top: 1px solid var(--border); white-space: pre-wrap;
                    font-size: 13px; line-height: 1.7; color: var(--text); }
.history-questions { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface2); white-space: pre-wrap; }
.history-actions { margin-top: 12px; display: flex; gap: 8px; }

/* ── QUIZ ──────────────────────────────── */
.test-builder-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); padding: 16px; }
.test-builder-head { font-weight: 600; margin-bottom: 12px; }
.test-builder-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.test-builder-controls select { min-width: 220px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
                                background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; }
.test-builder-note { margin-top: 10px; color: var(--text2); font-size: 12px; }
.quiz-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); padding: 18px; margin-top: 16px; }
.quiz-head h3 { font-size: 18px; margin-bottom: 6px; }
.quiz-head p { color: var(--text2); font-size: 13px; }
.quiz-actions-top { margin: 14px 0; }
.quiz-questions { display: flex; flex-direction: column; gap: 14px; }
.quiz-question-card { border: 1px solid var(--border); border-radius: var(--r); padding: 14px; background: var(--surface2); }
.quiz-question-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.quiz-question-type { font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.quiz-option input { margin-top: 2px; accent-color: var(--accent); }
.quiz-open-answer { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; outline: none; }
.quiz-open-answer:focus { border-color: var(--accent); }
.quiz-answer-feedback { margin-top: 10px; }
.quiz-feedback { font-size: 13px; line-height: 1.6; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); }
.quiz-feedback.ok { background: var(--green-bg); border-color: var(--green-b); color: var(--green); }
.quiz-feedback.bad { background: var(--red-bg); border-color: var(--red-b); color: var(--red); }
.quiz-correct-answer { margin-top: 8px; padding: 9px 11px; border-radius: var(--r); background: var(--amber-bg); border: 1px solid var(--amber-b); color: #92400e; font-size: 13px; line-height: 1.6; }
.quiz-submit-row { margin-top: 16px; display: flex; justify-content: flex-end; }

@media (max-width: 920px) {
  .app-layout { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-head { padding: 12px 14px; }
  .subject-nav { display: flex; gap: 8px; overflow-x: auto; padding: 8px; }
  .subject-link { flex: 0 0 auto; margin-bottom: 0; border: 1px solid var(--border); background: var(--surface); }
  .add-subject-btn { margin: 8px; }
  .sidebar-footer { display: none; }
  .main-area { min-height: 0; }
  .subject-header { padding: 12px 14px; flex-wrap: wrap; }
  .tabs-bar { padding: 0 10px; }
  .tab-content { padding: 14px 12px; }
  .upload-zone { padding: 18px 14px; }
  .lecture-actions { flex-direction: column; align-items: stretch; }
  .chat-layout { flex-direction: column; }
  .chat-sessions-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 8px; flex-direction: row; flex-wrap: wrap; max-height: 120px; }
  .sessions-list { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .session-item { flex: 0 1 auto; max-width: 150px; }
  .chat-wrap { padding-left: 0; padding-top: 12px; }
  .chat-input-row { flex-direction: column; align-items: stretch; }
  .chat-input-row .btn-primary { width: 100%; }
  .msg { max-width: 100%; }
  .exam-semester-row,
  .exam-upload-row,
  .exam-dev-controls,
  .test-builder-controls,
  .info-actions,
  .cheat-sheet-actions,
  .modal-btns { flex-direction: column; align-items: stretch; }
  .exam-semester-row select,
  .exam-dev-controls select,
  .test-builder-controls select,
  .quiz-submit-row .btn-primary,
  .exam-dev-controls .btn-primary { min-width: 0; width: 100%; }
  .quiz-submit-row { justify-content: stretch; }
  .history-head { align-items: flex-start; flex-wrap: wrap; }
  .history-preview { white-space: normal; }
  .modal-box { width: min(94vw, 420px); padding: 18px; }
  .modal-box-lg { width: min(94vw, 900px); max-height: calc(100vh - 24px); }
}

/* ── CHEAT SHEET ────────────────────────── */
.cheat-actions { margin-bottom: 14px; }
.cheat-sheet-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); overflow: hidden; }
.cheat-sheet-actions { padding: 10px 14px; background: var(--surface2); border-bottom: 1px solid var(--border);
                        display: flex; gap: 8px; }
.cheat-content { padding: 16px; font-size: 13px; line-height: 1.8; white-space: pre-wrap;
                  font-family: 'Inter', monospace; color: var(--text); }

@media print {
  .sidebar, .tabs-bar, .subject-header, .cheat-sheet-actions, .chat-input-row, .hint-bar { display: none !important; }
  .cheat-content { font-size: 11px; }
}

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

/* ── EXPORT ─────────────────────────────── */
.export-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); padding: 20px; }
.export-box h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.export-box p  { font-size: 13px; color: var(--text2); margin-bottom: 16px; }
.export-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.export-options label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
#exportStatus { margin-top: 14px; }

/* ── STATUS MESSAGES ────────────────────── */
.loading-msg { padding: 16px; color: var(--text2); font-style: italic; font-size: 14px; }
.error-msg   { padding: 14px 16px; color: var(--red); font-size: 14px; background: var(--red-bg);
               border: 1px solid var(--red-b); border-radius: var(--r); margin-top: 10px; }
.success-msg { padding: 12px 16px; background: var(--green-bg); border: 1px solid var(--green-b);
               border-radius: var(--r); color: var(--green); font-size: 14px; margin-top: 12px; }
.success-msg a { color: var(--green); font-weight: 500; }

/* ── LOADING OVERLAY ────────────────────── */
.loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex;
                    align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(2px); }
.loading-box     { background: var(--surface); border-radius: var(--rl); padding: 28px 36px;
                    text-align: center; border: 1px solid var(--border); min-width: 220px; }
.loading-box p   { margin-top: 14px; font-size: 14px; color: var(--text2); }
.spinner         { width: 32px; height: 32px; border: 3px solid var(--border);
                    border-top-color: var(--accent); border-radius: 50%;
                    animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin  { to { transform: rotate(360deg); } }

/* ── MODAL ──────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex;
                  align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-box     { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl);
                  padding: 22px; width: 320px; box-shadow: 0 8px 32px rgba(0,0,0,.12); }
.modal-box h3  { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.modal-btns    { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-btns button { padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--r);
                      background: var(--surface2); cursor: pointer; font-size: 13px; font-family: inherit; }
.modal-btns button:hover { background: var(--border); }
.modal-box-lg  { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.material-viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.material-viewer-head h3 { margin-bottom: 0; }
.material-viewer-meta { font-size: 13px; color: var(--text2); margin-bottom: 12px; }
.material-viewer-body { white-space: pre-wrap; overflow: auto; border: 1px solid var(--border); border-radius: var(--r);
                        background: var(--surface2); padding: 16px; line-height: 1.7; font-size: 14px; min-height: 220px; }
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot    { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2.5px solid transparent; transition: .12s; }
.color-dot.selected { border-color: var(--text); }

/* ── ADMIN ──────────────────────────────── */
.admin-topbar { display: flex; align-items: center; justify-content: space-between;
                padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
                position: sticky; top: 0; z-index: 10; }
.admin-topbar-left  { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.admin-topbar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text2); }
.admin-badge { font-size: 11px; padding: 2px 8px; background: var(--accent-bg); color: var(--accent);
               border: 1px solid var(--accent-b); border-radius: 999px; }
.admin-wrap    { max-width: 900px; margin: 0 auto; padding: 24px 20px; }
.admin-section { margin-bottom: 32px; }
.section-title         { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.section-title.pending { color: var(--amber); }
.section-title.approved{ color: var(--green); }
.section-title.rejected{ color: var(--red);   }
.user-table-wrap { overflow-x: auto; }
.user-table      { width: 100%; border-collapse: collapse; background: var(--surface);
                    border: 1px solid var(--border); border-radius: var(--rl); overflow: hidden; }
.user-table th   { padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600;
                    color: var(--text2); background: var(--surface2); border-bottom: 1px solid var(--border); }
.user-table td   { padding: 11px 14px; font-size: 14px; border-bottom: 1px solid var(--border); }
.user-table tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-approve { padding: 5px 12px; border: 1px solid var(--green-b); background: var(--green-bg);
               color: var(--green); border-radius: var(--r); cursor: pointer; font-size: 12px;
               font-family: inherit; font-weight: 500; transition: .12s; }
.btn-approve:hover { background: var(--green-b); }
.btn-reject  { padding: 5px 12px; border: 1px solid var(--red-b); background: var(--red-bg);
               color: var(--red); border-radius: var(--r); cursor: pointer; font-size: 12px;
               font-family: inherit; font-weight: 500; transition: .12s; }
.btn-reject:hover { background: var(--red-b); }
.role-badge         { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.role-badge.admin   { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-b); }
.role-badge.student { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
