:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --border: #dedbd2;
  --accent: #2e5bff;
  --accent-text: #ffffff;
  --good: #1f8a4c;
  --good-bg: #e3f4ea;
  --bad: #c2362b;
  --bad-bg: #fbe7e5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --surface: #1f1f1d; --surface-2: #2a2a27; --text: #f1f0ec; --muted: #a3a29b;
    --border: #3a3935; --accent: #6b8cff; --accent-text: #0d0d0c; --good: #5fd08f; --good-bg: #1d3326;
    --bad: #ff8a80; --bad-bg: #3a2220; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 64px; }
.narrow { max-width: 560px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
header.top h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 12px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=url], textarea, select {
  width: 100%; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 180px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; }
button:disabled { opacity: .5; cursor: default; }
button.small, .btn.small { padding: 6px 10px; font-size: 14px; }
.error { color: var(--bad); font-weight: 600; }
.notice { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.warn { background: var(--bad-bg); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.warn ul { margin: 4px 0 0; padding-left: 18px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill.open { background: var(--good-bg); color: var(--good); }
.hidden { display: none !important; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button[aria-selected=true] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Quizliste */
.quiz-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.quiz-item { cursor: pointer; margin: 0; }
.quiz-item:hover { border-color: var(--accent); }
.quiz-item h3 { margin-bottom: 4px; }

/* Redigering */
.q-edit { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); }
.q-edit + .q-edit { margin-top: 12px; }
.q-edit .num { font-weight: 700; color: var(--muted); font-size: 14px; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.opt-row input[type=radio] { width: 20px; height: 20px; accent-color: var(--good); flex: none; }
.opt-row .letter { width: 22px; font-weight: 700; color: var(--muted); flex: none; }
.q-edit.missing { border-color: var(--bad); }

/* Del / QR */
.share { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.qr { background: #fff; padding: 10px; border-radius: 12px; line-height: 0; width: max-content; }
.qr img, .qr svg { width: 200px; height: 200px; display: block; }
.code { font-size: 34px; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.link { word-break: break-all; font-size: 14px; }
@media (max-width: 640px) { .share { grid-template-columns: 1fr; justify-items: center; text-align: center; } .share .row { justify-content: center; } }

.present { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; }
.present .qr svg, .present .qr img { width: min(70vmin, 520px); height: min(70vmin, 520px); }
.present h1 { font-size: clamp(24px, 4vw, 44px); margin: 0; }
.present .code { font-size: clamp(32px, 6vw, 64px); }
.present .close { position: absolute; top: 16px; right: 16px; }

/* Resultater */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; font-size: 12px; font-weight: 700; }
.dot.ok { background: var(--good-bg); color: var(--good); }
.dot.no { background: var(--bad-bg); color: var(--bad); }
.dot.none { background: var(--surface-2); color: var(--muted); }
.stat { margin-top: 14px; }
.stat-q { font-weight: 600; margin-bottom: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr 36px; gap: 8px; align-items: center; font-size: 14px; margin: 3px 0; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 14px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--muted); border-radius: 99px; }
.bar-row.correct .bar > i { background: var(--good); }
.bar-row.correct .lbl { font-weight: 700; color: var(--good); }
.big-num { font-size: 28px; font-weight: 800; }

/* Deltaker */
.play-title { font-size: 24px; margin: 4px 0 6px; letter-spacing: -.01em; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 18px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.question { font-size: 21px; font-weight: 700; line-height: 1.35; margin: 0 0 16px; }
.choices { display: grid; gap: 10px; }
.choice {
  width: 100%; text-align: left; justify-content: flex-start; white-space: normal; padding: 14px 16px; font-size: 17px; font-weight: 500;
  border-radius: 12px; min-height: 56px;
}
.choice .letter { font-weight: 800; color: var(--muted); margin-right: 10px; }
.choice.picked { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; }
.choice.right { background: var(--good-bg); border-color: var(--good); color: var(--text); }
.choice.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--text); }
.feedback { margin-top: 14px; font-weight: 700; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--bad); }
.explain { margin-top: 6px; color: var(--muted); }
.score-big { font-size: 56px; font-weight: 800; line-height: 1; margin: 8px 0; }
.review-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.review-item:last-child { border-bottom: 0; }
.choice:disabled { opacity: 1; cursor: default; }
.choice:disabled:not(.right):not(.wrong):not(.picked) { opacity: .55; }

/* Stegliste mellom quizer */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; margin-top: 8px; }
.steps .mark { width: 28px; height: 28px; border-radius: 99px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; background: var(--surface-2); color: var(--muted); flex: none; }
.steps li.done .mark { background: var(--good-bg); color: var(--good); }
.steps li.now { border-color: var(--accent); outline: 1px solid var(--accent); }
.steps li.now .mark { background: var(--accent); color: var(--accent-text); }
