:root {
  --brand: #6d28d9; --brand-2: #7c3aed; --brand-50: #f5f3ff; --brand-100: #ede9fe; --brand-200: #ddd6fe;
  --navy: #1e1b4b; --navy-2: #2a2569;
  --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb; --bg: #f6f7fb; --card: #ffffff;
  --ok: #16a34a; --ok-50: #dcfce7; --warn: #eab308; --warn-50: #fef9c3; --bad: #dc2626; --bad-50: #fee2e2;
  --blue-50: #e0f2fe; --pink-50: #fce7f3; --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5em; color: var(--navy); line-height: 1.2; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; } .wrap { flex-wrap: wrap; } .between { justify-content: space-between; } .grow { flex: 1; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* brand */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--navy); }
.logo .mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #8b5cf6, #3b82f6); display: grid; place-items: center; color: #fff; }
.logo b { background: linear-gradient(90deg, #7c3aed, #3b82f6); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.tight { padding: 14px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* forms */
label.field { display: block; font-weight: 600; font-size: 14px; color: var(--navy); }
label.field > input, label.field > select, label.field > textarea, label.field > .input-icon, label.field > .copy-field { display: block; margin-top: 6px; font-weight: 400; }
label.field > .copy-field { display: flex; }
label.field .req { color: var(--bad); }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=email], select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: var(--ink); width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-100); }
textarea { resize: vertical; min-height: 80px; }
.input-icon { position: relative; } .input-icon input { padding-right: 40px; }
.input-icon button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; padding: 6px; color: var(--muted); }

/* buttons */
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; transition: background .15s, transform .05s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: #f9fafb; } .btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(109, 40, 217, .28); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.soft { background: var(--brand-50); color: var(--brand); border-color: var(--brand-200); }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 22px; font-size: 16px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 8px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: #f3f4f6; color: var(--navy); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* chips & badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #f3f4f6; color: #374151; }
.badge.ok { background: var(--ok-50); color: #166534; } .badge.warn { background: var(--warn-50); color: #854d0e; } .badge.bad { background: var(--bad-50); color: #991b1b; } .badge.brand { background: var(--brand-100); color: var(--brand); } .badge.blue { background: var(--blue-50); color: #075985; }

/* toggle */
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand-2); }
.switch input:checked + span::before { transform: translateX(20px); }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { background: var(--navy); color: #fff; font-weight: 600; font-size: 13px; }
.tbl th:first-child { border-top-left-radius: 10px; } .tbl th:last-child { border-top-right-radius: 10px; }
.tbl tr:hover td { background: #fafafa; }
.tbl td.num, .tbl th.num { text-align: center; }
.tbl .total { font-weight: 800; color: var(--brand); }
.table-wrap { overflow-x: auto; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(17, 24, 39, .5); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 18px; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 20px; } .modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100; box-shadow: var(--shadow); animation: fade .2s; max-width: 90vw; }
.toast.err { background: var(--bad); }
.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 30px; color: var(--muted); }

/* ===== Login ===== */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #ede9fe, transparent 40%), radial-gradient(circle at 90% 90%, #dbeafe, transparent 40%), var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-card .card { padding: 32px; }
.auth-card h2 { text-align: center; margin: 18px 0 22px; }
.lang-select { display: flex; justify-content: flex-end; margin-top: 14px; }
.lang-select select { width: auto; border: 0; background: transparent; color: var(--muted); font-weight: 600; }
.error-box { background: var(--bad-50); color: #991b1b; border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* ===== Teacher shell ===== */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #c7d2fe; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { color: #fff; margin: 0 6px 18px; } .sidebar .logo b { background: none; color: #fff; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #c7d2fe; font-weight: 500; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: linear-gradient(90deg, #7c3aed, #6d28d9); color: #fff; }
.sidebar .bottom { margin-top: auto; font-size: 13px; padding: 10px; color: #a5b4fc; }
.main { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #8b5cf6, #3b82f6); color: #fff; display: grid; place-items: center; font-weight: 700; }
.content { padding: 24px 28px 60px; max-width: 1200px; }
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-grid; }
  .content { padding: 16px; } .topbar { padding: 12px 16px; }
}

/* stat tiles */
.stat { border-radius: 14px; padding: 16px; }
.stat .n { font-size: 30px; font-weight: 800; color: var(--navy); }
.stat .l { font-weight: 600; color: #374151; }
.stat.blue { background: var(--blue-50); } .stat.pink { background: var(--pink-50); } .stat.violet { background: var(--brand-50); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.list-item:hover { border-color: var(--brand-200); background: #fcfbff; }
.progress { height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #8b5cf6, #6d28d9); border-radius: 99px; }

/* ===== Wizard ===== */
.stepper { display: flex; gap: 8px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; color: var(--muted); font-weight: 600; cursor: pointer; }
.step .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #c4b5fd; display: grid; place-items: center; font-size: 13px; color: var(--brand); background: #fff; }
.step.active { background: var(--brand-100); color: var(--brand); } .step.active .dot { background: var(--brand); color: #fff; border-color: var(--brand); }
.step.done .dot { background: #0f766e; border-color: #0f766e; color: #fff; }
.step-line { flex: 1; min-width: 12px; height: 2px; background: var(--line); }
.radio-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.radio-card { flex: 1; min-width: 160px; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 600; background: #fff; }
.radio-card.sel { border-color: var(--brand-2); background: var(--brand-50); color: var(--brand); }
.type-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .type-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.type-card { position: relative; border: 2px solid var(--line); border-radius: 14px; padding: 16px 10px; text-align: center; cursor: pointer; background: #fff; font-weight: 600; color: var(--navy); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.type-card svg.i { width: 30px; height: 30px; color: var(--brand); }
.type-card.sel { border-color: var(--brand-2); background: var(--brand-50); }
.type-card.sel::after { content: '✓'; position: absolute; top: 6px; right: 8px; background: var(--brand); color: #fff; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; display: grid; place-items: center; }
.ai-box { background: linear-gradient(135deg, #f5f3ff, #eef2ff); border: 1px solid var(--brand-200); border-radius: 14px; padding: 16px; }
.or { text-align: center; color: var(--muted); font-weight: 600; margin: 14px 0; }
.wizard-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.preview-tabs { display: flex; gap: 8px; }
.preview-tabs button { border: 0; padding: 8px 16px; border-radius: 10px; background: var(--brand-50); color: var(--brand); font-weight: 600; cursor: pointer; }
.preview-tabs button.active { background: var(--brand); color: #fff; }
.task-preview { display: grid; grid-template-columns: 1fr 1.1fr; gap: 18px; }
@media (max-width: 760px) { .task-preview { grid-template-columns: 1fr; } }
.task-img { border-radius: 12px; overflow: hidden; background: #eef2ff; aspect-ratio: 8 / 5; display: grid; place-items: center; border: 1px solid var(--line); }
.task-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.questions-box { background: var(--brand-50); border-radius: 12px; padding: 12px 14px; }
.questions-box ol { margin: 6px 0 0; padding-left: 20px; }

.rubric-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; }
@media (max-width: 1100px) { .rubric-layout { grid-template-columns: 1fr; } .rubric-layout > .col { flex-direction: row; flex-wrap: wrap; } .rubric-layout > .col > * { flex: 1; min-width: 160px; } }
.rubric-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.7fr) 76px 36px; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rubric-row input[type=number] { padding: 10px 6px; text-align: center; }
@media (max-width: 760px) { .rubric-row { grid-template-columns: 1fr 76px 36px; } .rubric-row > :first-child { grid-column: 1 / -1; } .rubric-row.small { display: none; } }
.total-pill { background: var(--brand-50); border: 1px solid var(--brand-200); color: var(--brand); font-weight: 800; border-radius: 12px; padding: 14px; text-align: center; font-size: 18px; }

.setting-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border: 0; }
.setting-row .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; flex: none; }
.setting-row .t { flex: 1; font-weight: 600; } .setting-row .t small { display: block; color: var(--muted); font-weight: 400; }
.setting-row select { width: 130px; }

/* share */
.share { text-align: center; }
.share .big-ic { width: 56px; height: 56px; color: var(--brand); margin: 0 auto 8px; }
.copy-field { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.copy-field input { border: 0; border-radius: 0; }
.code-big { font-size: 34px; font-weight: 800; letter-spacing: 6px; color: var(--navy); }
.qr { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; }

/* review */
.review { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .review { grid-template-columns: 1fr; } }
video.player { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 16 / 10; display: block; }
.ai-panel .crit { display: grid; grid-template-columns: 22px 1fr 86px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ai-panel .crit:last-child { border: 0; }
.ai-panel .crit input { width: 56px; padding: 6px; text-align: center; }
.check { color: var(--ok); font-weight: 900; }
.gaze-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: #eee; cursor: pointer; }
.gaze-bar i { height: 100%; }
.gaze-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; margin-top: 8px; }
.gaze-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); }
.transcript { white-space: pre-wrap; background: #fafafa; border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 260px; overflow: auto; font-size: 14px; }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; font-size: 12px; color: var(--muted); }
.bars .b i { width: 100%; max-width: 60px; background: linear-gradient(180deg, #8b5cf6, #6d28d9); border-radius: 8px 8px 0 0; min-height: 2px; }
.bars .b b { color: var(--navy); }

/* ===== Student ===== */
.stu-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.stu-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.stage { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 860px) { .stage { grid-template-columns: 1fr; } }
.cam { position: relative; border-radius: 16px; overflow: hidden; background: #111; aspect-ratio: 4 / 3; }
.cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam .rec { position: absolute; top: 12px; left: 12px; background: var(--bad); color: #fff; font-weight: 800; padding: 4px 10px; border-radius: 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.cam .rec::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.cam .corners { position: absolute; inset: 14% 22%; pointer-events: none; }
.cam .corners i { position: absolute; width: 28px; height: 28px; border: 3px solid #4ade80; }
.cam .corners i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; } .cam .corners i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.cam .corners i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; } .cam .corners i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.cam.away .corners i { border-color: #facc15; } .cam.noface .corners i { border-color: #f87171; }
.cam .overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(17, 24, 39, .55); color: #fff; font-size: 64px; font-weight: 800; }
.cam .gaze-tip { position: absolute; bottom: 12px; left: 12px; right: 12px; background: rgba(0,0,0,.6); color: #fff; border-radius: 10px; padding: 6px 10px; font-size: 13px; text-align: center; }
.timer { font-size: 28px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.timeline { height: 10px; border-radius: 99px; background: #e5e7eb; overflow: hidden; }
.timeline i { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #84cc16, #eab308, #f97316); transition: width .3s linear; }
.controls { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.round-btn { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--brand-200); background: #fff; color: var(--brand); cursor: pointer; display: grid; place-items: center; }
.stop-btn { background: var(--bad); color: #fff; border: 0; border-radius: 14px; padding: 14px 28px; font-weight: 800; font-size: 17px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.followup-card { background: linear-gradient(135deg, #fef3c7, #fde68a); border-radius: 14px; padding: 16px; border: 1px solid #fcd34d; }
.live-transcript { font-size: 13px; color: var(--muted); max-height: 120px; overflow: auto; }
.perm-list { display: flex; flex-direction: column; gap: 10px; }
.perm-list .perm { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: #f9fafb; border: 1px solid var(--line); }
.big-done { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-50); color: var(--ok); display: grid; place-items: center; margin: 0 auto 10px; }
.big-done svg.i { width: 38px; height: 38px; }
