/* =========================================================
   Arastu — o‘quvchi kabineti va admin panel (umumiy uslublar)
   ========================================================= */

:root {
  --paper: #F7F2E8;
  --paper-2: #EFE6D6;
  --surface: #FFFCF6;
  --ink: #14213D;
  --ink-2: #3D4863;
  --muted: #69718C;
  --line: rgba(20, 33, 61, .11);
  --line-2: rgba(20, 33, 61, .2);
  --gold: #C8962E;
  --gold-ink: #93661A;
  --gold-soft: #F1E2BF;
  --turq: #117571;
  --turq-soft: #D3EAE6;
  --terra: #B8412B;
  --terra-soft: #F6DDD5;
  --navy: #14213D;
  --on-navy: #F4EDE0;
  --on-navy-muted: #A9B2C8;
  --shadow-sm: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .05);
  --shadow: 0 18px 40px -18px rgba(20, 33, 61, .3);
  --shadow-lg: 0 40px 90px -40px rgba(20, 33, 61, .45);
  --f-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --f-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --gutter: clamp(16px, 3vw, 36px);
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #0C1322;
  --paper-2: #111A2D;
  --surface: #162038;
  --ink: #F1EADC;
  --ink-2: #CDD3E1;
  --muted: #98A1BA;
  --line: rgba(241, 234, 220, .1);
  --line-2: rgba(241, 234, 220, .2);
  --gold: #E0B25A;
  --gold-ink: #E8C170;
  --gold-soft: rgba(224, 178, 90, .16);
  --turq: #45B9B0;
  --turq-soft: rgba(69, 185, 176, .15);
  --terra: #E0775E;
  --terra-soft: rgba(224, 119, 94, .15);
  --navy: #070D1A;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .2);
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
  --shadow-lg: 0 40px 90px -40px rgba(0, 0, 0, .75);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100svh; background: var(--paper); color: var(--ink); font: 500 15px/1.6 var(--f-body); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
p { margin: 0 0 .8em; }
h1, h2, h3, h4 { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.display { font-family: var(--f-display); font-weight: 600; letter-spacing: -.01em; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 18px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 700; white-space: nowrap;
  transition: transform .16s var(--ease-out), background-color .2s ease, color .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: .82rem; }
.btn--lg { min-height: 52px; padding: 0 26px; font-size: .98rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--gold { background: var(--gold); color: #1A1406; }
.btn--ghost { box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn--danger { background: var(--terra-soft); color: var(--terra); }
.btn--tg { background: #229ED9; color: #fff; }
.icon-btn { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; color: var(--ink-2); transition: background-color .2s ease, transform .16s var(--ease-out); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn--danger { color: var(--terra); }
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { box-shadow: 0 12px 26px -14px rgba(20, 33, 61, .6); }
  .btn--ghost:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
  .btn--danger:hover { background: var(--terra); color: #fff; }
  .icon-btn:hover { background: var(--paper-2); }
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span, .label { font-size: .78rem; font-weight: 800; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line-2); background: var(--surface);
  font-size: 15px; font-weight: 600;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .7; }
.hint { font-size: .78rem; color: var(--muted); }
.error-text { font-size: .85rem; font-weight: 700; color: var(--terra); }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips label > span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 999px; font-size: .86rem; font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--line-2); transition: background-color .2s ease, color .2s ease; }
.chips input:checked + span { background: var(--ink); color: var(--paper); box-shadow: inset 0 0 0 1.5px var(--ink); }
.chips input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.pass-field { position: relative; }
.pass-field .input { padding-right: 48px; }
.pass-field .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* ---------- Cards, stats, badges ---------- */
.card { padding: 22px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); }
.card--pad-0 { padding: 0; overflow: hidden; }
.card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.card__title { font-family: var(--f-display); font-size: 1.55rem; font-weight: 600; line-height: 1.1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 18px 20px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); }
.stat__label { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat__value { margin-top: 4px; font-family: var(--f-display); font-size: 2.5rem; font-weight: 600; line-height: 1; }
.stat__value small { font-family: var(--f-body); font-size: .9rem; color: var(--muted); }
.stat--dark { background: var(--navy); color: var(--on-navy); border-color: transparent; }
.stat--dark .stat__label { color: var(--on-navy-muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .72rem; font-weight: 800; white-space: nowrap; background: var(--paper-2); color: var(--muted); }
.badge--ok { background: var(--turq-soft); color: var(--turq); }
.badge--warn { background: var(--gold-soft); color: var(--gold-ink); }
.badge--danger { background: var(--terra-soft); color: var(--terra); }
.badge--dark { background: var(--ink); color: var(--paper); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .icon-btn { display: inline-grid; vertical-align: middle; }
@media (hover: hover) { .table tbody tr:hover { background: color-mix(in srgb, var(--paper-2) 55%, transparent); } }
.cell-title { font-weight: 700; }
.cell-sub { font-size: .78rem; color: var(--muted); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 20px; overflow-x: auto; border-radius: 14px; background: var(--paper-2); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; padding: 9px 16px; border-radius: 10px; font-size: .88rem; font-weight: 700; color: var(--muted); transition: background-color .2s ease, color .2s ease; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.tabs a { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; font-size: .88rem; font-weight: 700; color: var(--muted); transition: background-color .2s ease, color .2s ease; }
.tabs a[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.tabs__count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--line); font-size: .74rem; text-align: center; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 18px; }
.filter-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: .84rem; font-weight: 700; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line-2); transition: background-color .2s ease, color .2s ease; }
.filter-chip span { font-size: .74rem; color: var(--muted); }
.filter-chip.is-active { background: var(--ink); color: var(--paper); box-shadow: inset 0 0 0 1.5px var(--ink); }
.filter-chip.is-active span { color: inherit; opacity: .7; }
button.filter-chip { cursor: pointer; }
.link-btn { margin-left: 6px; padding: 0; font: inherit; font-weight: 700; color: var(--turq); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.mode-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mode-card { position: relative; cursor: pointer; }
.mode-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mode-card > span { display: grid; gap: 4px; height: 100%; padding: 12px 14px; border-radius: 14px; box-shadow: inset 0 0 0 1.5px var(--line-2); transition: box-shadow .2s ease, background-color .2s ease; }
.mode-card b { font-size: .9rem; }
.mode-card small { font-size: .78rem; line-height: 1.35; color: var(--muted); }
.mode-card input:checked + span { background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); }
.mode-card input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.timing__summary { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--turq-soft); color: var(--turq); font-size: .86rem; font-weight: 700; }
.timing__summary:empty { display: none; }
.kab-filters { margin: 0 0 18px; }
.subject-tabs { display: grid; grid-template-columns: repeat(var(--tabs, 2), minmax(0, 1fr)); gap: 12px; margin: 0 0 22px; }
.subject-tab { position: relative; display: flex; align-items: center; gap: 14px; min-width: 0; padding: 12px 16px 12px 12px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); transition: background-color .25s ease, border-color .25s ease, transform .16s var(--ease-out), box-shadow .25s ease; }
.subject-tab:active { transform: scale(.985); }
.subject-tab img { flex: none; width: 64px; height: 64px; border-radius: 16px; object-fit: cover; background: var(--paper-2); }
.subject-tab > span { display: grid; gap: 2px; min-width: 0; }
.subject-tab b { font-family: var(--f-display); font-size: 1.6rem; font-weight: 600; line-height: 1.05; }
.subject-tab small { overflow: hidden; font-size: .8rem; font-weight: 700; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.subject-tab.is-active { border-color: transparent; background: var(--navy); color: var(--on-navy); box-shadow: var(--shadow); }
.subject-tab.is-active small { color: var(--on-navy-muted); }
.subject-tab.is-active img { box-shadow: 0 0 0 2px var(--gold); }
.subject-tab__dot { position: absolute; top: 10px; right: 12px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #1A1406; font-size: .72rem; font-weight: 800; }
@media (hover: hover) and (pointer: fine) { .subject-tab:not(.is-active):hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); } }
.subject-panel { animation: q-in .3s var(--ease-out); }
.filter-sep { width: 1px; align-self: stretch; margin: 4px; background: var(--line-2); }

/* ---------- Modal + toast ---------- */
.modal { width: min(560px, calc(100% - 24px)); max-height: calc(100svh - 24px); padding: 0; border: 0; border-radius: 24px; overflow: hidden; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.modal--wide { width: min(860px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(7, 13, 26, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal[open] { animation: dlg-in .25s var(--ease-out); }
.modal__inner { display: flex; flex-direction: column; max-height: calc(100svh - 24px); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 16px 22px; border-bottom: 1px solid var(--line); }
.modal__title { font-family: var(--f-display); font-size: 1.55rem; font-weight: 600; line-height: 1.1; }
.modal__body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 500; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lg); font-size: .9rem; font-weight: 700; opacity: 0; transform: translate(-50%, 14px); pointer-events: none; transition: opacity .2s var(--ease-out), transform .25s var(--ease-out); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: var(--terra); color: #fff; }

/* ---------- Loading / empty ---------- */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--gold); animation: spin .8s linear infinite; }
.loading { display: grid; place-items: center; min-height: 40vh; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 4px; font-family: var(--f-display); font-size: 1.45rem; font-weight: 600; color: var(--ink); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--gold-soft); color: var(--ink); font-size: .9rem; }
.notice--danger { background: var(--terra-soft); }

/* ---------- Brand + theme toggle ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand__mark { width: 34px; height: 34px; color: var(--gold); }
.brand__text { display: flex; flex-direction: column; line-height: 1; }
.brand__text b { font-family: var(--f-display); font-size: 1.5rem; font-weight: 700; }
.brand__text small { margin-top: 3px; font-size: .58rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.theme-btn .i-moon { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-moon { display: block; }
.lang-switch { display: inline-flex; padding: 3px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.lang-switch button { min-width: 36px; height: 30px; border-radius: 999px; font-size: .74rem; font-weight: 800; color: var(--muted); }
.lang-switch button[aria-pressed="true"] { background: var(--gold); color: #1A1406; }

/* ---------- Auth screen ---------- */
.auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 100svh; }
.auth__art { position: relative; display: grid; place-items: center; padding: 40px; overflow: hidden; background: var(--navy); color: var(--on-navy); }
.auth__art::before { content: ""; position: absolute; inset: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23F4EDE0' stroke-opacity='.06'%3E%3Crect x='20' y='20' width='24' height='24'/%3E%3Crect x='20' y='20' width='24' height='24' transform='rotate(45 32 32)'/%3E%3Ccircle cx='32' cy='32' r='5'/%3E%3C/g%3E%3C/svg%3E"); }
.auth__figure { position: relative; width: min(380px, 80%); }
.auth__figure img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 50% 50% 24px 24px / 37.5% 37.5% 24px 24px; box-shadow: 0 0 0 10px rgba(244, 237, 224, .06), var(--shadow-lg); }
.auth__quote { position: relative; margin-top: 28px; max-width: 380px; font-family: var(--f-display); font-size: 1.5rem; font-style: italic; line-height: 1.25; text-align: center; }
.auth__panel { display: flex; flex-direction: column; padding: 22px var(--gutter) 40px; }
.auth__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth__card { width: min(400px, 100%); margin: auto; padding-block: 40px; }
.auth__title { margin-bottom: 8px; font-family: var(--f-display); font-size: clamp(2.3rem, 5vw, 3rem); font-weight: 600; line-height: 1; }
.auth__sub { margin-bottom: 26px; color: var(--muted); }

/* ---------- App shell (kabinet) ---------- */
.topbar { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 82%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1180px; height: 64px; margin: 0 auto; padding: 0 var(--gutter); }
.topbar__tools { display: flex; align-items: center; gap: 6px; }
.page { max-width: 1180px; margin: 0 auto; padding: 26px var(--gutter) calc(60px + env(safe-area-inset-bottom)); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-title { font-family: var(--f-display); font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 600; line-height: 1.02; }
.page-sub { margin: 6px 0 0; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: .86rem; font-weight: 700; color: var(--muted); }
.back-link svg { width: 16px; height: 16px; transform: rotate(180deg); }

/* ---------- Test list ---------- */
.tests { display: grid; gap: 12px; }
.test-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.test-item__title { font-weight: 800; }
.test-item__meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; font-size: .8rem; color: var(--muted); }
.test-item__score { font-family: var(--f-display); font-size: 1.9rem; font-weight: 600; line-height: 1; text-align: right; }

/* ---------- Rating ---------- */
.rank { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; }
.rank + .rank { margin-top: 4px; }
.rank__pos { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--paper-2); font-size: .8rem; font-weight: 800; }
.rank:nth-child(1) .rank__pos { background: var(--gold); color: #1A1406; }
.rank:nth-child(2) .rank__pos { background: #C9CED8; color: #14213D; }
.rank:nth-child(3) .rank__pos { background: #D9A27A; color: #14213D; }
.rank__name { font-weight: 700; }
.rank__sub { font-size: .76rem; color: var(--muted); }
.rank__pct { font-family: var(--f-display); font-size: 1.5rem; font-weight: 600; }
.rank.is-me { background: var(--gold-soft); }

/* ---------- Kabinet dashboard ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 12px; font-family: var(--f-display); font-size: 1.65rem; font-weight: 600; line-height: 1.1; }
.section-title:first-child { margin-top: 0; }
.hello-chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; }

/* ---------- Test runner ---------- */
.runner { max-width: 820px; margin: 0 auto; }
.runner__bar {
  position: sticky; top: 64px; z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px 0 8px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.runner__title { flex: 1; min-width: 0; overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.timer { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--paper-2); font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.is-low { background: var(--terra-soft); color: var(--terra); }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.save-state.is-error { color: var(--terra); }
.progress-line { height: 4px; margin: 4px 0 20px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress-line span { display: block; height: 100%; background: linear-gradient(90deg, var(--turq), var(--gold)); transform: scaleX(0); transform-origin: 0 50%; transition: transform .4s var(--ease-out); }
.q-card { padding: clamp(20px, 4vw, 34px); border-radius: 26px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }
.q-anim { animation: q-in .3s var(--ease-out); }
@keyframes q-in { from { opacity: 0; transform: translateY(10px); } }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.q-count { font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--turq); }
.q-topic { padding: 4px 11px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); font-size: .76rem; font-weight: 700; }
.q-question { margin-bottom: 22px; font-family: var(--f-display); font-size: clamp(1.55rem, 3.4vw, 2.15rem); font-weight: 600; line-height: 1.18; white-space: pre-line; }
.q-options { display: grid; gap: 10px; margin-bottom: 24px; }
.q-opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 16px; border-radius: 16px; text-align: left; font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--line-2); transition: box-shadow .2s ease, background-color .2s ease, transform .16s var(--ease-out); }
.q-opt:active { transform: scale(.985); }
.q-opt__key { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--paper-2); font-size: .85rem; font-weight: 800; transition: background-color .2s ease, color .2s ease; }
.q-opt[aria-checked="true"] { background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); }
.q-opt[aria-checked="true"] .q-opt__key { background: var(--ink); color: var(--paper); }
@media (hover: hover) and (pointer: fine) { .q-opt:hover { box-shadow: inset 0 0 0 1.5px var(--ink); } }
.q-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.q-dot { width: 34px; height: 34px; border-radius: 10px; font-size: .76rem; font-weight: 800; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.q-dot.is-done { background: var(--gold-soft); color: var(--gold-ink); box-shadow: none; }
.q-dot.is-current { color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.q-nav { display: flex; justify-content: space-between; gap: 10px; }
.rich-p { margin: 0 0 .45em; white-space: pre-line; }
.rich-p:last-child { margin-bottom: 0; }
.rich-table { margin: 12px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--line-2); }
.rich-table table { width: 100%; border-collapse: collapse; font-family: var(--f-body); font-size: 14px; font-weight: 500; line-height: 1.45; letter-spacing: 0; overflow-wrap: anywhere; }
.rich-table th, .rich-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; vertical-align: top; white-space: normal; }
.rich-table th { background: var(--paper-2); font-weight: 800; }
.rich-table tr:last-child td { border-bottom: 0; }
.rich-table th:last-child, .rich-table td:last-child { border-right: 0; }
.rich-table b, .rich-p b { font-weight: 800; }
.q-question .rich-p b { font-weight: 700; color: var(--gold-ink); }
.review-item__q .rich-table, .qe__body .rich-table, .preview-item__q .rich-table { font-weight: 500; }
.rich-preview { margin: -6px 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--paper-2); font-size: .92rem; }
.rich-preview .label { display: block; margin-bottom: 6px; }
.qe__opt.pick { width: 100%; padding: 4px 8px; margin-left: -8px; border-radius: 8px; text-align: left; transition: background-color .15s ease; }
.qe__opt.pick svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .qe__opt.pick:hover { background: var(--turq-soft); color: var(--turq); } }
.q-image { position: relative; display: block; width: 100%; margin: -8px 0 22px; padding: 0; overflow: hidden; border-radius: 18px; border: 1px solid var(--line); background: var(--paper-2); cursor: zoom-in; }
.q-image img { width: 100%; max-height: min(52vh, 460px); object-fit: contain; }
.q-image__hint { position: absolute; right: 10px; bottom: 10px; padding: 4px 10px; border-radius: 999px; background: rgba(20, 33, 61, .72); color: #fff; font-size: .72rem; font-weight: 700; }
.review-img { display: block; margin: 0 0 10px; padding: 0; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); background: var(--paper-2); cursor: zoom-in; }
.review-img img { max-width: 100%; max-height: 220px; object-fit: contain; }
.zoom-box { display: grid; place-items: center; }
.zoom-img { max-width: 100%; max-height: 78vh; border-radius: 12px; object-fit: contain; }
.q-write { display: grid; gap: 8px; margin-bottom: 24px; }
.q-write__input { min-height: 58px; padding: 14px 18px; border-radius: 16px; font-size: 1.1rem; font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.q-write__input:focus { box-shadow: inset 0 0 0 2px var(--ink); }
.q-write__hint { font-size: .8rem; color: var(--muted); }

/* ---------- Result ---------- */
.result-hero { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 28px; }
.ring { position: relative; width: 160px; height: 160px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 1.2s var(--ease-out) .1s; }
.ring__val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-family: var(--f-display); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.ring__val small { display: block; margin-top: 4px; font-family: var(--f-body); font-size: .7rem; font-weight: 700; color: var(--muted); }
.bars { display: grid; gap: 14px; }
.bar__top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: .88rem; font-weight: 700; }
.bar__track { height: 8px; overflow: hidden; border-radius: 99px; background: var(--line); }
.bar__track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--turq), var(--gold)); transform: scaleX(0); transform-origin: 0 50%; transition: transform 1s var(--ease-out) .25s; }
.lock-note { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 18px; background: var(--paper-2); }
.lock-note svg { width: 22px; height: 22px; color: var(--gold-ink); }
.review { display: grid; gap: 12px; }
.review-item { padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.review-item__q { margin-bottom: 10px; font-weight: 800; white-space: pre-line; }
.review-item__exp { margin: 10px 0 0; padding-top: 10px; border-top: 1px dashed var(--line-2); font-size: .9rem; color: var(--ink-2); }
.opt-note { display: grid; grid-template-columns: 24px 1fr; gap: 10px; padding: 4px 0; font-size: .9rem; color: var(--muted); }
.opt-note b { display: block; color: var(--ink); }
.opt-note__mark { display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; font-size: .68rem; font-weight: 800; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.opt-note.is-correct b { color: var(--turq); }
.opt-note.is-correct .opt-note__mark { background: var(--turq); color: #fff; box-shadow: none; }
.opt-note.is-wrong b { color: var(--terra); }
.opt-note.is-wrong .opt-note__mark { background: var(--terra); color: #fff; box-shadow: none; }
.opt-note__tag { margin-left: 6px; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.opt-note__accepted { display: block; margin-top: 2px; }
.marks-sum { display: inline-flex; gap: 8px; font-family: var(--f-body); font-size: .85rem; font-weight: 800; }
.marks-sum span { padding: 3px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); }
.marks-sum .is-ok { background: var(--turq-soft); color: var(--turq); }
.marks-sum .is-bad { background: var(--terra-soft); color: var(--terra); }
.opt-note.is-pending b { color: var(--gold-ink); }
.opt-note.is-pending .opt-note__mark { background: var(--gold); color: #1A1406; box-shadow: none; }
.ai-note { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 16px; border-radius: 14px; background: var(--gold-soft); font-size: .9rem; font-weight: 600; }
.ai-note .spinner { width: 18px; height: 18px; border-width: 2px; flex: none; }
.grade-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 34px; }

/* ---------- Admin layout ---------- */
.admin { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; padding: 20px 14px; overflow-y: auto; background: var(--navy); color: var(--on-navy); }
.sidebar .brand { padding: 0 8px; }
.sidebar .brand__text small { color: var(--on-navy-muted); }
.sidebar__nav { display: grid; gap: 2px; margin-top: 26px; }
.sidebar__nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; font-size: .92rem; font-weight: 700; color: var(--on-navy-muted); transition: background-color .2s ease, color .2s ease; }
.sidebar__nav a svg { width: 19px; height: 19px; }
.sidebar__nav a.is-active { background: rgba(244, 237, 224, .1); color: var(--on-navy); }
.sidebar__nav a.is-active svg { color: var(--gold); }
@media (hover: hover) { .sidebar__nav a:hover { color: var(--on-navy); } }
.sidebar__foot { display: grid; gap: 10px; margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(244, 237, 224, .1); }
.sidebar__user { font-size: .78rem; color: var(--on-navy-muted); overflow-wrap: anywhere; }
.sidebar .icon-btn { color: var(--on-navy-muted); }
@media (hover: hover) { .sidebar .icon-btn:hover { background: rgba(244, 237, 224, .08); color: var(--on-navy); } }
.admin-main { min-width: 0; padding: 26px var(--gutter) 70px; }
.mobilebar { display: none; }
.scrim { display: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 200px; }

/* ---------- Question editor + import ---------- */
.qe { padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.qe + .qe { margin-top: 12px; }
.qe__head { display: flex; align-items: flex-start; gap: 12px; }
.qe__num { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 10px; background: var(--paper-2); font-size: .8rem; font-weight: 800; }
.qe__main { flex: 1; min-width: 0; }
.qe__body { font-weight: 700; white-space: pre-line; overflow-wrap: anywhere; }
.qe__opts { display: grid; gap: 4px; margin-top: 8px; }
.qe__opt { display: flex; gap: 8px; font-size: .9rem; color: var(--ink-2); }
.qe__opt.is-correct { color: var(--turq); font-weight: 800; }
.qe__tools { display: flex; flex: none; gap: 2px; }
.opt-row { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-row input[type="radio"] { width: 20px; height: 20px; accent-color: var(--turq); }
.opt-row .label { width: 18px; text-align: center; }
.qe__img { display: block; margin-top: 10px; padding: 0; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: var(--paper-2); cursor: zoom-in; }
.qe__img img { max-width: min(100%, 360px); max-height: 180px; object-fit: contain; }
.preview-img { display: block; max-width: min(100%, 280px); max-height: 140px; margin: 8px 0; border-radius: 10px; border: 1px solid var(--line); object-fit: contain; background: var(--paper-2); }
.img-drop { border-radius: 16px; border: 2px dashed var(--line-2); transition: border-color .2s ease, background-color .2s ease; }
.img-drop.is-over { border-color: var(--gold); background: var(--gold-soft); }
.img-drop__empty { display: grid; justify-items: center; gap: 4px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.img-drop__empty svg { width: 26px; height: 26px; color: var(--gold-ink); }
.img-drop__empty b { color: var(--ink-2); font-size: .88rem; }
.img-drop__preview { display: grid; justify-items: start; gap: 10px; padding: 12px; }
.img-drop__preview img { max-width: 100%; max-height: 260px; border-radius: 12px; object-fit: contain; background: var(--paper-2); }
.img-drop__preview label.btn { cursor: pointer; }
.acc-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; margin-bottom: 8px; }
.answer-test { margin-top: 12px; padding: 14px 16px 12px; border-radius: 16px; background: var(--paper-2); }
.answer-test .field { margin-bottom: 8px; }
.answer-test__result { margin: 0; font-size: .88rem; font-weight: 700; color: var(--muted); }
.answer-test__result.is-ok { color: var(--turq); }
.answer-test__result.is-bad { color: var(--terra); }
.dropzone { display: grid; place-items: center; gap: 8px; padding: 30px 18px; border-radius: 20px; border: 2px dashed var(--line-2); text-align: center; color: var(--muted); cursor: pointer; transition: border-color .2s ease, background-color .2s ease; }
.dropzone svg { width: 30px; height: 30px; color: var(--gold-ink); }
.dropzone.is-over { border-color: var(--gold); background: var(--gold-soft); }
.format-box { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--paper-2); font: 600 .82rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-x: auto; }
.preview-list { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.preview-item { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: .9rem; }
.preview-item.has-error { border-color: var(--terra); background: var(--terra-soft); }
.cred-card { padding: 18px; border-radius: 18px; background: var(--navy); color: var(--on-navy); font-size: .95rem; }
.cred-card b { color: var(--gold); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__art { display: none; }
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 90; width: 272px; transform: translateX(-100%); transition: transform .3s var(--ease-out); }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .scrim.is-on { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(7, 13, 26, .45); }
  .mobilebar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 var(--gutter); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 88%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  .admin-main { padding-top: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
  .result-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .test-item { grid-template-columns: 1fr; }
  .test-item__score { text-align: left; }
  .test-item .btn { width: 100%; }
  .q-nav .btn { flex: 1; }
  .runner__bar { top: 64px; }
  .toolbar .input, .toolbar .select { width: 100%; min-width: 0; }
  .modal--wide { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .modal--wide .modal__inner { max-height: 100%; height: 100%; }
  .stat__value { font-size: 2.1rem; }
  .opt-row { grid-template-columns: auto auto 1fr; }
  .opt-row .icon-btn { grid-column: 3; justify-self: end; }
  .grade-tools { margin-left: 0; }
  .mode-cards { grid-template-columns: 1fr; }
  .rich-table table { font-size: 13px; line-height: 1.4; }
  .rich-table th, .rich-table td { padding: 6px 7px; }
  .subject-tabs { gap: 8px; }
  .subject-tab { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; }
  .subject-tab img { width: 100%; height: 72px; border-radius: 14px; }
  .subject-tab b { font-size: 1.35rem; }
  .subject-tab small { white-space: normal; }
}
@media (max-width: 480px) {
  .topbar .brand__text small { display: none; }
  .topbar__tools { gap: 2px; }
  .topbar .lang-switch button { min-width: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
