:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e1e3e8;
  --text: #1a1d23;
  --text-muted: #63697b;
  --accent: #0f766e;
  --accent-hover: #0c5c56;
  --accent-soft: #e6f4f2;
  --correct: #1a7f37;
  --correct-bg: #e7f7ec;
  --wrong: #c4293b;
  --wrong-bg: #fdecee;
  --pastel-sba-bg: #dbeafe;
  --pastel-sba-text: #1d4ed8;
  --pastel-vsa-bg: #ede9fe;
  --pastel-vsa-text: #6d28d9;
  --pastel-mixed-bg: #fef3c7;
  --pastel-mixed-text: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1c1f26;
    --surface-2: #23262e;
    --border: #2e323c;
    --text: #eceef2;
    --text-muted: #9aa0b1;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: #133a37;
    --correct: #4ade80;
    --correct-bg: #123521;
    --wrong: #f87171;
    --wrong-bg: #3a1418;
    --pastel-sba-bg: #1e3a5f;
    --pastel-sba-text: #93c5fd;
    --pastel-vsa-bg: #3b2e5c;
    --pastel-vsa-text: #c4b5fd;
    --pastel-mixed-bg: #4a3510;
    --pastel-mixed-text: #fcd34d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 20px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #14161b;
  --surface: #1c1f26;
  --surface-2: #23262e;
  --border: #2e323c;
  --text: #eceef2;
  --text-muted: #9aa0b1;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #133a37;
  --correct: #4ade80;
  --correct-bg: #123521;
  --wrong: #f87171;
  --wrong-bg: #3a1418;
  --pastel-sba-bg: #1e3a5f;
  --pastel-sba-text: #93c5fd;
  --pastel-vsa-bg: #3b2e5c;
  --pastel-vsa-text: #c4b5fd;
  --pastel-mixed-bg: #4a3510;
  --pastel-mixed-text: #fcd34d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 20px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e1e3e8;
  --text: #1a1d23;
  --text-muted: #63697b;
  --accent: #0f766e;
  --accent-hover: #0c5c56;
  --accent-soft: #e6f4f2;
  --correct: #1a7f37;
  --correct-bg: #e7f7ec;
  --wrong: #c4293b;
  --wrong-bg: #fdecee;
  --pastel-sba-bg: #dbeafe;
  --pastel-sba-text: #1d4ed8;
  --pastel-vsa-bg: #ede9fe;
  --pastel-vsa-text: #6d28d9;
  --pastel-mixed-bg: #fef3c7;
  --pastel-mixed-text: #b45309;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.06);
}

/* Body text stays neutral dark (unchanged from light) rather than tinted, so legibility never
   suffers - the "rosa" flavor comes through in backgrounds/borders/accent instead, same as how
   dark mode keeps text near-white rather than colorizing it. Accent is a deep raspberry
   (#be123c), deliberately distinct from Oftalmologi's own magenta moment.json color (#db2777)
   so a subject badge never blends into the theme's buttons/links. */
:root[data-theme="pink"] {
  --bg: #fdf1f6;
  --surface: #ffffff;
  --surface-2: #fbe6ef;
  --border: #f4cfe1;
  --text: #1a1d23;
  --text-muted: #8a5a72;
  --accent: #be123c;
  --accent-hover: #9f1239;
  --accent-soft: #fce7f3;
  --correct: #1a7f37;
  --correct-bg: #e7f7ec;
  --wrong: #c4293b;
  --wrong-bg: #fdecee;
  --pastel-sba-bg: #dbeafe;
  --pastel-sba-text: #1d4ed8;
  --pastel-vsa-bg: #ede9fe;
  --pastel-vsa-text: #6d28d9;
  --pastel-mixed-bg: #fef3c7;
  --pastel-mixed-text: #b45309;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.06);
}

/* Same recipe as pink above: soft tinted bg/surface-2/border, neutral --text, saturated accent
   kept a visibly different shade from the closest moment.json/pastel token in that family (e.g.
   this blue's accent isn't literally Psykiatri's blue or the SBA pastel-text blue) so a subject
   badge or question-type badge never reads as "part of the theme" when it sits on a themed panel. */
:root[data-theme="blue"] {
  --bg: #eef5fc;
  --surface: #ffffff;
  --surface-2: #dde9f7;
  --border: #c2d9f0;
  --text: #1a1d23;
  --text-muted: #5c7593;
  --accent: #1e5eda;
  --accent-hover: #1747ab;
  --accent-soft: #e0ebfb;
  --correct: #1a7f37;
  --correct-bg: #e7f7ec;
  --wrong: #c4293b;
  --wrong-bg: #fdecee;
  --pastel-sba-bg: #dbeafe;
  --pastel-sba-text: #1d4ed8;
  --pastel-vsa-bg: #ede9fe;
  --pastel-vsa-text: #6d28d9;
  --pastel-mixed-bg: #fef3c7;
  --pastel-mixed-text: #b45309;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.06);
}

:root[data-theme="purple"] {
  --bg: #f6f1fc;
  --surface: #ffffff;
  --surface-2: #ebe0f9;
  --border: #d7c4ef;
  --text: #1a1d23;
  --text-muted: #7a6194;
  --accent: #9333ea;
  --accent-hover: #7418c9;
  --accent-soft: #f0e4fc;
  --correct: #1a7f37;
  --correct-bg: #e7f7ec;
  --wrong: #c4293b;
  --wrong-bg: #fdecee;
  --pastel-sba-bg: #dbeafe;
  --pastel-sba-text: #1d4ed8;
  --pastel-vsa-bg: #ede9fe;
  --pastel-vsa-text: #6d28d9;
  --pastel-mixed-bg: #fef3c7;
  --pastel-mixed-text: #b45309;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.06);
}

:root[data-theme="orange"] {
  --bg: #fdf4ec;
  --surface: #ffffff;
  --surface-2: #fbe7d1;
  --border: #f2cd9c;
  --text: #1a1d23;
  --text-muted: #9a6a3a;
  --accent: #d2691e;
  --accent-hover: #a6540f;
  --accent-soft: #fce6d0;
  --correct: #1a7f37;
  --correct-bg: #e7f7ec;
  --wrong: #c4293b;
  --wrong-bg: #fdecee;
  --pastel-sba-bg: #dbeafe;
  --pastel-sba-text: #1d4ed8;
  --pastel-vsa-bg: #ede9fe;
  --pastel-vsa-text: #6d28d9;
  --pastel-mixed-bg: #fef3c7;
  --pastel-mixed-text: #b45309;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.06);
}

:root {
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

/* "Nya frågor" (invented questions) has its own colour so it never reads as a real exam: lime, the widest free gap on
   the hue wheel - clear of every subject colour (moment.json: blue, violet, green, orange, pink, slate), the teal
   accent, ⭐ gold, wrong-red and all six themes' accents. Kept out of the theme blocks above on purpose: light is
   the default, dark applies only to system-dark with no manual theme and to the explicit "Mörkt" theme, so a manual
   light colour theme under a dark OS still gets the light values.
   --new = strokes/graphics, --new-fill = solid button fill (always with --new-ink text), --new-strong = text on
   --new-soft, --new-border = outlines. */
:root {
  --new: #65a30d;
  --new-fill: #84cc16;
  --new-strong: #3f6212;
  --new-soft: #ecfccb;
  --new-border: #bef264;
  --new-ink: #1a2e05;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --new: #a3e635;
    --new-fill: #a3e635;
    --new-strong: #bef264;
    --new-soft: #27360b;
    --new-border: #4d7c0f;
    --new-ink: #1a2e05;
  }
}
:root[data-theme="dark"] {
  --new: #a3e635;
  --new-fill: #a3e635;
  --new-strong: #bef264;
  --new-soft: #27360b;
  --new-border: #4d7c0f;
  --new-ink: #1a2e05;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 16px 28px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--accent), var(--accent-hover)) 1;
  box-shadow: var(--shadow);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-display);
}

.brand-icon { width: 26px; height: 26px; flex-shrink: 0; }
.brand-icon path { fill: var(--accent); }
.brand-icon circle { fill: var(--accent-soft); }

.topbar-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

.topbar-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.topbar-link:hover { color: var(--accent); background: var(--accent-soft); }

.topbar-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.topbar-icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.topbar-icon-btn svg { width: 20px; height: 20px; }

.topbar-notif-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--wrong);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* Unread notification row (renderForumNotificationsView) - same .module-card everywhere else, just
   a colored left edge + tinted background so unread ones stand out from already-read ones. */
.module-card.is-unread {
  background: var(--accent-soft);
  border-color: var(--accent);
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* Only shown for the pink theme (see :root[data-theme="pink"] above), and only once the viewport
   is wide enough that the margins beside #app's 760px column have real room - narrower than that,
   these would sit under real content instead of beside it. */
#pink-theme-decor { display: none; }
:root[data-theme="pink"] #pink-theme-decor { display: block; }
@media (max-width: 1200px) {
  #pink-theme-decor { display: none; }
}
.pink-decor-item {
  position: fixed;
  z-index: 0;
  filter: drop-shadow(0 2px 4px rgba(190, 18, 60, 0.15));
  cursor: pointer;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

.lead { color: var(--text-muted); margin-top: 0; }
.eyebrow { color: var(--text-muted); font-size: 0.9rem; margin-top: 0; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 20px;
}

.module-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-family: inherit;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.18s ease, border-color 0.18s ease;
}

/* Colored top bar that sweeps in on hover, plus the accent tokens every distinctness feature
   below (icon, hover border/shadow) reads from - falls back to the site's teal everywhere no
   .card-accent-* modifier is set, so ordinary (non-distinct) module-cards elsewhere still work. */
.module-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-accent, var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}

.module-card:hover {
  border-color: var(--card-accent, var(--accent));
  transform: translateY(-4px);
  box-shadow: var(--shadow), 0 12px 24px rgba(0, 0, 0, 0.1);
}
.module-card:hover::before { transform: scaleX(1); }

.module-card h3 { margin: 0; font-size: 1.05rem; font-family: var(--font-display); font-weight: 600; }
.module-card .eyebrow { margin-bottom: 8px; }
.module-card p.desc { margin: 0 0 10px; color: var(--text-muted); font-size: 0.92rem; line-height: 1.4; }
.module-card .stats-line { margin: 0; }

.card-accent-teal { --card-accent: var(--accent); --card-accent-soft: var(--accent-soft); }
.card-accent-amber { --card-accent: var(--pastel-mixed-text); --card-accent-soft: var(--pastel-mixed-bg); }
.card-accent-blue { --card-accent: var(--pastel-sba-text); --card-accent-soft: var(--pastel-sba-bg); }
.card-accent-purple { --card-accent: var(--pastel-vsa-text); --card-accent-soft: var(--pastel-vsa-bg); }
.card-accent-red { --card-accent: var(--wrong); --card-accent-soft: var(--wrong-bg); }
/* .module-card sets display:block, which beats the UA [hidden] rule - without this a "hidden" card (the forum's
   "Mina inlägg" for guests) stays visible. */
.module-card[hidden] { display: none; }

/* The "Mina kurser" course card (renderCourses): a solid-color hero card instead of the plain
   white module-card look, since it's the app's single entry point. Fixed brand-teal hex rather
   than var(--accent) - that token goes pale mint in dark mode, which white text can't sit on. */
.course-card-hero {
  /* Lime green, but a shade dark enough for the white text to stay readable (WCAG AA) -
     a true bright lime (e.g. #32CD32) is too light for white text to sit on. */
  background: linear-gradient(135deg, #4d7c0f, #3f6212);
  border-color: transparent;
  color: #ffffff;
}
.course-card-hero:hover { border-color: transparent; }
.course-card-hero::before { display: none; }
.course-card-hero h3 { font-size: 1.7rem; }

.course-topic-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.course-topic-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* Icon-left, heading-right header row (icon + bigger h3 than plain module-card titles
   elsewhere), used on the home page and Tentastatistik hub cards. */
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.card-head h3 { font-size: 1.3rem; }

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--card-accent-soft, var(--accent-soft));
  color: var(--card-accent, var(--accent));
}
.card-icon svg { width: 22px; height: 22px; }

/* Gamla tentor's own exam list: 2 cards per row instead of 1, so more exams fit on screen. */
.tentor-grid { grid-template-columns: repeat(2, 1fr); }

/* Exam list cards: title+date corners on top, status+chart corners on the bottom. Every card
   renders the exact same four elements (chart falls back to an all-grey placeholder when
   unpracticed - see buildMultiDonutSVG call), so cards stay a uniform size regardless of practice
   history instead of shrinking when there's no score to show. */
button.tenta-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tenta-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.tenta-card-title {
  margin: 0;
  font-size: 1.12rem;
  font-family: var(--font-display);
  font-weight: 600;
}
/* The Ordinarie/Omtentamen badge would otherwise sit inline after the title text and wrap to its
   own line only when the title was too long to fit both on one line - landing in a different spot
   from card to card. Always put it on its own line underneath instead, scoped to this card only
   (badge-omtenta/-ordinarie are shared classes used inline elsewhere). */
.tenta-card-title .badge-omtenta,
.tenta-card-title .badge-ordinarie {
  display: block;
  width: fit-content;
  margin-left: 0;
  margin-top: 4px;
}
.tenta-card-date {
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.tenta-card-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}
.tenta-card-status {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
}
.tenta-card-status.is-unpracticed { color: var(--text-muted); background: var(--surface-2); }
.tenta-card-status.is-practiced { color: var(--accent); background: var(--accent-soft); }
.module-card-chart { flex-shrink: 0; }
.module-card-chart svg { display: block; }

/* Moment (subject) toggle cards: Gamla tentor's multi-select exam filter, and the single-select
   Tentastatistik gate/sidebar. Each card sets --moment-color inline; active = filled with that
   color, inactive = plain grey - same visual language regardless of multi/single-select mode. */
.moment-toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.moment-toggle-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 11px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.moment-toggle-card:hover { border-color: var(--moment-color, var(--accent)); transform: translateY(-1px); }
.moment-toggle-card.is-active {
  background: var(--moment-color);
  border-color: var(--moment-color);
  color: #ffffff;
}
.moment-toggle-card.is-whole-exam {
  border-style: dashed;
}

/* Tentastatistik gate only: rectangular cards, two per row (half the panel width each) instead
   of the default wrapped .moment-toggle-grid layout (which Gamla tentor's subject selector keeps
   using as-is). */
.examstats-gate-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .examstats-gate-grid { grid-template-columns: 1fr; } }
.examstats-gate-card .card-head { margin-bottom: 8px; }
.examstats-gate-card .card-icon { font-size: 1.3rem; }
.examstats-gate-card.is-current { border-color: var(--card-accent); }
.examstats-gate-count { margin: 0; color: var(--text-muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.examstats-subject-badge { font-size: 0.9rem; padding: 5px 14px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 18px;
  box-shadow: var(--shadow);
}

.panel ul { margin: 0; padding-left: 20px; color: var(--text); }
.panel li { margin-bottom: 6px; line-height: 1.4; }

.sources-list { list-style: none; padding: 0; }
.sources-list li {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}
.sources-list li:last-child { border-bottom: none; }

.muted-list li { font-style: italic; opacity: 0.75; }

.note-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.87rem;
  color: var(--text);
  line-height: 1.5;
  margin: 4px 0 18px;
}

.resume-quiz-banner p { margin: 0; }
.resume-quiz-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.resume-quiz-actions .btn-primary,
.resume-quiz-actions .btn-ghost {
  width: auto;
  flex: 1;
  margin-top: 0;
}

/* Global uncaught-error banner: fixed to the very top of the viewport, above everything else
   (including the topbar) - see window "error"/"unhandledrejection" handlers in app.js. Reuses the
   app's existing --wrong/--wrong-bg tokens rather than inventing a new color. */
.global-error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--wrong-bg);
  border-bottom: 2px solid var(--wrong);
  color: var(--wrong);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}
.global-error-banner[hidden] { display: none; }
.global-error-banner-body { flex: 1; min-width: 0; }
.global-error-banner-body strong { display: block; margin-bottom: 2px; }
.global-error-banner-body p { margin: 2px 0 0; font-size: 0.85rem; line-height: 1.4; word-break: break-word; }
.global-error-banner-hint { color: var(--text-muted) !important; }
.global-error-banner-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.global-error-banner-actions .btn-ghost {
  width: auto;
  padding: 6px 14px;
  font-size: 0.85rem;
  margin-top: 0;
  border-color: var(--wrong);
  color: var(--wrong);
}
.global-error-banner-dismiss {
  background: none;
  border: none;
  color: var(--wrong);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
}

/* Floating paused-quiz reminder: fixed to the viewport (not inside any .view), so it stays
   visible across every page until the paused quiz is resumed or dismissed. */
.paused-quiz-widget {
  position: fixed;
  top: 84px;
  right: 16px;
  width: 260px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  z-index: 15;
}
.paused-quiz-widget[hidden] { display: none; }
.paused-quiz-widget-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  font-family: inherit;
}
.paused-quiz-widget-dismiss:hover { color: var(--text); }
.paused-quiz-widget-title {
  margin: 0 20px 4px 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}
.paused-quiz-widget-text {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.paused-quiz-widget .btn-primary {
  width: 100%;
  margin-top: 0;
  padding: 9px 14px;
  font-size: 0.9rem;
}

/* Live moment-switcher sidebar: fixed to the left of the viewport, outside the #app column -
   same "floating, independent of the single-column layout" technique as .paused-quiz-widget
   above (which sits on the right). Only shown (via [hidden]) inside Tentastatistik's Översikt,
   Ämnesfördelning and Återkommande frågor & koncept. */
.moment-sidebar {
  position: fixed;
  left: 16px;
  top: 96px;
  width: 190px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 12;
}
.moment-sidebar[hidden] { display: none; }
.moment-sidebar-title {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
/* Same card look as the rest of Tentastatistik: a coloured dot, the name, and - for the active subject - a tint in its
   own colour with a coloured edge, instead of a solid slab. Scoped here; the other .moment-toggle-card uses are untouched. */
.moment-sidebar .moment-toggle-card {
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  padding: 11px 14px;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
  border-left: 4px solid var(--moment-color, var(--accent));
  box-shadow: var(--shadow);
}
.moment-sidebar .moment-toggle-card::before {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--moment-color, var(--accent));
}
.moment-sidebar .moment-toggle-card:hover { transform: translateX(2px); }
.moment-sidebar .moment-toggle-card.is-active {
  background: color-mix(in srgb, var(--moment-color, var(--accent)) 14%, var(--surface));
  border-color: var(--moment-color, var(--accent));
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .moment-sidebar { display: none; }
}

.laerandemal-list li { margin-bottom: 10px; }
.mal-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 1px 7px;
  margin-right: 8px;
  white-space: nowrap;
  vertical-align: middle;
}

.section-heading { margin: 26px 0 0; }

/* "Nya läkarprogrammet"/"Gamla läkarprogrammet" on the Gamla tentor list - plain .section-heading
   (1.1rem body text) got lost above the bigger exam cards below it. */
.tentor-curriculum-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
}

.badge-tbl {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #d97706;
  background: rgba(217, 119, 6, 0.12);
  border-radius: 6px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.badge-reference {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.link-back {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 14px 7px 11px;
  border-radius: 999px;
  margin-bottom: 18px;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.link-back:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-soft);
}
.link-back:active { transform: scale(0.96); }

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.field-row label { color: var(--text); font-size: 0.95rem; font-weight: 600; }

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-field input[type="checkbox"] { width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--accent); }

select,
input[type="search"],
input[type="text"],
input[type="email"],
input[type="password"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.92rem;
  font-family: inherit;
  min-width: 180px;
}
input[type="search"],
input[type="text"],
input[type="email"],
input[type="password"] { min-width: 240px; }
input[type="search"]:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Label-above-input stacked field, for the forum's login/register/new-post forms - .field-row
   above is a horizontal label-left/input-right row instead, wrong shape for these. */
.form-field { margin-bottom: 14px; }
.form-field label { display: block; color: var(--text); font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; }
.form-field input { width: 100%; }
.form-error { color: var(--wrong); font-size: 0.85rem; margin: 4px 0 12px; min-height: 1em; }

/* Quoted-reference box for a forum post/thread linked to a specific flagged exam question -
   tinted surface-2 (not .panel/white) so it reads as nested inside the white panel around it. */
.linked-question-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.linked-question-chip .eyebrow { margin: 0 0 4px; }
.linked-question-chip p:last-child { margin: 0; }

/* Compact "Redigera"/"Ta bort" (or "Spara"/"Avbryt") pair on your own thread/reply - the shared
   .btn-primary/.btn-ghost are full-width by default, wrong for a small inline action row. */
.forum-owner-actions {
  display: flex;
  gap: 8px;
  margin: 6px 0 14px;
}
/* The static #forum-thread-owner-actions box is shown/hidden via the [hidden] attribute in JS -
   without this, .forum-owner-actions' own `display: flex` beats the UA [hidden] rule and the
   Redigera/Ta bort row stays visible even for someone who isn't the thread's author. Same class of
   bug as .result-tabs-row's, documented in CLAUDE.md - check for it on any flex/grid element
   toggled via .hidden/[hidden] rather than assuming the attribute alone is enough. */
.forum-owner-actions[hidden] { display: none; }
.forum-owner-actions .btn-ghost,
.forum-owner-actions .btn-primary {
  width: auto;
  padding: 6px 14px;
  font-size: 0.85rem;
  margin-top: 0;
}

/* Forum, Reddit style: a vote strip (up arrow, score, down arrow) on the left of each reply, the author/time
   line on top, the text, then the actions. The reply the thread's author marked as the answer is pinned first
   with a green edge and a "✓ Svar" pill; "✓ Besvarad" shows on the thread and in the thread lists. Upvote orange
   and downvote blue are Reddit's own and deliberately theme-independent (like the ⭐ badge's amber). */
.forum-solved-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--correct);
  background: var(--correct-bg);
  border: 1px solid var(--correct);
  white-space: nowrap;
}
/* The post itself: a real card (the ämne's colour on its edge) - ämne + attached exam question on top, the title,
   who asks and when, then the question in full-strength text; edit/delete along the bottom. */
.forum-hub-cards { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 560px) { .forum-hub-cards { grid-template-columns: 1fr; } }
.forum-post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--post-color, var(--accent));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px 20px;
  margin-top: 14px;
}
.forum-post-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.forum-post h1 { margin: 10px 0 10px; font-size: 1.7rem; line-height: 1.25; overflow-wrap: anywhere; }
.forum-post-author { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.9rem; }
.forum-post-author-name { font-weight: 700; color: var(--text); }
.forum-post-time { color: var(--text-muted); font-size: 0.82rem; }
.forum-post-body {
  margin: 16px 0 16px;
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.forum-post .linked-question-chip { margin-bottom: 4px; }
.forum-post .linked-question-chip > .eyebrow { color: var(--text); font-weight: 700; font-size: 0.82rem; margin-bottom: 8px; }
.forum-post .forum-owner-actions { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.forum-post-edit { margin-top: 14px; }
.forum-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}
.forum-avatar.is-small { width: 22px; height: 22px; font-size: 0.7rem; }
.forum-op-tag { font-size: 0.68rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 6px; }
.forum-linked-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.forum-linked-badge[hidden] { display: none; }
.forum-thread-preview {
  margin: 6px 0 6px;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.forum-reply-label { display: block; font-weight: 700; font-size: 0.95rem; margin-bottom: 8px; }
.forum-solved-banner {
  margin: 4px 0 14px;
  padding: 9px 14px;
  border-radius: 10px;
  color: var(--correct);
  background: var(--correct-bg);
  border: 1px solid var(--correct);
  font-size: 0.9rem;
  font-weight: 600;
}
.forum-solved-banner[hidden] { display: none; }
.forum-replies-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.forum-sort { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.85rem; font-weight: 600; }
.forum-sort[hidden] { display: none; }
.forum-sort select { min-width: 0; }

.forum-reply {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 10px;
  overflow: hidden;
}
.forum-reply.is-accepted { border-color: var(--correct); box-shadow: 0 0 0 1px var(--correct), var(--shadow); }
.forum-reply-main { flex: 1; min-width: 0; padding: 10px 14px 10px 12px; }
.forum-reply-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.forum-reply-author { font-weight: 700; color: var(--text); }
.forum-reply-body { margin: 0 0 8px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.forum-reply-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.forum-reply-actions .forum-owner-actions { margin: 0; }
.forum-accept-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}
.forum-accept-btn:hover { border-color: var(--correct); color: var(--correct); }
.forum-accept-btn.is-on { border-color: var(--correct); color: var(--correct); background: var(--correct-bg); }

.forum-vote {
  width: 46px;
  flex-shrink: 0;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
}
.forum-vote-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.forum-vote-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.forum-vote-btn.is-down svg { transform: rotate(180deg); }
.forum-vote-btn.is-up:not(:disabled):hover { color: #ff4500; background: color-mix(in srgb, #ff4500 14%, transparent); }
.forum-vote-btn.is-down:not(:disabled):hover { color: #7193ff; background: color-mix(in srgb, #7193ff 16%, transparent); }
.forum-vote-btn:not(:disabled):active { transform: scale(0.92); }
.forum-vote-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.forum-vote-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.forum-vote-score { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.2; }
.forum-vote.is-upvoted .forum-vote-btn.is-up { color: #ff4500; }
.forum-vote.is-upvoted .forum-vote-btn.is-up svg { fill: currentColor; }
.forum-vote.is-upvoted .forum-vote-score { color: #ff4500; }
.forum-vote.is-downvoted .forum-vote-btn.is-down { color: #7193ff; }
.forum-vote.is-downvoted .forum-vote-btn.is-down svg { fill: currentColor; }
.forum-vote.is-downvoted .forum-vote-score { color: #7193ff; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 6px;
  font-family: inherit;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.stats-line {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 10px 0 0;
  text-align: center;
}

/* Quiz view */
.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.quiz-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
}
#quiz-progress-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.vignette {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

#quiz-question {
  font-size: 1.15rem;
  line-height: 1.4;
  margin-bottom: 18px;
}

.question-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.question-images[hidden] { display: none; }
.question-image {
  max-height: 280px;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  object-fit: contain;
  background: var(--surface-2);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 10, 14, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  cursor: zoom-out;
}
.image-lightbox[hidden] { display: none; }
.image-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.options-list[hidden] { display: none; }

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 0.96rem;
  line-height: 1.4;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.1s ease, background 0.1s ease;
}
.option-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.option-btn:disabled { cursor: default; }

.option-key {
  flex: none;
  margin-left: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
}

.option-btn.correct { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); font-weight: 600; }
.option-btn.wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); font-weight: 600; }
.option-btn.dim { opacity: 0.55; }
.option-btn.selected { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.feedback {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.feedback-verdict { margin: 0 0 6px; font-weight: 700; }
.feedback-verdict.is-correct { color: var(--correct); }
.feedback-verdict.is-wrong { color: var(--wrong); }
#quiz-feedback-explanation { margin: 0; color: var(--text-muted); line-height: 1.5; font-size: 0.92rem; }

/* Kortsvar (free-text) practice */
.kortsvar-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.kortsvar-block[hidden] { display: none; }

.kortsvar-textarea {
  width: 100%;
  min-height: 90px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.96rem;
  font-family: inherit;
  line-height: 1.4;
  resize: vertical;
}
.kortsvar-textarea:disabled { opacity: 0.7; }

.kortsvar-reveal {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kortsvar-reveal[hidden] { display: none; }
.kortsvar-compare-line { margin: 0; font-size: 0.95rem; line-height: 1.4; }
.kortsvar-compare-label { color: var(--text-muted); font-weight: 600; margin-right: 4px; }

.kortsvar-self-grade {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.kortsvar-self-grade[hidden] { display: none; }
.kortsvar-self-grade-label { color: var(--text-muted); font-size: 0.9rem; }

.self-grade-btn {
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.self-grade-correct:hover { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); }
.self-grade-wrong:hover { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }

.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}
.quiz-actions .btn-primary { width: auto; flex: 1; }

/* Flag-for-review toggle, next to the quiz progress bar (Gamla tentor exam mode only). */
.flag-toggle-btn {
  flex: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  filter: grayscale(1);
  transition: opacity 0.12s ease, filter 0.12s ease, border-color 0.12s ease;
}
.flag-toggle-btn:hover { opacity: 0.8; border-color: var(--text-muted); }
.flag-toggle-btn.is-flagged { opacity: 1; filter: none; border-color: var(--wrong); }

/* Floating "föregående/nästa fråga" arrow pair, bottom-right corner - a simple always-there
   alternative to Gamla tentor exam mode's full nav bar below, shown for every quiz type (see
   renderQuizNavArrows()). Fixed to the viewport like .paused-quiz-widget, not inside any .view. */
.quiz-nav-arrows {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 10px;
  z-index: 18;
}
.quiz-nav-arrows[hidden] { display: none; }
/* Lifts the pair above the full-width exam-nav-bar when both are visible (exam mode), so they
   don't overlap - matches #app.has-exam-nav's own 76px reserve below. */
.quiz-nav-arrows.is-above-exam-nav { bottom: 92px; }

.quiz-nav-arrow-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.quiz-nav-arrow-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.quiz-nav-arrow-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.quiz-nav-arrow-btn:disabled:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.quiz-nav-arrow-btn[hidden] { display: none; }

/* Bottom question-navigator strip (Gamla tentor exam mode only): fixed to the viewport, present on
   both the quiz view and the review view. #app gets extra bottom padding while it's visible so the
   bar never covers the last bit of question/review content. */
#app.has-exam-nav { padding-bottom: 76px; }

.exam-nav-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 10px 0;
}
.exam-nav-bar[hidden] { display: none; }

.exam-nav-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: thin;
}

.exam-nav-item {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.exam-nav-item:hover { border-color: var(--accent); color: var(--text); }
.exam-nav-item.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.exam-nav-item.is-answered:not(.is-current) {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
}
/* Answered = small check badge, top-right; flagged = small flag badge, top-left. Opposite corners
   so a question that's both answered and flagged shows both at once without colliding. */
.exam-nav-item.is-answered::after {
  content: "✓";
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--correct);
  color: #fff;
  font-size: 0.55rem;
  line-height: 14px;
  text-align: center;
}
.exam-nav-item.is-flagged::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wrong);
}

/* Whenever facit is withheld mid-quiz ("Simulera hela tentan", or "Uppdelat i ämnen" with "Först i
   slutresultatet"): answered = neutral light blue, no checkmark badge, so nothing on the navigator
   hints at correctness before you see the facit (unanswered stays the plain grey base style above;
   flags are unaffected either way). */
#exam-nav-bar.is-deferred-feedback .exam-nav-item.is-answered:not(.is-current) {
  background: var(--pastel-sba-bg);
  border-color: var(--pastel-sba-text);
  color: var(--pastel-sba-text);
}
#exam-nav-bar.is-deferred-feedback .exam-nav-item.is-answered::after {
  content: none;
}

/* Review page: one row per question, table-like but stacked (works at any width). */
.exam-review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.exam-review-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.exam-review-row.is-clickable { cursor: pointer; }
.exam-review-row.is-clickable:hover { border-color: var(--accent); background: var(--accent-soft); }
.exam-review-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.exam-review-row-num { font-weight: 700; }
.exam-review-flag-badge { color: var(--wrong); font-size: 0.82rem; font-weight: 600; }
.exam-review-row-head .result-verdict-badge { margin-left: auto; }
.exam-review-row-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.exam-review-row .kortsvar-self-grade { margin-top: 10px; }

/* Result view */
.result-donut-wrap {
  display: flex;
  justify-content: center;
  margin: 10px 0 4px;
}
.result-donut-wrap svg { max-width: 100%; height: auto; }
.donut-track { fill: none; stroke: var(--wrong); stroke-width: 16; }
.donut-segment-correct { fill: none; stroke: var(--correct); stroke-width: 16; stroke-linecap: butt; }
.donut-segment-wrong { fill: none; stroke: var(--wrong); stroke-width: 16; stroke-linecap: butt; }
.donut-segment-grey { fill: none; stroke: var(--border); stroke-width: 16; stroke-linecap: butt; }
.donut-center-text { font-size: 22px; font-weight: 700; fill: var(--text); }

/* Solid pie wedges (filled to center, no hole) - see buildPieSVG(). Used on the "Tidigare tentor
   och statistik" session cards, unlike the ring-shaped .donut-segment-* above. */
.pie-segment-correct { fill: var(--correct); }
.pie-segment-wrong { fill: var(--wrong); }
.pie-segment-grey { fill: var(--border); }

.result-score {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

.missed-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.missed-item .topic-tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 8px;
}
.missed-item .q-text { font-weight: 600; margin: 0 0 8px; }
.missed-item .your-answer { color: var(--wrong); font-size: 0.9rem; margin: 0 0 4px; }
.missed-item .right-answer { color: var(--correct); font-size: 0.9rem; margin: 0 0 8px; }
.missed-item .explanation,
.facit-card .explanation { color: var(--text-muted); font-size: 0.88rem; margin: 8px 0 0; line-height: 1.5; }
.missed-item.is-correct .your-answer { color: var(--correct); }
/* A pending (not yet self-graded) VSA card on the result screen - tinted to stand out from the
   already-graded Rätt/Fel cards around it as still needing action. */
.missed-item.is-pending { background: var(--pastel-mixed-bg); border-color: var(--pastel-mixed-text); }

/* "Visa hela frågan" disclosure inside a result-item card: reuses the facit-card building blocks
   (vignette/options/answer) without the .facit-card box itself, since it's already nested inside
   the .missed-item card. */
.result-full-question { margin-top: 10px; }
.result-full-question > summary { font-size: 0.85rem; }
.result-full-question-body { margin-top: 10px; }

.result-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.result-verdict-badge {
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}
.result-verdict-badge.is-correct { color: var(--correct); background: var(--correct-bg); }
.result-verdict-badge.is-wrong { color: var(--wrong); background: var(--wrong-bg); }
.result-verdict-badge.is-unanswered { color: var(--text-muted); background: var(--surface-2); }
/* "Besvarad" on the simulate-mode review page - deliberately neutral (not green), since it must
   not read as "correct" the way .is-correct does. */
.result-verdict-badge.is-answered-neutral { color: var(--pastel-sba-text); background: var(--pastel-sba-bg); }
.result-item-head .topic-tag { margin-bottom: 0; }

/* Lecture view */
.lecture-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 0;
  padding-bottom: 0;
}

.lecture-tab-btn, .stats-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.lecture-tab-btn:hover, .stats-tab-btn:hover { color: var(--text); }
.lecture-tab-btn.is-active, .stats-tab-btn.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.lecture-tab-panel, .stats-tab-panel { padding-top: 18px; }
.lecture-tab-panel[hidden], .stats-tab-panel[hidden] { display: none; }

/* Återkommande frågor & koncept: same tab buttons, but as clearly highlighted boxes instead of
   the subtle underline style above - the underline was too easy to miss when switching tabs. */
.examstats-recur-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}
.examstats-recur-tabs .stats-tab-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  margin-bottom: 0;
  font-weight: 600;
}
.examstats-recur-tabs .stats-tab-btn:hover { border-color: var(--accent); color: var(--text); }
.examstats-recur-tabs .stats-tab-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Practice view */
.practice-block-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 20px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.practice-block-group summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
  list-style: none;
}
.practice-block-group summary::-webkit-details-marker { display: none; }
.practice-block-group summary::before { content: "▸ "; color: var(--text-muted); }
.practice-block-group[open] summary::before { content: "▾ "; }

.practice-lecture-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px dashed var(--border);
  font-size: 0.92rem;
}
.practice-lecture-row label { flex: 1; cursor: pointer; }
.practice-lecture-row .stats-line { margin: 0; white-space: nowrap; }
.practice-lecture-row.is-empty label { color: var(--text-muted); font-style: italic; }
.practice-lecture-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }

/* "Om Tentastugan": a deliberately quiet page. The two entry points are tiny muted text links (start
   page + Inställningar), not topbar items; the page itself is one calm panel of plain text. */
.about-link-row { margin: 32px 0 0; text-align: center; }
.about-link {
  background: none;
  border: none;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 0.15s, text-decoration-color 0.15s;
}
.about-link:hover, .about-link:focus-visible { color: var(--accent); text-decoration-color: currentColor; }
.about-panel { padding: 22px 24px; }
.about-section + .about-section { margin-top: 22px; }
.about-section h2 { margin: 0 0 6px; font-size: 1.05rem; }
.about-section p { margin: 0 0 8px; line-height: 1.6; }
.about-section p:last-child { margin-bottom: 0; }
.about-section a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Status / OBS view */
.status-desc { color: var(--text-muted); font-size: 0.88rem; margin: -6px 0 14px; }

.status-panel { border-left-width: 4px; border-left-style: solid; }
.status-missing { border-left-color: var(--wrong); }
.status-uncertain { border-left-color: #d97706; }
.status-excluded { border-left-color: var(--text-muted); }

.status-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.status-item:last-child { border-bottom: none; }
.status-item .status-title { font-weight: 600; margin: 0 0 4px; }
.status-item .status-block {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 1px 7px;
  margin-bottom: 5px;
}
.status-item .status-detail { color: var(--text-muted); font-size: 0.87rem; margin: 0; line-height: 1.45; }

/* Statistik / radar chart */
.stats-radar-host {
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.stats-radar-host.is-transitioning {
  opacity: 0;
  transform: scale(0.97);
}

.radar-chart-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 6px 0 4px;
}
.radar-chart-wrap svg { max-width: 100%; height: auto; overflow: visible; }
.radar-grid-line { stroke: var(--border); fill: none; }
.radar-grid-line.is-outer { stroke: var(--text-muted); stroke-opacity: 0.35; }
.radar-pass-line { fill: none; stroke: var(--correct); stroke-width: 1.5; stroke-dasharray: 5 4; stroke-opacity: 0.7; }
.radar-axis-line { stroke: var(--border); transition: stroke 0.12s ease, stroke-width 0.12s ease; }
.radar-axis-line.is-highlighted { stroke: var(--text-muted); stroke-width: 2; }
.radar-data-poly { fill: var(--accent); fill-opacity: 0.14; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.radar-axis-badge { cursor: default; transition: opacity 0.12s ease; }
.radar-axis-badge circle { stroke: var(--surface); stroke-width: 2; }
.radar-axis-badge text { font-size: 12px; font-weight: 700; fill: #fff; font-family: inherit; pointer-events: none; }
.radar-point-g { cursor: pointer; }
.radar-point { stroke: var(--surface); stroke-width: 2; transform-box: fill-box; transform-origin: center; transition: transform 0.14s ease; }
.radar-point.is-strong { fill: var(--correct); }
.radar-point.is-weak { fill: var(--wrong); }
.radar-point.is-empty { fill: var(--surface); stroke: var(--text-muted); stroke-dasharray: 2 2; }
.radar-point-halo { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0.7); transition: opacity 0.14s ease, transform 0.14s ease; pointer-events: none; }
.radar-point-halo.is-strong { fill: var(--correct); }
.radar-point-halo.is-weak { fill: var(--wrong); }
.radar-point-halo.is-empty { fill: var(--text-muted); }
.radar-point-hit { fill: transparent; }
/* Hover/focus on a point, a badge or a legend row: that axis lights up, the others step back. */
.radar-point-g.is-highlighted .radar-point { transform: scale(1.22); }
.radar-point-g.is-highlighted .radar-point-halo { opacity: 0.28; transform: scale(1); }
.radar-axis-badge.is-highlighted circle { stroke: var(--text); }
.has-highlight .radar-point-g:not(.is-highlighted), .has-highlight .radar-axis-badge:not(.is-highlighted) { opacity: 0.4; }
.radar-tooltip {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--text);
  color: var(--surface);
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: nowrap;
  text-align: center;
  transform: translate(-50%, -100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}
.radar-tooltip.is-visible { opacity: 1; }
.radar-tooltip strong { font-size: 0.84rem; }

.radar-legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.radar-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  border-radius: 10px;
  margin: 0 -8px;
  padding: 6px 8px;
  transition: background 0.12s ease;
}
.radar-legend li.is-highlighted { background: var(--surface-2); }
.radar-legend li.is-clickable { cursor: pointer; }
.radar-legend li.is-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.radar-legend li.is-clickable .radar-legend-name { color: var(--accent); font-weight: 600; }
.radar-legend .radar-legend-idx {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.radar-legend .radar-legend-name { flex: 1; min-width: 0; color: var(--text); }
.radar-legend-bar {
  position: relative;
  flex: none;
  width: 110px;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.radar-legend li.is-highlighted .radar-legend-bar { background: var(--border); }
.radar-legend-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--text-muted); transition: width 0.3s ease; }
.radar-legend-bar-fill.is-strong { background: var(--correct); }
.radar-legend-bar-fill.is-weak { background: var(--wrong); }
.radar-legend-bar::after { content: ""; position: absolute; top: 0; bottom: 0; left: 70%; width: 2px; background: var(--text); opacity: 0.5; }
.radar-legend .radar-legend-value { flex: none; min-width: 9.5em; text-align: right; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.radar-legend .radar-legend-value.is-strong { color: var(--correct); font-weight: 600; }
.radar-legend .radar-legend-value.is-weak { color: var(--wrong); font-weight: 600; }
@media (max-width: 520px) {
  .radar-legend-bar { width: 56px; }
  .radar-legend .radar-legend-value { min-width: 0; }
}

.radar-empty-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin: 10px 0 0;
}

/* Gamla tentor - ordinarie/omtentamen were --wrong (red) vs --accent (teal), a jarring high-
   contrast pairing for what's just a scheduling distinction, not a pass/fail signal. Reusing the
   existing SBA (blue) / VSA (purple) pastel tokens instead - adjacent, similarly muted hues. */
.badge-ordinarie {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--pastel-sba-text);
  background: var(--pastel-sba-bg);
  border-radius: 6px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.badge-omtenta {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--pastel-vsa-text);
  background: var(--pastel-vsa-bg);
  border-radius: 6px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

/* "Hur vill du öva på tentan?" mode-choice cards: a "Hela tentan"/subject-name badge row
   replacing the old grey .desc line. Same .mode-choice-badge markup either way (one static
   "Hela tentan" badge on the simulate card, one per moment.json subject on the subjects card)
   so they render identically apart from --badge-color. */
.mode-choice-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.mode-choice-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--badge-color, var(--accent));
  background: color-mix(in srgb, var(--badge-color, var(--accent)) 16%, var(--surface-2));
  white-space: nowrap;
}

.facit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.facit-card .topic-tag {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 8px;
}
.facit-vignette {
  background: var(--surface-2);
  border-left: 3px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 10px;
}
.facit-question { font-weight: 600; margin: 0 0 10px; line-height: 1.4; }

mark.search-highlight {
  background: var(--pastel-mixed-bg);
  color: var(--pastel-mixed-text);
  border-radius: 3px;
  padding: 0 2px;
}
.facit-options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.facit-options li {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}
.facit-options li.is-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  font-weight: 600;
}
.facit-options li.was-chosen-wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
  font-weight: 600;
}
.facit-answer { color: var(--correct); font-weight: 600; margin: 0; }
.facit-your-answer { color: var(--text-muted); font-size: 0.88rem; margin: 6px 0 0; }

.facit-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.facit-card-head .topic-tag { margin-bottom: 0; }

.exam-source-badge {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: -10px 0 14px;
  text-align: right;
}

.duplicate-star-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #d97706;
  background: rgba(217, 119, 6, 0.12);
  border-radius: 6px;
  padding: 1px 8px;
  margin-left: 8px;
  white-space: nowrap;
  vertical-align: middle;
}
.duplicate-star-badge.tier-high {
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.14);
}

/* "🧩 Samma koncept i N tentor" - a deliberately different badge from the star (amber/purple):
   same underlying fact recurring, not necessarily this exact question's own wording. Uses the
   theme's own --accent/--accent-soft (unlike the star, which is theme-independent amber) since
   this one isn't a special highlight state, just a normal on-brand info badge. */
.concept-recur-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 1px 8px;
  margin-left: 8px;
  white-space: nowrap;
  vertical-align: middle;
}

.duplicate-ranking-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.duplicate-ranking-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: 520px;
}
.duplicate-rank-item {
  position: relative;
  padding-bottom: 40px !important;
}
.duplicate-locate-btn {
  position: absolute;
  right: 14px;
  bottom: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.duplicate-locate-btn:hover { border-color: #15803d; color: #15803d; }
.duplicate-locate-btn.is-active {
  background: repeating-linear-gradient(135deg, #16a34a 0 8px, #15803d 8px 16px);
  border-color: #15803d;
  color: #ffffff;
}
.duplicate-rank-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.duplicate-rank-head .duplicate-star-badge { margin-left: 0; }
.duplicate-rank-head .radar-legend-idx {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tentastatistik */
.examstats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
}
@media (max-width: 640px) {
  .examstats-summary { grid-template-columns: 1fr; }
}
.examstats-stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
}
.examstats-stat-value {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
.examstats-stat-label {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.examstats-exams-panel summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.examstats-exams-panel summary::-webkit-details-marker { display: none; }
.examstats-exams-panel summary::before { content: "▸ "; color: var(--text-muted); }
.examstats-exams-panel[open] summary::before { content: "▾ "; }

/* Generic <details> disclosure look, reused by the exam-sessions panel and the facit list panel. */
.disclosure-panel > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.disclosure-panel > summary::-webkit-details-marker { display: none; }
.disclosure-panel > summary::before { content: "▸ "; color: var(--text-muted); }
.disclosure-panel[open] > summary::before { content: "▾ "; }


/* "Facit" page of an exam (view-tenta-facit): a toolbar panel (search + one pill per ämne with its count),
   then the questions grouped under a heading per ämne. The pills are the app's .moment-toggle-card. */
.tenta-facit-toolbar .field-row { margin-bottom: 14px; }
.tenta-facit-toolbar .field-row input[type="search"] { flex: 1; min-width: 0; max-width: 460px; }
.moment-toggle-card:disabled { opacity: 0.45; cursor: default; transform: none; }
.moment-toggle-card:disabled:hover { border-color: var(--border); transform: none; }
.tenta-facit-pill-count {
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--moment-color, var(--accent)) 16%, var(--surface));
  color: var(--text);
}
.moment-toggle-card.is-active .tenta-facit-pill-count { background: rgba(255, 255, 255, 0.25); color: #ffffff; }

.facit-group { margin-top: 28px; }
.facit-group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid color-mix(in srgb, var(--subject-color) 40%, var(--border));
}
.facit-group-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--subject-color); flex-shrink: 0; align-self: center; }
.facit-group-head h2 { margin: 0; font-size: 1.35rem; font-family: var(--font-display); font-weight: 700; }
.facit-group-count { color: var(--text-muted); font-size: 0.88rem; }
.facit-group .facit-card { border-left: 4px solid var(--subject-color); }
.facit-q-number {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 8px;
  white-space: nowrap;
}
.facit-card-head .flagged-q-type { font-size: 0.72rem; }

/* Exam-filter panel ("Vilka tentor ska ingå?"): fixed to the right of the viewport, mirroring
   .moment-sidebar on the left, so it stays visible while scrolling. Placed low enough to clear
   .paused-quiz-widget (also right-side, near the top) when both happen to be visible at once.
   Boxes sit two-per-row in a grid so the whole thing fits within a typical viewport height
   instead of needing its own scroll. */
.exam-filter-panel {
  position: fixed;
  right: 16px;
  top: 270px;
  width: 280px;
  max-height: calc(100vh - 286px);
  overflow-y: auto;
  z-index: 12;
}
.exam-filter-panel[hidden] { display: none; }
.exam-filter-box-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
/* The "Alla tentor" select-all box and each curriculum's group label always span both columns,
   so they sit on their own row above/between the individual exam boxes. */
.exam-filter-box-grid .is-whole-exam,
.exam-filter-box-grid .exam-filter-group-label {
  grid-column: 1 / -1;
}
.exam-filter-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin: 10px 0 0;
}
.exam-filter-group-label:first-of-type { margin-top: 0; }
/* A bit more compact than the default .moment-toggle-card so two still fit comfortably side by
   side, but noticeably bigger than before - closer to a real card than a small pill. */
.exam-filter-box {
  padding: 12px 14px;
  font-size: 0.88rem;
  flex-wrap: wrap;
  justify-content: center;
  text-align: center;
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow);
}
.exam-filter-box.is-whole-exam { justify-content: flex-start; text-align: left; font-weight: 700; }
/* Ticked = a soft accent tint and a ✓ instead of a solid navy slab; the green "var förekommer" stripes below still win. */
.exam-filter-box.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.exam-filter-box { position: relative; }
.exam-filter-box.is-active::before { content: "✓"; position: absolute; top: 5px; right: 9px; color: var(--accent); font-size: 0.8rem; font-weight: 800; }
.exam-filter-box.is-whole-exam.is-active::before { position: static; margin-right: 8px; font-size: 0.9rem; }
/* "Var förekommer denna?" (Mest återanvända frågor) highlight - a solid diagonal-striped
   ("polkagris") green fill, deliberately hardcoded rather than theme-driven: none of THEME_OPTIONS'
   accents (js/app.js) are green, so this reads the same regardless of which color theme is active -
   unlike the first version (an amber ring), which clashed with the orange theme. Independent of
   .is-active (solid fill = "included in the analysis filter") - a box can be highlighted whether or
   not its exam is currently selected in the filter, so both can apply to the same box at once. */
.exam-filter-box.is-locate-highlighted {
  background: repeating-linear-gradient(135deg, #16a34a 0 12px, #15803d 12px 24px);
  border-color: #15803d;
  color: #ffffff;
}
.exam-filter-box-question-badge {
  flex: 0 0 100%;
  font-size: 0.72rem;
  font-weight: 700;
  color: #d97706;
}
.exam-filter-box.is-active .exam-filter-box-question-badge,
.exam-filter-box.is-locate-highlighted .exam-filter-box-question-badge { color: #ffffff; }

@media (max-width: 1460px) {
  .exam-filter-panel { display: none; }
}

.exam-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px dashed var(--border);
  font-size: 0.88rem;
}
.exam-session-row:first-child { border-top: none; margin-top: 10px; }
.exam-session-date { color: var(--text-muted); white-space: nowrap; }
.exam-session-score { font-weight: 600; }

.exam-session-row.is-clickable {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px dashed var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  padding: 10px 8px;
  margin: 0 -8px;
}
.exam-session-row.is-clickable:first-child { border-top: none; margin-top: 10px; }
.exam-session-row.is-clickable:hover { background: var(--surface-2); }

/* "Hela tentan"/"Uppdelat i ämnen" panel headings on "Tidigare tentor och statistik" - plain h2
   (1.1rem, no color) read too quietly next to the bigger session cards below them. Each sits in a
   head row with its reset button pinned to the opposite (top-right) corner. */
.tenta-history-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
}
.tenta-history-panel-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent);
  margin: 0;
}
.tenta-history-reset-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.tenta-history-reset-btn:hover { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }

/* Expanded session cards ("Tidigare tentor och statistik" only, opts.expanded on
   buildSessionRow) - bigger cards instead of thin stacked rows, with room for a pie chart. All
   cards sit in a single row (flex, not a wrapping grid) so each gets thicker as there are fewer
   of them; overflow-x lets the row scroll instead of squeezing cards illegibly thin if there are
   many attempts. Row container class is applied in index.html, not per-card. */
.exam-session-card-grid {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.exam-session-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  flex: 1 1 0;
  min-width: 150px;
}
.exam-session-card:hover { border-color: var(--accent); }
.exam-session-card-attempt { font-weight: 700; font-size: 1rem; }
.exam-session-card .exam-session-date { font-size: 0.82rem; }
.exam-session-card .exam-session-score { font-weight: 600; font-size: 0.92rem; }
.exam-session-card-chart { display: flex; justify-content: center; }
.exam-session-card-chart svg { display: block; }
.exam-session-pass-badge {
  display: inline-block;
  font-weight: 800;
  font-size: 1.5rem;
  padding: 2px 14px;
  border-radius: 999px;
}
.exam-session-pass-badge.is-pass { color: var(--correct); background: var(--correct-bg); }
.exam-session-pass-badge.is-fail { color: var(--wrong); background: var(--wrong-bg); }

.examstats-exam-list { list-style: none; margin: 14px 0 0; padding: 0; }
.examstats-exam-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
  font-size: 0.88rem;
}
.examstats-exam-row:first-child { border-top: none; }
.examstats-exam-name { color: var(--text); }
.examstats-exam-count { color: var(--text-muted); white-space: nowrap; }

/* Tentastatistik > Översikt (renderExamStatsOverview): hero share-of-total, the "Jämfört med alla
   ämnen" box, and the big pie + its table twin. --moment-color is set inline on the
   #view-examstats-overview section to the active subject's moment.json color; the pie carries
   identity through the legend table, wedge tooltips and the ⭐ stripe pattern, never color alone.
   "Exakt återkommande" reuses the Ämnesfördelning bar's gold candy-stripe on purpose. */

/* Hero: one big sans figure (not the Fraunces display face - dataviz guidance), in plain ink; the
   thin meter beneath carries the subject color, its track a 16% wash of the same color. */
.overview-hero { padding: 20px 22px 22px; }
.overview-hero + .lead { margin-top: 16px; }
.overview-hero-badge { font-size: 0.85rem; padding: 4px 12px; }
.overview-hero-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 22px;
  margin-top: 12px;
}
.overview-hero-figure {
  margin: 0;
  font-size: 3.8rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.overview-hero-text { display: flex; flex-direction: column; gap: 2px; }
.overview-hero-count { margin: 0; font-size: 1.3rem; font-weight: 700; color: var(--text); }
.overview-hero-sub { margin: 0; font-size: 0.92rem; color: var(--text-muted); }
.overview-hero-meter {
  position: relative;
  height: 12px;
  margin-top: 18px;
  border-radius: 6px;
  overflow: hidden;
}
.overview-hero-meter::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--moment-color);
  opacity: 0.16;
}
.overview-hero-meter-fill {
  position: relative;
  height: 100%;
  background: var(--moment-color);
  border-radius: 6px;
}

/* "Jämfört med alla ämnen": a big real checkbox (visually-hidden native input + drawn box, so it
   stays keyboard-focusable and announced as a checkbox). Checked state is mirrored as .is-checked
   on the label by JS rather than :has(), to not depend on newer selector support. */
.overview-compare-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.overview-compare-toggle:hover { border-color: var(--moment-color, var(--accent)); }
.overview-compare-toggle.is-checked {
  border-color: var(--moment-color, var(--accent));
  background: color-mix(in srgb, var(--moment-color, var(--accent)) 8%, var(--surface));
}
.overview-compare-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.overview-compare-box {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid var(--text-muted);
  border-radius: 8px;
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}
.overview-compare-toggle input:checked + .overview-compare-box {
  background: var(--moment-color, var(--accent));
  border-color: var(--moment-color, var(--accent));
}
.overview-compare-toggle input:checked + .overview-compare-box::after {
  content: "✓";
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
}
.overview-compare-toggle input:focus-visible + .overview-compare-box {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.overview-compare-text { display: flex; flex-direction: column; gap: 2px; }
.overview-compare-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.overview-compare-sub { font-size: 0.85rem; color: var(--text-muted); line-height: 1.35; }

/* States what 100% is for the pie below - the thing that was misread, so it's bold and centered. */
.overview-pie-caption {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.overview-pie-caption:empty { display: none; }

/* Pie on top (big, centered), table full-width underneath. Side by side was tried first and didn't
   fit: #app is only 760px wide, so the table's nowrap numeric columns overflowed the panel. */
.overview-pie-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  margin-top: 14px;
}
.overview-pie-svg-wrap { width: min(100%, 340px); }
.overview-pie-svg { display: block; width: 100%; height: auto; }
.overview-pie-table-wrap { width: 100%; min-width: 0; }
.overview-pie-panel + .status-desc { margin-top: 16px; }

.overview-pie-wedge {
  stroke: var(--surface);
  stroke-width: 2;
  stroke-linejoin: round;
  transition: opacity 0.15s;
}
.overview-pie-wedge-exact { fill: url(#overview-pie-stripe); }
.overview-pie-wedge-concept { fill: var(--moment-color); }
.overview-pie-wedge-single { fill: var(--moment-color); fill-opacity: 0.3; }
.overview-pie-wedge-other { fill: var(--text-muted); fill-opacity: 0.3; }
/* Ink text with a surface-colored halo so the % stays readable on any wedge fill in every theme. */
.overview-pie-label {
  font-size: 15px;
  font-weight: 700;
  fill: var(--text);
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
  paint-order: stroke;
  pointer-events: none;
}
.overview-pie-panel.has-hover .overview-pie-wedge:not(.is-hovered) { opacity: 0.4; }

.overview-pie-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.overview-pie-table th {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-align: left;
}
.overview-pie-table td { padding: 10px 0; border-top: 1px solid var(--border); vertical-align: top; }
.overview-pie-table tbody tr:first-child td { border-top: none; }
.overview-pie-table .is-num {
  padding-left: 12px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.overview-pie-row.is-hovered td { background: var(--surface-2); }
.overview-pie-name-flex { display: flex; gap: 10px; align-items: flex-start; }
.overview-pie-swatch { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 2px; border-radius: 4px; }
.overview-pie-swatch-exact { background: repeating-linear-gradient(135deg, #eab308 0 4px, #ca8a04 4px 8px); }
.overview-pie-swatch-concept { background: var(--moment-color); }
.overview-pie-swatch-single { background: var(--moment-color); opacity: 0.3; }
.overview-pie-swatch-other { background: var(--text-muted); opacity: 0.3; }
.overview-pie-name-text { display: flex; flex-direction: column; gap: 1px; }
.overview-pie-name { color: var(--text); font-weight: 600; }
.overview-pie-sub { color: var(--text-muted); font-size: 0.78rem; line-height: 1.3; }
.overview-pie-total-row td { font-weight: 700; color: var(--text); border-top: 1px solid var(--border); }

.examstats-bar-chart { margin-top: 22px; }
.examstats-bar-row { margin-top: 14px; }
.examstats-bar-row:first-child { margin-top: 0; }
.examstats-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
}
.examstats-bar-name { font-size: 0.88rem; color: var(--text); }
.examstats-bar-track {
  display: flex;
  align-items: center;
  gap: 8px;
}
.examstats-bar-fill {
  height: 20px;
  max-width: 100%;
  background: var(--accent);
  border-radius: 4px 10px 10px 4px;
}
/* When a topic has any "återanvänd fråga" (duplicateGroupSize > 1 - same definition as Mest
   återanvända frågor) content, .examstats-bar-fill switches from a plain filled block to a
   positioning host for .examstats-bar-fill-pill (the actual rounded/clipped colored bar) plus the
   label below - Sam asked for the reused portion marked *within* the existing blue bar ("denna
   stapeln ska vara i den blåa"), not as a separate indicator next to it. */
.examstats-bar-fill.has-reused-segment {
  position: relative;
  background: none;
  border-radius: 0;
}
.examstats-bar-fill-pill {
  display: flex;
  height: 100%;
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
}
.examstats-bar-fill-normal { background: var(--accent); }
.examstats-bar-fill-reused {
  min-width: 3px;
  background: repeating-linear-gradient(135deg, #eab308 0 8px, #ca8a04 8px 16px);
}
/* A sibling of .examstats-bar-fill-pill, not a child of the reused segment itself, and positioned
   via `left` in JS at the pill's own normal/reused boundary - lets it overflow past the bar's right
   edge (not clipped by the pill's own overflow:hidden) when the reused segment is too narrow to
   hold it, which is common for topics with only a couple of reused questions. */
.examstats-bar-fill-reused-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  line-height: 1;
  cursor: default;
}
.examstats-bar-value {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.examstats-perf-track {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
  background: var(--surface-2);
}
.examstats-perf-segment { height: 100%; }
.examstats-perf-segment.is-green { background: var(--correct); }
.examstats-perf-segment.is-yellow { background: #d97706; }
.examstats-perf-segment.is-red { background: var(--wrong); }
.examstats-perf-segment.is-grey { background: var(--border); }

.examstats-perf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.examstats-perf-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.examstats-perf-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.examstats-perf-dot.is-green { background: var(--correct); }
.examstats-perf-dot.is-yellow { background: #d97706; }
.examstats-perf-dot.is-red { background: var(--wrong); }
.examstats-perf-dot.is-grey { background: var(--border); }
.examstats-bar-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.examstats-bar-practice-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.examstats-bar-practice-btn:hover { background: var(--accent-soft); }
.examstats-bar-practice-btn:disabled { opacity: 0.4; cursor: default; }
.examstats-bar-practice-btn:disabled:hover { background: none; }

.examstats-bar-reset-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.examstats-bar-reset-btn:hover { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }

/* Gamla tentor result screen: "Resultat per del" (see computeExamMomentBreakdown in app.js) - same
   bar-row anatomy as .examstats-bar-*, but one bar per moment.json subject with that subject's own
   color instead of a shared --accent fill, plus a color dot next to the name (identity never relies
   on hue alone, since psykiatri/beroendemedicin's blue/purple sit close for some color-vision
   deficiencies - the dot + name label carry it). */
.result-moment-breakdown h2 { margin: 0 0 4px; font-size: 1rem; }
.result-moment-row { margin-top: 16px; }
.result-moment-row:first-child { margin-top: 10px; }
.result-moment-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
}
.result-moment-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.92rem;
  color: var(--text);
}
.result-moment-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.result-moment-pct {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.result-moment-track {
  height: 20px;
  background: var(--surface-2);
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
}
.result-moment-fill { height: 100%; border-radius: 4px 10px 10px 4px; }
.result-moment-detail {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* Fel svar/Alla svar tab row + the "Resultat per del" filter beside it. .lecture-tabs keeps its own
   rule untouched (reused by 3 other views) - only overridden here, nested under .result-tabs-row,
   so its border/margin merge into this row's shared ones instead of doubling up. */
.result-tabs-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 0;
}
/* display:flex above otherwise beats the [hidden] attribute's own (very low-specificity) UA rule -
   without this, setting .hidden = true in JS (see openTentaSessionReviewSummaryOnly) has no visual
   effect at all. */
.result-tabs-row[hidden] { display: none; }
.result-tabs-row .lecture-tabs { margin: 0; border-bottom: none; }
.result-moment-filter {
  margin: 0 0 8px;
  gap: 6px;
}
.result-moment-filter .moment-toggle-card {
  padding: 5px 10px;
  font-size: 0.76rem;
  gap: 5px;
}

/* Result card corner dot (see buildResultItem) - same subject color as its "Resultat per del" bar
   and filter card, so a card's subject reads at a glance without opening it. */
.missed-item { position: relative; }
.result-moment-corner-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.typed-practice-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.typed-practice-btns .btn-primary {
  width: auto;
  flex: 1;
  margin-top: 0;
  min-width: 110px;
}
/* Each practice-type button gets its own pastel fill (SBA/VSA/Blandat, in that fixed order from
   buildTypedPracticeButtons' variants list) instead of a uniform accent color. */
.typed-practice-btns .typed-practice-btn:nth-child(1) { background: var(--pastel-sba-bg); color: var(--pastel-sba-text); }
.typed-practice-btns .typed-practice-btn:nth-child(2) { background: var(--pastel-vsa-bg); color: var(--pastel-vsa-text); }
.typed-practice-btns .typed-practice-btn:nth-child(3) { background: var(--pastel-mixed-bg); color: var(--pastel-mixed-text); }
.typed-practice-btns .typed-practice-btn:hover { filter: brightness(0.95); }

.concept-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 44px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.concept-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.concept-count-badge {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}
.concept-label { margin: 10px 0 4px; font-size: 1rem; }
.concept-notes {
  margin: 8px 0 0;
  color: #d97706;
  font-size: 0.85rem;
  line-height: 1.4;
}
.concept-occurrences { margin-top: 10px; }
.concept-occurrences summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.85rem;
  list-style: none;
}
.concept-occurrences summary::-webkit-details-marker { display: none; }
.concept-occurrences summary::before { content: "▸ "; }
.concept-occurrences[open] summary::before { content: "▾ "; }
.concept-occurrences ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.concept-occurrences li {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.concept-occurrences li strong { color: var(--text); }
.concept-occurrences li em { color: var(--correct); font-style: normal; font-weight: 600; }

.concept-occurrence-toggle {
  display: block;
  margin-top: 6px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.concept-occurrence-toggle:hover { text-decoration: underline; }
.concept-occurrence-full { margin-top: 4px; }
.concept-occurrence-full .facit-card { margin-top: 8px; }

.view[hidden] { display: none; }

/* ---------- Flaggade frågor (topbar page) ----------
   Hero = the big number (reuses .overview-hero*), subject chips and the one big "öva alla" button; then
   one section per ämne (its moment.json colour on the dot, rule and the cards' left edge) holding one
   card per område: heading + count, SBA/VSA/Blandat buttons (.typed-practice-btns) and a collapsible
   list of the flagged questions with facit and a "ta bort flagga" each. */
.flagged-hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.flagged-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 15%, var(--surface-2));
}
.flagged-chip b { font-variant-numeric: tabular-nums; }
.flagged-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.flagged-hero-actions .btn-primary { width: auto; margin: 0; padding: 12px 24px; font-size: 1rem; }
.flagged-hero-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
}
.flagged-hero-mode select { min-width: 0; }

/* Ämnena är hopfällbara: huvudet är ett helt kort att klicka på, innehållet glider upp/ner
   (grid-rows 0fr -> 1fr, så ingen höjd behöver mätas i JS). Stängt innehåll är visibility:hidden efter
   övergången, så det inte går att tabba in i det. */
.flagged-chip {
  border: none;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.flagged-chip:hover { filter: brightness(1.12); transform: translateY(-1px); }
.flagged-groups-bar { display: flex; justify-content: flex-end; margin-top: 22px; }
.flagged-toggle-all {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.flagged-toggle-all:hover { text-decoration: underline; }

.flagged-subject { margin-top: 12px; }
.flagged-subject-head {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--subject-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding-right: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.flagged-subject-head:hover { border-color: var(--subject-color); }
.flagged-subject-title { flex: 1; min-width: 0; margin: 0; font-size: inherit; }
.flagged-subject-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  width: 100%;
  background: none;
  border: none;
  padding: 16px 8px 16px 14px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius);
}
.flagged-subject-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.flagged-subject-label { display: inline-flex; align-items: center; gap: 10px; }
.flagged-subject-chevron {
  display: inline-block;
  width: 1em;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), color 0.15s ease;
}
.flagged-subject.is-open .flagged-subject-chevron { transform: rotate(90deg); color: var(--subject-color); }
.flagged-subject-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--subject-color); flex-shrink: 0; }
.flagged-subject-name { font-size: 1.35rem; font-family: var(--font-display); font-weight: 700; line-height: 1.2; }
.flagged-subject-count { color: var(--text-muted); font-size: 0.88rem; font-weight: 500; }
.flagged-subject-practice { flex-shrink: 0; }

.flagged-subject-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.flagged-subject.is-open .flagged-subject-body { grid-template-rows: 1fr; }
.flagged-subject-body-inner {
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  padding: 0 4px 0 0;
  transition: visibility 0s linear 0.32s;
}
.flagged-subject-body-inner > .flagged-area:last-child { margin-bottom: 6px; }
.flagged-subject.is-open .flagged-subject-body-inner { visibility: visible; transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) {
  .flagged-subject-body, .flagged-subject-chevron { transition: none; }
}

.flagged-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--subject-color);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.flagged-area-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.flagged-area-head h3 { margin: 0; font-size: 1.15rem; font-family: var(--font-display); font-weight: 600; line-height: 1.25; }
.flagged-area-count {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--subject-color);
  background: color-mix(in srgb, var(--subject-color) 15%, var(--surface-2));
}
.flagged-area-list { margin-top: 12px; }
.flagged-area-list > summary {
  cursor: pointer;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
  user-select: none;
}
.flagged-area-list > summary::-webkit-details-marker { display: none; }
.flagged-area-list > summary::before { content: "▸"; display: inline-block; width: 1.1em; transition: transform 0.15s ease; }
.flagged-area-list[open] > summary::before { transform: rotate(90deg); }
.flagged-area-list > summary:hover { color: var(--text); }

.flagged-q { padding: 12px 0 14px; border-top: 1px solid var(--border); }
.flagged-q:first-of-type { border-top: none; }
.flagged-q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.76rem; color: var(--text-muted); margin-bottom: 6px; }
.flagged-q-type { font-weight: 700; padding: 1px 8px; border-radius: 6px; }
.flagged-q-type.is-sba { background: var(--pastel-sba-bg); color: var(--pastel-sba-text); }
.flagged-q-type.is-vsa { background: var(--pastel-vsa-bg); color: var(--pastel-vsa-text); }
.flagged-q-text p { margin: 0; }
.flagged-q-vignette {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px !important;
}
.flagged-q-question { font-weight: 600; font-size: 0.95rem; line-height: 1.4; }
.flagged-q-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; margin-top: 8px; }
.flagged-q-unflag {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
}
.flagged-q-unflag:hover { border-color: var(--wrong); color: var(--wrong); }
.flagged-q-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.flagged-q-ask {
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.flagged-q-ask:hover { border-color: var(--accent); transform: translateY(-1px); }
.flagged-q-meta .topic-tag { font-size: 0.72rem; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 8px; }
.flagged-search { padding: 14px 18px; }
.flagged-search .field-row { margin-bottom: 0; }
.flagged-search .field-row input[type="search"] { flex: 1; min-width: 0; max-width: 460px; }
.flagged-q-full { margin-top: 10px; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; }
.flagged-q-full p { margin: 0 0 10px; }
.flagged-q-full .facit-options, .flagged-q-full .facit-answer { margin-bottom: 4px; }

.flag-all-wrong-btn:disabled { opacity: 1; color: var(--correct); border-color: var(--correct); cursor: default; }
.flag-all-wrong-btn:not(:disabled) { color: var(--wrong); }
.flag-all-wrong-btn:not(:disabled):hover { border-color: var(--wrong); color: var(--wrong); }
.unflag-correct-btn:disabled { opacity: 1; color: var(--correct); border-color: var(--correct); cursor: default; }
.unflag-correct-btn:not(:disabled) { color: var(--correct); }
.unflag-correct-btn:not(:disabled):hover { border-color: var(--correct); color: var(--correct); }

.flagged-empty { text-align: center; padding: 46px 26px 50px; }
.flagged-empty-flag { font-size: 3.2rem; line-height: 1; }
.flagged-empty h2 { margin: 14px 0 10px; font-family: var(--font-display); font-size: 1.5rem; }
.flagged-empty p { max-width: 540px; margin: 0 auto; color: var(--text-muted); line-height: 1.6; }

@media (max-width: 480px) {
  .flagged-subject-head { flex-wrap: wrap; padding-bottom: 0; }
  .flagged-subject-title { flex: 1 1 100%; }
  .flagged-subject-name { font-size: 1.2rem; }
  .flagged-subject-practice { margin: -4px 0 12px 14px; }
  .flagged-hero-mode { margin-left: 0; }
  .flagged-hero-actions .btn-primary { width: 100%; }
}

@media (max-width: 480px) {
  #app { padding: 20px 14px 70px; }
  .quiz-actions { flex-direction: column-reverse; }
  .quiz-actions .btn-primary, .quiz-actions .btn-ghost { width: 100%; }
  .examstats-summary { grid-template-columns: 1fr; }
  .tentor-grid { grid-template-columns: 1fr; }

  /* The topbar can wrap to multiple lines at this width, so anchoring the widget to a fixed
     top offset would risk overlapping it; pin to the bottom instead, clear of the topbar
     regardless of how tall it gets. */
  .paused-quiz-widget {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}

/* ---------- Nya frågor (topbar page): invented questions, own colour ----------
   Same shape as Flaggade frågor (it reuses .flagged-subject*, .flagged-area*, .flagged-q* and .typed-practice-btns,
   so ämne sections, område cards and the SBA/VSA/Blandat buttons look exactly like there) - what is new is the
   lime chrome: topbar dot, "Påhittade" badge, the hero, the filter pills, and the lime progress bar in a quiz. */
.topbar-link-new { color: var(--new-strong); }
.topbar-link-new::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--new);
  vertical-align: 1px;
}
.topbar-link-new:hover { color: var(--new-strong); background: var(--new-soft); }

.nf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--new-strong);
  background: var(--new-soft);
  border: 1px solid var(--new-border);
  white-space: nowrap;
}
.nf-badge-lg {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.8rem;
  margin-left: 10px;
  vertical-align: middle;
  position: relative;
  top: -3px;
}
.nf-warn {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--pastel-mixed-text);
  background: var(--pastel-mixed-bg);
  white-space: nowrap;
}

.nf-search { padding: 14px 18px; }
.nf-hero {
  position: relative;
  border-color: var(--new-border);
  background: linear-gradient(135deg, var(--new-soft) 0%, var(--surface) 62%);
  box-shadow: inset 0 4px 0 var(--new), var(--shadow);
}
.nf-hero .overview-hero-figure { color: var(--new-strong); }
.nf-hero-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 2px; }
.nf-hero .flagged-hero-actions { border-top-color: var(--new-border); }
.nf-hero .flagged-hero-actions .btn-primary.nf-btn-primary,
.nf-hero .flagged-hero-actions .nf-btn-ghost { width: auto; margin: 0; }
.nf-btn-primary {
  background: var(--new-fill);
  color: var(--new-ink);
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.nf-btn-primary:hover { background: var(--new-fill); filter: brightness(0.94); }
.nf-btn-ghost {
  border-color: var(--new-border);
  color: var(--new-strong);
  font-weight: 600;
  background: var(--surface);
}
.nf-btn-ghost:hover { border-color: var(--new); color: var(--new-strong); }
.nf-btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }
.nf-sim-extra { display: contents; }

.nf-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.nf-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.nf-pill b { font-variant-numeric: tabular-nums; }
.nf-pill:hover { border-color: var(--new); color: var(--text); transform: translateY(-1px); }
.nf-pill.is-active { border-color: var(--new); background: var(--new-soft); color: var(--new-strong); }
.nf-pill:disabled { opacity: 0.45; cursor: default; transform: none; }

/* The område card's left edge etc. keep the ämne colour (it is the subject's identity); the lime only marks "invented". */
.nf-view .flagged-q-meta .topic-tag { color: var(--new-strong); background: var(--new-soft); }
.nf-view .concept-recur-badge { margin-left: 0; }

/* In a quiz / result: a lime progress bar and the "Påhittad fråga" badge, so an invented question is never mistaken for a real one. */
#view-quiz.is-synthetic .quiz-progress-fill { background: var(--new); }
.exam-source-badge .nf-badge { margin-right: 2px; }
.kortsvar-extra { margin: 4px 0 12px; font-size: 0.9rem; line-height: 1.5; color: var(--text); }
.kortsvar-extra[hidden] { display: none; }
.kortsvar-extra .grading-note { display: block; margin-bottom: 4px; }
.grading-note { font-size: 0.88rem; line-height: 1.45; margin: 0 0 8px; color: var(--text); }
.grading-note b { font-weight: 700; }

#view-quiz.is-synthetic .vignette { border-left-color: var(--new); }

/* The topbar grew a sixth link: on a phone the two icon buttons move up beside the brand and the links get their own full-width
   rows (3 + 3), so it is no taller than before. */
@media (max-width: 560px) {
  .topbar-nav { order: 2; flex-basis: 100%; }
  .topbar-icon-btn { order: 1; }
}

/* ===== Result page: ring with the big G / U, verdict line, celebration ===== */
.result-donut-wrap { margin: 14px 0 0; }
.result-ring { position: relative; width: min(260px, 78vw); aspect-ratio: 1; }
.result-ring svg { width: 100%; height: 100%; display: block; overflow: visible; }
.result-ring-track { fill: none; stroke: var(--surface-2); }
.result-ring-arc { fill: none; stroke-linecap: butt; animation: result-ring-draw 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.result-ring-arc.is-correct { stroke: var(--correct); }
.result-ring-arc.is-wrong { stroke: var(--wrong); animation-delay: 0.5s; }
@keyframes result-ring-draw { from { stroke-dasharray: 0 100; } }
.result-ring-limit { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; opacity: 0.75; }
.result-ring-limit-label { font-size: 11px; font-weight: 700; fill: var(--text-muted); }
.result-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  pointer-events: none;
}
.result-grade-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.6rem, 18vw, 5.4rem);
  line-height: 0.95;
  animation: result-letter-pop 0.7s 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.result-grade-letter.is-pass { color: var(--correct); }
.result-grade-letter.is-fail { color: var(--wrong); }
.result-grade-pct { font-size: 1.45rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.result-grade-pct.is-solo { font-size: 2.2rem; }
@keyframes result-letter-pop { from { transform: scale(0.3); opacity: 0; } }

.result-verdict { text-align: center; margin: 14px 0 4px; }
.result-verdict[hidden] { display: none; }
.result-verdict-title { font-family: var(--font-display); font-weight: 700; font-size: 1.7rem; margin: 0 0 4px; }
.result-verdict-sub { margin: 0 auto; max-width: 440px; color: var(--text); font-size: 0.98rem; line-height: 1.45; }
#view-result.is-result-pass .result-verdict-title { color: var(--correct); }
.result-score { margin: 8px 0 18px; }

/* The celebration layer: click-through, fixed over everything, takes itself away after a few seconds. */
.celebration-layer { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.celebration-layer::before { content: ""; position: absolute; inset: 0; animation: celebration-wash 6.5s ease-out both; }
.celebration-layer.is-pass::before { background: radial-gradient(ellipse at 50% 42%, rgba(34, 197, 94, 0.42), rgba(34, 197, 94, 0.14) 55%, transparent 80%); }
.celebration-layer.is-fail::before { background: linear-gradient(180deg, rgba(71, 85, 105, 0.34), rgba(71, 85, 105, 0.12) 60%, transparent); }
@keyframes celebration-wash { 0% { opacity: 0; } 12% { opacity: 1; } 70% { opacity: 0.85; } 100% { opacity: 0; } }
.celebration-emoji, .celebration-confetti { position: absolute; left: var(--x); will-change: transform, opacity; }
.celebration-emoji { font-size: var(--size, 2rem); line-height: 1; }
.celebration-emoji.is-rain { top: -12vh; animation: celebration-fall var(--dur, 3.4s) var(--delay, 0s) cubic-bezier(0.3, 0.5, 0.6, 1) both; }
.celebration-emoji.is-sad { top: -10vh; animation: celebration-sad-fall var(--dur, 5.5s) var(--delay, 0s) linear both; }
.celebration-emoji.is-pop { top: var(--y); animation: celebration-pop 1.9s var(--delay, 0s) ease-out both; }
.celebration-confetti { top: -6vh; width: var(--w, 8px); height: var(--h, 14px); background: var(--confetti, #22c55e); border-radius: 2px; animation: celebration-confetti-fall var(--dur, 3s) var(--delay, 0s) cubic-bezier(0.3, 0.4, 0.6, 1) both; }
@keyframes celebration-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--drift, 0px), 118vh) rotate(var(--rot, 120deg)); opacity: 0; }
}
@keyframes celebration-sad-fall {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 0.9; }
  50% { transform: translate(var(--drift, 20px), 55vh); }
  85% { opacity: 0.8; }
  100% { transform: translate(calc(var(--drift, 20px) * -0.6), 115vh); opacity: 0; }
}
@keyframes celebration-pop {
  0% { transform: scale(0) rotate(var(--rot, 0deg)); opacity: 0; }
  25% { transform: scale(1.35) rotate(var(--rot, 0deg)); opacity: 1; }
  70% { transform: scale(1) rotate(var(--rot, 0deg)); opacity: 1; }
  100% { transform: scale(0.8) translateY(-40px) rotate(var(--rot, 0deg)); opacity: 0; }
}
@keyframes celebration-confetti-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--drift, 0px), 112vh) rotate(var(--rot, 720deg)); opacity: 0.9; }
}
.celebration-banner {
  position: absolute;
  left: 50%;
  top: 72%;
  transform: translate(-50%, -50%);
  max-width: 90vw;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  animation: celebration-banner 6s ease-out both;
}
.celebration-layer.is-pass .celebration-banner { font-size: clamp(4.5rem, 18vw, 9rem); color: #fff; text-shadow: 0 4px 0 #15803d, 0 8px 28px rgba(21, 128, 61, 0.7); }
@keyframes celebration-banner {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  10% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  16% { transform: translate(-50%, -50%) scale(1); }
  75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -58%) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .result-ring-arc, .result-grade-letter { animation: none; }
}

/* ===== Rätta dina VSA (step before the result) ===== */
.grade-vsa-progress-text { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.grade-vsa-card .q-text { font-weight: 600; font-size: 1.1rem; line-height: 1.45; margin: 0 0 14px; }
.grade-vsa-card .kortsvar-reveal { margin-bottom: 18px; }
.grade-vsa-buttons { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grade-vsa-buttons .self-grade-btn { flex: 1; min-width: 120px; padding: 14px 18px; font-size: 1.05rem; }
.grade-vsa-buttons .self-grade-correct { border-color: var(--correct); color: var(--correct); }
.grade-vsa-buttons .self-grade-wrong { border-color: var(--wrong); color: var(--wrong); }
.grade-vsa-buttons .self-grade-correct:hover, .grade-vsa-buttons .self-grade-correct.is-chosen { background: var(--correct-bg); }
.grade-vsa-buttons .self-grade-wrong:hover, .grade-vsa-buttons .self-grade-wrong.is-chosen { background: var(--wrong-bg); }
.grade-vsa-buttons .self-grade-btn.is-chosen { box-shadow: 0 0 0 2px currentColor; }
.grade-vsa-actions { justify-content: space-between; }
.grade-vsa-actions .btn-ghost:disabled { opacity: 0.4; cursor: default; }

/* ===== Topbar slide-down menus (Gamla tentamen / AI frågebank) ===== */
.topbar-menu { position: relative; }
.topbar-menu-toggle { display: inline-flex; align-items: center; gap: 6px; }
.topbar-menu-caret { width: 11px; height: 11px; flex: none; transition: transform 0.18s ease; }
.topbar-menu.is-open .topbar-menu-caret { transform: rotate(180deg); }
.topbar-menu.is-open > .topbar-menu-toggle { color: var(--accent); background: var(--accent-soft); }
.topbar-menu.topbar-menu-new.is-open > .topbar-menu-toggle { color: var(--new-strong); background: var(--new-soft); }
.topbar-menu.is-current > .topbar-menu-toggle { color: var(--accent); }
.topbar-menu.topbar-menu-new.is-current > .topbar-menu-toggle { color: var(--new-strong); }
/* Always rendered (not [hidden]) so it can slide: closed = invisible, out of the tab order and click-through. */
.topbar-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 210px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(20, 20, 30, 0.16), 0 2px 6px rgba(20, 20, 30, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.topbar-menu.is-open > .topbar-menu-list {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.16s ease, transform 0.18s ease, visibility 0s;
}
.topbar-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 9px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.topbar-menu-item:hover, .topbar-menu-item:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.topbar-menu-new .topbar-menu-item:hover, .topbar-menu-new .topbar-menu-item:focus-visible { background: var(--new-soft); color: var(--new-strong); }
@media (prefers-reduced-motion: reduce) {
  .topbar-menu-list, .topbar-menu.is-open > .topbar-menu-list, .topbar-menu-caret { transition: none; }
}

/* ===== Frågebanksstatistik (AI frågebank > Frågebanksstatistik) ===== */
.stats-scope { font-weight: 700; letter-spacing: 0.02em; margin: 0 0 4px; }
.is-ai-stats .stats-scope, .nf-view .stats-scope { color: var(--new-strong); }
.bankstats-splits { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 28px; }
@media (max-width: 640px) { .bankstats-splits { grid-template-columns: 1fr; } }
.bankstats-split-title { margin: 0 0 10px; font-size: 0.95rem; font-weight: 700; }
.bankstats-split-bar { display: flex; gap: 3px; height: 16px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.bankstats-split-seg { min-width: 6px; }
.bankstats-split-seg.is-sba, .bankstats-split-swatch.is-sba { background: var(--pastel-sba-text); }
.bankstats-split-seg.is-vsa, .bankstats-split-swatch.is-vsa { background: var(--pastel-vsa-text); }
.bankstats-split-seg.is-concept, .bankstats-split-swatch.is-concept { background: var(--accent); }
.bankstats-split-seg.is-fresh, .bankstats-split-swatch.is-fresh { background: var(--new); }
.panel .bankstats-split-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.9rem; }
.panel .bankstats-split-legend li { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.bankstats-split-swatch { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.bankstats-split-pct { color: var(--text-muted); }
.bankstats-heading { margin: 26px 0 10px; font-family: var(--font-display); font-size: 1.3rem; }
.bankstats-subject { border-left: 4px solid var(--subject-color, var(--accent)); margin-bottom: 14px; }
.bankstats-subject-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.bankstats-subject-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--subject-color, var(--accent)); align-self: center; }
.bankstats-subject-name { margin: 0; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.bankstats-subject-count { color: var(--text-muted); font-size: 0.88rem; }
.bankstats-area-row { display: grid; grid-template-columns: minmax(130px, 38%) 1fr 2.4em; align-items: center; gap: 12px; padding: 5px 0; font-size: 0.92rem; }
.bankstats-area-name { min-width: 0; overflow-wrap: anywhere; }
.bankstats-area-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bankstats-area-fill { height: 100%; border-radius: 999px; background: var(--subject-color, var(--accent)); }
.bankstats-area-count { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .bankstats-area-row { grid-template-columns: 1fr 2.4em; } .bankstats-area-track { grid-column: 1 / -1; grid-row: 2; } }

/* ===== Ämnesfördelning: the big "only recurring questions" switch (gold = the ⭐ colour, same in every theme) ===== */
.examstats-recurring-toggle { --moment-color: #ca8a04; margin: 16px 0; }
.examstats-recurring-toggle .overview-compare-title { font-size: 1.15rem; }
.examstats-recurring-toggle .overview-compare-sub { font-size: 0.9rem; }

/* ===== Clearer page titles and info text (Sam, 2026-10-11): bigger/bolder h1, and the text under it (.lead, .eyebrow, .status-desc,
   the info box) in a near-body colour instead of faint grey. --text-soft sits between --text and --text-muted in every theme. ===== */
:root { --text-soft: color-mix(in srgb, var(--text) 82%, var(--text-muted)); }
h1 { font-size: clamp(1.9rem, 5vw, 2.35rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 8px; }
.lead { color: var(--text-soft); font-size: 1.05rem; line-height: 1.5; margin: 0 0 6px; }
.eyebrow { color: var(--text-soft); font-size: 0.95rem; font-weight: 600; }
.status-desc { color: var(--text-soft); font-size: 0.95rem; line-height: 1.45; }
.stats-line { color: var(--text-soft); font-size: 0.92rem; }
.module-card p.desc { color: var(--text-soft); font-size: 0.97rem; }
.note-banner { font-size: 0.96rem; padding: 12px 16px; border-left-width: 4px; }
.overview-hero-sub { color: var(--text-soft); }

/* ===== Anteckningar: the 📝 button + note box in a quiz, the note under a result item, the page ===== */
.note-toggle-btn {
  flex: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  filter: grayscale(1);
  transition: opacity 0.12s ease, filter 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.note-toggle-btn:hover { opacity: 0.85; border-color: var(--text-muted); }
.note-toggle-btn.has-note { opacity: 1; filter: none; border-color: var(--accent); background: var(--accent-soft); }
.note-toggle-btn[aria-expanded="true"] { opacity: 1; filter: none; border-color: var(--accent); }
.note-toggle-btn + .flag-toggle-btn { margin-left: 0; }

.quiz-note { margin-top: 18px; padding: 12px 14px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.quiz-note[hidden] { display: none; }
.quiz-note-label { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: 0.88rem; font-weight: 700; color: var(--text); }
.quiz-note-status { font-weight: 600; font-size: 0.8rem; color: var(--correct); }
.quiz-note-textarea, .note-block-textarea {
  display: block;
  width: 100%;
  min-height: 74px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
}
.quiz-note-textarea:focus, .note-block-textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.note-block { margin-top: 10px; }
.note-block-toggle { font-size: 0.85rem; }
.note-block-box { margin-top: 8px; }
.note-block-box[hidden] { display: none; }
.note-block-box .quiz-note-status { display: inline-block; margin-top: 4px; }

.notes-hero .flagged-hero-actions { margin-top: 16px; }
.notes-hero .flagged-chip.is-active { box-shadow: 0 0 0 2px var(--chip-color); }
.notes-card { border-left: 4px solid var(--subject-color, var(--accent)); margin-bottom: 14px; }
.notes-card .flagged-q-meta { margin-bottom: 8px; }
.notes-card-note { margin-top: 14px; }
.notes-card-actions { margin-top: 12px; }
@media (max-width: 560px) {
  .grade-vsa-buttons .kortsvar-self-grade-label { flex: 1 0 100%; }
  .grade-vsa-buttons .self-grade-btn { min-width: 0; }
}

/* Practice rounds have no grade: the verdict line is plain, the "Bra jobbat!" banner is smaller than the simulation's giant "G!". */
.result-verdict-sub:empty { display: none; }
.celebration-layer.is-pass.is-practice .celebration-banner { font-size: clamp(2.4rem, 10vw, 4.6rem); }

/* ===== Flaggade frågor <-> Anteckningar: scope pills (Flaggade / Antecknade / Alla), flag state on a row ===== */
.scope-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.scope-pills[hidden] { display: none; }
.scope-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.scope-pill b { font-variant-numeric: tabular-nums; }
.scope-pill:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.scope-pill.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.scope-pill:disabled { opacity: 0.45; cursor: default; transform: none; }
.flagged-q-flagstate { font-weight: 700; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-muted); }
.flagged-q-flagstate.is-flagged { background: var(--wrong-bg); color: var(--wrong); }
.flagged-q-flagstate[hidden] { display: none; }
.notes-hero .notes-flag-chip { --chip-color: var(--wrong); }
.flagged-q .note-block { margin-top: 10px; }

/* ===== Login gate (view-login), topbar account chip, Inställningar > Konto ===== */
body.is-logged-out .topbar-nav,
body.is-logged-out .topbar-icon-btn,
body.is-logged-out .topbar-subtitle { display: none; }
body.is-logged-out .brand { cursor: default; }
body.is-booting { visibility: hidden; }
body.is-logged-out .view { display: none; }
body.is-logged-out #view-login { display: block; }
.login-view { max-width: 460px; margin: 0 auto; padding-top: 30px; }
.login-card { display: flex; flex-direction: column; gap: 0; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; }
.login-brand .brand-icon { width: 34px; height: 34px; }
.login-view h1 { text-align: center; margin-bottom: 18px; }
.login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.login-tabs button {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 14px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.login-tabs button:hover { color: var(--text); }
.login-tabs button.is-active { background: var(--accent); color: #fff; }
.login-panel { padding: 22px 22px 24px; }
.login-panel[hidden] { display: none; }
.login-panel .form-field { margin-bottom: 14px; }
.login-panel input[type="email"], .login-panel input[type="text"], .login-panel input[type="password"] { width: 100%; box-sizing: border-box; }
.password-field { position: relative; display: flex; }
.password-field input { padding-right: 64px; }
.password-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 5px 10px; border: none; border-radius: 8px; background: none; color: var(--accent); font-family: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer; }
.password-toggle:hover { background: var(--accent-soft); }
.login-remember { margin: 4px 0 6px; font-size: 0.95rem; }
.login-panel .btn-primary { width: 100%; margin-top: 6px; }
.login-panel .btn-primary:disabled { opacity: 0.7; cursor: progress; }
.login-panel .form-error { min-height: 1.2em; }

.topbar-account-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.topbar-account-btn[hidden] { display: none; }
.topbar-account-btn:hover { background: var(--accent); color: #fff; }
.settings-account-line { margin: 0 0 6px; }
.settings-account .btn-ghost { margin-top: 8px; }
.login-panel input[type="email"], .login-panel input[type="text"], .login-panel input[type="password"] { padding: 11px 12px; font-size: 1rem; min-width: 0; }

/* ===== Login: verification / reset steps, the test-mode mail box ===== */
.login-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 6px; }
.login-options .login-remember { margin: 0; }
.link-button { background: none; border: none; padding: 4px 2px; color: var(--accent); font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { color: var(--accent-hover); }
.link-button:disabled { color: var(--text-muted); cursor: default; text-decoration: none; }
.form-success { color: var(--correct); font-size: 0.9rem; font-weight: 600; margin: 4px 0 10px; }
.form-success:empty { display: none; }
.login-step-text { margin: 0 0 14px; font-size: 1rem; line-height: 1.5; color: var(--text); }
.login-step-links { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.5rem !important; letter-spacing: 0.35em; text-align: center; }
.login-tabs[hidden] { display: none; }
