@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --border: #e5e7f0;
  --text: #1c2140;
  --muted: #69708f;
  --primary: #6a45f5;
  --primary-600: #5a35e6;
  --primary-50: #f2eeff;
  --primary-100: #e5ddff;
  --teal: #0f766e;
  --teal-600: #0b5f58;
  --teal-50: #e6f5f3;
  --green: #15803d;
  --green-50: #e8f7ee;
  --red: #c62828;
  --red-50: #fdeeee;
  --amber: #b45309;
  --amber-50: #fff4e0;
  --sidebar: #1a2040;
  --sidebar-text: #c9cde4;
  --code-bg: #1e1e2e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 60, .05), 0 4px 16px rgba(20, 24, 60, .05);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.65; -webkit-text-size-adjust: 100%; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .ltr, .mono { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
code { background: var(--primary-50); color: #3d2a9c; padding: 1px 6px; border-radius: 6px; font-size: .9em; white-space: pre-wrap; }
pre { margin: 0; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 20px; padding: 4px 10px 18px; }
.brand-icon { color: #a78bfa; font-family: var(--mono); font-weight: 700; }
.brand small { display: block; font-size: 11px; font-weight: 400; color: var(--sidebar-text); }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); padding: 10px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .ico { width: 20px; text-align: center; opacity: .9; }
.sidebar .spacer { flex: 1; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 28px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-100); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.user-chip .name { font-weight: 600; line-height: 1.2; }
.user-chip .role { font-size: 12px; color: var(--muted); }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; margin: 0 auto; }
.mobile-nav { display: none; }
.topbar > .brand { visibility: hidden; }
@media (max-width: 960px) { .topbar > .brand { visibility: visible; } }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; background: var(--sidebar); }
  .mobile-nav a { color: var(--sidebar-text); white-space: nowrap; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
  .mobile-nav a.active { background: var(--primary); color: #fff; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
}

/* ---------- building blocks ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; display: flex; align-items: center; gap: 12px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.head-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h2 { font-size: 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 { font-size: 15px; margin: 16px 0 8px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 9px 18px; font-weight: 600; cursor: pointer; background: var(--card); border-color: var(--border); min-height: 42px; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #c9cce0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-run { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-run:hover { background: var(--teal-600); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { padding: 5px 12px; min-height: 34px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--primary-50); color: var(--primary); }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.b-easy { background: var(--green-50); color: var(--green); }
.b-medium { background: var(--amber-50); color: var(--amber); }
.b-hard { background: var(--red-50); color: var(--red); }
.b-topic { background: var(--primary-50); color: var(--primary); }
.b-draft { background: #eceef5; color: var(--muted); }
.b-ok { background: var(--green-50); color: var(--green); }
.b-bad { background: var(--red-50); color: var(--red); }
.b-warn { background: var(--amber-50); color: var(--amber); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 500; min-height: 40px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; background: #fff; min-height: 42px; }
.input:focus { outline: 2px solid var(--primary-100); border-color: var(--primary); }
textarea.input { min-height: 90px; resize: vertical; }
textarea.code, .input.code { font-family: var(--mono); direction: ltr; text-align: left; font-size: 13.5px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
label.field > small { display: block; color: var(--muted); margin-top: 4px; font-size: 12.5px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: right; color: var(--muted); font-weight: 600; background: #f8f9fd; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: #fafbff; }
.table tr.clickable { cursor: pointer; }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.notice-info { background: var(--primary-50); color: #3d2a9c; }
.notice-warn { background: var(--amber-50); color: #7a3e06; }
.notice-bad { background: var(--red-50); color: #8a1c1c; }
.notice-ok { background: var(--green-50); color: #0f5a2b; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; }

.modal-back { position: fixed; inset: 0; background: rgba(20,24,50,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: var(--radius); max-width: 900px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px; }

.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: var(--primary-100); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- problem list ---------- */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 22px; }
.hero-card { background: linear-gradient(135deg, #f3eeff, #ece6ff); border: 1px solid var(--primary-100); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; justify-content: center; }
.hero-card h2 { color: var(--primary); font-size: 22px; margin-bottom: 6px; }
.stats-card { display: flex; align-items: center; gap: 22px; }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(var(--teal) calc(var(--p) * 1%), #e8eaf3 0); display: grid; place-items: center; flex: none; }
.ring > div { width: 94px; height: 94px; background: var(--card); border-radius: 50%; display: grid; place-items: center; text-align: center; line-height: 1.2; }
.ring b { font-size: 24px; }
.stat-list { flex: 1; display: grid; gap: 8px; }
.stat-list div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.stat-list b { font-size: 18px; }
.filters { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.search { max-width: 280px; }
.exam-list { display: grid; gap: 12px; margin-bottom: 24px; }
.exam-card { display: grid; gap: 8px; background: var(--card); border: 1px solid var(--border); border-inline-start: 5px solid var(--amber); border-radius: var(--radius); padding: 16px 18px; color: inherit; box-shadow: var(--shadow); }
.exam-card.open { border-inline-start-color: var(--red); background: linear-gradient(90deg, #fff, #fff8f2); }
.exam-card:hover { border-color: var(--primary); }
.exam-card h3 { font-size: 17px; }
.exam-timer { position: sticky; top: 70px; z-index: 10; display: flex; align-items: center; gap: 14px; justify-content: space-between; background: var(--sidebar); color: #fff; border-radius: var(--radius); padding: 12px 20px; font-size: 16px; }
.exam-timer b { font-family: var(--mono); font-size: 26px; letter-spacing: 1px; }
.exam-timer.warn { background: var(--red); }
.exam-problems { display: grid; gap: 10px; }
.exam-problem { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; color: inherit; }
a.exam-problem:hover { border-color: var(--primary); background: #fbfaff; }
.exam-problem .num { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.exam-rules { margin: 10px 0 0; padding-inline-start: 22px; color: var(--text); font-size: 14.5px; display: grid; gap: 4px; }
.exam-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--sidebar); color: #fff; border-radius: 12px; padding: 10px 16px; margin-bottom: 14px; position: sticky; top: 64px; z-index: 15; }
.exam-banner a { color: #c9b8ff; }
.exam-banner b { font-family: var(--mono); font-size: 20px; }
.exam-banner.warn { background: var(--red); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tcard { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); color: inherit; transition: border-color .15s, transform .15s; border-top: 4px solid var(--primary); }
.tcard:hover { border-color: var(--primary); transform: translateY(-2px); }
.tcard.done { border-top-color: var(--green); }
.tcard h3 { font-size: 19px; }
.tcard p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.t-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 18px; flex: none; }
.topic-progress { min-width: 220px; padding: 12px 16px; }
.topic-progress .row { margin-bottom: 8px; }
.list-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.list-head h2 { font-size: 19px; }
.toolbar { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.filter-group { display: flex; align-items: center; gap: 10px; }
.filter-label { color: var(--muted); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.segmented { display: inline-flex; background: #f1f2f8; border-radius: 11px; padding: 3px; gap: 2px; }
.segmented .chip { border: 0; background: transparent; min-height: 36px; padding: 6px 14px; border-radius: 9px; color: var(--text); white-space: nowrap; }
.segmented .chip:hover { background: rgba(106, 69, 245, .08); }
.segmented .chip.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(20, 24, 60, .12); font-weight: 600; }
.search-box { position: relative; margin-inline-start: auto; flex: 0 1 260px; min-width: 180px; }
.search-box .input { padding-inline-start: 34px; min-height: 40px; }
.search-ico { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
@media (max-width: 700px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-group { justify-content: space-between; }
  .search-box { margin-inline-start: 0; flex-basis: auto; }
}
.problem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.pcard { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); color: inherit; transition: border-color .15s, transform .15s; }
.pcard:hover { border-color: var(--primary); transform: translateY(-1px); }
.pcard h3 { font-size: 16.5px; }
.pcard p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .num { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.pcard.solved { background: linear-gradient(0deg, #f3fbf6, #fff 45%); }
.pstatus { font-weight: 600; font-size: 13.5px; }
.pstatus.ok { color: var(--green); }
.pstatus.try { color: var(--amber); }

/* ---------- problem page ---------- */
.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.workspace { display: grid; grid-template-columns: minmax(340px, 0.9fr) 1.1fr; gap: 18px; align-items: start; }
.statement-panel { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; }
.statement p { margin: 0 0 10px; }
.statement ul { margin: 0 0 10px; padding-inline-start: 22px; }
.examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.example { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.example .ex-title { background: #f6f7fc; padding: 6px 12px; font-weight: 600; font-size: 13.5px; }
.example pre { padding: 8px 12px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.example .lbl { padding: 6px 12px 0; font-size: 12px; color: var(--muted); direction: ltr; text-align: left; font-family: var(--mono); }
.editor-card { background: var(--code-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.editor-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; color: #c9cbe0; font-size: 13px; background: #181825; gap: 8px; flex-wrap: wrap; }
.editor-bar .file { display: flex; align-items: center; gap: 8px; direction: ltr; font-family: var(--mono); }
.editor-bar .lang { background: var(--primary); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; }
.editor-bar button { background: transparent; border: 0; color: #c9cbe0; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.editor-bar button:hover { background: rgba(255,255,255,.08); }
#editor { height: 480px; direction: ltr; }
#editor textarea.fallback { width: 100%; height: 100%; background: var(--code-bg); color: #e4e4f0; border: 0; padding: 12px; font-family: var(--mono); font-size: 14px; line-height: 1.55; resize: none; direction: ltr; text-align: left; tab-size: 4; }
.actions { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.actions .btn { min-width: 130px; }
.save-state { color: var(--muted); font-size: 13px; margin-inline-start: auto; align-self: center; }
.io-box textarea { min-height: 80px; }
.result-head { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.result-head.ok { color: var(--green); }
.result-head.bad { color: var(--red); }
.result-head.warn { color: var(--amber); }
.verdict-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 16px; flex: none; }
.ok .verdict-ico { background: var(--green); }
.bad .verdict-ico { background: var(--red); }
.warn .verdict-ico { background: var(--amber); }
.out-pre { background: #f6f7fc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; min-height: 38px; max-height: 300px; overflow: auto; text-align: left; }
.test-row { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.test-row > .th { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 14px; }
.test-row > .th .dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; flex: none; }
.test-row.pass .dot { background: var(--green); }
.test-row.fail .dot { background: var(--red); }
.test-row > .tb { padding: 0 12px 12px; display: grid; gap: 8px; }
.test-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.test-strip .ts { min-width: 34px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 700; padding: 0 6px; }
.test-strip .ts.p { background: var(--green-50); color: var(--green); }
.test-strip .ts.f { background: var(--red-50); color: var(--red); }
.cmp { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.cmp .lbl { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.err-item { border: 1px solid #f3c7c7; background: #fff8f8; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.err-item .loc { font-weight: 700; color: var(--red); }
.err-item .orig { font-family: var(--mono); direction: ltr; text-align: left; font-size: 13px; color: #6b1e1e; margin: 4px 0; }
.hint-card { background: linear-gradient(135deg, #f5f1ff, #efe9ff); border: 1px solid var(--primary-100); }
.hint-item { background: #fff; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--primary-100); }
details.policy summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14px; }
details.policy ul { margin: 8px 0 0; padding-inline-start: 20px; font-size: 14px; color: var(--muted); }
.sub-list { display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.sub-list .item { display: flex; align-items: center; gap: 8px; justify-content: space-between; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: 13.5px; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .statement-panel { position: static; max-height: none; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-card { flex-direction: column; align-items: stretch; }
  .ring { margin: 0 auto; }
  #editor { height: 380px; }
  .actions .btn { flex: 1; min-width: 0; }
}

/* ---------- teacher ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { display: flex; align-items: center; gap: 14px; }
.kpi .k-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: var(--primary-50); color: var(--primary); flex: none; }
.kpi b { font-size: 24px; display: block; line-height: 1.1; }
.bar { height: 8px; border-radius: 99px; background: #e8eaf3; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--teal); border-radius: 99px; }
.matrix td.cell { text-align: center; font-size: 13px; }
.cell-ok { background: var(--green-50); color: var(--green); font-weight: 700; }
.cell-try { background: var(--amber-50); color: var(--amber); }
.tests-editor .t-row { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; display: grid; grid-template-columns: 130px 1fr 1fr; gap: 10px; align-items: start; background: #fcfcff; }
.tests-editor .t-row.mismatch { border-color: var(--red); background: #fff7f7; }
.tests-editor .t-row .t-hint { grid-column: 2 / 4; }
.tests-editor textarea { min-height: 64px; }
.teacher-notes { background: var(--amber-50); border: 1px solid #f5d39a; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.check-row { display: flex; gap: 16px; flex-wrap: wrap; }
.check-row label { display: flex; align-items: center; gap: 6px; }
@media (max-width: 800px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
  .tests-editor .t-row { grid-template-columns: 1fr; }
  .tests-editor .t-row .t-hint { grid-column: auto; }
}

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #ece6ff, transparent 40%), var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { color: var(--text); justify-content: center; padding-bottom: 6px; }
.login-card .brand small { color: var(--muted); }

/* ---------- AI import ---------- */
.dropzone { display: grid; place-items: center; gap: 6px; text-align: center; border: 2px dashed var(--primary-100); background: #fbfaff; border-radius: var(--radius); padding: 28px 16px; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-50); }
.file-list { display: grid; gap: 6px; margin-top: 10px; }
.file-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.choice-card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 24px; color: inherit; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.choice-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.choice-card h2 { font-size: 20px; margin: 0; }
.choice-card p { margin: 0; color: var(--muted); flex: 1; }
.choice-ico { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-50); display: grid; place-items: center; font-size: 28px; }

/* ---------- login cards (print) ---------- */
.cred-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cred-card { border: 1px dashed #b9bdd3; border-radius: 10px; padding: 10px 12px; display: grid; gap: 3px; background: #fff; }
@media print {
  body * { visibility: hidden !important; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area { position: absolute; inset: 0; padding: 10mm; }
  .cred-card { break-inside: avoid; }
}

/* class bar / segmented controls wrap instead of overflowing on narrow screens */
.segmented { flex-wrap: wrap; max-width: 100%; }
.filter-group { flex-wrap: wrap; min-width: 0; }
select[data-move] { min-width: 130px; }

/* ---------- interactive questions ---------- */
.b-elec { background: #fff1d6; color: #8a4b00; }
.segmented { flex-wrap: wrap; }
.subject-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.unit { margin-bottom: 26px; }
.unit > h3 { font-size: 18px; padding-inline-start: 12px; border-inline-start: 4px solid var(--primary); margin-bottom: 4px; }
.unit > p { margin: 0 0 12px; color: var(--muted); }
.q-layout { display: grid; grid-template-columns: minmax(320px, .95fr) 1.05fr; gap: 18px; align-items: start; }
.q-layout.single { grid-template-columns: minmax(0, 860px); justify-content: center; }
.q-layout.single .statement-panel { position: static; max-height: none; }
.q-layout > * { min-width: 0; }
@media (max-width: 1080px) { .q-layout { grid-template-columns: minmax(0, 1fr); } .q-layout .statement-panel { position: static; max-height: none; } }
.q-code { background: #1e1e2e; color: #dfe3f5; border-radius: 12px; padding: 12px 0; overflow-x: auto; font-size: 13.5px; line-height: 1.75; margin: 12px 0; text-align: left; }
.q-code .ln { display: flex; padding: 0 14px; white-space: pre; min-width: max-content; }
.q-code .ln > b { width: 30px; flex: none; color: #7d84ab; font-weight: 400; user-select: none; }
.q-code .ln.hot { background: rgba(255, 209, 102, .22); box-shadow: inset 3px 0 #ffd166; }
.q-code i { font-style: normal; } .c-kw { color: #8fb4ff; } .c-str { color: #f4b183; } .c-com { color: #8fbf8f; }
.q-code .blank { background: #2d2f48; border: 1px solid #6d73a8; color: #fff; border-radius: 6px; font: inherit; padding: 1px 8px; width: 140px; margin: 2px 3px; }
.q-code .blank:focus { outline: 2px solid #ffd166; }
.q-figs { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 14px 0; }
.q-fig { margin: 0; text-align: center; max-width: 100%; }
.q-fig img { max-width: 100%; max-height: 340px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.q-fig figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.q-part { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; border-inline-start-width: 5px; min-width: 0; }
.q-part.r-ok { border-inline-start-color: var(--green); } .q-part.r-bad { border-inline-start-color: var(--red); }
.q-part.r-part, .q-part.r-pend { border-inline-start-color: var(--amber); }
.q-part-head { display: flex; gap: 10px; align-items: flex-start; }
.q-num { min-width: 30px; height: 30px; padding: 0 7px; border-radius: 9px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.q-prompt { flex: 1; min-width: 0; } .q-prompt p { margin: 2px 0 6px; }
.q-pts { font-size: 12.5px; color: var(--muted); white-space: nowrap; padding-top: 4px; }
.q-type { font-size: 13px; color: var(--teal); margin: 2px 0 8px; }
.q-res { font-size: 14px; } .q-res:not(:empty) { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.r-ok .q-res > b { color: var(--green); } .r-bad .q-res > b { color: var(--red); } .r-part .q-res > b, .r-pend .q-res > b { color: var(--amber); }
.q-comment { background: var(--primary-50); border-radius: 10px; padding: 8px 12px; margin-top: 6px; }
.q-opts { display: grid; gap: 8px; }
.q-opt { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; cursor: pointer; min-height: 44px; }
.q-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.q-opt input { width: 18px; height: 18px; flex: none; } .q-opt p { margin: 0; }
.q-screen { background: #101223 !important; color: #c8f7d4 !important; line-height: 1.7; }
.q-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.q-table th, .q-table td { border: 1px solid var(--border); padding: 5px; text-align: center; min-width: 74px; }
.q-table th { background: #f3f4fb; font-family: var(--mono); font-size: 13px; padding: 7px; }
.q-table td.given { background: #fafbff; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; text-align: start; padding: 6px 9px; }
.q-table td .input { min-height: 38px; padding: 5px 8px; text-align: center; font-family: var(--mono); font-size: 14px; }
.q-table td textarea.input { text-align: start; min-width: 190px; font-family: var(--font); }
.q-table.trace td:has(.m-ok), .m-ok { background: var(--green-50) !important; } .m-ok { border-color: var(--green) !important; color: #0f5a2b !important; }
.m-bad { border-color: var(--red) !important; background: var(--red-50) !important; color: #8a1c1c !important; } .m-pend { border-color: var(--amber) !important; }
.q-list { overflow-x: auto; margin: 10px 0; } .q-list svg { display: block; height: auto; margin: 0 auto; font-family: var(--mono); }
.nbox { fill: #fff; stroke: #4b5280; stroke-width: 1.8; } .nline, .nnull { stroke: #4b5280; stroke-width: 1.6; }
.nval { font-size: 16px; text-anchor: middle; fill: var(--text); font-weight: 600; } .nid { font-size: 12px; text-anchor: middle; fill: var(--muted); }
.nvar { font-size: 15px; text-anchor: middle; fill: var(--primary); font-weight: 700; } .narr { stroke: var(--primary); stroke-width: 2; } .nhead, .ndot { fill: var(--primary); }
.q-nodes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.q-node { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; background: #fbfbff; }
.q-node > b { font-family: var(--mono); color: var(--muted); } .q-node.var > b { color: var(--primary); }
.q-node label { display: grid; gap: 2px; font-size: 11.5px; color: var(--muted); } .q-node .input { width: 84px; min-height: 38px; padding: 4px 8px; font-family: var(--mono); }
.q-sol { display: flex; gap: 12px; border-top: 1px solid var(--border); padding: 10px 0; } .q-sol > b { color: var(--primary); }
.topic-content { margin-bottom: 18px; }
.asg { margin-bottom: 14px; } .asg.late { border-color: #f0c2c2; }
/* interactive editor */
.ed-part { border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; background: #fcfcff; }
.ed-grid { border-collapse: collapse; } .ed-grid td, .ed-grid th { padding: 3px; } .ed-grid .input { min-height: 36px; padding: 4px 8px; min-width: 96px; font-family: var(--mono); font-size: 13px; }
.ed-grid .cell { position: relative; } .ed-grid .given .input { background: #f0f1f8; } .ed-grid .open .input { background: var(--amber-50); }
.result-head.warn { color: var(--amber); }
.heat { height: 10px; border-radius: 6px; background: #eceef5; overflow: hidden; min-width: 80px; } .heat i { display: block; height: 100%; }
.q-table.trace th, .q-table.trace td { min-width: 52px; padding: 3px; }
.q-table.trace td .input { padding: 4px; min-width: 46px; }
.q-table.trace th:first-child, .q-table.trace td:first-child { position: sticky; left: 0; z-index: 1; min-width: 40px; text-align: center; }
.q-table.trace th:last-child { min-width: 110px; }
.q-table.trace td select.input { min-width: 84px; }
.q-layout { grid-template-columns: minmax(320px, .8fr) 1.2fr; }
@media (max-width: 1080px) { .q-layout { grid-template-columns: minmax(0, 1fr); } }
.q-layout.single { grid-template-columns: minmax(0, 860px); }
.q-fig.full { width: 100%; } .q-fig.full img { width: 100%; max-height: none; padding: 4px; }
.q-layout:has(.q-fig.full) { grid-template-columns: minmax(360px, 1.15fr) 1fr; }
@media (max-width: 1080px) { .q-layout:has(.q-fig.full) { grid-template-columns: minmax(0, 1fr); } }
.q-editor { height: 300px; direction: ltr; }
.q-editor textarea.fallback { width: 100%; height: 100%; background: var(--code-bg); color: #e4e4f0; border: 0; padding: 12px; font-family: var(--mono); font-size: 14px; line-height: 1.55; resize: none; direction: ltr; text-align: left; tab-size: 4; }
.q-fig img { cursor: zoom-in; }
.zoom-img { width: 100%; background: #fff; border-radius: 10px; } .q-try { margin-top: 8px; } .q-try textarea { margin: 8px 0; } .q-try pre { margin-top: 8px; }
.space-switch { display: grid; gap: 4px; background: rgba(255,255,255,.07); border-radius: 12px; padding: 5px; margin-bottom: 10px; }
.space-switch button { border: 0; background: transparent; color: var(--sidebar-text); border-radius: 9px; padding: 9px 10px; font-weight: 600; cursor: pointer; text-align: start; min-height: 40px; }
.space-switch button.on { background: #fff; color: #1a2040; } body[data-space=electronics] .space-switch button.on { background: #ffd166; }
.mobile-nav .space-switch { display: flex; margin: 0; } .mobile-nav .space-switch button { white-space: nowrap; min-height: 34px; padding: 5px 10px; }
