:root {
  --bg: #f6f7f9;
  --card: #fff;
  --ink: #1b1f24;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
.top { display: flex; align-items: baseline; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-weight: 700; color: inherit; text-decoration: none; }
.sub { color: var(--muted); font-size: .85rem; }
main { max-width: 720px; margin: 1.5rem auto; padding: 0 1rem; }
footer { text-align: center; padding: 2rem 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; }
h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
h2 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 2.5rem; font-weight: 700; margin: .5rem 0; }

form { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; margin-top: 1rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
select, input[type=number] { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; }
input[type=number] { width: 6rem; }
label.check { flex-direction: row; align-items: center; gap: .4rem; flex-basis: 100%; color: var(--ink); }
label.check input { margin: 0; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: .55rem 1rem; color: var(--ink); }
button:disabled { cursor: default; opacity: .6; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { background: none; border: none; color: var(--muted); padding: 0; text-decoration: underline; margin-top: .5rem; }

.progress table { border-collapse: collapse; margin-top: .5rem; }
.progress td { padding: .2rem 1.5rem .2rem 0; font-size: .9rem; }
.progress td.stat { font-variant-numeric: tabular-nums; }

.bar { display: flex; gap: .75rem; align-items: center; font-size: .9rem; color: var(--muted); }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 0 .6rem; font-size: .8rem; }
.score { margin-left: auto; font-variant-numeric: tabular-nums; }
.question { font-size: 1.15rem; font-weight: 600; margin: 1rem 0; }

.choices { display: grid; gap: .5rem; }
.choice { display: flex; gap: .75rem; align-items: flex-start; text-align: left; padding: .75rem .9rem; width: 100%; }
.choice:not(:disabled):hover { border-color: var(--accent); }
.choice .letter { font-weight: 700; color: var(--muted); min-width: 1.2rem; }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); opacity: 1; }
.choice.correct .letter { color: var(--ok); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); opacity: 1; }
.choice.wrong .letter { color: var(--bad); }
.choice.eliminated { text-decoration: line-through; opacity: .35; }

.feedback { margin-top: 1rem; font-weight: 700; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.explanation { margin: .35rem 0 0; }
.actions { display: flex; gap: .75rem; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }
.actions .cite { margin-left: auto; display: inline-flex; align-items: center; gap: .35rem; position: relative; }
#cite-help summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; user-select: none; }
#cite-help summary::-webkit-details-marker { display: none; }
#cite-help summary:hover, #cite-help[open] summary { color: var(--accent); }
#cite-help .body { position: absolute; right: 0; bottom: 1.6rem; z-index: 2; width: min(22rem, 85vw); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; box-shadow: 0 6px 24px rgba(0,0,0,.12); font-size: .85rem; text-align: left; }
#cite-help .body p { margin: 0 0 .5rem; }
#cite-help .body p:last-child { margin-bottom: 0; }
#cite-help code { font-size: .8rem; background: var(--bg); padding: 0 .25rem; border-radius: 4px; }

#quiz { touch-action: pan-y; } /* keep horizontal swipes for card navigation */

/* Statute popup: the <dialog> is a full-viewport backdrop, .panel is the card. */
#statute-dialog { border: 0; padding: 0; background: rgba(0,0,0,.35); width: 100vw; height: 100vh; max-width: none; max-height: none; }
#statute-dialog::backdrop { background: transparent; }
#statute-dialog[open] { display: flex; align-items: center; justify-content: center; }
#statute-dialog .panel { position: relative; margin: 0; width: min(44rem, 92vw); max-height: 88vh; overflow: auto; background: var(--card); border-radius: 12px; padding: 1.25rem 1.5rem; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
#statute-dialog h2 { margin: 0 2rem .5rem 0; font-size: 1.05rem; }
#statute-dialog .close { position: absolute; top: .6rem; right: .6rem; border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); }
#statute-dialog .body { white-space: pre-line; font-size: .92rem; line-height: 1.55; }
#statute-dialog .src { margin: 1rem 0 0; }
a.cite-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
a.cite-link:hover { color: var(--accent); }
