/* Pluggis – elevchatten. Mobil först (iPhone), fungerar även på dator. */
:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #1f2328; --muted: #6b7076; --line: #e4e2dc;
  /* Pluggis färger: mörkblått (loggan) och gult för det som ska lysa */
  --accent: #022153; --accent-soft: #e6ebf5; --me: #022153; --me-ink: #fff; --bot: #fff;
  --red: #c4473b; --gold: #b7862a; --yellow: #fec434; --navy: #022153; --good: #2e9a62;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
/* Mörkt: följer telefonen/datorn om inget valts, eller valt med ◐/☀/☾ (data-theme på <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111315; --panel: #1c1f22; --ink: #ecebe7; --muted: #9aa0a6; --line: #2c3035;
    --accent: #6f8fe0; --accent-soft: #1a2540; --me: #24418f; --bot: #1f2326;
  }
}
:root[data-theme="dark"] {
  --bg: #111315; --panel: #1c1f22; --ink: #ecebe7; --muted: #9aa0a6; --line: #2c3035;
  --accent: #6f8fe0; --accent-soft: #1a2540; --me: #24418f; --bot: #1f2326;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
button { font: inherit; color: inherit; }

.bar {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 14px 10px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.title { font-weight: 700; font-size: 19px; display: flex; gap: 6px; align-items: center; }
.logo { width: 34px; height: 34px; object-fit: contain; border-radius: 7px; }
/* Pluggis figur bredvid sina svar (bara på det första i en rad av svar) */
.msg.bot { position: relative; margin-left: 40px; }
.msg.bot::before { content: ''; position: absolute; left: -40px; bottom: -2px; width: 32px; height: 32px;
  background: url(avatar-96.png) center / contain no-repeat; }
.msg.bot + .msg.bot::before { display: none; }
.login-logo { display: block; width: 150px; margin: 6px auto 14px; }
.chips { display: flex; gap: 8px; align-items: center; }
.chip {
  background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 10px;
  font-weight: 600; font-size: 15px; border: 0;
}
.chip.icon { padding: 4px 8px; }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: #3fb27f; }
.dot.off { background: var(--red); }

main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }

.tabbar {
  flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar button {
  background: none; border: 0; padding: 7px 0 8px; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tabbar button span { font-size: 22px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--accent); font-weight: 600; }
.tabbar button.on span { filter: none; opacity: 1; }

/* Chatt */
.status { padding: 8px 14px; background: var(--accent-soft); color: var(--accent); font-size: 15px; font-weight: 600; }
.status.idle { background: transparent; color: var(--muted, #6b7280); font-weight: 500; font-size: 14px; padding: 4px 14px; }
.status .bar-track { height: 6px; background: rgba(0,0,0,.08); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.status .bar-fill { height: 100%; background: var(--yellow); transition: width .8s linear; }
.msgs { flex: 1; padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--me); color: var(--me-ink); border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.note { align-self: center; background: none; color: var(--muted); font-size: 14px; padding: 2px 8px; text-align: center; }
.msg.err { align-self: center; color: var(--red); font-size: 14px; background: none; }
.msg.reminder { border-color: var(--gold); }
.card {
  align-self: stretch; margin: 2px 6%; background: var(--panel); border: 2px solid var(--accent);
  border-radius: 16px; padding: 18px; text-align: center; font-size: 21px; font-weight: 600;
}
.card.right { border-color: #3fb27f; } .card.wrong { border-color: var(--red); }
.card small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); margin-top: 6px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.quick { display: flex; gap: 8px; overflow-x: auto; padding: 6px 12px; scrollbar-width: none; flex: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button {
  flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 7px 13px; font-size: 15px; white-space: nowrap;
}
.composer {
  flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px 10px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px;
  font: inherit; font-size: 17px; /* ≥16px så att iPhone inte zoomar */ max-height: 120px;
  background: var(--bg); color: var(--ink);
}
.round {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent-soft);
  font-size: 20px; display: grid; place-items: center;
}
.round.send { background: var(--accent); color: #fff; }
.round.rec { background: var(--red); color: #fff; }

/* Plan och läxor */
.page { padding: 14px 14px 24px; }
.page h2 { font-size: 20px; margin: 6px 0 10px; }
.page h3 { font-size: 15px; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
.page h3::first-letter { text-transform: uppercase; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .meta { color: var(--muted); font-size: 14px; }
.row.done .task { text-decoration: line-through; color: var(--muted); }
.tick {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--accent);
  background: none; display: grid; place-items: center; font-size: 16px; color: #fff;
}
.row.done .tick { background: var(--accent); }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.tag.test { background: #f7e3e1; color: var(--red); }
.tag.late { background: #f5ecd8; color: var(--gold); }
.empty { color: var(--muted); padding: 18px 14px; text-align: center; }
.big {
  display: block; width: 100%; padding: 14px; border-radius: 14px; border: 0; background: var(--accent);
  color: #fff; font-weight: 600; margin-bottom: 14px;
}
.small-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-size: 14px; flex: none; }

/* Bottenark för uppladdning */
.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 20;
}
.sheet[hidden] { display: none; }
.sheet .panel {
  width: 100%; background: var(--panel); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  max-height: 85dvh; overflow-y: auto;
}
.sheet h2 { margin: 0 0 12px; font-size: 19px; }
.sheet label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
.sheet select { width: 100%; font: inherit; font-size: 17px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.sheet .check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 16px; }
.sheet .check input { width: 22px; height: 22px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet .actions button { flex: 1; padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.sheet .actions .go { background: var(--accent); color: #fff; border: 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-b));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 15px;
  z-index: 30; max-width: 90%; text-align: center;
}
.toast.bad { background: var(--red); color: #fff; }

.login { padding: 30px 20px; text-align: center; }
.login input { width: 100%; font-size: 17px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); margin: 14px 0; }

/* På dator: håll chatten smal och centrerad */
@media (min-width: 700px) and (max-width: 899px) {
  body { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* Poäng */
.score { background: linear-gradient(135deg, var(--accent), #3f9a82); color: #fff; border-radius: 18px; padding: 18px; text-align: center; }
.score .big-num { font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.score .unit { font-size: 16px; opacity: .9; margin-top: 4px; }
.score .money { font-size: 20px; font-weight: 700; margin-top: 12px; }
.score .track { height: 10px; background: rgba(255,255,255,.3); border-radius: 5px; margin-top: 8px; overflow: hidden; }
.score .fill { height: 100%; background: #fff; border-radius: 5px; transition: width .6s ease; }
.score .small { font-size: 13px; opacity: .9; margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.plus { font-weight: 700; color: var(--accent); flex: none; }
.rules .row { padding: 9px 14px; font-size: 15px; }

.code-input { font: 700 28px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 8px; text-align: center; text-transform: uppercase; }
.title { cursor: pointer; }

.row.tap { cursor: pointer; }
.row.tap:active { background: var(--accent-soft); }
.mats { display: flex; flex-direction: column; gap: 10px; }
.mat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.mat-img { display: block; width: 100%; max-height: 260px; object-fit: cover; object-position: top; background: var(--line); cursor: zoom-in; }
.mat-body { padding: 10px 12px; }
.mat-body > .meta, .mat-body .collapsible .meta { color: var(--muted); font-size: 15px; margin-top: 4px; }
.mat-heads { margin: 6px 0 2px; padding-left: 18px; color: var(--ink, inherit); font-size: 15px; line-height: 1.45; }
.collapsible.closed { max-height: 7.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 15px; cursor: pointer; }
.mat-title { font-weight: 700; }
.mat-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mat-text { white-space: pre-wrap; font-size: 16px; line-height: 1.5; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.sheet .zoomed { max-width: 100%; max-height: 100%; margin: auto; display: block; }

.progs { display: flex; flex-direction: column; gap: 8px; }
.prog { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.prog-head { display: flex; gap: 8px; align-items: center; }
.prog-title { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-when { color: var(--accent); font-weight: 700; font-size: 14px; flex: none; }
.prog-track { height: 8px; background: var(--line); border-radius: 4px; margin: 8px 0 6px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--yellow); border-radius: 4px; }
.day-done { background: var(--accent); color: #fff; font-weight: 700; padding: 14px; border-radius: 14px; text-align: center; margin-bottom: 6px; }

.file-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.file-thumb { position: relative; flex: 0 0 72px; height: 92px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-doc { display: flex; align-items: center; justify-content: center; height: 100%; font-weight: 700; color: var(--muted); }
.file-n { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; border-radius: 6px; padding: 0 5px; }
.file-x { position: absolute; right: 3px; top: 3px; width: 24px; height: 24px; border-radius: 12px; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; padding: 0; }
.file-add { flex: 0 0 72px; height: 92px; border-radius: 10px; border: 2px dashed var(--line); background: transparent; font-size: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink); }
.file-add small { font-size: 11px; color: var(--muted); }
.sheet .hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.mic-ico { width: 1.15em; height: 1.15em; vertical-align: -0.2em; }
.round .mic-ico { width: 22px; height: 22px; vertical-align: middle; }
.mic-hint { font-size: 13px; color: var(--muted); text-align: center; padding: 2px 12px 4px; }
.mic-hint .mic-ico { color: var(--ink); }

.deck-bar { height: 5px; background: rgba(0,0,0,.08); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.deck-bar div { height: 100%; background: var(--yellow); }
.hint-small { color: var(--muted); font-size: 13px; text-align: center; margin-top: 12px; }
.fc-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px 18px; margin-top: 14px;
  min-height: 170px; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.fc-front { font-size: 24px; font-weight: 700; line-height: 1.25; }
.fc-hint { color: var(--muted); font-size: 15px; margin-top: 10px; }
.fc-back { font-size: 20px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); color: var(--accent); }
.fc-back[hidden], .fc-hint[hidden] { display: none; }
.fc-controls { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; align-items: center; }
.fc-controls .big { margin-bottom: 0; }
.fc-controls:has(.fc-right) { flex-direction: row; }
.fc-wrong, .fc-right { flex: 1; padding: 16px; border-radius: 14px; border: 0; font-weight: 700; font-size: 17px; color: #fff; }
.fc-wrong { background: var(--red); }
.fc-right { background: var(--good); }
.fc-status { text-align: center; margin-top: 12px; }
#points[hidden], #tabbar button[hidden] { display: none !important; }

.block-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 4px; font-weight: 700; font-size: 15px;
  border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 9%, transparent); }
.block-head + .row, .row.in-block { border-left: 4px solid var(--c); }
.block-ico { font-size: 18px; }
.block-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c); }
.block-min { font-size: 13px; color: var(--muted); font-weight: 600; }
.row.in-block { padding-left: 18px; }

.quiz-maker { padding: 12px 14px; }
.quiz-title { font-weight: 700; margin-bottom: 8px; }
.quiz-sel { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 15px; color: var(--ink); }
.quiz-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.quiz-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); font-size: 26px; color: var(--ink); }
.quiz-btn span { font-size: 16px; font-weight: 700; }
.quiz-btn small { font-size: 12px; color: var(--muted); }
.quiz-btn:disabled { opacity: .7; }
.quiz-progress { height: 6px; border-radius: 3px; background: rgba(0,0,0,.08); margin-top: 10px; overflow: hidden; }
.quiz-progress[hidden], .quiz-btn[hidden] { display: none; }
.quiz-progress div { height: 100%; width: 0; background: var(--yellow); transition: width .3s; }
.choices { display: grid; gap: 10px; width: 100%; }
.choice { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--panel); font-size: 17px; color: var(--ink); }
.choice-letter { flex: 0 0 28px; height: 28px; border-radius: 14px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--panel)); }
.choice.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, var(--panel)); }
.choice:disabled { color: var(--ink); opacity: 1; }
.cloze-gap { display: inline-block; min-width: 4em; border-bottom: 3px solid var(--accent); color: var(--accent); margin: 0 4px; }
.next-btn { margin-top: 4px; width: 100%; }

.quiz-btns.three { grid-template-columns: 1fr 1fr 1fr; }
.ex-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ex-msg { display: flex; gap: 8px; align-items: flex-start; max-width: 88%; padding: 10px 12px; border-radius: 16px; font-size: 16px; line-height: 1.35; }
.ex-msg.pluggis { background: var(--panel); border: 1px solid var(--line); align-self: flex-start; }
.ex-msg.me { background: var(--accent); color: #fff; align-self: flex-end; }
.ex-who { font-size: 20px; }
.ex-input { display: flex; flex-direction: column; gap: 8px; }
.ex-input textarea { width: 100%; box-sizing: border-box; border-radius: 12px; border: 1px solid var(--line); padding: 10px; font-size: 16px; background: var(--panel); color: var(--ink); }
.ex-summary { padding: 14px; }
.ex-score { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.ex-point { padding: 4px 0; }
.ex-point.ok { color: var(--good); }
.ex-point.miss { color: var(--muted); }

.tabbar button[hidden] { display: none; }

.quiz-btns.four { grid-template-columns: 1fr 1fr; }
.exam-intro { text-align: center; padding: 22px 16px; }
.exam-intro h2 { margin: 6px 0; }
.exam-ico { font-size: 40px; }
.exam-q { font-size: 20px; font-weight: 600; min-height: 110px; }
.exam-text { width: 100%; box-sizing: border-box; border-radius: 12px; border: 1px solid var(--line); padding: 10px; font-size: 16px; background: var(--panel); color: var(--ink); }
.choice.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.exam-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.exam-nav .big { flex: 0 0 55%; margin: 0; }
.exam-score { text-align: center; padding: 20px 14px; }
.exam-big { font-size: 44px; font-weight: 800; color: var(--accent); }
.exam-review { padding: 14px; margin-top: 12px; }
.exam-item { align-items: flex-start; }
.exam-mark { flex: 0 0 26px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; margin-right: 10px; }
.exam-mark.ok { background: var(--good); } .exam-mark.half { background: var(--gold, #b7862a); } .exam-mark.miss { background: var(--red); }
.exam-answer { color: var(--accent); }

/* ---- Dator / iPad liggande: sidomeny, luftigare innehåll, dagens plan bredvid chatten ---- */
@media (min-width: 900px) {
  body { display: grid; grid-template-columns: 210px 1fr; grid-template-rows: auto 1fr; height: 100vh; max-width: none; margin: 0; border: 0; }
  .bar { grid-column: 1 / -1; padding: 12px 22px; }
  .tabbar { grid-row: 2; grid-auto-flow: row; grid-auto-rows: max-content; align-content: start; gap: 4px;
    border-top: 0; border-right: 1px solid var(--line); padding: 14px 10px; }
  .tabbar button { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 14px; font-size: 16px; border-radius: 10px; }
  .tabbar button span { font-size: 20px; }
  .tabbar button.on { background: var(--accent-soft); }
  .tabbar button:hover { background: var(--accent-soft); }
  main { grid-row: 2; grid-column: 2; min-height: 0; }
  .page { width: 100%; max-width: 860px; margin: 0 auto; padding: 22px 28px 40px; }
  .msgs { padding: 18px 28px 6px; }
  .msgs, .quick, .composer, .mic-hint, .status { width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; }
  .msg { max-width: 70%; }
  .composer { padding-bottom: 16px; }
  .quiz-btns.four { grid-template-columns: repeat(4, 1fr); }
  .quiz-btns.three { grid-template-columns: repeat(3, 1fr); }
  .choices { grid-template-columns: 1fr 1fr; }
  .fc-card { min-height: 210px; }
  .fc-front { font-size: 28px; }
  .exam-nav .big { flex: 0 0 auto; min-width: 220px; }
  .sheet { align-items: center; justify-content: center; }
  .sheet .panel { width: 520px; border-radius: 18px; padding-bottom: 20px; }
  .toast { left: calc(50% + 105px); bottom: 28px; }
}
@media (min-width: 1100px) {
  .chat-wide { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 360px; }
  .chat-wide > div:first-child { min-height: 0; border-right: 1px solid var(--line); }
  .side { overflow-y: auto; padding: 18px 18px 30px; background: var(--bg); }
  .side-title { font-weight: 700; color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 8px; }
  .side .box + .side-title, .side .prog + .side-title { margin-top: 18px; }
  .side .prog { margin-bottom: 8px; }
}

.quiz-btns.six { grid-template-columns: 1fr 1fr; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-tile { min-height: 58px; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel);
  font-size: 15px; line-height: 1.25; color: var(--ink); text-align: center; transition: transform .1s; }
.match-tile.r { background: color-mix(in srgb, var(--accent) 5%, var(--panel)); }
.match-tile.sel { border-color: var(--accent); transform: scale(1.03); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.match-tile.done { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--panel)); color: var(--muted); opacity: .55; }
.match-tile.miss, .order-step.miss { border-color: var(--red); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.match-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); font-size: 18px; }
.order-placed { display: flex; flex-direction: column; gap: 6px; }
.order-slot, .order-done { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px; border-radius: 12px; }
.order-slot { border: 2px dashed var(--line); color: var(--muted); }
.order-done { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border: 2px solid var(--accent); font-weight: 600; }
.order-n { flex: 0 0 26px; height: 26px; border-radius: 13px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.order-slot .order-n { background: var(--line); color: var(--muted); }
.order-pool { display: flex; flex-direction: column; gap: 8px; }
.order-step { padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); font-size: 16px; text-align: left; color: var(--ink); }
.order-why { margin-top: 12px; padding: 10px 12px; border-left: 3px solid var(--accent); }
.order-why[hidden] { display: none; }
@media (min-width: 900px) { .quiz-btns.six { grid-template-columns: repeat(3, 1fr); } .match-tile { min-height: 64px; font-size: 16px; } }

.listen { padding: 14px; margin-top: 14px; }
.listen-head { display: flex; gap: 10px; align-items: center; }
.listen-ico { font-size: 26px; }
.listen-title { font-weight: 700; }
.listen-hint { margin-top: 2px; }
.listen .quiz-progress { margin-top: 12px; }
.listen-now { margin-top: 10px; font-size: 16px; line-height: 1.4; min-height: 2.8em; color: var(--ink); }
.listen-now[hidden] { display: none; }
.listen-ctrl { display: flex; justify-content: center; align-items: center; gap: 22px; margin-top: 10px; }
.listen-play { width: 62px; height: 62px; border-radius: 31px; border: 0; background: var(--accent); color: #fff; font-size: 26px; }
.listen-btn { width: 46px; height: 46px; border-radius: 23px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; color: var(--ink); }
.listen-mark { margin-top: 4px; }
.listen-mark.on { color: var(--accent); font-weight: 600; }
.listen-mark:empty { display: none; }

.focus-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 4px; }
.focus-row:empty { display: none; }
.focus-label { color: var(--muted); font-size: 14px; margin-right: 2px; }
.focus-chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 18px; padding: 7px 13px; font-size: 14px; }
.focus-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* Mörkt: följer telefonen/datorn om inget valts, eller valt med ◐/☀/☾ (data-theme på <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .listen-play, :root:not([data-theme="light"]) .tabbar button.on span { color: #fff; }
}
:root[data-theme="dark"] .listen-play, :root[data-theme="dark"] .tabbar button.on span { color: #fff; }


:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
.theme-btn { min-width: 36px; }

/* Övningspassets gula rad: knapparna läsbara i både ljust och mörkt läge */
#runBar .small-btn { background: #022153; color: #fff; border-color: #022153; }

/* Testprovets resultat: det som blev fel med rätt svar */
.exam-wrong { padding: 10px 0; border-top: 1px solid var(--line, rgba(127,127,127,.2)); }
.exam-wrong:first-of-type { border-top: 0; }
.exam-wrong .exam-answer { color: var(--good, #1f9d55); font-weight: 600; margin-top: 2px; }
.exam-all { margin-top: 14px; }
.exam-all summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

/* Lyssna med frågor: frågorna efter ett avsnitt, i spelaren */
.listen-quiz { margin: 10px 0; padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line, #8883); }
.listen-quiz[hidden] { display: none; }
.listen-qtext { font-size: 1.1rem; font-weight: 600; margin: 6px 0 10px; }
.listen-q[hidden] { display: none; }

.small-btn.ghost-btn { background: transparent; border: 1px solid var(--line, #8884); color: var(--muted, inherit); }

/* Fira ett avbockat moment */
.cheer-layer { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(0,0,0,.45); }
.cheer-layer .fireworks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cheer { position: relative; padding: 18px 26px; border-radius: 18px; text-align: center; background: #1d3f8f;
  color: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.35); animation: cheer-pop .45s cubic-bezier(.2,1.6,.4,1); max-width: 86vw; }
.cheer.big { padding: 26px 34px; }
.cheer-title { font-size: 26px; font-weight: 800; }
.cheer.big .cheer-title { font-size: 32px; }
.cheer-task { margin-top: 6px; opacity: .85; }
.cheer-left { margin-top: 10px; font-weight: 600; color: #fec434; }
@keyframes cheer-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
