body { margin: 0 }
img { max-width: 100% }

/* Layout: uma coluna de trabalho (máx. 980px), abas fixas no topo; telas pensadas para o celular do professor */
:root {
  --bg: #F3F6F9; --surface: #FFFFFF; --ink: #14212D; --muted: #5A6B7B; --line: #D6DFE8;
  --accent: #1F4E78; --accent-ink: #FFFFFF; --accent-soft: #E3EDF6;
  --ok: #1D7A35; --ok-soft: #E2F3E6; --bad: #B3261E; --bad-soft: #FBE7E5; --warn: #9A5800; --warn-soft: #FFF1DC;
  --bubble: #7A7A7A;
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0F171F; --surface: #17222D; --ink: #E6EDF3; --muted: #9AABBB; --line: #2A3946;
  --accent: #7FB2E0; --accent-ink: #0B1824; --accent-soft: #1C3248;
  --ok: #6BCB83; --ok-soft: #173322; --bad: #FF8A80; --bad-soft: #3A1C1A; --warn: #F2B35B; --warn-soft: #36280F;
  --bubble: #8A9AA8; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0F171F; --surface: #17222D; --ink: #E6EDF3; --muted: #9AABBB; --line: #2A3946;
  --accent: #7FB2E0; --accent-ink: #0B1824; --accent-soft: #1C3248;
  --ok: #6BCB83; --ok-soft: #173322; --bad: #FF8A80; --bad-soft: #3A1C1A; --warn: #F2B35B; --warn-soft: #36280F;
  --bubble: #8A9AA8; color-scheme: dark }

* { box-sizing: border-box }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface) }
button, input, select { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px }
.num { font-variant-numeric: tabular-nums }

header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top-in { max-width: 980px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-block: 10px 0 }
.brand { display: flex; flex-direction: column; margin-right: auto; padding-bottom: 6px }
.brand b { font-family: var(--f-display); font-stretch: 87%; font-weight: 800; font-size: 20px; letter-spacing: .01em; color: var(--accent); line-height: 1.1 }
.brand span { font-size: 13px; color: var(--muted) }
nav.tabs { display: flex; gap: 4px; width: 100%; overflow-x: auto }
nav.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap }
nav.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent) }

main { max-width: 980px; margin: 0 auto; padding-block: 18px 60px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 18px }
h2 { font-family: var(--f-display); font-stretch: 87%; font-weight: 800; font-size: 22px; margin: 0; text-wrap: balance }
h3 { font-family: var(--f-display); font-stretch: 87%; font-weight: 600; font-size: 17px; margin: 0 }
.muted { color: var(--muted) }
.small { font-size: 14px }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; min-width: 0 }
.banner { border-radius: var(--r); padding: 10px 14px; font-size: 14px; background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent) }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 11px 18px; font-weight: 700; border: 1.5px solid var(--accent); background: var(--surface); color: var(--accent) }
.btn.primary { background: var(--accent); color: var(--accent-ink) }
.btn.big { padding: 16px 22px; font-size: 18px }
.btn.ghost { border-color: var(--line); color: var(--ink) }
.btn.danger { border-color: var(--bad); color: var(--bad) }
.btn:disabled { opacity: .5; cursor: default }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center }
.capture, .stack { display: grid; gap: 14px }
[hidden] { display: none !important }
.capture .row .btn { flex: 1 1 220px }
.tips { margin: 0; padding-left: 20px; font-size: 14px; color: var(--muted); display: grid; gap: 2px }
input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none }

/* fila */
.queue { display: grid; gap: 12px }
.qitem { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden }
.qhead { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; align-items: center }
.qhead .who { font-weight: 700; min-width: 0 }
.qhead .who small { display: block; font-weight: 400; color: var(--muted) }
.score { font-family: var(--f-display); font-stretch: 87%; font-weight: 800; font-size: 26px; text-align: right; line-height: 1 }
.score small { display: block; font-family: var(--f-body); font-size: 12px; font-weight: 400; color: var(--muted) }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent) }
.chip.ok { background: var(--ok-soft); color: var(--ok) }
.chip.bad { background: var(--bad-soft); color: var(--bad) }
.chip.warn { background: var(--warn-soft); color: var(--warn) }
.qbody { border-top: 1px solid var(--line); padding: 14px; display: grid; gap: 14px }
.qbody canvas { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); background: #fff }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted) }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 3px solid }

/* editor de respostas: as mesmas bolinhas do cartão */
.answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 18px }
.arow { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 8px }
.arow.flag { background: var(--warn-soft) }
.arow .qn { width: 30px; font-weight: 700 }
.arow .res { margin-left: auto; width: 20px; text-align: center; font-weight: 700 }
.bub { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--bubble); background: transparent; color: var(--muted); font-size: 14px; display: grid; place-items: center; padding: 0 }
.bub[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 700 }
.bub.key { box-shadow: 0 0 0 3px var(--ok-soft); border-color: var(--ok) }
.subj { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 6px; font-weight: 700 }
label.field { display: grid; gap: 4px; font-size: 14px; font-weight: 700 }
select, input[type=number] { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); min-width: 0 }

/* resultados */
.filters { display: flex; gap: 6px; flex-wrap: wrap }
.filters button { border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 14px }
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px }
.tile b { display: block; font-family: var(--f-display); font-stretch: 87%; font-weight: 800; font-size: 30px; line-height: 1.1 }
.tile span { font-size: 13px; color: var(--muted) }
.bars { display: grid; gap: 8px }
.bar { display: grid; grid-template-columns: 92px 1fr 48px; gap: 10px; align-items: center; font-size: 14px }
.bar .track { height: 12px; border-radius: 6px; background: var(--accent-soft); overflow: hidden }
.bar .fill { height: 100%; background: var(--accent); border-radius: 6px }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface) }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--bg); position: sticky; top: 0 }
th button { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit }
td.c, th.c { text-align: center }
tr.pending td { color: var(--muted) }
tr.clickable { cursor: pointer }
tr.clickable:hover td { background: var(--accent-soft) }
.mini { display: inline-block; width: 70px; height: 8px; border-radius: 4px; background: var(--accent-soft); vertical-align: middle; overflow: hidden; margin-right: 6px }
.mini > span { display: block; height: 100% }
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 22px }
.krow { display: flex; align-items: center; gap: 6px }
.krow .qn { width: 30px; font-weight: 700 }
.krow label { margin-left: auto; font-size: 13px; display: flex; gap: 4px; align-items: center; color: var(--muted) }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 24px)); background: var(--surface); color: var(--ink) }
dialog::backdrop { background: rgba(10, 20, 30, .5) }
.dlg { padding: 18px; display: grid; gap: 14px; max-height: 85vh; overflow-y: auto }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; z-index: 20; max-width: calc(100vw - 32px) }
@media (prefers-reduced-motion: no-preference) { .qitem { animation: in .25s ease-out } @keyframes in { from { transform: translateY(6px); opacity: .4 } } }

/* ---- extras da versão com servidor ---- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0) }
.grow { margin-right: auto; flex: 1 1 auto; min-width: 0 }
.push { margin-left: auto }
.m0 { margin: 0 }
.mb8 { margin-bottom: 8px }
.w110 { width: 110px }
.ar { text-align: right }
.tile .of { font-size: 18px; color: var(--muted) }
.btn.sm { padding: 6px 12px; font-size: 14px }
.userbox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 6px }
.userbox select { max-width: 260px }
.loading { padding: 40px 16px; text-align: center; color: var(--muted) }
td.is-key { color: var(--ok); font-weight: 700 }
td.is-trap { color: var(--bad); font-weight: 700 }
td.actions { display: flex; gap: 6px }
.legend i.lg-ok { border-color: #1D9A3F } .legend i.lg-bad { border-color: #D0312D }
.legend i.lg-key { border-color: #1D9A3F; border-style: dashed } .legend i.lg-warn { border-color: #E08A00 }
input[type=text], input:not([type]), input[type=password] { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); min-width: 0 }
.formrow { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 12px }
.formrow .field { flex: 1 1 200px }
.formrow .full { flex-basis: 100% }
.secret { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px }
.secret code { font-size: 18px; font-weight: 700; letter-spacing: .04em; user-select: all }
/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
.login { width: min(400px, 100%); display: grid; gap: 14px }
.login .brand b { font-size: 24px }
.login form { display: grid; gap: 12px }
.login input { font-size: 17px; padding: 12px }
.err { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 0 }
.secret code { white-space: nowrap }
@media (max-width: 640px) { header.top { position: static } .userbox select { max-width: 100%; flex: 1 1 100% } }
main > *, .stack > *, .capture > * { min-width: 0 }
.tablewrap { max-width: 100% }
