/* ==========================================================================
   Eksamensmedisin — stilark
   Mobilførst. Alle farger er variabler, definert i to komplette temaer.
   Ingen farge skal skrives direkte i en regel utenfor :root-blokkene.
   ========================================================================== */

:root {
  /* --- flater og tekst --- */
  --bg:            #eff3f8;
  --surface:       #ffffff;
  --surface-2:     #e8eef6;
  --surface-3:     #dde7f2;
  --border:        #dbe4ee;
  --border-strong: #c5d3e2;
  --ink:           #0f2438;
  --ink-2:         #5b7186;
  --ink-3:         #596d80;

  /* --- merkefarge --- */
  --brand:         #2568a8;
  --brand-strong:  #1b4e80;
  --brand-ink:     #ffffff;
  --brand-soft:    #dfeaf6;
  --brand-soft-ink:#1d5488;

  /* --- svarstatus (aldri brukt til annet) --- */
  --ok:        #1c6437;
  --ok-bg:     #d6ecdc;
  --ok-line:   #8cc79f;
  --err:       #a03038;
  --err-bg:    #f7d5d6;
  --err-line:  #e0989b;

  /* --- varsel --- */
  --warn:      #8a6208;
  --warn-bg:   #fdeec9;
  --warn-line: #eccf87;
  --accent:    #e0a11f;
  --accent-ink:#2a1e02;

  /* --- fagfeltfamilier --- */
  --fam-indremedisin: #2E6CA4;
  --fam-kirurgi:      #2F7F86;
  --fam-nevro-psyk:   #6B5CA5;
  --fam-kvinne-barn:  #B5527E;
  --fam-sanser-hud:   #A8752B;
  --fam-akutt:        #B85C38;
  --fam-diagnostikk:  #566878;
  --fam-samfunn:      #667A3F;

  /* --- form --- */

  /* Skriftstørrelse i alle skrivbare felter. Safari på iOS zoomer inn på et
     felt med skrift under 16px, og zoomer ikke ut igjen. Verdien styres derfor
     ett sted, som en variabel: en media query lenger nede løfter den til 16px
     på touch. Det må gjøres slik, og ikke ved å overstyre selektorene, fordi
     `.field input` slår en regel som bare sier `input` uansett rekkefølge. */
  --felt-skrift: 15px;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow: 0 1px 2px rgba(15, 36, 56, .05);
  --shadow-lg: 0 8px 28px rgba(15, 36, 56, .12);
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 74px;
  --tabbar-h: 60px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Poppins", var(--font);

  color-scheme: light;
}

@media (pointer: coarse) {
  :root { --felt-skrift: 16px; }
}

:root[data-theme="dark"] {
  --bg:            #0d151f;
  --surface:       #151f2b;
  --surface-2:     #1b2735;
  --surface-3:     #223040;
  --border:        #263442;
  --border-strong: #33445533;
  --ink:           #e7eef5;
  --ink-2:         #94a7b9;
  --ink-3:         #8497aa;

  --brand:         #5aa2e0;
  --brand-strong:  #7cb8ea;
  --brand-ink:     #08131e;
  --brand-soft:    #1a2c3f;
  --brand-soft-ink:#8cc0ec;

  --ok:        #7fd0a0;
  --ok-bg:     #16311f;
  --ok-line:   #2f6b41;
  --err:       #f3a3a8;
  --err-bg:    #351a1d;
  --err-line:  #6d3239;

  --warn:      #f0cf85;
  --warn-bg:   #33280f;
  --warn-line: #5d4a1c;
  --accent:    #f0b843;
  --accent-ink:#2a1e02;

  --fam-indremedisin: #6BA6DC;
  --fam-kirurgi:      #63BFC6;
  --fam-nevro-psyk:   #A497E0;
  --fam-kvinne-barn:  #E88FB4;
  --fam-sanser-hud:   #DDAE5E;
  --fam-akutt:        #E5906E;
  --fam-diagnostikk:  #9AAEBF;
  --fam-samfunn:      #A9BC79;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 32px rgba(0, 0, 0, .5);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0d151f;
    --surface:       #151f2b;
    --surface-2:     #1b2735;
    --surface-3:     #223040;
    --border:        #263442;
    --ink:           #e7eef5;
    --ink-2:         #94a7b9;
    --ink-3:         #8497aa;
    --brand:         #5aa2e0;
    --brand-strong:  #7cb8ea;
    --brand-ink:     #08131e;
    --brand-soft:    #1a2c3f;
    --brand-soft-ink:#8cc0ec;
    --ok:        #7fd0a0;  --ok-bg:  #16311f;  --ok-line:  #2f6b41;
    --err:       #f3a3a8;  --err-bg: #351a1d;  --err-line: #6d3239;
    --warn:      #f0cf85;  --warn-bg:#33280f;  --warn-line:#5d4a1c;
    --accent:    #f0b843;
    --fam-indremedisin: #6BA6DC;  --fam-kirurgi:     #63BFC6;
    --fam-nevro-psyk:   #A497E0;  --fam-kvinne-barn: #E88FB4;
    --fam-sanser-hud:   #DDAE5E;  --fam-akutt:       #E5906E;
    --fam-diagnostikk:  #9AAEBF;  --fam-samfunn:     #A9BC79;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

/* ==========================================================================
   Grunnlag
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 1em; height: 1em; display: block; flex: none; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Skall
   ========================================================================== */

.app { min-height: 100dvh; }

.main {
  padding: 16px 16px calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  min-width: 0;
}

/* --- sidemeny (skrivebord) --- */
.sidebar { display: none; }

/* --- bunnmeny (mobil) --- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  /* minmax(0,1fr) framfor 1fr: ellers får kolonnene min-content som gulv,
     og den bredeste etiketten presser menyen ut over skjermbredden. */
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: var(--tabbar-h);
  font-size: 10.5px; font-weight: 600; letter-spacing: .1px;
  color: var(--ink-3);
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar a[aria-current="page"] { color: var(--brand); }

/* --- toppstripe på mobil --- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wordmark {
  font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -.2px;
  display: inline-flex; align-items: center; min-height: 42px; padding-right: 8px;
}
.topbar .spacer { flex: 1; }

/* ==========================================================================
   Skrivebord: sidemeny i skjermhøyde, sammenleggbar
   ========================================================================== */

@media (min-width: 900px) {
  .app {
    display: flex; align-items: flex-start; gap: 22px;
    padding: 22px; max-width: 1460px; margin: 0 auto;
  }
  .topbar, .tabbar { display: none; }
  .main { padding: 0; flex: 1; }

  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 22px;
    height: calc(100dvh - 44px);
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 20px 14px 14px;
    transition: width .18s ease, flex-basis .18s ease;
    overflow: hidden;
  }
  .app[data-sidebar="collapsed"] .sidebar {
    width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed);
    padding-left: 10px; padding-right: 10px;
  }
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 8px 20px; min-width: 0;
}
.brand .logo {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  background: linear-gradient(150deg, var(--brand), var(--brand-strong));
  color: var(--brand-ink); display: grid; place-items: center; font-size: 19px;
}
.brand .name {
  font-family: var(--display); font-weight: 700; font-size: 16.5px;
  letter-spacing: -.3px; line-height: 1.1; white-space: nowrap;
}
.brand .name small { display: block; font-family: var(--font); font-weight: 500; font-size: 11px; color: var(--ink-3); letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r);
  font-size: 14.5px; font-weight: 500; color: var(--ink-2);
  min-height: 42px; white-space: nowrap;
  transition: background .13s, color .13s;
}
.nav a svg { width: 19px; height: 19px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-soft-ink); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; gap: 6px; }
.icon-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: var(--r); flex: none;
  color: var(--ink-2); font-size: 18px;
  transition: background .13s, color .13s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.grow { width: auto; flex: 1; gap: 9px; grid-auto-flow: column; font-size: 14px; font-weight: 500; }

.app[data-sidebar="collapsed"] .nav a span,
.app[data-sidebar="collapsed"] .brand .name,
.app[data-sidebar="collapsed"] .icon-btn.grow span { display: none; }
.app[data-sidebar="collapsed"] .nav a { justify-content: center; padding-left: 0; padding-right: 0; }
.app[data-sidebar="collapsed"] .brand { justify-content: center; padding-left: 0; padding-right: 0; }
.app[data-sidebar="collapsed"] .sidebar-foot { flex-direction: column; }
.app[data-sidebar="collapsed"] .icon-btn.grow { width: 42px; flex: none; }

/* ==========================================================================
   Typografi og småting
   ========================================================================== */

h1, h2, h3 { font-family: var(--display); letter-spacing: -.4px; margin: 0; }
.h-page { font-size: 26px; font-weight: 700; line-height: 1.15; }
.h-sec  { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }

@media (min-width: 900px) { .h-page { font-size: 32px; } }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head .h-page { flex: 1; min-width: 0; }

/* ==========================================================================
   Kort, knapper, merker
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.pad { padding: 16px; }
@media (min-width: 900px) { .pad { padding: 20px; } }

.grid-2 { display: grid; gap: 16px; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  background: var(--brand); color: var(--brand-ink);
  border-radius: var(--r); font-weight: 600; font-size: 15px;
  transition: background .13s, opacity .13s;
}
.btn:hover { background: var(--brand-strong); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet { background: var(--surface-2); color: var(--ink); }
.btn.quiet:hover { background: var(--surface-3); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 13px; font-size: 13.5px; border-radius: var(--r-sm); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.3;
  background: var(--surface-2); color: var(--ink-2);
}
.chip svg { width: 14px; height: 14px; }
.chip.brand { background: var(--brand-soft); color: var(--brand-soft-ink); }
.chip.warn  { background: var(--warn-bg); color: var(--warn); }
.chip.err   { background: var(--err-bg); color: var(--err); }
.chip.ok    { background: var(--ok-bg); color: var(--ok); }
.chip.fam   { background: color-mix(in srgb, var(--fam) 14%, var(--surface)); color: var(--fam); }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r); margin-bottom: 14px;
  font-size: 14px; line-height: 1.45;
}
.banner svg { width: 17px; height: 17px; margin-top: 2px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--brand-soft); color: var(--brand-soft-ink); }

.empty { text-align: center; padding: 44px 20px; color: var(--ink-2); }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }

/* ==========================================================================
   Statistikkstripe
   ========================================================================== */

.statbar {
  display: grid; grid-template-columns: repeat(2, 1fr);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 16px;
}
.statbar .stat { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-width: 0; }
.statbar .stat:nth-child(even) { border-left: 1px solid var(--border); }
.statbar .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
.statbar .ico { color: var(--brand); font-size: 22px; }
.statbar .lbl { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.statbar .val { font-family: var(--display); font-weight: 700; font-size: 19px; line-height: 1.1; }

@media (min-width: 700px) {
  .statbar { grid-template-columns: repeat(var(--stat-cols, 4), 1fr); }
  .statbar .stat:nth-child(n) { border-top: none; border-left: 1px solid var(--border); }
  .statbar .stat:first-child { border-left: none; }
}

/* ==========================================================================
   Fliser på forsiden
   ========================================================================== */

.tile {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface-2); border-radius: var(--r);
  padding: 14px 16px; min-height: 74px;
  transition: background .13s;
}
.tile + .tile { margin-top: 10px; }
.tile:hover { background: var(--surface-3); }
.tile .ico {
  width: 44px; height: 44px; flex: none; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 22px; color: var(--brand);
}
.tile .body { flex: 1; min-width: 0; }
.tile .name { font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.2; }
.tile .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.tile .go { color: var(--ink-3); font-size: 18px; }

@media (min-width: 700px) {
  .tile .name { font-size: 20px; }
  .tile .ico { width: 48px; height: 48px; font-size: 24px; }
}

/* ==========================================================================
   Fagfeltrutenett
   ========================================================================== */

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.cat-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px 12px 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 132px; text-align: center;
  transition: border-color .13s, transform .13s;
}
.cat-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--fam);
}
.cat-card:hover { border-color: var(--fam); transform: translateY(-1px); }
.cat-card .ico { font-size: 40px; color: var(--fam); }
.cat-card .nm { font-size: 13px; font-weight: 650; line-height: 1.25; }
.cat-card .ct { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }

.fam-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* ==========================================================================
   Eksamensliste
   ========================================================================== */

.exam-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 13px 15px; margin-bottom: 9px;
  min-height: 62px;
  transition: border-color .13s, background .13s;
}
.exam-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.exam-row .ring {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  color: var(--ink-3); background: var(--surface-2);
  border: 2px solid var(--border);
}
.exam-row.started .ring { border-color: var(--accent); color: var(--accent); }
.exam-row.done .ring { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok); }
.exam-row .t { font-family: var(--display); font-weight: 700; font-size: 16px; }
.exam-row .s { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.exam-row .go { color: var(--ink-3); font-size: 17px; }

/* ==========================================================================
   Fremdriftslinjer
   ========================================================================== */

.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .3s; }
.bar.fam > i { background: var(--fam); }
.bar.thin { height: 5px; }

.progress-top {
  position: sticky; top: 0; z-index: 20;
  height: 3px; background: var(--surface-3);
}
.progress-top > i { display: block; height: 100%; background: var(--brand); transition: width .25s; }

/* ==========================================================================
   Oppgavevisning
   ========================================================================== */

.quiz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.quiz-head .title {
  flex: 1; min-width: 0; text-align: center;
  font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--brand);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.quiz-head .count { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--ink-2); }
@media (min-width: 900px) { .quiz-head .title { font-size: 24px; } .quiz-head .count { font-size: 18px; } }

.quiz-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 10px 0 14px; }
.quiz-meta .term { margin-left: auto; font-weight: 600; font-size: 13px; color: var(--ink-2); }

.quiz-body { display: grid; gap: 18px; }
@media (min-width: 1000px) {
  .quiz-body { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 30px; align-items: start; }
}

.stem { font-size: 16.5px; line-height: 1.55; }
@media (min-width: 900px) { .stem { font-size: 17.5px; } }
.stem-p { margin: 0 0 12px; white-space: pre-wrap; }
.stem-p:last-child { margin-bottom: 0; }

.stem-table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: 6px 0 14px;
  font-size: 14.5px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.stem-table th, .stem-table td {
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
}
.stem-table thead th { background: var(--surface-2); font-weight: 600; font-size: 13px; color: var(--ink-2); }
.stem-table tbody tr:last-child td { border-bottom: none; }
.stem-table td { font-variant-numeric: tabular-nums; }

.stem-img { margin-top: 14px; }
.stem-img img {
  border-radius: var(--r-sm); border: 1px solid var(--border);
  cursor: zoom-in; display: block;
  /* Bevisst hvit uansett tema: røntgenbilder og figurer fra fasiten har ofte
     gjennomsiktig bakgrunn og blir uleselige på mørk flate. */
  background: #fff;
}

/* --- svaralternativer --- */
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); transition: border-color .13s, background .13s;
}
.opt::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: transparent; transition: background .13s;
}
.opt-main {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 15px; width: 100%; text-align: left; min-height: 56px;
}
.opt-main .badge {
  width: 26px; height: 26px; flex: none; border-radius: 7px;
  display: grid; place-items: center; margin-top: 1px;
  font-size: 13px; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2);
  transition: background .13s, color .13s;
}
.opt-main .txt { flex: 1; font-size: 15.5px; line-height: 1.45; }
.opt-main .caret { color: var(--ink-3); font-size: 16px; margin-top: 4px; }

.opt:not(.revealed):hover { border-color: var(--border-strong); background: var(--surface-2); }
.opt.picked { border-color: var(--brand); }
.opt.picked::before { background: var(--brand); }
.opt.picked .badge { background: var(--brand); color: var(--brand-ink); }

.opt.correct { border-color: var(--ok-line); background: var(--ok-bg); }
.opt.correct::before { background: var(--ok); }
.opt.correct .badge { background: var(--ok); color: var(--ok-bg); }
.opt.wrong { border-color: var(--err-line); background: var(--err-bg); }
.opt.wrong::before { background: var(--err); }
.opt.wrong .badge { background: var(--err); color: var(--err-bg); }

.expl {
  padding: 0 15px 14px 53px; font-size: 14.5px; line-height: 1.55;
}
.expl .rule { height: 1px; background: currentColor; opacity: .18; margin-bottom: 10px; }
.expl .none { color: var(--ink-3); font-style: italic; }

.note {
  margin-top: 12px; border-radius: var(--r); padding: 13px 15px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.note.ai { border-style: dashed; border-color: var(--brand); background: var(--brand-soft); }
.note .lbl {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--brand-soft-ink); margin-bottom: 7px;
}
.note p { margin: 0 0 8px; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; }
.note p:last-child { margin-bottom: 0; }

/* --- handlingsrad, festet nederst på mobil --- */
.quiz-foot { display: flex; gap: 10px; margin-top: 22px; }
.quiz-foot .btn { flex: 1; min-height: 50px; font-size: 16px; }
.quiz-foot .btn.narrow { flex: 0 0 auto; min-width: 52px; padding: 0 14px; }

@media (max-width: 899px) {
  .quiz-foot {
    position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    margin: 22px -16px 0; padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }
}

/* --- bildeforstørrelse --- */
.zoom {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(4, 12, 20, .88); padding: 20px;
}
.zoom img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); background: #fff; }

/* ==========================================================================
   Lister
   ========================================================================== */

.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .mk { font-size: 16px; }
.row .mk.ok { color: var(--ok); }
.row .mk.no { color: var(--err); }
.row .tx {
  flex: 1; min-width: 0; font-size: 14px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row .meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.row .tag { font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); padding: 3px 8px; border-radius: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: none; }

/* ==========================================================================
   Faner
   ========================================================================== */

.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--surface-2); padding: 4px; border-radius: var(--r);
}
.tabs button {
  flex: 1; min-height: 38px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  transition: background .13s, color .13s;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.seg { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: var(--r-sm); }
.seg button {
  min-height: 32px; padding: 0 12px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); }

/* ==========================================================================
   Temabytte

   Chromium re-resolver ikke var() på allerede tegnede elementer når
   variabelen endres på en forfar, dersom egenskapen har en transition.
   Resultatet er at svaralternativene blir hengende igjen i forrige tema.
   Vi slår derfor av alle overganger i det øyeblikket temaet byttes — det
   fjerner både feilen og en uønsket kryssfade av hele grensesnittet.
   ========================================================================== */

.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: none !important;
}

/* Kildelenkene på Om-siden er mange og korte — de trenger eget trykkareal. */
.src-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 16px; }
.src-links a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px;
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--brand);
  font-size: 13.5px; font-weight: 500;
}
.src-links a:hover { background: var(--surface-3); }

/* ==========================================================================
   Installasjonshint (kun Safari på iOS)
   ========================================================================== */

.install-hint {
  position: fixed; z-index: 45;
  left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; line-height: 1.45;
}
.install-hint .ico { color: var(--brand); font-size: 19px; margin-top: 1px; }
.install-hint button { margin: -6px -6px 0 0; width: 34px; height: 34px; font-size: 16px; }

/* ==========================================================================
   Skjemafelt
   ========================================================================== */

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 46px; padding: 10px 13px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r);
  font: inherit; font-size: var(--felt-skrift);
}
.field textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.field small { display: block; margin-top: 5px; font-size: 12.5px; }

/* Sikkerhetsnett for felter uten egen regel — se --felt-skrift i :root. */
input, textarea, select { font-size: var(--felt-skrift); }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; line-height: 1.45; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }

.sidebar-foot + .sidebar-foot { margin-top: 0; padding-top: 8px; border-top: none; }
.sidebar-foot[data-auth-slot] { margin-top: auto; }
.sidebar-foot[data-auth-slot]:empty { display: none; }

/* Lås på innhold som krever konto */
.lock {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-3);
}
.lock svg { width: 13px; height: 13px; }
.exam-row.is-locked .t, .cat-card.is-locked .nm { color: var(--ink-2); }
.cat-card.is-locked .ico { opacity: .55; }

/* ==========================================================================
   Diskusjon
   ========================================================================== */

.cmt-section {
  margin-top: 28px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.cmt-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.cmt-head .h-sec { margin: 0; }

.switch {
  display: inline-flex; align-items: center; gap: 9px;
  margin-left: auto; font-size: 13.5px; color: var(--ink-2);
  cursor: pointer; min-height: 40px;
}
.switch input {
  appearance: none; width: 40px; height: 23px; flex: none;
  border-radius: 999px; background: var(--surface-3);
  position: relative; cursor: pointer; transition: background .15s;
}
.switch input::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .15s;
}
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(17px); }

.cmt {
  padding: 13px 0; border-top: 1px solid var(--border);
}
.cmt.reply {
  margin-left: 16px; padding-left: 14px;
  border-top: none; border-left: 2px solid var(--border);
}
.cmt header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.cmt .who { font-weight: 650; font-size: 14px; }
.cmt .who.anon { color: var(--ink-2); font-style: italic; }
.cmt .mine {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  background: var(--brand-soft); color: var(--brand-soft-ink);
  padding: 2px 6px; border-radius: 5px;
}
.cmt time, .cmt .edited { font-size: 12px; color: var(--ink-3); }
.cmt p { margin: 0 0 8px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmt footer { display: flex; align-items: center; gap: 14px; }

.cmt .vote {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--ink-2); min-height: 34px;
}
.cmt .vote svg { width: 15px; height: 15px; }
.cmt .vote[aria-pressed="true"] { color: var(--brand); font-weight: 600; }
.cmt .link {
  font-size: 13px; color: var(--ink-2); min-height: 34px;
}
.cmt .link:hover { color: var(--ink); text-decoration: underline; }
.cmt .link[disabled] { color: var(--ink-3); text-decoration: none; cursor: default; }

.composer { margin-top: 14px; }
.composer textarea {
  width: 100%; min-height: 84px; padding: 11px 13px; resize: vertical;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r);
  font: inherit; font-size: var(--felt-skrift); line-height: 1.5;
}
.composer textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.composer-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px;
}
.composer-foot .anon-check { font-size: 13.5px; }
.composer-foot .as { margin-left: auto; }
.composer-msg { margin: 8px 0 0; }
.reply-box { margin-top: 4px; }

/* ==========================================================================
   Løpende tekst (juridiske sider og Om)
   ========================================================================== */

.prose { max-width: 68ch; line-height: 1.65; }
.prose p { margin: 0 0 14px; }
.prose ol, .prose ul { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 7px; }
.prose .h-sec { margin-top: 22px; }
.prose .h-sec:first-child { margin-top: 0; }
.prose code {
  font-size: 13.5px; padding: 1px 5px; border-radius: 5px;
  background: var(--surface-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Bunntekst med juridiske lenker */
.footer-links {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--ink-3);
}
.footer-links a { color: var(--ink-2); }
.footer-links a:hover { color: var(--brand); }
