/* Student app: phone first */
.top { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
.top .row { flex-wrap: nowrap; }
main.page { padding: 16px 16px 96px; max-width: 760px; margin: 0 auto; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; font-size: 0.78rem; font-weight: 600; color: var(--muted); text-decoration: none; min-height: 56px; justify-content: center; }
.bottomnav a.on { color: var(--brand); }
.bottomnav svg { width: 24px; height: 24px; }
.banner { background: var(--warn-soft); border: 1px solid #f1d9a8; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }

/* exam screen */
.exam { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--card); }
.exam-top { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.exam-top .bar1 { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.exam-top .title { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.95rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.05rem; padding: 4px 10px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.net { width: 10px; height: 10px; border-radius: 50%; background: var(--good); flex: none; }
.net.off { background: var(--bad); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 36px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 0.9rem; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.exam-body { flex: 1; display: flex; }
.qpane { flex: 1; padding: 16px 16px 150px; max-width: 760px; margin: 0 auto; width: 100%; touch-action: pan-y; }
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.stem { font-size: 1.05rem; margin-bottom: 16px; }
.opt { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 14px; margin-bottom: 10px; border: 2px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; min-height: 56px; font-size: 1rem; }
.opt .k { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--grey); display: grid; place-items: center; font-weight: 800; font-size: 0.9rem; color: var(--muted); }
.opt.on { border-color: var(--brand); background: var(--brand-soft); }
.opt.on .k { background: var(--brand); border-color: var(--brand); color: #fff; }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .k { background: var(--good); border-color: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.explain { border-left: 4px solid var(--brand); background: var(--brand-soft); padding: 12px 14px; border-radius: 0 12px 12px 0; margin-top: 8px; }
.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--card); border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.actions .r1 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.actions .r2 { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.actions .btn { min-height: 48px; padding: 8px; font-size: 0.92rem; }

/* palette */
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 0.82rem; margin-bottom: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend .pq { width: 28px; height: 28px; flex: none; font-size: 0.75rem; padding: 0; }
.legend .pq.am::after { width: 9px; height: 9px; right: -2px; bottom: -2px; }
.pal { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pq { position: relative; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; }
.pq.nv { background: #fff; color: var(--muted); }
.pq.na { background: var(--bad); border-color: var(--bad); color: #fff; }
.pq.an { background: var(--good); border-color: var(--good); color: #fff; }
.pq.mk { background: var(--mark); border-color: var(--mark); color: #fff; border-radius: 50%; }
.pq.am { background: var(--mark); border-color: var(--mark); color: #fff; border-radius: 50%; }
.pq.am::after { content: ''; position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--good); border: 2px solid #fff; }
.pq.cur { outline: 3px solid var(--ink); outline-offset: 1px; }
.side-pal { display: none; }
@media (min-width: 1000px) {
  .side-pal { display: block; width: 340px; flex: none; border-left: 1px solid var(--line); padding: 16px; overflow: auto; max-height: calc(100vh - 100px); position: sticky; top: 100px; }
  .actions { right: 340px; }
  .actions .palbtn { display: none; }
}

/* results */
.scorebig { font-size: 2.6rem; font-weight: 900; line-height: 1; }
.subjrow { display: grid; grid-template-columns: 90px 1fr 70px; gap: 10px; align-items: center; margin: 8px 0; font-size: 0.92rem; }
.sol { border-top: 1px solid var(--line); padding: 16px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.filterbar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.filterbar button { flex: none; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 0.88rem; }
.filterbar button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.treeunit { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.treeunit > summary { padding: 12px; font-weight: 700; cursor: pointer; min-height: 44px; }
.treeunit .check { padding: 0 12px; }
