/* The teacher's page, the printable slips (codes.html), the setup page and the front page.
   Made for a phone first (390 px): the four tabs are a bar at the bottom of the screen, everything is one column.
   From 900 px up (a PC) the tabs move into the header and the lists get two columns.
   Touch targets are at least 44 px; colour is never the only signal; nothing here is a ranking. */

body.teacher { --gutter: 14px; --dock-h: 62px; --head-h: 0px; padding-bottom: calc(var(--dock-h) + 24px); }
body.sheet-open { overflow: hidden; }
body.teacher #board { max-width: none; margin: 0; padding: 0; }
body.teacher .panel, body.teacher #problems { max-width: 1180px; margin-inline: auto; padding-inline: var(--gutter); }
body.teacher #problems { margin-block: 8px 0; border-radius: 10px; }

/* ---------- the login ---------- */
body.teacher #app > .login { max-width: 420px; margin: 12vh auto; }
.login form { display: grid; gap: 12px; margin-block-start: 10px; }
#pin { font-size: 1.6rem; text-align: center; }
#pin:not(:placeholder-shown) { letter-spacing: .3em; }

/* ---------- the header and the tabs ---------- */
.top { background: var(--sheet); border-bottom: 1px solid var(--rule); padding: 4px max(var(--gutter), calc((100% - 1180px) / 2 + var(--gutter))) 0; }
.top-line { display: flex; align-items: center; flex-wrap: wrap; gap: 0 8px; }
.top-line #logout { margin-inline-start: auto; }      /* the one button of the line sits on the left, like every lone button */
.top-line #link-home { order: 1; margin-inline-start: auto; }      /* the home link on the far left */
.top-line #logout { order: 2; margin-inline-start: 0; }
.top-title { font-size: 1.1rem; margin-inline-end: auto; }
.hlink { min-height: 44px; display: inline-flex; align-items: center; padding-inline: 8px; font-weight: 600; white-space: nowrap; }
.hbtn { min-height: 44px; padding: 2px 14px; border-width: 1px; }
.summary { flex: 1 1 100%; margin: 0 0 6px; color: var(--ink-2); font-size: .85rem; min-height: 1.2em; }
.summary:empty { display: none; }
/* phones and tablets: the header is ONE row of 48 px: the title, the summary in one line (cut with …), the home icon, «خروج»; the links to the app
   and the projector are for a desk, not a phone */
@media (max-width: 899px) {
  .top { padding-top: 0; }
  .top-line { flex-wrap: nowrap; gap: 6px; min-height: 48px; }
  .top-title { font-size: 1.05rem; margin: 0; white-space: nowrap; }
  .summary { flex: 1 1 0; min-width: 0; margin: 0; order: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; text-align: end; }
  .top-line #link-app, .top-line #link-screen { display: none; }
  .top-line #link-overview { padding-inline: 6px; font-size: .95rem; }      /* the overview of the pupils stays reachable from the phone */
  .top-line #link-home { order: 1; margin-inline-start: 0; padding-inline: 6px; }
  .top-line #link-home span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .top-line #logout { order: 2; min-height: 38px; padding: 0 10px; }
}
.class-switch { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding-block: 0 6px; }
.class-switch[hidden] { display: none; }
.class-switch-label { color: var(--ink-2); font-weight: 600; }
.class-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.class-chip { min-height: 44px; min-width: 44px; padding: 2px 16px; border-radius: 999px; border-width: 1px; font-weight: 700; }
.class-chip.on, .class-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.tabs { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); height: var(--dock-h);
  background: var(--sheet); border-top: 1px solid var(--rule); box-shadow: 0 -2px 10px rgba(23, 32, 58, .08); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tab { position: relative; flex-direction: column; gap: 0; height: 100%; min-height: 0; padding: 4px 2px; border: 0; border-radius: 0; background: transparent; color: var(--ink-2); font-size: .8rem; line-height: 1.3; }
.tab:hover { background: var(--accent-wash); }
.tab-ic { display: inline-grid; place-items: center; line-height: 1; }
.tab-ic .ic { display: block; }
button .ic { vertical-align: -5px; margin-inline-end: .35em; }
.tab[aria-selected="true"] { color: var(--accent-dark); background: var(--accent-wash); box-shadow: inset 0 3px 0 var(--accent); }
.tab-n { position: absolute; top: 2px; left: 50%; margin-left: 12px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--bad); color: #fff; font-size: .8rem; font-weight: 700; line-height: 22px; text-align: center; }
.tab[data-tab="queue"] .tab-n { background: var(--warn); }
.panel { padding-block: 10px 20px; }
.damaged ul { margin: 4px 0 0; padding-inline-start: 22px; }

/* A message (Board.toast) sits ON the bar where nothing can be pressed: on a phone over the tabs, on a PC over the header.
   It never takes a tap, and it is never put over a button of the page. */
body.teacher .toast { inset-inline: 0; bottom: 0; top: auto; margin: 0; width: auto; max-width: none; height: var(--dock-h); display: flex; align-items: center; justify-content: center;
  text-align: center; border-radius: 0; padding: 0 16px; pointer-events: none; z-index: 60; }
body.teacher.sheet-open .toast { top: 0; bottom: auto; height: 56px; }
/* the «connection lost» strip of common.js is put in the same place and takes no taps either: it never hides the logout button or a tab */
body.teacher .offline { inset-block: auto 0; height: var(--dock-h); display: flex; align-items: center; justify-content: center; padding: 0 16px; pointer-events: none; }
body.teacher.sheet-open .offline { inset-block: 0 auto; height: 56px; }

@media (min-width: 900px) {
  body.teacher { --head-h: 64px; padding-bottom: 40px; }
  .top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: var(--head-h); padding-block: 0; }
  .top-line { display: contents; }
  .top-title { order: 1; margin-inline-end: 8px; white-space: nowrap; }
  .class-switch { order: 1; padding-block: 0; flex-wrap: nowrap; white-space: nowrap; }
  .class-chips { flex-wrap: nowrap; }
  .class-chip { min-height: 36px; min-width: 36px; padding: 0 10px; }
  .summary-class { display: none; }
  .tabs { order: 2; position: static; display: flex; gap: 4px; height: auto; border: 0; box-shadow: none; background: transparent; padding: 0; }
  .tab { flex-direction: row; gap: 6px; height: 44px; padding: 0 10px; border-radius: 12px; font-size: .95rem; }
  .tab[aria-selected="true"] { box-shadow: inset 0 -3px 0 var(--accent); }
  .tab-n { position: static; margin: 0; }
  .summary { order: 3; flex: 1 1 0; min-width: 0; margin: 0; text-align: end; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .8rem; }
  .hlink { order: 4; }
  .hbtn { order: 5; }
  .top-line #link-home { order: 4; margin-inline-start: 0; }      /* one row: the home link with the other links on the left, the one button last */
  .top-line #logout { order: 5; }
  body.teacher .toast, body.teacher .offline { inset-block: 0 auto; height: var(--head-h); }
}

/* ---------- small things used everywhere ---------- */
.hint.tight, .row.tight { margin-block: 6px; }
.row.tight > input { flex: 1 1 12rem; width: auto; }
.label { margin: 8px 0 4px; font-weight: 600; }
.inl { display: inline; margin: 0; }
.fold > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.fold[open] > summary { margin-block-end: 10px; }
.brief { color: var(--ink-2); font-size: .9rem; }
.fold-in { margin-block: 4px; }
.fold-in > summary { cursor: pointer; font-weight: 600; padding-block: 10px; min-height: 44px; }
.fold-body { display: grid; gap: 8px; padding-block-end: 6px; }
.field { display: grid; gap: 4px; font-weight: 500; }
.field input { font-weight: 400; }
.empty.big-empty { padding: 24px 8px; text-align: center; }
.legend { color: var(--ink-2); font-size: .85rem; margin-block: 10px; line-height: 1.9; }
.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.danger-solid:hover:not(:disabled) { background: #7d1a14; }
.dangerzone { border-top: 1px dashed var(--bad); padding-top: 10px; margin-top: 12px; }
.chip-s { min-height: 44px; padding: 4px 14px; border-radius: 999px; border-width: 1px; font-size: .9rem; font-weight: 600; }
.chip-s[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-s[aria-pressed="true"]::before { content: "✓"; }

/* a segmented control: one button of the row is pressed (with a tick, so colour is not the only sign) */
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--sheet); max-width: 100%; width: fit-content; justify-self: end; margin-inline-start: auto; }
.seg-b { min-height: 44px; border: 0; border-radius: 0; padding: 4px 16px; background: transparent; font-weight: 600; }
.seg-b + .seg-b { border-inline-start: 1px solid var(--rule); }
.seg-b[aria-pressed="true"], .seg-b[aria-checked="true"] { background: var(--accent); color: #fff; }
.seg-b[aria-pressed="true"]::before, .seg-b[aria-checked="true"]::before { content: "✓"; }
.seg.wrap { flex-wrap: wrap; border: 0; gap: 6px; background: transparent; overflow: visible; }
.seg.wrap .seg-b { border: 1px solid var(--rule); border-radius: 999px; background: var(--sheet); }
.seg.wrap .seg-b[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

/* ---------- «صف»: the bar that stays on top ---------- */
.qbar { position: sticky; top: var(--head-h); z-index: 9; display: grid; gap: 8px; margin-inline: calc(var(--gutter) * -1); padding: 8px var(--gutter); background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: 0 2px 8px rgba(23, 32, 58, .06); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { flex-direction: column; gap: 0; min-height: 52px; padding: 2px 4px; border-width: 1px; border-color: var(--rule); background: var(--sheet); line-height: 1.3; }
.stat-n { font-size: 1.3rem; }
.stat-t { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.stat.has .stat-n { color: var(--accent-dark); }
#stat-waiting.has { background: var(--warn-wash); border-color: var(--warn); }
#stat-waiting.has .stat-n { color: var(--warn); }
.stat[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.stat[aria-pressed="true"] .stat-n, .stat[aria-pressed="true"] .stat-t { color: #fff; }
.stat[aria-pressed="true"]::after { content: "✓"; color: #fff; font-size: .8rem; }
.acts { display: flex; gap: 8px; }
.act { flex: 1 1 auto; padding: 4px 10px; font-size: .95rem; }
.act-n { font-weight: 700; }
.act.live { border-color: var(--warn); background: var(--warn-wash); }
.act.live::before { content: "●"; color: var(--warn); }
.group { margin-block-start: 12px; }
.group-h { margin: 10px 0 6px; font-size: 1.05rem; scroll-margin-top: 130px; }
details.group > summary.group-h { cursor: pointer; min-height: 44px; display: flex; align-items: center; margin: 4px 0; }
.cards { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.rows { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); }

/* a card: waiting, being read, a registration */
.item { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.item.warned { border-color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }
.item-head { display: flex; align-items: center; gap: 10px; }
.item-who { display: grid; min-width: 0; flex: 1 1 auto; }
.item-who .who { overflow-wrap: anywhere; line-height: 1.5; }
.meta { color: var(--ink-2); font-size: .85rem; line-height: 1.6; }
.item-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.tag { display: inline-block; padding: 0 9px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); color: var(--ink-2); font-size: .8rem; font-weight: 600; line-height: 1.8; white-space: nowrap; }
.tag.fix { background: var(--accent-wash); border-color: #b9c5f3; color: var(--accent-dark); }
.old-problem { margin: 0; padding: 6px 10px; border-radius: 10px; background: var(--warn-wash); color: #5b3600; font-size: .88rem; line-height: 1.7; }
.thumb-btn { display: block; width: 100%; min-height: 0; padding: 0; border: 0; border-radius: 10px; background: #0e1424; cursor: zoom-in; overflow: hidden; }
.thumb { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.item .codeview, .detail .codeview { max-height: 14rem; }
.warnings { margin: 0; padding: 8px 14px; padding-inline-start: 30px; background: var(--warn-wash); color: #5b3600; border-radius: 10px; }
.btns { display: flex; gap: 10px; }
.btns > button { flex: 1 1 0; min-height: 48px; padding-inline: 8px; font-size: .95rem; }
.chore { margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-wash); color: var(--accent-dark); font-size: .92rem; line-height: 1.9; }
.return-panel { display: grid; gap: 8px; padding: 10px; border: 1px dashed var(--bad); border-radius: 12px; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.transcript { display: grid; gap: 8px; }
.explain { margin: 0; padding: 8px 12px; border-inline-start: 4px solid var(--accent); background: var(--accent-wash); border-radius: 8px; }
.explain-h { margin: 0; font-weight: 700; font-size: .9rem; }
.explain-t { margin: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reg-top { display: flex; gap: 12px; align-items: flex-start; }
.reg-photo { flex: none; width: 88px; height: 88px; min-height: 0; padding: 0; border-radius: 14px; border: 1px solid var(--rule); overflow: hidden; background: var(--paper); display: grid; place-items: center; cursor: zoom-in; }
.reg-photo.plain { cursor: default; }
.reg-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reg-fields { flex: 1 1 auto; min-width: 0; }
.pending-box { border-color: var(--warn); background: var(--warn-wash); }
.keep-photo { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
.keep-photo input { width: 22px; height: 22px; flex: none; }

/* a result: one line; a tap opens the whole card */
.qrow { background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.qrow.open { border-color: var(--accent); box-shadow: 0 2px 12px rgba(39, 64, 201, .14); }
.qrow.on-screen { border-inline-start: 5px solid var(--ok); }
.qrow-head { width: 100%; min-height: 52px; padding: 4px 10px; border: 0; border-radius: 0; background: transparent; font-weight: 400; justify-content: flex-start; gap: 8px; text-align: start; }
.qrow-head.static { min-height: 48px; cursor: default; }
.qrow-head:hover:not(.static) { background: var(--accent-wash); }
.qr-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.qr-name { font-weight: 700; }
.dot { margin-inline: .3em; color: var(--ink-2); }
.qr-pct { font-weight: 600; }
.qr-issue.ok { color: var(--ok); font-weight: 600; }
.qr-flag { flex: none; padding: 0 8px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); color: var(--ink-2); font-size: .8rem; font-weight: 600; line-height: 1.7; white-space: nowrap; }
.qr-flag.screen { border-color: var(--ok); color: var(--ok); }
.qr-flag.wall { border-color: var(--warn); color: #7a4a00; }
.qr-verdict { flex: none; font-size: 1.1rem; display: inline-flex; align-items: center; gap: 1px; min-width: 1.3em; justify-content: center; }
.qr-verdict small { font-size: .75rem; font-weight: 500; color: var(--ink-2); margin-inline-end: 4px; }
.qr-chev { flex: none; width: 9px; height: 9px; margin-inline: 4px 6px; margin-block-start: -3px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); transition: transform .15s; }
.qrow.open .qr-chev { transform: rotate(225deg); margin-block-start: 3px; }
.returned-row .when { flex: none; color: var(--ink-2); font-size: .85rem; }
.qrow-body { border-top: 1px solid var(--rule); }
.detail { display: grid; gap: 12px; padding: 12px; grid-template-columns: minmax(0, 1fr); }
.detail-problem { margin: 0; }
.verdict-block, .show-block { display: grid; gap: 4px; }
.verdict-block .label, .show-block .label { margin: 0; }
.verdict-btns, .show-btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.verdict, .show { min-height: 52px; padding: 4px 8px; font-size: 1rem; }
.verdict.yes { border-color: var(--ok); color: var(--ok); }
.verdict.no { border-color: var(--bad); color: var(--bad); }
.verdict.yes[aria-pressed="true"] { background: var(--ok); color: #fff; }
.verdict.no[aria-pressed="true"] { background: var(--bad); color: #fff; }
.verdict[aria-pressed="true"]::after { content: "✓"; }
.show.on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-dark); }
.ai-block { display: grid; gap: 8px; }

/* ---------- «کلاس» ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-block: 4px 10px; }
.toolbar > * { flex: 1 1 auto; }
.viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-block: 8px 12px; }
.people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pcard { position: relative; flex-direction: column; justify-content: flex-start; align-items: center; gap: 2px; min-height: 176px; padding: 8px 8px 10px; border-width: 1px; border-color: var(--rule); border-radius: 14px;
  background: var(--sheet); text-align: center; font-weight: 400; min-width: 0; }
.pcard.here { border-color: #8cc7a3; }
.pcard.has-flag { border-color: var(--warn); }
.pc-top { display: flex; justify-content: space-between; align-items: center; width: 100%; color: var(--ink-2); font-size: .85rem; }
.here-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink-2); }
.here-dot.on { background: var(--ok); border-color: var(--ok); }
.pc-ring { position: relative; width: 80px; height: 80px; display: grid; place-items: center; }
.pc-ring .ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring .track { stroke: var(--rule); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; }
.pc-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; line-height: 1.5; }
.pc-label { color: var(--ink-2); font-size: .8rem; line-height: 1.3; }
.pc-stop .ic, .try-p .ic, .cur-state .ic, .qr-verdict .ic { vertical-align: -3px; }
.pc-stop { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent-dark); font-size: .85rem; }
.pc-flag { margin-top: 2px; padding: 0 8px; border-radius: 8px; background: var(--warn-wash); color: #5b3600; font-size: .8rem; font-weight: 600; line-height: 1.7; }
.legend .here-dot { width: 10px; height: 10px; vertical-align: middle; }
.road-box { overflow-x: auto; }

/* ---------- sheets: a person's file, a form, a question ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; align-items: end; background: rgba(15, 23, 48, .55); }
.sheet { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; background: var(--paper); animation: sheet-in .18s ease-out; }
.sheet-sm { height: auto; max-height: 92vh; border-radius: 18px 18px 0 0; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .qr-chev { transition: none; } }
.sheet-head { position: relative; flex: none; display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 6px 14px; background: var(--sheet); border-bottom: 1px solid var(--rule); }
.sheet-title { flex: 1 1 auto; margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.sheet-x { flex: none; width: 46px; height: 46px; padding: 0; border-radius: 50%; border-width: 1px; font-size: 1.1rem; }
.sheet-say { position: absolute; inset-block: 0; inset-inline: 0 66px; z-index: 2; display: grid; place-items: center; margin: 0; padding: 0 12px; background: var(--ink); color: #fff; font-weight: 600; text-align: center; pointer-events: none; }
.sheet-say.bad { background: var(--bad); }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px; display: grid; gap: 12px; align-content: start; grid-template-columns: minmax(0, 1fr); -webkit-overflow-scrolling: touch; }
.confirm-text p { margin-block: 6px; }
.confirm-btns { display: grid; gap: 10px; margin-top: 8px; padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (min-width: 900px) {
  .sheet-backdrop { align-items: center; justify-items: center; }
  .sheet { width: min(720px, 94vw); height: auto; max-height: 90vh; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 70px rgba(0, 0, 0, .4); }
  .sheet-sm { width: min(480px, 94vw); }
  .confirm-btns { grid-template-columns: 1fr 1fr; }
}

/* a person's file */
.pv-head { display: grid; gap: 8px; }
.pv-top { display: flex; gap: 14px; align-items: center; }
.pv-rest { display: grid; gap: 4px; }
.pv-avatar { flex: none; padding: 0; min-height: 0; border: 0; background: transparent; border-radius: 50%; cursor: default; }
button.pv-avatar { cursor: zoom-in; }
.pv-id { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.pv-name { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.pv-label, .pv-stop, .pv-xp { margin: 0; }
.pv-stop { font-weight: 600; color: var(--accent-dark); }
.xpbar { display: block; height: 12px; border-radius: 6px; background: var(--rule); overflow: hidden; }
.xpbar.thin { height: 8px; min-width: 60px; flex: 1 1 60px; }
.xpfill { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); border-radius: inherit; }
.pv-sec { display: grid; gap: 8px; padding: 12px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
.pv-sec h3, .pv-sec h4 { margin: 0; }
.pv-sec h4 { margin-top: 6px; }
.medal-list, .badge-list, .award-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.award-list { grid-template-columns: minmax(0, 1fr); }
.medal, .bdg, .award { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); min-width: 0; }
.medal.on { border-color: var(--warn); background: var(--warn-wash); }
.medal-list.soft .medal { opacity: .8; background: var(--paper); }
.m-emoji { font-size: 1.6rem; line-height: 0; flex: none; display: inline-flex; }
.m-body { display: grid; flex: 1 1 auto; min-width: 0; line-height: 1.5; }
.m-body small { color: var(--ink-2); font-size: .82rem; }
.give-box { display: grid; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--rule); }
.medal-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mp-opt { min-height: 52px; padding: 4px 8px; border-width: 1px; font-size: .95rem; justify-content: flex-start; text-align: start; }
.mp-opt[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.mp-opt[aria-checked="true"]::after { content: "✓"; margin-inline-start: auto; }
.tries { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.try { padding: 8px 10px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); display: grid; gap: 4px; }
.try-h { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.try-t { flex: 1 1 8rem; min-width: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.try-b { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.try-pct { font-weight: 700; }
.try-s.ok, .try-p.ok { color: var(--ok); font-weight: 600; }
.manage details { border-top: 1px solid var(--rule); }
.manage details:first-of-type { border-top: 0; }
.av-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.av-opt { position: relative; min-height: 48px; padding: 0; border-width: 1px; border-radius: 12px; font-size: 1.6rem; }
.av-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-wash); box-shadow: 0 0 0 3px var(--accent); }
.av-opt[aria-checked="true"]::after { content: "✓"; position: absolute; top: 0; inset-inline-end: 3px; font-size: .75rem; color: var(--accent-dark); font-weight: 700; }
.photo-big { justify-self: start; width: 160px; min-height: 0; padding: 0; border: 0; border-radius: 14px; overflow: hidden; cursor: zoom-in; }
.photo-big img { width: 100%; display: block; }
.code-line { margin: 0; padding: 10px; border-radius: 12px; background: var(--paper); font-family: var(--mono); font-size: 1.6rem; letter-spacing: .3em; text-align: center; color: var(--ink-2); }
.code-line.on { background: var(--code-bg); color: #fff; font-family: var(--mono); font-weight: 700; letter-spacing: .25em; }
.admin-state { font-size: 1.05rem; font-weight: 700; margin-block: 6px; }
.admin-state.is-open { color: var(--ok, #0f7a3a); }
.admin-state.is-closed { color: var(--warn, #9a5b00); }
.admin-form { display: flex; flex-direction: column; gap: 12px; margin-block-start: 8px; }
.admin-form label.check { flex-direction: row; align-items: center; gap: 8px; }
.admin-problem { color: var(--bad, #b3261e); background: var(--bad-wash, #fde8e6); padding: 8px 12px; border-radius: 10px; }
.study-box .question-card { margin-block: 10px; }
.study-box textarea { width: 100%; box-sizing: border-box; min-height: 3.2em; padding: 8px 10px; border: 2px solid var(--rule); border-radius: 10px; font: inherit; }
.up-entry { margin-block: 8px; }
.up-entry > summary { cursor: pointer; font-weight: 700; min-height: 40px; display: flex; align-items: center; }
.up-body { color: var(--ink-2); line-height: 1.9; }
.up-body ul { padding-inline-start: 20px; }
#class-card .row.tight input { flex: 1 1 10em; max-width: 16em; padding: 8px 12px; border: 2px solid var(--rule); border-radius: 12px; font: inherit; }
.stepper { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.stepper .primary { flex: 1 1 100%; max-width: 260px; }
.step { width: 52px; height: 52px; padding: 0; border-radius: 50%; font-size: 1.6rem; }
.step-v { min-width: 4ch; text-align: center; font-size: 1.6rem; font-weight: 700; }

/* registration at the door */
.door-form { display: grid; gap: 8px; }
.selfie { width: 140px; height: 140px; border-radius: 16px; overflow: hidden; border: 1px solid var(--rule); }
.selfie img { width: 100%; height: 100%; object-fit: cover; display: block; }
.door-done { display: grid; gap: 10px; text-align: center; justify-items: center; }
.door-who { display: flex; gap: 12px; align-items: center; text-align: start; }
.door-who h3 { margin: 0; }
.hugecode { margin: 0; padding: 14px 8px; width: 100%; border-radius: 18px; background: var(--code-bg); color: #fff; font-family: var(--mono); font-size: clamp(3.4rem, 24vw, 6.5rem); font-weight: 700; letter-spacing: .14em; line-height: 1.3; }

/* ---------- «مسئله» ---------- */
.now-card h2, .bank-card h2 { margin-block-end: 4px; }
.bank { display: grid; gap: 10px; margin-block-start: 8px; }
.bank-item { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); }
.bank-item.running { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.bi-main { display: grid; gap: 4px; min-width: 0; }
.bi-title { margin: 0; overflow-wrap: anywhere; }
.bi-meta { margin: 0; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.bi-acts { display: flex; gap: 10px; }
.bi-acts button { flex: 1 1 0; min-height: 48px; }
.concepts { margin-block: 0; }
.case-row { display: grid; gap: 8px; margin-block: 8px; padding: 10px; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); }
.case-n { font-weight: 700; color: var(--ink-2); font-size: .9rem; }
.case-io { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.show-case { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.show-case input { width: 22px; height: 22px; }
.form-actions { display: grid; gap: 4px; margin-block: 14px; }
.form-actions button { min-height: 52px; }
.form-actions .hint { margin-block: 0 10px; }
.concept-chips { margin-block: 8px; }
.current { display: grid; gap: 0; margin-block-start: 6px; }
.cur-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who nc" "best state"; gap: 4px 12px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--rule); }
.cur-head { display: none; }
.cur-who { grid-area: who; display: flex; align-items: center; gap: 8px; min-width: 0; }
.cur-who b { overflow-wrap: anywhere; }
.cur-who small { color: var(--ink-2); }
.cur-nc { grid-area: nc; display: flex; gap: 2px 12px; color: var(--ink-2); font-size: .9rem; white-space: nowrap; }
.cur-n::before, .cur-c::before { content: attr(data-label) ": "; }
.cur-best { grid-area: best; display: flex; align-items: center; gap: 8px; min-width: 0; }
.cur-state { grid-area: state; justify-self: end; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.cur-row.done .cur-state { color: var(--ok); }

/* ---------- «تنظیمات» ---------- */
.bigcode { margin: 6px 0; padding: 12px 8px; border-radius: 16px; background: var(--accent-wash); color: var(--accent-dark); font-family: var(--font); font-size: clamp(2.2rem, 12vw, 3.8rem); font-weight: 700; word-spacing: .3em; text-align: center; line-height: 1.4; }
.linkline { margin: 4px 0; padding: 8px 12px; border-radius: 10px; background: var(--paper); font-family: var(--mono); font-size: .85rem; overflow-wrap: anywhere; text-align: left; user-select: all; }
.qr-box { display: grid; justify-items: center; gap: 4px; margin-block: 10px; }
.qr-box svg { width: min(240px, 70vw); height: auto; padding: 10px; background: #fff; border: 1px solid var(--rule); border-radius: 14px; }
.setting { display: grid; gap: 6px; padding-block: 12px; border-top: 1px solid var(--rule); }
.setting:first-of-type { border-top: 0; }
.setting h3 { margin: 0; }
.provider-line { margin: 0; font-weight: 600; }
#exports a { flex: 1 1 8rem; }

@media (min-width: 560px) {
  .people { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .case-io { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cur-row { grid-template-columns: minmax(0, 1.6fr) 4.5em 4.5em minmax(0, 1.5fr) minmax(0, 1.5fr); grid-template-areas: "who n c best state"; }
  .cur-nc { display: contents; }
  .cur-n { grid-area: n; }
  .cur-c { grid-area: c; }
  .cur-head { display: grid; font-size: .8rem; color: var(--ink-2); font-weight: 600; }
  .cur-head span:nth-child(1) { grid-area: who; } .cur-head span:nth-child(2) { grid-area: n; } .cur-head span:nth-child(3) { grid-area: c; } .cur-head span:nth-child(4) { grid-area: best; } .cur-head span:nth-child(5) { grid-area: state; }
  .cur-n::before, .cur-c::before { content: none; }
}

@media (min-width: 900px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 14px; }
  .rows { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .rows .qrow.open { grid-column: 1 / -1; }
  .qbar { display: flex; align-items: stretch; gap: 16px; }
  .stats { flex: 0 0 auto; grid-template-columns: repeat(3, 150px); }
  .acts { flex: 1 1 auto; justify-content: flex-end; }          /* buttons on the left (the end of the right-to-left row) */
  .act { flex: 0 1 auto; padding-inline: 18px; }
  .people { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
  .bank-item { grid-template-columns: minmax(0, 1fr) 190px; align-items: center; }
  .bi-acts { flex-direction: column; }
  #tab-problem { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; align-items: start; }
  #tab-problem > .now-card, #tab-problem > .bank-card { grid-column: 1; }
  #tab-problem > #form-box { grid-column: 2; grid-row: 1 / span 2; }
  #tab-settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; align-items: start; }
  #tab-settings > #settings-problems { grid-column: 1 / -1; }
  .medal-pick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .verdict-btns, .show-btns { max-width: 560px; }
}

/* ---------- /teacher/codes: the slips to cut out ---------- */
body.codes .page { max-width: 920px; }
body.codes .privacy-note { background: var(--warn-wash); color: #5b3600; border-radius: 12px; padding: 12px 16px; margin-block: 12px; }
body.codes .privacy-note ul { margin: 6px 0 0; padding-inline-start: 22px; }
body.codes .slips { list-style: none; margin: 14px 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
body.codes .slip { position: relative; display: grid; grid-template-rows: auto auto 1fr; gap: 4px; padding: 14px 16px 10px; border: 1px dashed #777; background: #fff; text-align: start; break-inside: avoid; page-break-inside: avoid; margin: 0 -1px -1px 0; }
body.codes .slip-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
body.codes .slip-label { font-weight: 700; font-size: 1.15rem; }
body.codes .slip-name { color: var(--ink-2); font-weight: 600; overflow-wrap: anywhere; }
body.codes .slip-class { color: var(--ink-2); font-size: .85em; }
body.codes .slip-code { font-family: var(--mono); font-size: 2.6rem; font-weight: 700; letter-spacing: .22em; text-align: center; line-height: 1.3; direction: ltr; }
body.codes .slip-steps { margin: 0; padding-inline-start: 1.5em; font-size: .9rem; line-height: 1.8; list-style-type: persian; }
body.codes .slip-steps bdi { font-family: var(--mono); font-weight: 600; }
body.codes .slip-secret { margin: 2px 0 0; font-size: .85rem; font-weight: 600; }
@media (max-width: 560px) { body.codes .slips { grid-template-columns: minmax(0, 1fr); } }
@media print {
  @page { size: A4; margin: 10mm; }
  body.codes { background: #fff; color: #000; font-size: 11pt; }
  body.codes .page { max-width: none; padding: 0; }
  body.codes h1 { display: none; }
  body.codes .slips { grid-template-columns: repeat(2, 1fr); margin: 0; }
  body.codes .slip { height: 54mm; padding: 3mm 5mm 2mm; gap: 1px; overflow: hidden; }
  body.codes .slip-label { font-size: 1rem; line-height: 1.5; }
  body.codes .slip-code { font-size: 24pt; line-height: 1.2; }
  body.codes .slip-steps { line-height: 1.5; }
  body.codes .slip-secret { line-height: 1.5; }
}

/* ---------- /setup and the front page ---------- */
.addr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.addr-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0; border-bottom: 1px dashed var(--rule); }
.addr-list li > span { flex: 0 0 auto; font-weight: 600; min-width: 7em; }
.addr-list bdi { flex: 1 1 14rem; font-family: var(--mono); font-size: .92rem; overflow-wrap: anywhere; text-align: left; }
body.setup .card h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
body.setup ol { list-style-type: persian; }
body.home .links { gap: 12px; }
body.home .links .button { min-width: 8rem; }
body.home .lead + .row { margin-block: 0 14px; }

/* «بررسی کلاسی»: one folded row per pupil */
.review-list { display: grid; gap: 8px; margin-top: 10px; }
.review-row { border: 1px solid var(--rule); border-radius: 12px; padding: 8px 12px; background: #fff; }
.review-row summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.review-row.review-back { border-color: var(--sun-deep, #e2a100); }
.review-problem { margin: 8px 0; padding-inline-start: 10px; border-inline-start: 3px solid var(--rule); }
.review-problem .bullets { margin: 4px 0; }
.chip-warn { background: var(--sun, #ffe9a8); }
.chip-bad { background: #ffe1e1; color: #8a1c1c; }

/* ---- the set: the open problems of the class ---- */
.set-box { display: grid; gap: 10px; margin: 8px 0; }
.set-row { display: grid; gap: 8px; padding: 10px 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); }
.set-row.focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.set-row.bonus { border-style: dashed; }
.set-title { margin: 0; font-size: 1.05rem; }
.set-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); font-size: .92rem; }
.set-clock { font-weight: 700; color: var(--accent-dark, var(--accent)); font-variant-numeric: tabular-nums; padding: 1px 10px; border: 2px solid currentColor; border-radius: 999px; }
.set-acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.set-acts select { min-height: 40px; border-radius: 10px; border: 1px solid var(--rule); padding: 0 8px; font: inherit; }
.start-opts { align-items: center; gap: 8px 16px; }
.start-opts .opt { display: inline-flex; align-items: center; gap: 6px; font-size: .92rem; }
.start-opts select { min-height: 40px; border-radius: 10px; border: 1px solid var(--rule); padding: 0 8px; font: inherit; }
.badge-given { background: var(--sun-wash, #fff3d1); color: var(--sun-ink, #7a4d00); }
.badge-late { background: #fde7f1; color: #8a1c4e; }
.tag.late { background: #fde7f1; color: #8a1c4e; }
.bank-item.given .bi-title::after { content: " ✓"; color: var(--ink-2); font-weight: 400; }
.history { display: grid; gap: 8px; }
.hist-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--radius); }
.hist-row.open { border-color: var(--accent); }
.hist-title { margin: 0; font-size: 1rem; }
.hist-meta { margin: 2px 0 0; color: var(--ink-2); font-size: .88rem; }
.hist-acts { display: flex; justify-content: flex-end; }
.old-problem.open-problem { color: var(--ink-2); }
