/* ==========================================================================
   ADVANCE Placement — design system
   Brand palette and typography taken from advancecenter.uz
   ========================================================================== */

:root {
  /* Brand tokens copied verbatim from the advancecenter.uz stylesheet:
     --primary #0066ff · --primary-dark #004dc2 · accent #00d1ff
     --dark #0f172a · --light #f8fafc · text #1e293b / #64748b        */
  --brand: #0066ff;
  --brand-deep: #004dc2;
  --brand-dark: #0f172a;
  --sky: #00d1ff;
  --sky-deep: #00a8d6;
  --brand-glow: rgba(0, 102, 255, .2);

  /* Aliases, so the rest of the stylesheet reads unchanged. */
  --green: var(--brand);
  --green-deep: var(--brand-deep);
  --green-dark: var(--brand-dark);
  --green-darker: #0b1220;
  --green-050: #f1f6ff;
  --green-100: #dde9ff;
  --green-200: #b8d3ff;

  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(15, 23, 42, .09);
  --border-strong: rgba(15, 23, 42, .18);

  --danger: #c0392f;
  --danger-bg: #fdecea;
  --warn: #9a6100;
  --warn-bg: #fdf4e3;
  --info: var(--sky-deep);
  --info-bg: #e8f5fc;
  --ok: #17805a;
  --ok-bg: #e7f6f0;

  /* Radii match the site: 8 / 14 / 32. */
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 2px rgba(16, 40, 70, .06), 0 1px 3px rgba(16, 40, 70, .05);
  --shadow: 0 2px 4px rgba(16, 40, 70, .05), 0 8px 24px rgba(16, 40, 70, .08);
  --shadow-lg: 0 4px 8px rgba(16, 40, 70, .06), 0 20px 48px rgba(16, 40, 70, .14);

  /* Same typefaces as advancecenter.uz. */
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', var(--font);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --maxw: 1240px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-family: var(--font-display); font-size: 27px; letter-spacing: -.02em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--green-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

small { font-size: 12.5px; }

::selection { background: var(--green-200); }

:focus-visible {
  outline: 2px solid var(--green-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Layout ──────────────────────────────────────────────────────────── */

.shell { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.shell--narrow { max-width: 760px; }
.shell--mid { max-width: 960px; }

/* Every page is `class="shell page"`, so a `padding` shorthand here would also
   reset the side padding .shell just set — vertical only. */
.page { padding-top: 30px; padding-bottom: 72px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-head .eyebrow {
  font-size: 11.5px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase;
  color: var(--green-deep); margin-bottom: 6px;
}
.page-head .sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.stack { display: grid; gap: 18px; }
.stack-sm { display: grid; gap: 10px; }

/* Grid and flex children default to min-width:auto, so a card holding a wide
   table refuses to shrink below that table and pushes the whole page sideways.
   Letting them shrink is what makes the table scroll inside its own card. */
.stack > *, .stack-sm > *, .grid-2 > *, .grid-3 > *, .form-grid > *,
.toggle-grid > *, .card-head > *, .row > *, .row-between > * { min-width: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.spacer { flex: 1 1 auto; }

/* ── Brand header ────────────────────────────────────────────────────── */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 22px;
  display: flex; align-items: center; gap: 18px; min-height: 62px;
}

.logo { display: inline-flex; align-items: center; gap: 12px; color: var(--brand); text-decoration: none; }
.logo:hover { text-decoration: none; }
/* The official logo is a wide lockup (mark + wordmark): fix its height, let width follow. */
.logo img { height: 30px; width: auto; display: block; }
.logo-text {
  display: flex; flex-direction: column; line-height: 1.05;
  padding-left: 12px; border-left: 1px solid var(--border-strong);
}
.logo-name { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: .1em; color: var(--brand-deep); }
.logo-sub { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.logo-sub--solo { font-size: 11px; letter-spacing: .09em; color: var(--muted); }

/* Admin bar: logo · menu · user. The outer columns share the leftover space
   equally, which puts the menu in the centre of the bar rather than merely
   between its neighbours. */
.topbar-admin { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; }
.topbar-admin .logo { justify-self: start; }
.topbar-admin .nav { justify-self: center; margin-left: 0; }
.topbar-admin .userchip { justify-self: end; }

.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: 8px; }
.nav a {
  padding: 7px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.nav a:hover { background: var(--green-050); color: var(--green-deep); text-decoration: none; }
.nav a.active { background: var(--green); color: #fff; }

.userchip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.userchip strong { color: var(--ink); font-weight: 600; }

/* ── Cards ───────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-hint { color: var(--muted); font-size: 13px; }

.panel { background: var(--green-050); border: 1px solid var(--green-100); border-radius: var(--radius); padding: 16px 18px; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  --btn-bg: var(--green);
  --btn-fg: #fff;
  --btn-border: var(--green);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: filter .14s ease, background .14s ease, box-shadow .14s ease, transform .06s ease;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-ghost { --btn-bg: var(--surface); --btn-fg: var(--ink-2); --btn-border: var(--border-strong); }
.btn-ghost:hover { --btn-bg: var(--green-050); --btn-fg: var(--green-deep); --btn-border: var(--green-200); filter: none; }
.btn-quiet { --btn-bg: transparent; --btn-fg: var(--muted); --btn-border: transparent; }
.btn-quiet:hover { --btn-bg: var(--green-050); --btn-fg: var(--green-deep); filter: none; }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-border: #eccdcb; }
.btn-danger:hover { --btn-bg: var(--danger-bg); filter: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 15.5px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────────── */

.field { display: grid; gap: 6px; }
.field > label, .label {
  font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  letter-spacing: .02em;
}
.field .hint { font-size: 12.5px; color: var(--muted); }

.input, .select, .textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14.5px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%236d7d70' d='M2.5 4.5 6 8l3.5-3.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 12px;
}
.input-mono { font-family: var(--mono); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--green); }

/* ── Alerts / flash ──────────────────────────────────────────────────── */

.alert {
  border-radius: var(--radius-sm); padding: 12px 15px; font-size: 14px;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.alert-ok { background: var(--ok-bg); border-color: #cfe6cf; color: #21601f; }
.alert-error { background: var(--danger-bg); border-color: #f0cfcc; color: #8c1c16; }
.alert-warn { background: var(--warn-bg); border-color: #f0dfba; color: #7a4d00; }
.alert-info { background: var(--info-bg); border-color: #cfe0ec; color: #17506f; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.flash-wrap { position: sticky; top: 62px; z-index: 30; }
.flash-wrap .alert { margin: 14px 0 0; box-shadow: var(--shadow-sm); }

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
  background: var(--green-050); color: var(--green-deep); border: 1px solid var(--green-100);
  white-space: nowrap;
}
.badge-grey { background: #f0f2ef; color: var(--muted); border-color: var(--border); }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: #cfe6cf; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dfba; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: #f0cfcc; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: #cfe0ec; }

.level {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; padding: 3px 10px; border-radius: 7px;
  font-size: 12.5px; font-weight: 800; letter-spacing: .04em;
  color: #0f172a; background: var(--green);
}
/* Level chips use their own pastel scale so levels are told apart at a glance. */
.level-A1 { background: #7dd3fc; }  /* светло-голубой  */
.level-A2 { background: #86efac; }  /* светло-зелёный  */
.level-B1 { background: #fca5a5; }  /* светло-красный  */
.level-B2 { background: #fde047; }  /* светло-жёлтый   */
.level-C1 { background: #c4b5fd; }  /* светло-фиолетовый */
.level-lg { min-width: 56px; padding: 6px 14px; font-size: 16px; border-radius: 9px; }

/* ── Tables ──────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
table.data th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--green-050); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.tight { white-space: nowrap; }
.t-name { font-weight: 600; color: var(--ink); }
.t-sub { color: var(--muted); font-size: 12.5px; }

.empty {
  padding: 46px 22px; text-align: center; color: var(--muted);
  background: var(--surface); border-radius: var(--radius);
}
.empty h3 { color: var(--ink-2); margin-bottom: 6px; }

/* ── Stats ───────────────────────────────────────────────────────────── */

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
/* The site's signature gradient: linear-gradient(135deg, #06f, #00d1ff). */
.stat-accent { background: linear-gradient(135deg, var(--brand) 0%, var(--sky) 100%); border-color: transparent; color: #fff; }
.stat-accent .k { color: rgba(255,255,255,.78); }
.stat-accent .v, .stat-accent .d { color: #fff; }

/* ── Score bars ──────────────────────────────────────────────────────── */

.bar { height: 8px; border-radius: 99px; background: var(--green-100); overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--sky) 0%, var(--brand) 100%); border-radius: 99px; }
.bar-weak > span { background: #d08a2c; }
.bar-bad > span { background: #c05a4e; }

.metric-row {
  display: grid; grid-template-columns: 74px 1fr 74px; gap: 12px; align-items: center;
  padding: 9px 0; border-bottom: 1px dashed var(--border);
}
.metric-row:last-child { border-bottom: 0; }
.metric-row .m-label { font-weight: 700; font-size: 13px; }
.metric-row .m-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13.5px; }
.metric-row .m-value small { color: var(--muted); font-weight: 500; }

/* ── Student flow ────────────────────────────────────────────────────── */

/* no-repeat + explicit colour, otherwise the gradient tiles again below a short page */
body.student {
  background-color: var(--bg);
  background-image: linear-gradient(180deg, #e6f1ff 0%, var(--bg) 400px);
  background-repeat: no-repeat;
  min-height: 100vh;
}

.steps { display: flex; gap: 8px; align-items: center; margin-bottom: 26px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted-2); font-weight: 600; }
.step i {
  width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--muted);
  font-size: 11.5px; font-style: normal; font-weight: 700;
}
.step.done i { background: var(--green-100); border-color: var(--green-200); color: var(--green-deep); }
.step.current { color: var(--green-deep); }
.step.current i { background: var(--green); border-color: var(--green); color: #fff; }
.step-sep { flex: 0 0 18px; height: 1px; background: var(--border-strong); }

.hero {
  text-align: center; padding: 30px 0 6px;
}
.hero .logo { justify-content: center; margin-bottom: 20px; }
.hero .logo img { height: 44px; }
.hero .logo-name { font-size: 19px; }
.hero .logo-sub--solo { font-size: 12px; }
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.hero p { color: var(--muted); max-width: 520px; margin: 0 auto; }

.pin-input {
  display: flex; gap: 10px; justify-content: center; margin: 6px 0 4px;
}
.pin-input input {
  width: 58px; height: 68px; text-align: center;
  font-size: 27px; font-weight: 700; font-family: var(--mono);
  border: 1.5px solid var(--border-strong); border-radius: 12px; background: var(--surface);
  color: var(--ink); transition: border-color .14s ease, box-shadow .14s ease;
}
.pin-input input:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--brand-glow);
}
.pin-input input.filled { border-color: var(--green-200); background: var(--green-050); }

.sa-table { display: grid; gap: 12px; }
.sa-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); }
.sa-item .sa-skill { font-weight: 700; font-size: 14.5px; }
.sa-item .sa-q { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.sa-options { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sa-options label {
  flex: 1 1 130px; text-align: center; padding: 9px 10px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: all .12s ease;
}
.sa-options input { position: absolute; opacity: 0; pointer-events: none; }
.sa-options label:hover { border-color: var(--green-200); background: var(--green-050); }
.sa-options input:checked + span,
.sa-options label.checked { background: var(--green); border-color: var(--green); color: #fff; }

/* Test question cards */
.q-progress {
  position: sticky; top: 62px; z-index: 25;
  background: rgba(242, 245, 250, .93); backdrop-filter: blur(8px);
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.q-progress-inner { display: flex; align-items: center; gap: 14px; }
.q-progress .bar { flex: 1 1 auto; }
.q-progress .q-count { font-size: 13px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-timer { font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.q-timer.low { color: var(--danger); }

.section-head {
  margin: 34px 0 14px; padding-bottom: 10px; border-bottom: 2px solid var(--green-100);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.section-head h2 { font-size: 17px; color: var(--green-deep); letter-spacing: .01em; }
.section-head .sec-meta { font-size: 12.5px; color: var(--muted); }

.q-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 14px; scroll-margin-top: 130px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.q-card.answered { border-color: var(--green-200); }
.q-card.missing { border-color: #e8c3bf; background: #fffafa; }
.q-num {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px;
  border-radius: 7px; background: var(--green-050); color: var(--green-deep);
  font-size: 12.5px; font-weight: 800; margin-right: 10px; padding: 0 6px;
}
.q-card.answered .q-num { background: var(--green); color: #fff; }
.q-context {
  background: var(--surface-2); border-left: 3px solid var(--green-200);
  padding: 12px 15px; border-radius: 0 9px 9px 0; margin: 0 0 13px;
  font-size: 14.5px; color: var(--ink-2); white-space: pre-line;
}
.q-prompt { font-size: 15.5px; font-weight: 600; margin-bottom: 13px; }
.q-options { display: grid; gap: 8px; }
.q-option {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-size: 14.5px;
  transition: all .12s ease;
}
.q-option:hover { border-color: var(--green-200); background: var(--green-050); }
.q-option input { position: absolute; opacity: 0; pointer-events: none; }
.q-option .k {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 800;
  background: #eef1ec; color: var(--muted); border: 1px solid var(--border);
  transition: all .12s ease;
}
.q-option.checked { border-color: var(--green); background: var(--green-050); box-shadow: inset 0 0 0 1px var(--green); }
.q-option.checked .k { background: var(--green); border-color: var(--green); color: #fff; }

.submit-bar {
  position: sticky; bottom: 0; z-index: 26;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); padding: 14px 0; margin-top: 26px;
}
.submit-bar-inner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.result-score {
  text-align: center; padding: 12px 0 6px;
}
.result-score .big {
  font-size: 68px; font-weight: 800; letter-spacing: -.03em; line-height: 1;
  color: var(--green-deep); font-variant-numeric: tabular-nums;
}
.result-score .big span { font-size: 30px; color: var(--muted-2); font-weight: 700; }
.result-score .cap { font-size: 12.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }

.num-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.num-cell {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 14px;
  text-align: center; background: var(--surface-2);
}
.num-cell .k { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.num-cell .v { font-size: 21px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ── Admin: result detail ────────────────────────────────────────────── */

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 600; }

.answers-table td.ans { font-family: var(--mono); font-weight: 700; text-align: center; width: 60px; }
.answers-table tr.wrong td { background: #fdf6f5; }
.answers-table tr.wrong:hover td { background: #fbeeec; }
.answers-table tr.blank td { background: #fbfaf4; }
.mark-ok { color: var(--ok); font-weight: 800; }
.mark-bad { color: var(--danger); font-weight: 800; }

.weak-list { display: flex; flex-wrap: wrap; gap: 8px; }
.weak-item {
  border: 1px solid #f0dfba; background: var(--warn-bg); color: #7a4d00;
  padding: 7px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
}
.weak-item small { display: block; font-weight: 500; opacity: .8; font-size: 11.5px; }
.weak-item.self { border-color: #bcdff2; background: var(--info-bg); color: #14567a; }

.weak-more { margin-top: 12px; }
.weak-more summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-deep);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2);
}
.weak-more summary::-webkit-details-marker { display: none; }
.weak-more summary::before { content: '▾'; font-size: 11px; }
.weak-more[open] summary::before { content: '▴'; }
.weak-more summary:hover { border-color: var(--green-200); background: var(--green-050); }

.ladder { display: grid; gap: 8px; }
.ladder-row {
  display: grid; grid-template-columns: 52px 1fr 92px 108px; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.ladder-row.is-mastered { border-color: var(--green-200); background: var(--green-050); }
.ladder-row.is-target { border-color: var(--green); background: #fff; box-shadow: inset 0 0 0 1px var(--green); }
.ladder-row .l-score { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; }
.ladder-row .l-state { font-size: 12px; font-weight: 700; text-align: right; }
.ladder-row .l-state.ok { color: var(--ok); }
.ladder-row .l-state.no { color: var(--warn); }

/* ── Admin: filters ──────────────────────────────────────────────────── */

.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;
  align-items: end;
}
.filters .field { min-width: 0; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
}
.pagination a:hover { border-color: var(--green-200); background: var(--green-050); text-decoration: none; }
.pagination .current { background: var(--green); border-color: var(--green); color: #fff; }
.pagination .muted { color: var(--muted-2); border-color: transparent; background: transparent; }

/* ── PIN cards in the assignments page ───────────────────────────────── */

.pin-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 21px; font-weight: 700; letter-spacing: .14em;
  color: var(--green-deep); background: var(--green-050); border: 1px solid var(--green-100);
  padding: 5px 13px; border-radius: 10px;
}
.copy-btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted);
  border-radius: 7px; padding: 4px 8px; font: inherit; font-size: 12px; cursor: pointer;
}
.copy-btn:hover { border-color: var(--green-200); color: var(--green-deep); background: var(--green-050); }
.copy-btn.done { color: var(--ok); border-color: #cfe6cf; background: var(--ok-bg); }

.link-box {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; word-break: break-all;
}

/* ── Test editor ─────────────────────────────────────────────────────── */

.editor-q {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  margin-bottom: 12px; overflow: hidden;
}
.editor-q-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); cursor: pointer;
  flex-wrap: wrap;
}
.editor-q-head .grip { color: var(--muted-2); cursor: grab; font-size: 15px; line-height: 1; }
.editor-q-head .title { flex: 1 1 220px; font-size: 14px; font-weight: 600; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-q-body { padding: 16px 18px; display: grid; gap: 14px; }
.editor-q.collapsed .editor-q-body { display: none; }
/* okey · text · "верный" · upload — the upload control was added later and did
   not fit the old three-column grid, so the row is flexible now. */
.editor-opt { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.editor-opt > .input { flex: 1 1 220px; min-width: 0; }
.editor-opt .okey {
  display: grid; place-items: center; width: 34px; height: 38px; flex: none; border-radius: 9px;
  background: #eef1ec; border: 1px solid var(--border); font-weight: 800; font-size: 13px; color: var(--muted);
}
.editor-opt.is-answer .okey { background: var(--green); border-color: var(--green); color: #fff; }
.editor-toolbar {
  position: sticky; bottom: 0; background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); padding: 12px 0; margin-top: 20px; z-index: 20;
}
.editor-toolbar-inner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--danger); }

.readonly-note {
  display: flex; gap: 10px; align-items: center;
  background: var(--info-bg); border: 1px solid #cfe0ec; color: #17506f;
  padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px;
}

/* ── Print (student result / admin card) ─────────────────────────────── */

@media print {
  .topbar, .page-actions, .submit-bar, .editor-toolbar, .filters, .pagination, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .page { padding: 0; }
}

/* ── Responsive ──────────────────────────────────────────────────────── */

/* Between roughly 860 and 980 the six menu items no longer fit beside the logo
   and the user chip, and wrapping them mid-row looks like a mistake. Give the
   menu its own row before that happens. */
@media (max-width: 980px) {
  .topbar-admin { grid-template-columns: 1fr auto; gap: 8px 10px; }
  .topbar-admin .nav { grid-column: 1 / -1; justify-self: stretch; flex-wrap: nowrap; overflow-x: auto; }
}

@media (max-width: 860px) {
  /* Logo and user on the first row, the menu scrolling across the second. */
  .topbar-inner { flex-wrap: wrap; padding: 10px 16px; min-height: 0; gap: 10px; }
  .topbar-admin { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; }
  .topbar-admin .nav { grid-column: 1 / -1; justify-self: stretch; }
  .nav {
    order: 3; width: 100%; margin-left: 0; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { font-size: 13px; padding: 8px 11px; }

  /* Two sticky bars at top: 0 would overlap, and on a phone the brand bar is
     the one worth giving up — only the progress bar has to stay in view. */
  .topbar { position: static; }
  .q-progress { top: 0; }
  .flash-wrap { top: 0; }

  .shell { padding: 0 16px; }
  /* Clears the sticky bottom bar, which wraps to ~110px on a phone — with less
     the last question sits underneath it and cannot be reached. */
  .page { padding-top: 18px; padding-bottom: 130px; }
  h1 { font-size: 23px; }
  .hero h1 { font-size: 25px; }
  .result-score .big { font-size: 54px; }
  .ladder-row { grid-template-columns: 46px 1fr 76px; }
  .ladder-row .l-state { grid-column: 2 / -1; text-align: left; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }

  /* Wide admin tables scroll inside their card instead of stretching the page. */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 10px; }
  .essay-answer { max-width: none; }
}

@media (max-width: 620px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; text-align: center; }

  /* Progress: counter and timer on one line, the bar on its own full-width. */
  .q-progress-inner { flex-wrap: wrap; gap: 8px 12px; }
  .q-progress .bar { order: 3; flex-basis: 100%; }

  .filters { grid-template-columns: 1fr; }
  .form-actions .btn { flex: 1 1 auto; }

  /* Compact sticky bar: a full-width button with the two status lines sharing
     the row under it, instead of three stacked rows eating the screen. */
  .submit-bar { padding: 10px 0; }
  .submit-bar-inner { gap: 6px 12px; }
  .submit-bar-inner > .btn { flex: 1 1 100%; }
  .submit-bar-inner .save-state,
  .submit-bar-inner .card-hint { font-size: 12px; }
  .submit-bar-inner .spacer { display: none; }
  .editor-toolbar-inner > .btn { flex: 1 1 100%; }

  .grid-2, .grid-3, .form-grid, .toggle-grid { grid-template-columns: 1fr; }
  .stat .v { font-size: 26px; }
  .import-steps { grid-template-columns: 1fr; }

  .editor-opt { align-items: stretch; }
  .editor-opt .okey { width: 100%; height: 30px; }
  .q-order-item { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .pin-input input { width: 48px; height: 58px; font-size: 22px; }
  .card-pad, .card-body { padding: 16px; }
  .q-card { padding: 15px 16px; }
  .sa-options label { flex-basis: 100%; }

  /* Safari zooms the page when a focused field is under 16px. Students type
     names, gap answers and whole essays on phones, so this matters. */
  .input, .select, .textarea { font-size: 16px; padding: 11px 13px; }
  .input-gap { width: 6.5em; padding: 6px 9px; }

  /* Comfortable tap targets. */
  .btn { padding: 11px 18px; }
  .btn-sm { padding: 8px 12px; }
  .q-option { padding: 13px 14px; }
  .check input { width: 18px; height: 18px; }
  .lang-choice { padding: 18px; }
}

/* A long unbroken word (a URL in a question, a pasted token) must not push the
   page sideways on a narrow screen. */
.q-prompt, .q-context, .module-passage, .essay-answer, .t-name, .t-sub {
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Language chooser
   ========================================================================== */
.lang-choices { display: grid; gap: 10px; }
.lang-choice {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); transition: border-color .15s, background .15s;
}
.lang-choice:hover { border-color: var(--green-200); background: var(--green-050); }
.lang-choice input { position: absolute; opacity: 0; pointer-events: none; }
.lang-choice .code {
  display: inline-grid; place-items: center; min-width: 46px; padding: 6px 10px;
  border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--muted);
}
.lang-choice .name { font-weight: 600; font-size: 16px; }
.lang-choice.checked { border-color: var(--green); background: var(--green-050); box-shadow: inset 0 0 0 1px var(--green); }
.lang-choice.checked .code { background: var(--green); border-color: var(--green); color: #fff; }

/* ==========================================================================
   Modules
   ========================================================================== */
.module-chip {
  padding: 4px 10px; border-radius: 999px; background: var(--green-050);
  border: 1px solid var(--green-200); color: var(--brand-deep);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.module-audio audio, .q-media audio { width: 100%; }
.module-audio.spent { opacity: .6; }
.module-img { display: block; max-width: 100%; border-radius: 12px; }
.module-passage { white-space: pre-line; line-height: 1.7; }
.module-scores { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.module-score-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; }
.module-score-row .name { font-weight: 600; }
.module-score-row .val { font-family: var(--mono); font-weight: 700; }

/* ==========================================================================
   Question types
   ========================================================================== */
.q-hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.q-media { margin: 12px 0; }
.q-media img { display: block; max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.opt-img { display: block; max-width: 220px; margin-top: 8px; border-radius: 9px; }
.q-options--tf { grid-template-columns: 1fr 1fr; }

/* Inline blanks sit in the sentence, so they must not break the line box. */
.q-gap-text { line-height: 2.4; }
.input-gap {
  /* `width: auto` on a text input means its default ~20-character intrinsic
     size — about 200px, which breaks the sentence onto several lines on a
     phone. An em width keeps the blank proportional to the text around it. */
  display: inline-block; width: 9em; min-width: 0; max-width: 100%;
  margin: 0 4px; padding: 5px 10px; font-size: 15px;
}
select.input-gap { width: auto; max-width: 100%; }
.q-gaps { display: grid; gap: 10px; }
.q-gap-row { display: flex; align-items: center; gap: 10px; }
.q-gap-n {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--muted);
}

.q-match { display: grid; gap: 10px; }
.q-match-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: center; }
.q-match-row .left { font-weight: 600; }

.q-order { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: ord; }
.q-order-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.q-order-item::before {
  counter-increment: ord; content: counter(ord);
  display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none;
  border-radius: 7px; background: var(--green-050); border: 1px solid var(--green-200);
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--brand-deep);
}
.q-order-item .txt { flex: 1; }

.q-essay { min-height: 190px; font-size: 15.5px; line-height: 1.65; }
.q-words { display: flex; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.q-words .counter { font-family: var(--mono); font-weight: 600; }
.q-words .counter.short { color: var(--warn); }
.q-words .counter.over { color: var(--danger); }

/* Overtime: the clock goes red and keeps counting up when the invitation was
   issued with the soft-deadline switch on. */
.q-timer.over { color: var(--danger); font-weight: 700; }

@media (max-width: 620px) {
  .q-match-row { grid-template-columns: 1fr; gap: 6px; }
  .q-options--tf { grid-template-columns: 1fr; }
}

/* Long written answers inside the admin answers table. */
.essay-answer {
  max-width: 460px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px;
}

/* Editor: module boxes and upload controls. */
.module-box {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  background: var(--surface-2); display: grid; gap: 12px;
}
.upl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upl-preview { max-height: 64px; max-width: 140px; border-radius: 8px; border: 1px solid var(--border); }
.upl-audio { height: 34px; max-width: 240px; }

/* Editor: behaviour switches and per-module question groups. */
.toggle-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px 22px; }
.q-group { display: grid; gap: 10px; }
.q-group + .q-group { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border-strong); }
.q-group-head { display: flex; align-items: baseline; gap: 10px; }
.q-group-head h3 { font-size: 15.5px; }

/* Import page */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 14px; padding: 34px 22px;
  text-align: center; color: var(--muted); cursor: pointer; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--green); background: var(--green-050); color: var(--ink-2); }
.import-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.import-step { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.import-step b { display: block; margin-bottom: 4px; color: var(--ink); }

/* New-test type picker */
.type-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.type-choice {
  display: grid; gap: 4px; cursor: pointer; padding: 13px 15px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.type-choice:hover { border-color: var(--green-200); background: var(--green-050); }
.type-choice input { position: absolute; opacity: 0; pointer-events: none; }
.type-choice .t { font-weight: 650; }
.type-choice .d { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.type-choice.checked { border-color: var(--green); background: var(--green-050); box-shadow: inset 0 0 0 1px var(--green); }

/* Below the version's minimal score — a flag, never a pass/fail verdict. */
.below-pass { color: var(--danger); }
.pass-hint { font-size: 12px; color: var(--muted); }

/* Collapsible optional block (sections) */
.opt-block > summary {
  cursor: pointer; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); display: flex; align-items: baseline; gap: 12px; list-style: none;
}
.opt-block > summary::-webkit-details-marker { display: none; }
.opt-block > summary::before { content: '▸'; color: var(--muted); }
.opt-block[open] > summary::before { content: '▾'; }
.opt-block[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: none; }
.opt-block > .card { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ==========================================================================
   QR for the student link
   ========================================================================== */
.qr-block {
  display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap;
  padding: 16px; margin: 4px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.qr-frame {
  flex: none; line-height: 0;
  padding: 10px; border-radius: 12px; background: #fff; border: 1px solid var(--border);
}
.qr-frame svg { display: block; width: 168px; height: 168px; }
.qr-side { flex: 1 1 220px; min-width: 0; display: grid; gap: 8px; align-content: start; }
.qr-side .link-box { word-break: break-all; }

@media (max-width: 620px) {
  .qr-block { justify-content: center; text-align: center; }
  .qr-side { justify-items: center; }
  .qr-side .row { justify-content: center; }
}

/* Printing the page should give a big, clean code and nothing else noisy. */
@media print {
  .qr-frame svg { width: 300px; height: 300px; }
}
