/* ==========================================================================
   Физика — гимназия. Design system.
   Idea: a physics lab notebook. Millimetre graph paper, fountain-pen blue ink,
   one highlighter yellow for the thing that matters most on each screen.
   ========================================================================== */

:root {
  --ink: #172340;
  --ink-2: #4a5878;
  --ink-3: #7a879f;
  --paper: #ffffff;
  --bg: #f3f6fb;
  --grid: #dfe7f3;
  --grid-strong: #c9d6ea;
  --line: #e2e8f1;
  --pen: #2347c8;
  --pen-dark: #1a369e;
  --pen-soft: #e9eefc;
  --marker: #ffd84d;
  --marker-soft: #fff6cf;
  --ok: #17805a;
  --ok-soft: #e4f4ec;
  --bad: #c23a33;
  --bad-soft: #fcebe9;
  --warn: #9a5c00;
  --warn-soft: #fff3d6;

  --font: "Golos Text", "Segoe UI", "Noto Sans", Arial, sans-serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(23, 35, 64, .06), 0 4px 16px rgba(23, 35, 64, .06);
  --shadow-lift: 0 2px 4px rgba(23, 35, 64, .08), 0 12px 32px rgba(23, 35, 64, .10);
  --focus: 0 0 0 3px rgba(35, 71, 200, .35);
  --container: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--pen); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--pen-dark); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.tnum { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 28px; } }

/* Graph paper ------------------------------------------------------------ */
.graph-paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 50px 50px, 50px 50px, 10px 10px, 10px 10px;
  background-position: -1px -1px;
}

/* Header ----------------------------------------------------------------- */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: .8rem; color: var(--ink-2); }
.header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: none; }
@media (max-width: 560px) { .brand-name { font-size: .85rem; max-width: 52vw; } .hide-sm { display: none !important; } }

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font: 600 .95rem/1 var(--font);
  border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--pen); color: #fff; }
.btn-primary:hover { background: var(--pen-dark); color: #fff; }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--grid-strong); }
.btn-secondary:hover { border-color: var(--pen); color: var(--pen); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--pen-soft); color: var(--pen); }
.btn-danger { background: var(--paper); color: var(--bad); border-color: #efc7c3; }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { background: #126a4a; color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 1.05rem; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Forms ------------------------------------------------------------------ */
.field { margin-bottom: 18px; }
.field > label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px;
  font: 400 1rem/1.4 var(--font); color: var(--ink);
  background: var(--paper); border: 1px solid var(--grid-strong); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus, .select:focus { outline: none; border-color: var(--pen); box-shadow: var(--focus); }
.select {
  appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234a5878' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.help { font-size: .825rem; color: var(--ink-2); margin-top: 6px; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--bad); font-size: .85rem; font-weight: 500; }
.field.has-error .input, .field.has-error .select { border-color: var(--bad); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--pen); flex: none; }
.form-grid { display: grid; gap: 0 18px; }
@media (min-width: 720px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label { cursor: pointer; }

/* Messages --------------------------------------------------------------- */
.messages { display: grid; gap: 8px; margin: 18px 0; }
.msg {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--r-sm); font-size: .95rem; font-weight: 500;
  border: 1px solid transparent; background: var(--pen-soft); color: var(--pen-dark);
}
.msg-success { background: var(--ok-soft); color: var(--ok); border-color: #c4e6d4; }
.msg-error { background: var(--bad-soft); color: var(--bad); border-color: #f2cbc7; }
.msg-warning { background: var(--warn-soft); color: var(--warn); border-color: #f3dfaa; }

/* Badges ----------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--ink-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-draft { background: var(--pen-soft); color: var(--pen); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-live { background: var(--ok-soft); color: var(--ok); }
.badge-live::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* Panels & tables -------------------------------------------------------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h2, .panel-head h3 { margin: 0; }
@media (max-width: 560px) { .panel { padding: 16px; border-radius: var(--r); } }

.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th {
  text-align: left; font-weight: 600; font-size: .82rem; color: var(--ink-2);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table a.row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.table a.row-link:hover { color: var(--pen); }

.empty {
  text-align: center; padding: 40px 20px; color: var(--ink-2);
  border: 1.5px dashed var(--grid-strong); border-radius: var(--r); background: #fafcff;
}
.empty h3 { color: var(--ink); }
.empty .btn { margin-top: 8px; }

/* ==========================================================================
   STUDENT: home
   ========================================================================== */
.hero { border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.hero .container { display: grid; gap: 32px; padding-top: 48px; padding-bottom: 56px; position: relative; }
@media (min-width: 900px) { .hero .container { grid-template-columns: 1.1fr 1fr; align-items: center; padding-top: 72px; padding-bottom: 80px; } }
.hero-copy h1 { max-width: 14ch; }
.hero-copy p { font-size: 1.1rem; color: var(--ink-2); max-width: 40ch; }
.hero-plot { position: absolute; inset: 0; pointer-events: none; }
.hero-plot svg { width: 100%; height: 100%; }
.plot-line { stroke: var(--pen); stroke-width: 2.5; fill: none; stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 2.2s .3s ease-out forwards; opacity: .35; }
.plot-dot { fill: var(--pen); opacity: 0; animation: appear .3s 2.4s forwards; }
.plot-label { font: 600 15px var(--font); fill: var(--pen); opacity: 0; animation: appear .4s 2.5s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: .6; } }

.code-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift); padding: 28px; position: relative; z-index: 1;
}
.code-card h2 { font-size: 1.25rem; }
.code-input {
  width: 100%; height: 72px; padding: 0 16px; text-align: center;
  font: 800 2rem/1 var(--font); letter-spacing: .32em; text-transform: uppercase;
  color: var(--ink); background: var(--marker-soft);
  border: 2px solid var(--marker); border-radius: var(--r);
  font-variant-numeric: tabular-nums;
}
.code-input::placeholder { color: #c8b46a; letter-spacing: .32em; }
.code-input:focus { outline: none; border-color: var(--pen); box-shadow: var(--focus); background: #fff; }
.code-card .btn { margin-top: 14px; }

.grades-section { padding: 48px 0 64px; }
.grade-switch { display: flex; gap: 8px; margin: 20px 0 24px; overflow-x: auto; padding-bottom: 4px; }
.grade-tab {
  flex: 1 1 0; min-width: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px 10px 12px; border-radius: var(--r); text-decoration: none;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink-2);
}
.grade-tab .n { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.grade-tab .t { font-size: .8rem; margin-top: 4px; }
.grade-tab .count { font-size: .72rem; font-weight: 600; margin-top: 6px; color: var(--ok); }
.grade-tab:hover { border-color: var(--pen); color: var(--pen); }
.grade-tab[aria-current="true"] { background: var(--pen); border-color: var(--pen); color: #dfe6ff; }
.grade-tab[aria-current="true"] .n { color: #fff; }
.grade-tab[aria-current="true"] .count { color: var(--marker); }

.test-list { display: grid; gap: 12px; }
@media (min-width: 720px) { .test-list { grid-template-columns: 1fr 1fr; } }
.test-item {
  display: flex; gap: 16px; align-items: center; padding: 18px 20px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  text-decoration: none; color: var(--ink);
}
.test-item:hover { border-color: var(--pen); color: var(--ink); box-shadow: var(--shadow); }
.test-item .body { flex: 1; min-width: 0; }
.test-item .title { font-weight: 700; margin-bottom: 2px; }
.test-item .meta { font-size: .85rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.test-item .go {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pen-soft); color: var(--pen);
}
.test-item:hover .go { background: var(--pen); color: #fff; }

/* Join -------------------------------------------------------------------- */
.narrow { max-width: 560px; margin: 0 auto; }
.page { padding: 36px 0 64px; }
.join-card { padding: 30px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 24px; }
.fact { background: var(--bg); border-radius: var(--r-sm); padding: 12px; text-align: center; }
.fact b { display: block; font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fact span { font-size: .8rem; color: var(--ink-2); }
.rules { margin: 0 0 22px; padding: 0; list-style: none; font-size: .925rem; color: var(--ink-2); display: grid; gap: 6px; }
.rules li { padding-left: 22px; position: relative; }
.rules li::before { content: ""; position: absolute; left: 4px; top: .6em; width: 8px; height: 8px; border-radius: 2px; background: var(--marker); }

/* ==========================================================================
   STUDENT: taking a test
   ========================================================================== */
.quiz-top {
  position: sticky; top: 0; z-index: 40; background: var(--paper); border-bottom: 1px solid var(--line);
}
.quiz-top .container { display: flex; align-items: center; gap: 14px; min-height: 62px; }
.quiz-top .topic { min-width: 0; flex: 1; }
.quiz-top .topic b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.quiz-top .topic span { font-size: .8rem; color: var(--ink-2); }
.timer {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--bg); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem;
}
.timer svg { width: 18px; height: 18px; }
.timer.is-low { background: var(--bad-soft); color: var(--bad); }

/* The ruler: one tick per question, numbered because it is a sequence. */
.ruler { display: flex; gap: 4px; padding: 14px 0 6px; overflow-x: auto; scrollbar-width: thin; }
.ruler button {
  flex: 1 0 34px; height: 38px; border: 1px solid var(--grid-strong); background: var(--paper);
  border-radius: 6px; font: 600 .85rem var(--font); color: var(--ink-2); cursor: pointer;
  font-variant-numeric: tabular-nums; position: relative;
}
.ruler button.answered { background: var(--pen-soft); border-color: #bccaf5; color: var(--pen); }
.ruler button.current { background: var(--pen); border-color: var(--pen); color: #fff; }
.ruler button.current::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--pen);
}

.q-stage { padding: 18px 0 120px; }
.q-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px; box-shadow: var(--shadow); }
@media (max-width: 560px) { .q-card { padding: 18px; border-radius: var(--r); } }
.q-count { font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.q-text { font-size: clamp(1.1rem, 1rem + .5vw, 1.3rem); font-weight: 600; line-height: 1.5; margin-bottom: 22px; white-space: pre-line; }
.options { display: grid; gap: 10px; border: 0; padding: 0; margin: 0; }
.option {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 60px;
  border: 1.5px solid var(--grid-strong); border-radius: var(--r); background: var(--paper);
  cursor: pointer; transition: border-color .12s, background-color .12s;
}
.option:hover { border-color: var(--pen); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option .letter {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; background: var(--bg); color: var(--ink-2); transition: inherit;
}
.option .text { flex: 1; font-size: 1.02rem; }
.option:has(input:checked) { border-color: var(--pen); background: var(--pen-soft); }
.option:has(input:checked) .letter { background: var(--pen); color: #fff; }
.option:has(input:focus-visible) { box-shadow: var(--focus); }

.q-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px); padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
}
.q-nav .container { display: flex; gap: 10px; align-items: center; }
.q-nav .spacer { flex: 1; text-align: center; font-size: .85rem; color: var(--ink-2); }
@media (max-width: 560px) { .q-nav .spacer { display: none; } .q-nav .btn { flex: 1; } }
.save-state { font-size: .8rem; color: var(--ink-3); }

dialog.modal {
  border: 0; border-radius: var(--r-lg); padding: 26px; max-width: 420px; width: calc(100% - 32px);
  box-shadow: var(--shadow-lift); color: var(--ink);
}
dialog.modal::backdrop { background: rgba(23, 35, 64, .45); }
dialog.modal h3 { font-size: 1.25rem; }

/* ==========================================================================
   STUDENT: result
   ========================================================================== */
.result-hero { text-align: center; padding: 34px 26px; }
.ring { position: relative; width: 168px; height: 168px; margin: 8px auto 18px; }
.ring svg { transform: rotate(-90deg); width: 168px; height: 168px; }
.ring .track { stroke: var(--bg); }
.ring .value { stroke: var(--pen); stroke-linecap: round; transition: stroke-dashoffset 1.2s ease-out; }
.ring.mark-5 .value, .ring.mark-4 .value { stroke: var(--ok); }
.ring.mark-2 .value { stroke: var(--bad); }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .pct { font-size: 2.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ring .lbl { font-size: .85rem; color: var(--ink-2); margin-top: 4px; }
.score-line { font-size: 1.15rem; margin-bottom: 18px; }
.score-line b { font-variant-numeric: tabular-nums; }
.mark {
  display: inline-flex; align-items: center; gap: 12px; padding: 10px 18px 10px 10px; border-radius: 999px;
  background: var(--bg); font-weight: 600;
}
.mark .n {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 800; background: var(--paper); border: 2px solid currentColor;
}
.mark-5, .mark-4 { color: var(--ok); }
.mark-3 { color: var(--warn); }
.mark-2 { color: var(--bad); }
.mark.mark-5, .mark.mark-4 { background: var(--ok-soft); }
.mark.mark-3 { background: var(--warn-soft); }
.mark.mark-2 { background: var(--bad-soft); }

.review { display: grid; gap: 12px; margin-top: 20px; }
.review-item { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; background: var(--paper); border-left: 4px solid var(--ok); }
.review-item.wrong { border-left-color: var(--bad); }
.review-item .q { font-weight: 600; margin-bottom: 8px; }
.review-item .a { font-size: .95rem; display: grid; gap: 4px; }
.review-item .a .yours { color: var(--bad); }
.review-item.right .a .yours { color: var(--ok); }
.review-item .a .right-ans { color: var(--ok); }
.review-item .expl { margin-top: 10px; font-size: .9rem; color: var(--ink-2); background: var(--bg); border-radius: var(--r-sm); padding: 10px 12px; }

/* ==========================================================================
   TEACHER: app shell
   ========================================================================== */
.shell { display: grid; min-height: 100vh; }
@media (min-width: 1000px) { .shell { grid-template-columns: 252px 1fr; } }
.sidebar {
  background: var(--ink); color: #c9d2e6; padding: 18px 14px; display: none;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
@media (min-width: 1000px) { .sidebar { display: flex; flex-direction: column; } }
.sidebar .brand { color: #fff; padding: 4px 8px 18px; }
.sidebar .brand:hover { color: #fff; }
.sidebar .brand-sub { color: #93a0bd; }
.nav-group { margin-top: 18px; }
.nav-title { font-size: .78rem; color: #8b98b7; padding: 0 12px 6px; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: #d6ddee; text-decoration: none; font-weight: 500; font-size: .95rem;
}
.nav-link svg { width: 19px; height: 19px; opacity: .8; flex: none; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-link.active svg { opacity: 1; }
.nav-link .grade-num {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, .08); font-weight: 700; font-size: .85rem;
}
.nav-link.active .grade-num { background: var(--marker); color: var(--ink); }
.sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .85rem; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot form { margin-top: 8px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: #a9b6d6; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linklike:hover { color: #fff; }

.mobile-bar { background: var(--ink); color: #fff; }
.mobile-bar .container { display: flex; align-items: center; gap: 10px; min-height: 58px; }
.mobile-bar .brand { color: #fff; }
.mobile-bar .brand-sub { color: #93a0bd; }
.mobile-nav { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 12px; background: var(--ink); }
.mobile-nav a {
  flex: none; padding: 8px 12px; border-radius: 999px; color: #d6ddee; text-decoration: none;
  font-size: .875rem; font-weight: 500; background: rgba(255, 255, 255, .07);
}
.mobile-nav a.active { background: var(--marker); color: var(--ink); }
@media (min-width: 1000px) { .mobile-bar, .mobile-nav { display: none; } }

.main { min-width: 0; padding: 28px 0 64px; }
.main > .container { max-width: 1080px; }
.page-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.crumbs { font-size: .875rem; color: var(--ink-2); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--pen); }
.crumbs .sep { color: var(--ink-3); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
@media (min-width: 820px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat b { display: block; font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .85rem; color: var(--ink-2); }
.stat.attention { background: var(--marker-soft); border-color: #f3e3a0; }

.two-col { display: grid; gap: 20px; }
@media (min-width: 1000px) { .two-col { grid-template-columns: 1.4fr 1fr; align-items: start; } }

.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.grade-card {
  display: block; padding: 16px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--paper); text-decoration: none; color: var(--ink);
}
.grade-card:hover { border-color: var(--pen); color: var(--ink); }
.grade-card .n { font-size: 2.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.grade-card .t { font-weight: 600; margin: 2px 0 8px; }
.grade-card .m { font-size: .82rem; color: var(--ink-2); }

.list { display: grid; }
.list-item { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--ink); text-decoration: none; display: block; }
.list-item a.title:hover { color: var(--pen); }
.list-item .meta { font-size: .85rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.code-chip {
  font-weight: 800; letter-spacing: .12em; background: var(--marker-soft); color: var(--ink);
  border-radius: 6px; padding: 2px 8px; font-variant-numeric: tabular-nums;
}

/* Topic rows */
.topic-row { display: flex; gap: 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.topic-row:last-child { border-bottom: 0; }
.topic-row .ord { width: 34px; flex: none; color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.topic-row .body { flex: 1; min-width: 0; }
.topic-row .title { font-weight: 600; color: var(--ink); text-decoration: none; }
.topic-row .title:hover { color: var(--pen); }
.bar { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; margin-top: 8px; max-width: 260px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }

/* Question bank */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .925rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--pen); border-bottom-color: var(--pen); }
.tabs .n { font-weight: 500; color: var(--ink-3); margin-left: 4px; font-variant-numeric: tabular-nums; }
.bulkbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; position: sticky; top: 0;
  background: var(--paper); z-index: 5; border-bottom: 1px solid var(--line);
}
.bulkbar .check { margin-right: auto; font-weight: 600; font-size: .9rem; }
.qitem { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.qitem:last-child { border-bottom: 0; }
.qitem > input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--pen); flex: none; }
.qitem .body { flex: 1; min-width: 0; }
.qitem .qtext { font-weight: 600; margin-bottom: 8px; white-space: pre-line; }
.qitem .opts { display: grid; gap: 4px 18px; font-size: .925rem; color: var(--ink-2); margin: 0 0 10px; padding: 0; list-style: none; }
@media (min-width: 720px) { .qitem .opts { grid-template-columns: 1fr 1fr; } }
.qitem .opts li { display: flex; gap: 8px; }
.qitem .opts .l { font-weight: 700; color: var(--ink-3); flex: none; }
.qitem .opts li.is-correct { color: var(--ok); font-weight: 600; }
.qitem .opts li.is-correct .l { color: var(--ok); }
.qitem .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.qitem .foot .actions { margin-left: auto; display: flex; gap: 6px; }
.note-warn { font-size: .85rem; color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 6px; margin-bottom: 10px; }

.side-stack { display: grid; gap: 20px; }
.job { border-radius: var(--r); padding: 14px 16px; background: var(--pen-soft); color: var(--pen-dark); font-size: .925rem; }
.job.done { background: var(--ok-soft); color: var(--ok); }
.job.failed { background: var(--bad-soft); color: var(--bad); }
.progress { height: 6px; background: rgba(35, 71, 200, .15); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--pen); transition: width .4s; }
.progress.indeterminate i { width: 35%; animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.source-preview {
  max-height: 220px; overflow: auto; font-size: .875rem; color: var(--ink-2); white-space: pre-line;
  background: var(--bg); border-radius: var(--r-sm); padding: 12px 14px;
}

/* Correct-answer picker in the question form */
.opt-edit { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.opt-edit .pick { position: relative; }
.opt-edit .pick input { position: absolute; opacity: 0; }
.opt-edit .pick span {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  font-weight: 700; border: 1.5px solid var(--grid-strong); background: var(--paper); color: var(--ink-2);
}
.opt-edit .pick input:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt-edit .pick input:focus-visible + span { box-shadow: var(--focus); }
.preview-box { border: 1px dashed var(--grid-strong); border-radius: var(--r); padding: 16px; background: #fafcff; }

/* Quiz board: the code for the projector */
.code-board {
  border-radius: var(--r-lg); padding: 26px; background: var(--marker); color: var(--ink);
  display: grid; gap: 14px; position: relative; overflow: hidden;
}
.code-board .lbl { font-weight: 600; }
.code-board .code {
  font-size: clamp(3rem, 2rem + 6vw, 5.5rem); font-weight: 800; letter-spacing: .14em; line-height: 1;
  font-variant-numeric: tabular-nums; word-break: break-all;
}
.code-board .how { font-size: .95rem; }
.code-board .how b { font-weight: 700; }
.code-board.closed { background: var(--bg); color: var(--ink-2); }
.code-board:fullscreen { display: grid; place-content: center; text-align: center; padding: 6vw; border-radius: 0; }
.code-board:fullscreen .code { font-size: 18vw; }
.code-board:fullscreen .how { font-size: 2.2vw; }
.code-board:fullscreen .lbl { font-size: 2.2vw; }
.code-board:fullscreen .board-actions { display: none; }

.marks-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.marks-row div { text-align: center; padding: 10px 6px; border-radius: var(--r-sm); background: var(--bg); }
.marks-row b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.marks-row span { font-size: .78rem; }
.qstat { display: grid; grid-template-columns: 1fr 56px; gap: 4px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.qstat:last-child { border-bottom: 0; }
.qstat .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qstat .p { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.qstat .bar { grid-column: 1 / -1; max-width: none; margin-top: 0; }
.bar i.low { background: var(--bad); }
.bar i.mid { background: #e0a100; }

/* Login */
.login-wrap { min-height: calc(100vh - 65px); display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 420px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 22px 0; font-size: .85rem; color: var(--ink-2); background: var(--paper); }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }
.site-footer a { color: var(--ink-2); }

/* Math */
.katex { font-size: 1.05em; }
.option .katex, .qitem .katex { font-size: 1em; }

/* Print: results tables */
@media print {
  .sidebar, .mobile-bar, .mobile-nav, .btn, .board-actions, .site-header, form { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .panel { border: 0; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .plot-line { stroke-dashoffset: 0; }
  .plot-dot, .plot-label { opacity: .6; }
}

/* JS-enhanced test: one question at a time (without JS all questions show) */
.js .q-card:not(.current) { display: none; }
.no-js-only { display: none; }
html:not(.js) .no-js-only { display: block; }
html:not(.js) .q-card + .q-card { margin-top: 16px; }
html:not(.js) #prev, html:not(.js) #next { display: none; }
h2 > svg, h3 > svg { display: inline-block; width: 20px; height: 20px; vertical-align: -3px; margin-right: 6px; color: var(--pen); }

/* Class picker on the join page: big tap targets, one per class */
.class-pick { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.class-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
.class-option { position: relative; cursor: pointer; }
.class-option input { position: absolute; opacity: 0; pointer-events: none; }
.class-option span {
  display: grid; place-items: center; min-height: 52px; border-radius: var(--r-sm);
  border: 1.5px solid var(--grid-strong); background: var(--paper);
  font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums;
}
.class-option:hover span { border-color: var(--pen); }
.class-option input:checked + span { background: var(--pen); border-color: var(--pen); color: #fff; }
.class-option input:focus-visible + span { box-shadow: var(--focus); }

/* Results grouped by class */
.class-tabs { margin-bottom: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 0 8px; }
.class-tabs a { padding: 14px 14px; }
.avg-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.avg-cell b { width: 44px; flex: none; }
.avg-cell .bar { flex: 1; margin-top: 0; }
.class-group .panel-head h2 { margin-bottom: 2px; }
