/* StudyBuddy — layout & components. Consumes css/tokens.css. */

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }
/* Reserve the scrollbar's space on every page, so content doesn't shift
   sideways between short (no scrollbar) and long pages. */
html { scrollbar-gutter: stable; }
/* Scrollbars in the theme's own colours, everywhere: a slim thumb in the line colour on no track, instead of
   the system's wide grey bar with arrow buttons (which looked foreign on the dark theme). scrollbar-color is
   inherited, so this one line covers the page and every list, panel and dialog that scrolls; a part that
   wants none or its own (the sidebar, sideways chip rows) still sets it. */
:root { scrollbar-color: var(--line-strong) transparent; }
* { scrollbar-width: thin; }
/* The page's own ground on <html> too, not only on <body>: iOS Safari colours its status bar and the
   area around its floating toolbar from the root, and with no colour there it drew them white over a
   dark theme. */
html { background: var(--canvas); }

body {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: var(--font-display); line-height: var(--lh-tight); font-weight: 700; }
h1 { font-size: var(--fs-xxl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

a { color: var(--brand-ink); }

.tabular { font-variant-numeric: tabular-nums; }

/* An outline, not a box-shadow: a component that sets its own box-shadow (the set cards, tiles, anything
   with a shadow) used to override the ring and showed no focus at all. Components that draw their own
   ring say so with outline: none; box-shadow: var(--ring) and still win by specificity. */
:focus-visible {
  outline: 3px solid var(--focus-color, var(--brand));
  outline-offset: 2px;
}

/* Elements with tabindex="-1" are only ever focused programmatically — we move
   focus to a view's heading on navigation so keyboard and screen-reader users
   start at the new content. A focus ring there is noise: the user didn't press
   anything, and they can't Tab to it either. Genuine focus rings are untouched. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Visible only to assistive tech. */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skiplink {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -120%);
  z-index: 100; background: var(--brand); color: #fff;
  padding: var(--s-2) var(--s-4); border-radius: 0 0 var(--r-md) var(--r-md);
  font-weight: 700; text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out);
}
.skiplink:focus { transform: translate(-50%, 0); }

/* Dark ink on the bright orange, not white — white on this amber is only
   2.7:1. Keeps the colour, passes AA. */
.streakbadge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px var(--s-3); border-radius: var(--r-full);
  background: var(--retry); color: #2B2B3A;
  font-size: var(--fs-sm); font-weight: 700; text-decoration: none;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--retry) 60%, transparent),
              0 2px 16px -3px color-mix(in srgb, var(--retry) 85%, transparent);
  transition: box-shadow var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
}
@media (hover: hover) { a.streakbadge:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--retry) 75%, transparent),
              0 3px 22px -3px color-mix(in srgb, var(--retry) 95%, transparent);
} }
:root[data-theme="dark"] .streakbadge { color: #21170C; }
/* At risk: a freeze is standing by. Cool blue instead of the warm streak amber. */
.streakbadge--risk {
  background: var(--info); color: #fff;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--info) 60%, transparent),
              0 2px 16px -3px color-mix(in srgb, var(--info) 80%, transparent);
}
:root[data-theme="dark"] .streakbadge--risk { color: #08222E; }

.resume h3 { margin-bottom: 0; }

/* ---------- app shell ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
/* Long words and URLs wrap instead of pushing a page wider than the screen (a 33-letter Swedish compound in
   a question, a pasted link in a set title). "anywhere" also lowers the min-content width, so flex and
   grid items shrink to fit rather than growing around the word. It is applied to the places that show a
   student's or a set's own text, not to the whole app: short UI labels (tabs, chips, buttons) keep
   their one line. Add a new text-heavy container to this list. */
.shell__main h1, .shell__main h2, .shell__main h3,
.question, .choice, .feedback, .delta__prompt, .delta__answer, .delta__explain, .delta__topic,
.psheet__title, .psheet__meta, .psheet__q, .psheet__stimulus, .psheet__choices, .psheet__akey,
.classgrid__title, .classmiss__topic, .set-row, .set-list, .set-misses,
.acard__title, .exam-set__title { overflow-wrap: break-word; overflow-wrap: anywhere; }   /* break-word first: Safari < 15.4 has no "anywhere" */
:is(.question, .choice, .feedback, .delta__explain, .psheet__q, .psheet__stimulus) :is(table, th, td, pre, code, .katex) { overflow-wrap: normal; }
.shell { flex: 1; display: flex; align-items: stretch; }
.shell__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Left sidebar — the whole nav on desktop. Hidden below 900px, where the
   topbar (and its ⋮ menu) covers the same ground. */
.sidebar { display: none; }
/* Pinned to the top of the sidebar's own scroll, so the logo never scrolls
   out of view. The negative margins pull its solid band over the sidebar's
   padding (top and sides) and the padding puts the logo back exactly where it
   was — links slide underneath instead of past it, and nothing moves at rest.
   `top` is negative because sticky offsets count from inside the scroll
   container's padding: -padding pins it flush to the sidebar's top edge. */
.sidebar__brand {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
  color: var(--ink); text-decoration: none;
  position: sticky; top: calc(-1 * var(--s-5)); z-index: 1; background: var(--surface);
  margin: calc(-1 * var(--s-5)) calc(-1 * var(--s-3)) var(--s-3);
  padding: var(--s-5) calc(var(--s-3) + var(--s-2)) var(--s-3);
}
.sidebar__brand img { width: 28px; height: 28px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__link {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-3); border-radius: var(--r-md);
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: var(--fs-sm);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.sidebar__link svg { flex: none; }
@media (hover: hover) { .sidebar__link:hover { background: var(--surface-sunk); color: var(--ink); } }
.sidebar__link.is-active { background: var(--brand-tint); color: var(--brand-ink); }
.sidebar__link.is-active svg { color: var(--brand-ink); }
.sidebar__group {
  margin: var(--s-4) var(--s-3) 4px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint);
}
.sidebar__nav > .sidebar__group:first-child { margin-top: 0; }
.sidebar__div { height: 1px; margin: var(--s-3) var(--s-3) var(--s-2); background: var(--line); }

/* "Verktyg" — one row, same footprint as a link, that opens its pages in a
   flyout beside the sidebar (.toolfly below) instead of unfolding them. */
.sidebar__acc {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  margin-top: var(--s-3);
  padding: 9px var(--s-3); border-radius: var(--r-md);
  background: none; border: none; font: inherit; text-align: left; cursor: pointer;
  color: var(--ink-soft); font-weight: 600; font-size: var(--fs-sm);
  transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .sidebar__acc:hover { background: var(--surface-sunk); color: var(--ink); } }
.sidebar__acc svg:first-child { flex: none; }
.sidebar__acc-label { flex: 1; }
.sidebar__acc-count {
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint);
  background: var(--surface-sunk); padding: 1px 7px; border-radius: var(--r-full);
}
.sidebar__acc svg:last-child { flex: none; color: var(--ink-faint); transition: transform var(--dur-fast); }
.sidebar__acc[aria-expanded="true"] { background: var(--surface-sunk); color: var(--ink); }
.sidebar__acc[aria-expanded="true"] svg:last-child { transform: translateX(2px); color: var(--ink-soft); }
.sidebar__acc.is-active { background: var(--brand-tint); color: var(--brand-ink); }
.sidebar__acc.is-active svg:first-child { color: var(--brand); }
/* The flyout group's own links: hidden in the normal sidebar (they live in the
   flyout), shown inline only by the very-short-window icon dock further down. */
.sidebar__acc-body { display: none; }

/* The flyout itself: a popover pinned beside the sidebar, opened from the row. */
.popover--flyout { padding: 6px; gap: 2px; animation: flyout-in var(--dur-fast) var(--ease-out); }
@keyframes flyout-in { from { opacity: 0; transform: translateX(-6px); } }
@media (prefers-reduced-motion: reduce) { .popover--flyout { animation: none; } }
.toolfly__title {
  margin: 4px 8px 4px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint);
}
.toolfly__item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px;
  color: var(--ink-soft); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
  transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .toolfly__item:hover { background: var(--surface-sunk); color: var(--ink); } }
.toolfly__item.is-active { background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.toolfly__icon {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  border-radius: 8px; background: var(--surface-sunk); color: var(--ink-soft);
  transition: background var(--dur-fast);
}
.toolfly__item:hover .toolfly__icon { background: var(--line); }
.toolfly__item.is-active .toolfly__icon { background: var(--surface); color: var(--brand); }

/* One row: the streak card takes the width, the theme button sits beside it at
   the same height and on the same fill, so the two read as one footer. */
.sidebar__foot { display: flex; align-items: stretch; gap: var(--s-2); margin-top: var(--s-4); }

/* Fuller streak row (icon + the day count in words) — sidebar only, the
   topbar keeps the compact .streakbadge pill. */
.sidebar__streak {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px 7px 7px; border-radius: var(--r-md);
  background: var(--surface-sunk); color: var(--ink);
  font-size: calc(13px * var(--fs-scale, 1)); font-weight: 700; line-height: 1.25; text-decoration: none;
  transition: background var(--dur-fast);
}
@media (hover: hover) { .sidebar__streak:hover { background: var(--line); } }
/* The label above the count, both short enough that the pair stays as high as the flame disc. */
.sidebar__streak-text { display: grid; gap: 1px; min-width: 0; line-height: 1.15; }
.sidebar__streak-text small { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); }
.sidebar__streak-text b { font-weight: 700; overflow-wrap: anywhere; }
.sidebar__streak--none .sidebar__streak-text b { font-weight: 600; }
/* The flame disc breathes a warm glow — an ember, not a whole-button halo. */
.sidebar__streak-icon {
  width: 32px; height: 32px; flex: none; border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--retry); background: var(--retry-tint);
  --glow: var(--retry);
  box-shadow: 0 0 8px 0 color-mix(in srgb, var(--glow) 40%, transparent);
  animation: streak-ember 2.4s var(--ease-out) infinite;
}
@keyframes streak-ember {
  0%, 100% { box-shadow: 0 0 7px 0 color-mix(in srgb, var(--glow) 42%, transparent); }
  50%      { box-shadow: 0 0 18px 3px color-mix(in srgb, var(--glow) 70%, transparent); }
}
.sidebar__streak--risk .sidebar__streak-icon {
  color: var(--info); background: var(--info-tint); --glow: var(--info);
}
/* Zero-streak: same fixed spot in the footer, just muted rather than the
   vivid orange — no ember until there's a streak to celebrate. */
.sidebar__streak--none { color: var(--ink-soft); }
.sidebar__streak--none .sidebar__streak-icon {
  color: var(--ink-faint); background: var(--surface); box-shadow: none; animation: none;
}

.sidebar__themebtn {
  flex: none; width: 46px; display: grid; place-items: center;
  font: inherit; border: none; border-radius: var(--r-md); cursor: pointer;
  background: var(--surface-sunk); color: var(--ink-soft);
  transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .sidebar__themebtn:hover { background: var(--line); color: var(--ink); } }
.sidebar__themebtn.is-active { background: var(--brand-tint); color: var(--brand-ink); }
/* The theme menu's rows: label takes the width so the check sits at the right edge. */
.cardmenu__item--pick span { flex: 1; }

/* Segmented light/system/dark switcher, mobile ⋮ menu footer. */
.sidebar__theme { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-full); background: var(--surface-sunk); }
.sidebar__theme-btn {
  flex: 1; display: grid; place-items: center; height: 30px; font: inherit;
  border: none; border-radius: var(--r-full); background: transparent; color: var(--ink-faint);
  cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .sidebar__theme-btn:hover { color: var(--ink); } }
.sidebar__theme-btn[aria-pressed="true"] { background: var(--surface); color: var(--brand-ink); box-shadow: var(--shadow-1); }
/* The pressed state's box-shadow above outranks the global focus ring (higher
   specificity), so tabbing to the currently-active theme button showed no
   focus indicator at all — this outranks the pressed state in turn. */
.sidebar__theme-btn[aria-pressed="true"]:focus-visible { outline: none; box-shadow: var(--ring); }

/* The sidebar's scrollbar, should it ever need one: thin, and only while the pointer is over it. (On desktop
   the list between the logo and the footer is what scrolls, on the smallest windows: design.css.) */
.sidebar { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sidebar:hover { scrollbar-color: var(--line-strong) transparent; }

@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column; flex: none;
    width: 236px; position: sticky; top: var(--s-4); align-self: flex-start;
    height: calc(100vh - var(--s-4) * 2); overflow-y: auto;
    margin: var(--s-4) 0 var(--s-4) var(--s-4);
    padding: var(--s-5) var(--s-3);
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-lg);
  }
  /* Topbar stays on desktop but collapses to the language + bell + account
     controls, floating top-right over the content — the sidebar carries
     brand/nav/streak, and the language switcher lives up here. */
  .topbar { background: transparent; backdrop-filter: none; border-bottom: none; }
  .topbar__inner { justify-content: flex-end; padding-top: var(--s-4); padding-right: var(--s-6); }
  .topbar .brand,
  .topbar .streakbadge { display: none; }
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--canvas);   /* for browsers without color-mix(), which drop the next line */
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: var(--s-3) clamp(var(--s-4), 3vw, var(--s-7));
  display: flex; align-items: center; gap: var(--s-4);
}
.brand {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
  color: var(--ink); text-decoration: none;
}
.brand img { width: 30px; height: 30px; }
.topbar__spacer { flex: 1; }

.wordmark { display: inline-block; letter-spacing: -.02em; }
/* The name itself: Lexend Bold, tight and upright, with "Era" in the brand blue (js/lib/wordmark.js).
   Used wherever "PluggEra" stands next to the logo — the sidebar, the topbar, the front page, the sign-in page, the
   footer, the welcome screen and the profile card. */
.wordmark__text {
  display: inline-block; font-family: "Lexend", var(--font-display); font-weight: 700; letter-spacing: -.035em;
  font-size: 1.2em;   /* a touch larger than the text around it, so the name reads next to the logo */
}
.wordmark__text b { font-weight: inherit; color: var(--brand-ink); }
/* On the two panels that are a fixed dark colour in every theme: a lighter blue on the sign-in panel; on the profile card,
   which is itself blue, the whole name stays white. */
.auth__panelbrand .wordmark__text b { color: #8FB0FF; }
.idcard__brand .wordmark__text b { color: inherit; }

/* Bottom tab bar — mobile's primary nav (see js/main.js tabBar()). Fixed and
   thumb-reachable; hidden on desktop by the min-width:900px block above. */
.tabbar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--surface);   /* for browsers without color-mix(), which drop the next line */
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 0 7px; border: none; background: none; font: inherit; cursor: pointer;
  color: var(--ink-faint); text-decoration: none;
}
.tabbar__item svg { flex: none; }
.tabbar__item span { font-size: calc(10.5px * var(--fs-scale, 1)); font-weight: 600; }
.tabbar__item.is-active { color: var(--brand-ink); }
.tabbar__more { flex: 1; display: flex; }   /* not positioned: the menu below anchors to the whole bar */
/* Desktop carries the whole nav in the sidebar — hide the mobile bar. Placed
   after .tabbar's base rule so it wins the cascade (media queries add no
   specificity, so source order decides). */
@media (min-width: 900px) { .tabbar { display: none; } }

/* The "Meny" tab's popover — the full nav, opened upward from the bottom bar. */
/* A grid of icon-over-label tiles, spanning the width of the bar. The old
   one-per-row list was ~730px tall (~810 signed in) and scrolled on every small
   phone; this needs about 380px and never scrolls, down to a 568px-tall screen
   and in landscape. Tiles stay >= 60px tall, so they are easy targets. */
.topmenu__list {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 8px); z-index: 30;
  padding: 8px;
  max-height: calc(100vh - 90px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px;
}
.topmenu__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 62px; padding: 8px 2px; border-radius: var(--r-md); text-align: center;
  color: var(--ink); text-decoration: none; font-size: calc(10.5px * var(--fs-scale, 1)); line-height: 1.15; font-weight: 600;
  overflow-wrap: break-word; hyphens: auto;
}
@media (hover: hover) { @media (hover: hover) { .topmenu__item:hover { background: var(--surface-sunk); } } }
.topmenu__item svg { flex: none; width: 20px; height: 20px; color: var(--ink-soft); }
.topmenu__item.is-active { background: var(--brand-tint); color: var(--brand-ink); }
.topmenu__item.is-active svg { color: var(--brand-ink); }
.topmenu__group {
  margin: 8px 10px 2px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint);
}
/* In the grid the section headings and rules go: the tiles are self-explanatory,
   and letting them flow (instead of every section starting a new row) is what lets
   the menu fit narrow phones and landscape. Only the theme footer keeps a rule. */
.topmenu__list > .topmenu__group, .topmenu__list > .topmenu__div { display: none; }
/* Theme switcher tucked in the ⋮ menu's footer — the sidebar carries it on
   desktop, but there's no sidebar on mobile. */
.topmenu__foot { grid-column: 1 / -1; padding: 6px 4px 2px; border-top: 1px solid var(--line); }
body.has-topmenu .sitechat__fab { display: none; }
.topmenu__foot .topmenu__group { margin: 4px 0 6px; }
.topmenu__foot .sidebar__theme { width: 100%; }

@media (max-width: 560px) {
  .topbar__inner { gap: var(--s-2); padding-left: var(--s-3); padding-right: var(--s-3); }
  .topbar__inner .brand { font-size: var(--fs-md); }
  .topbar__inner .brand img { width: 40px; height: 40px; }   /* the buttons beside it are 44px tall: 26px read as lost next to them */
  /* Bell + account + ⋮ need the room; the streak already shows in the
     "Idag" panel and the language toggle stays. */
  .topbar__inner > .streakbadge { display: none; }
}
@media (max-width: 430px) {
  /* Leaderboard + notifications + account + language + ⋮ is a lot of chrome on
     a small phone — drop the wordmark and let the logo carry the home link. */
  .topbar__inner .brand__name { display: none; }
  /* Alone, the logo sits in the middle of the room between the screen edge and the language button,
     not against the edge. */
  .topbar__inner > .topbar__spacer { display: none; }
  .topbar__inner .brand { flex: 1 1 auto; justify-content: center; }
  .topbar__inner .brand img { transform: translateX(-8px); }   /* a little left of the middle, to the eye the logo reads centred */
}

/* "← Home" control at the top of every sub-screen. */
.homebtn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft);
  padding: 5px 12px 5px 8px; border-radius: var(--r-full);
  border: 1px solid var(--line-strong); background: var(--surface);
  margin-bottom: var(--s-4);
  /* Stay pill-sized inside grid/flex-column page wrappers instead of stretching. */
  justify-self: start; align-self: flex-start;
}
@media (hover: hover) { .homebtn:hover { color: var(--brand); border-color: var(--brand); } }
.homebtn { text-decoration: none; }
@media (hover: hover) { .homebtn:hover { text-decoration: none; } }
/* With the sidebar on screen, "← Home" at the top and "Back to menu" at the foot of a page only
   repeat it. Both stay on phones and on full-screen routes (a session, a worksheet), where the
   sidebar is gone. */
@media (min-width: 900px) {
  body:not(.route-immersive) .homebtn:not(.psheet__bar .homebtn),
  body:not(.route-immersive) .pageback { display: none; }
}
.homebtn svg { flex: none; }
.psheet__bar .homebtn { margin-bottom: 0; }
/* Phones: the tab bar already leads home, so "← Home" is a quiet text link rather than a bordered pill
   (still 44px tall to tap, see the phone block further down), and it sits closer to the title. :root
   lifts it over design.css's .homebtn border. */
@media (max-width: 899.98px) {
  :root .homebtn { border-color: transparent; background: transparent; padding-inline: 2px 10px; margin-left: -2px; }
  :root .homebtn:not(.psheet__bar .homebtn) { margin-bottom: var(--s-1); }
  @media (hover: hover) { :root .homebtn:hover { border-color: transparent; } }
}

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 38px; height: 38px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .iconbtn:hover { background: var(--surface-sunk); border-color: var(--line-strong); } }
/* Same cascade collision as .btn above: .iconbtn's own resting shadow otherwise
   silently beats the global focus ring on equal specificity + later source order. */
.iconbtn:focus-visible { outline: none; box-shadow: var(--ring); }
.iconbtn svg { stroke-width: 1.8; }

/* Language toggle: the globe alone is ambiguous, so it carries the code it
   will switch to. */
.langbtn { position: relative; width: auto; min-width: 40px; gap: 5px; padding: 0 10px; }
.langbtn__flag { display: inline-flex; flex: none; }
.langbtn__flag svg { width: 18px; height: auto; display: block; border-radius: 2px; }
.langbtn__code { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .03em; }

.content {
  flex: 1;
  max-width: var(--maxw); width: 100%; margin: 0 auto;
  padding: var(--s-6) clamp(var(--s-4), 3vw, var(--s-7)) var(--s-8);
  /* Column, so the footer can sit at the bottom of a short page (margin-top:auto)
     instead of floating right under the content. */
  display: flex; flex-direction: column; row-gap: var(--s-8);
}
.content > * { min-width: 0; }
@media (max-width: 899.98px) {
  /* Room for the fixed bottom tab bar so page content — and anything that
     floats at the bottom, like the solve-screen hint — never sits under it.
     Immersive routes (a running session, print) drop the tab bar, so no
     clearance is needed and the session's own hint button owns the bottom. */
  /* Tab bar + the chat bubble above it, so the last row can scroll clear of both. */
  .shell:not(.shell--immersive) .content { padding-bottom: calc(70px + 56px + var(--s-5) + env(safe-area-inset-bottom, 0)); }
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md);
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 10px 18px; min-height: 42px; border-radius: var(--r-md);
  font-size: .95rem; letter-spacing: -.005em;
  border: none; cursor: pointer; text-decoration: none;
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast), color var(--dur-fast);
}
/* Darken on hover rather than lift: a button that jumps reads as a toy. */
@media (hover: hover) { .btn:hover { background: color-mix(in srgb, var(--brand) 86%, #000); } }
/* .btn's own resting box-shadow above has the same specificity as the global
   :focus-visible rule (app.css:29) and comes later in the file, so it silently
   wins and a tabbed-to button shows no ring at all — this restores it by
   outranking both .btn and .btn--ghost's box-shadow on specificity alone. */
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn--ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
@media (hover: hover) { .btn--ghost:hover { background: var(--surface-sunk); } }
.btn--ok { background: var(--ok); }
@media (hover: hover) { .btn--ok:hover { background: color-mix(in srgb, var(--ok) 86%, #000); } }
.btn--danger { background: var(--c-berry-ink); color: #fff; }
@media (hover: hover) { .btn--danger:hover { background: color-mix(in srgb, var(--c-berry-ink) 86%, #000); } }
.btn--sm { padding: 6px 12px; min-height: 34px; font-size: var(--fs-sm); border-radius: 8px; }
/* Not opacity — 0.5 on a coloured button drops the label to ~2.3:1 and reads as
   broken rather than "not yet". Explicit muted colours stay legible. */
.btn:disabled {
  cursor: not-allowed; transform: none; box-shadow: none;
  background: var(--surface-sunk); color: var(--ink-faint);
  /* Softer edge than a ghost button's --line-strong, so "disabled" and
     "secondary action" do not end up looking like the same control. */
  border: 1px solid var(--line);
}
@media (hover: hover) { .btn:disabled:hover { transform: none; box-shadow: none; background: var(--surface-sunk); } }

/* ---------- cards & panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card, var(--shadow-1));
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-card, var(--shadow-1)); }

/* ---------- menu / home ---------- */
.home__head { margin-bottom: var(--s-5); }
.home__starter { margin-bottom: var(--s-5); }
.home__cta { display: flex; gap: var(--s-2); flex-wrap: wrap; }
/* The starter-set suggestion under a new student's head. */
.home-suggest {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center;
  width: 100%; max-width: 520px; margin-top: var(--s-4); padding: var(--s-3) var(--s-4);
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--dur-fast);
}
@media (hover: hover) { .home-suggest:hover { border-color: var(--brand); } }
.home-suggest:disabled { opacity: .6; cursor: progress; }
.home-suggest > svg { color: var(--ink-faint); }
.home-suggest__ic {
  width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-ink);
}
.home-suggest__body { display: flex; flex-direction: column; min-width: 0; }
.home-suggest__eyebrow { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.home-suggest__title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-suggest__meta { font-size: var(--fs-sm); color: var(--ink-soft); }
/* Solve / Library / New-set — a row on its own, between the "Idag" panel
   and "Dina set". */

.tabs { display: inline-flex; background: var(--surface-sunk); border-radius: var(--r-full); padding: 4px; gap: 4px; }
.tab {
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-sm);
  border: none; background: transparent; color: var(--ink-soft);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-full); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
/* How many sets each tab holds. */
.tab__n { margin-left: 6px; font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tab__n { color: var(--ink-soft); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-4); }
.chip {
  font-size: var(--fs-sm); font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-soft); padding: 6px var(--s-3); border-radius: var(--r-full); cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring);
  display: inline-flex; align-items: center; gap: 6px;
}
@media (hover: hover) { .chip:hover { transform: translateY(-1px); } }
.chip__dot { width: 10px; height: 10px; border-radius: var(--r-full); background: var(--subject, var(--ink-faint)); }
.chip[aria-pressed="true"] { color: #fff; background: var(--subject-ink, var(--brand)); border-color: transparent; }
.chip[aria-pressed="true"] .chip__dot { background: rgba(255,255,255,.85); }
/* A subject the user pre-added — no sets under it yet. */
.chip--empty:not([aria-pressed="true"]) { opacity: .5; }
/* "+ add subject" control at the end of the row, and its inline input. */
.chip--add { color: var(--ink-faint); border-style: dashed; padding-inline: 9px; }
@media (hover: hover) { .chip--add:hover { color: var(--brand); border-color: var(--brand); } }
.chip--add svg { display: block; }
.chip--addinput { width: 130px; font: inherit; font-size: var(--fs-sm); font-weight: 600; padding: 5px var(--s-3); color: var(--ink); }
.chip--addinput:focus-visible { border-color: var(--brand); outline: none; }

/* ---------- today strip ---------- */
.today { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.tile {
  display: flex; align-items: center; gap: var(--s-3); text-decoration: none; color: inherit;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast);
}
@media (hover: hover) { .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); } }
.tile strong { display: block; font-family: var(--font-display); font-size: var(--fs-md); }
.tile__sub { display: block; font-size: var(--fs-sm); color: var(--ink-soft); }
.tile__icon {
  width: 36px; height: 36px; flex: none; border-radius: var(--r-full);
  display: grid; place-items: center; background: var(--surface-sunk); color: var(--ink-soft);
}
.tile--accent { border-color: var(--brand); background: var(--brand-tint); }
.tile--accent .tile__icon { background: var(--brand); color: #fff; }

/* "Continue where you left off" — the loudest tile on the strip. */
.tile--resume {
  border-color: var(--brand); border-left-width: 4px;
  background: var(--brand-tint);
  box-shadow: 0 3px 18px -5px color-mix(in srgb, var(--brand) 55%, transparent);
}
@media (hover: hover) { .tile--resume:hover { box-shadow: 0 6px 24px -6px color-mix(in srgb, var(--brand) 60%, transparent); } }
.tile--resume .tile__icon { background: var(--brand); color: #fff; }
.tile--resume strong { color: var(--brand-ink); }

/* Streak / goal / weak-spot tiles all get the same glowing treatment as the
   top-bar streak badge, each in its own colour. */
.tile--streak {
  border-color: var(--line); border-color: color-mix(in srgb, var(--retry) 55%, var(--line));
  box-shadow: 0 2px 16px -4px color-mix(in srgb, var(--retry) 60%, transparent);
}
.tile--streak .tile__icon { background: var(--retry); color: #2B2B3A; }
:root[data-theme="dark"] .tile--streak .tile__icon { color: #21170C; }

.tile--goal {
  border-color: var(--line); border-color: color-mix(in srgb, var(--ok-bright) 55%, var(--line));
  box-shadow: 0 2px 16px -4px color-mix(in srgb, var(--ok-bright) 60%, transparent);
}
@media (hover: hover) { .tile--goal:hover { box-shadow: 0 5px 22px -5px color-mix(in srgb, var(--ok-bright) 65%, transparent); } }

.tile--weak {
  border-color: var(--line); border-color: color-mix(in srgb, var(--c-berry) 55%, var(--line));
  box-shadow: 0 2px 16px -4px color-mix(in srgb, var(--c-berry) 60%, transparent);
}
@media (hover: hover) { .tile--weak:hover { box-shadow: 0 5px 22px -5px color-mix(in srgb, var(--c-berry) 65%, transparent); } }
.tile--weak .tile__icon { background: var(--c-berry); color: #fff; }
:root[data-theme="dark"] .tile--weak .tile__icon { color: #3B1E2B; }

/* Calendar day chooser: subject dot in each row. */
.daymenu { z-index: 60; min-width: 190px; }
.daymenu__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------- home: "Today" + "Your sets" panels ---------- */
.home-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: var(--s-4) var(--s-5); margin-bottom: var(--s-5);
}
.home-panel__label {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md);
  color: var(--ink); margin-bottom: var(--s-3);
}
/* Quieter link-style text on the home page specifically (the achievements
   count, "switch to Tests", "Show all") — same elsewhere (Study, Progress,
   Settings, the Kommande dialog), just not underlined here. */
.home-panel .linkbtn { text-decoration: none; }

/* Backup nudge — a warm-tinted card so it reads as "attention" without alarm. */
.home-panel--backup { border-color: var(--line); border-color: color-mix(in srgb, var(--retry) 40%, var(--line)); background: var(--retry-tint); }
.home-panel--backup .home-panel__label { align-items: flex-start; }
.home-panel--backup .home-panel__label span { color: var(--retry-ink); }
.home-panel--backup .home-panel__label .linkbtn { flex: none; white-space: nowrap; font-size: var(--fs-sm); }
.home-panel--backup .note { color: var(--ink-soft); }

/* Two-column home page: the panels on the left, a sticky rail (upcoming
   deadlines + achievements teaser) on the right. Falls back to one column
   below 1100px, or whenever homeRail() has nothing to show. */
/* The home page is one column (views/menu.js): the greeting, the shortcuts, the focus card and the sets. */
.home-layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.home-main { min-width: 0; container: homemain / inline-size; }
.home-main > .focuscard { margin-bottom: var(--s-5); }

/* "Vad vill du plugga idag?" — the big shortcuts at the top of the home page. */
.home-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: var(--s-3); margin-bottom: var(--s-5);
}
/* Each tile is a card in the page's own colour with a faint tint of its hue
   (--tile, set per tile in menu.js), a neon edge with a soft glow, and the
   icon on a chip of the full colour. */
.home-tile {
  display: grid; gap: 14px; align-content: start; min-height: 148px; padding: 18px 16px;
  border-radius: var(--r-lg); color: var(--ink); text-decoration: none;
  background: var(--surface); background: color-mix(in oklab, var(--tile) 9%, var(--surface));
  border: 1.5px solid var(--tile);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tile) 25%, transparent), 0 0 18px -4px color-mix(in srgb, var(--tile) 55%, transparent);
  transition: box-shadow var(--dur-fast), transform var(--dur-fast);
}
@media (hover: hover) { .home-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tile) 45%, transparent), 0 0 26px -2px color-mix(in srgb, var(--tile) 70%, transparent);
} }
.home-tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.home-tile__ic {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--tile); color: #fff; box-shadow: 0 0 12px -2px color-mix(in srgb, var(--tile) 70%, transparent);
}
.home-tile b { display: block; font-size: calc(15px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink); }
.home-tile small { display: block; margin-top: 4px; font-size: calc(13px * var(--fs-scale, 1)); line-height: 1.4; color: var(--ink-soft); }
@media (max-width: 620px) {
  .home-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
  /* Icon beside the name, no description: five tiles in about 190px instead of 470px. */
  .home-tile { min-height: 0; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 10px 12px; }
  .home-tile__ic { width: 34px; height: 34px; border-radius: 10px; }
  .home-tile b { font-size: calc(14px * var(--fs-scale, 1)); line-height: 1.25; }
  .home-tile small { display: none; }
  .home-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* Every banner variant points at one of the tiles right above it. */
  .home-main .house-ad { display: none; }
}
/* Too narrow for five side by side (a laptop or Chromebook beside the rail, a big iPad, a tablet): three over two,
   each tile with its icon beside the words, so the block stays about as tall as one row of five. */
@container homemain (min-width: 521px) and (max-width: 829px) {
  .home-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .home-tile {
    grid-column: span 2; min-height: 0; grid-template-columns: auto minmax(0, 1fr); align-items: center;
    gap: 12px; padding: 14px;
  }
  .home-tile:nth-child(n + 4) { grid-column: span 3; }
  .home-tile small { margin-top: 2px; }
}
@media (prefers-reduced-motion: reduce) { @media (hover: hover) { .home-tile:hover { transform: none; } } }

/* Studify promoting Studify (see js/components/house-ad.js) — a tinted banner so it reads as
   "part of the app," not an inserted ad slot. */
.house-ad {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--brand-tint); border: 1px solid var(--brand); border-left-width: 4px;
  margin-bottom: var(--s-3);
}
.house-ad__ic { flex: none; color: var(--brand-ink); margin-top: 1px; }
.house-ad__body { flex: 1; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; min-width: 0; }
.house-ad__body strong { color: var(--brand-ink); font-size: var(--fs-sm); }
.house-ad__body span { color: var(--ink-soft); font-size: var(--fs-sm); }
.house-ad__x {
  flex: none; background: none; border: none; padding: 4px; margin: -4px -4px 0 0;
  color: var(--ink-faint); border-radius: var(--r-sm); cursor: pointer;
}
@media (hover: hover) { .house-ad__x:hover { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-ink); } }

.filterdrawer { display: flex; flex-direction: column; gap: var(--s-3); margin: var(--s-2) 0 var(--s-3); }
.filterdrawer .sortsel { align-self: flex-start; }
.filterdrawer__row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
/* "Filter": open, or with a filter left on, it reads as on; the count says how many. */
.filtertoggle.is-on { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-tint); }
.filtertoggle__n {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: var(--r-full); background: var(--brand); color: #fff;
  font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 700; font-variant-numeric: tabular-nums;
}
.filtertoggle .caret { display: inline-block; transition: transform var(--dur-fast); }
.filtertoggle[aria-expanded="true"] .caret { transform: rotate(180deg); }

/* ---------- calendar page: the month planner (js/views/calendar.js) ---------- */
.planner-page { display: flex; flex-direction: column; gap: var(--s-3); }
.planner-page__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); flex-wrap: wrap;
}
.planner-page__head h1 { margin: 0; }
.planner-page__sub { margin: 0 0 var(--s-2); max-width: 60ch; }

.planner { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); align-items: start; }
@media (min-width: 1180px) { .planner { grid-template-columns: minmax(0, 1fr) 300px; } }

/* --- month grid --- */
.plan-cal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--s-4);
}
.plan-cal__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.plan-nav { display: flex; gap: var(--s-1); flex: none; }
.plan-nav__btn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-soft); cursor: pointer; font-size: calc(17px * var(--fs-scale, 1)); line-height: 1;
  display: grid; place-items: center; transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .plan-nav__btn:hover { background: var(--surface-sunk); color: var(--ink); } }
.plan-cal__month {
  flex: 1; min-width: 0;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
  text-transform: capitalize; letter-spacing: -.01em;
}
.plan-cal__today { flex: none; }

.plan-cal__wd, .plan-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s-1); }
.plan-cal__wd { margin-bottom: var(--s-1); }
.plan-cal__wd span {
  padding-left: 4px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint);
}
.plan-cal__cell {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  min-height: 86px; padding: 4px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); overflow: hidden; font: inherit; color: inherit;
}
button.plan-cal__cell { cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast); }
@media (hover: hover) { button.plan-cal__cell:hover { background: var(--brand-tint); border-color: var(--brand-bright); } }
/* Days that have passed and the neighbouring months keep the same ground as the rest: only their number
   steps back, in a colour that still reads (darker blocks and opacity left a patchy grid, grey in the
   light theme, and chips at 1.9:1). Cells of the neighbouring months lose their frame instead. */
.plan-cal__cell.is-outside { background: transparent; border-color: transparent; }
.plan-cal__cell.is-past:not(.is-today) .plan-cal__date,
.plan-cal__cell.is-outside .plan-cal__date { color: var(--ink-faint); font-weight: 600; }
.plan-cal__cell.is-past .plan-cal__chip { background: var(--surface-sunk); color: var(--ink-soft); }
.plan-cal__cell.is-past .plan-cal__chip-x { background: var(--surface-sunk); }
.plan-cal__date {
  align-self: flex-end; padding: 1px 3px;
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.plan-cal__cell.is-today .plan-cal__date {
  background: var(--brand); color: #fff; border-radius: var(--r-full);
  min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px;
}

.plan-cal__chip {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 5px; border-radius: 5px;
  /* A set with no subject colour used to fall back to nothing (on paper, the same tan as the cell). The left edge is a
     3:1 marker that does not depend on the tint. */
  background: var(--subject-tint, var(--brand-tint)); color: var(--subject-text, var(--subject-ink, var(--brand-ink)));
  box-shadow: inset 3px 0 0 var(--subject, var(--brand));
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; line-height: 1.35; text-decoration: none;
  overflow: hidden;
}
@media (hover: hover) { .plan-cal__chip:hover { outline: 1px solid var(--subject); } }
/* A chip's × (removeBtn in views/calendar.js) shows on hover or keyboard focus, over the chip's right
   end; on a touch screen wide enough for chip titles it stays faintly visible. */
.plan-cal__chipwrap { position: relative; }
.plan-cal__chip-x {
  position: absolute; top: 0; right: 0; width: 24px; height: 24px; padding: 0;   /* 24 px is the smallest target WCAG 2.5.8 allows */
  display: grid; place-items: center; border: none; border-radius: 4px; cursor: pointer;
  background: var(--subject-tint, var(--surface-sunk)); color: var(--ink-soft);
  opacity: 0; transition: opacity var(--dur-fast), color var(--dur-fast);
}
.plan-cal__chipwrap:hover .plan-cal__chip-x, .plan-cal__chip-x:focus-visible { opacity: 1; }
@media (hover: hover) { .plan-cal__chip-x:hover { color: var(--ink); } }
.plan-cal__chip-x:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: none) and (min-width: 561px) { .plan-cal__chip-x { opacity: .8; } .plan-cal__chipwrap .plan-cal__chip { padding-right: 24px; } }   /* the × is always there: keep the title clear of it */
.plan-cal__chip-dot { width: 5px; height: 5px; border-radius: 2px; background: var(--subject); flex: none; }
.plan-cal__chip.is-test .plan-cal__chip-dot { border-radius: var(--r-full); }
/* Two lines before it is cut: "Prov · Samhällskunskap" doesn't fit one line of a day cell, and "Prov ·" says nothing. */
.plan-cal__chip-t {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  min-width: 0; hyphens: auto; overflow-wrap: anywhere;
}
.plan-cal__more {
  align-self: flex-start; padding: 1px 3px; font: inherit; font-size: calc(10.5px * var(--fs-scale, 1)); font-weight: 700;
  color: var(--ink-faint); background: none; border: none; cursor: pointer;
}
@media (hover: hover) { .plan-cal__more:hover { color: var(--brand-ink); } }

/* The "+" grows to fill whatever height the chips leave, so any empty part of
   a today/future cell is a click target. Hidden until the cell is hovered. */
.plan-cal__add {
  flex: 1 1 auto; align-self: stretch; min-height: 24px;   /* WCAG 2.5.8: a 24px minimum target */
  border: none; background: none; cursor: pointer; border-radius: 4px;
  display: grid; place-items: center; color: var(--ink-faint);
  opacity: 0; transition: opacity var(--dur-fast), background var(--dur-fast);
}
.plan-cal__cell:hover .plan-cal__add, .plan-cal__add:focus-visible { opacity: .75; }
.plan-cal__add:hover { background: var(--brand-tint); color: var(--brand-ink); opacity: 1; }
/* Touch, wide enough for it not to be clutter (tablet): a faint standing "+". */
@media (hover: none) and (min-width: 561px) { .plan-cal__add { opacity: .4; } }
/* Phone: no "+" (a grid of them is clutter at this size), but the whole cell is its target, the day's
   number included, and it lights up under the thumb. Chips stay on top as their own links. */
@media (hover: none) and (max-width: 560px) {
  .plan-cal__add { position: absolute; inset: 0; min-height: 0; opacity: 1; border-radius: inherit; }
  .plan-cal__add svg { display: none; }
  .plan-cal__add:active { background: var(--brand-tint); }
  .plan-cal__chip, .plan-cal__more { position: relative; z-index: 1; }
  .plan-cal__chip-x { display: none; }
  .plan-cal__date { pointer-events: none; }
}

/* --- agenda rail --- */
.plan-agenda { display: flex; flex-direction: column; gap: var(--s-4); }
.plan-agenda__head { margin: 0; font-size: var(--fs-md); color: var(--ink-soft); }
.plan-agenda__group { display: flex; flex-direction: column; gap: var(--s-2); }
.plan-agenda__gtitle {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin: 0;
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint);
}
/* Passed deadlines: closed by default, at the bottom of the agenda. */
.plan-agenda__past { padding-top: var(--s-2); border-top: 1px solid var(--line); }
.plan-agenda__past > summary { display: list-item; cursor: pointer; }
.plan-agenda__past[open] > summary { margin-bottom: var(--s-2); }
.plan-row.is-past { opacity: .75; border-style: dashed; }
.plan-agenda__count {
  font-size: calc(10.5px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint);
  background: var(--surface-sunk); border-radius: var(--r-full); padding: 0 6px;
}
.plan-agenda__rows { display: flex; flex-direction: column; gap: var(--s-2); }
.plan-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--subject, var(--brand));
  text-decoration: none; color: inherit;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
@media (hover: hover) { .plan-row:hover { background: var(--surface-sunk); } }
/* A row's link with an × beside it that removes the deadline (removeBtn in views/calendar.js). */
.plan-item { position: relative; }
.plan-item .plan-row { padding-right: 40px; }
.plan-row__x {
  position: absolute; right: 6px; top: 50%; translate: 0 -50%;
  width: 28px; height: 28px; padding: 0; border: none; border-radius: var(--r-full);
  display: grid; place-items: center; background: transparent; color: var(--ink-faint); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .plan-row__x:hover { background: var(--surface-sunk); color: var(--ink); } }
.plan-row__x:focus-visible { outline: none; box-shadow: var(--ring); }
/* Within two days: just the day word in the accent, as on the home page — no warning-coloured card. */
.plan-row.is-soon .plan-row__when { color: var(--brand-ink); font-weight: 600; }
.plan-row.is-overdue { border-color: var(--retry); border-left-color: var(--retry); background: var(--retry-tint); }
.plan-row__body { flex: 1; min-width: 0; }
.plan-row__title {
  display: block; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plan-row__meta { display: flex; align-items: center; gap: var(--s-2); font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-soft); }
.plan-row.is-overdue .plan-row__meta { color: var(--retry-ink); }
.plan-row__type {
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--brand-ink); background: var(--brand-tint); border-radius: var(--r-full); padding: 0 5px;
}
.plan-row.is-overdue .plan-row__type {
  color: var(--retry-ink); background: color-mix(in srgb, var(--retry) 22%, transparent);
}

.plan-agenda__empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2);
  padding: var(--s-6) var(--s-4); color: var(--ink-faint);
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
}
.plan-agenda__empty-t { margin: 0; font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.plan-agenda__empty .note { margin: 0; max-width: 34ch; }

@media (max-width: 560px) {
  .plan-cal { padding: var(--s-3); }
  .plan-cal__cell { min-height: 54px; }
  /* No room for titles on a phone — each deadline is a thin colour bar; the
     agenda below carries the detail. */
  .plan-cal__chip { padding: 0; height: 5px; border-radius: 3px; background: var(--subject); }
  .plan-cal__chip-t, .plan-cal__chip-dot { display: none; }
  .plan-cal__more { font-size: calc(9px * var(--fs-scale, 1)); }
}

/* ---------- upcoming deadlines ---------- */
.upcoming { margin-bottom: var(--s-4); }
.upcoming__title {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-md); margin-bottom: var(--s-3); color: var(--ink-soft);
}
.upcoming .cal { margin-bottom: var(--s-4); }
.upcoming__list { display: flex; flex-direction: column; gap: var(--s-2); }
.upcoming__row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px var(--s-3); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .upcoming__row:hover { border-color: var(--brand); } }
/* Passed: under "Passerade", quieter than what is still ahead. */
.upcoming__row.is-past { background: transparent; border-style: dashed; }
.upcoming__row.is-past .upcoming__main strong { color: var(--ink-soft); }
.upcoming__dot {
  width: 8px; height: 8px; flex: none; border-radius: var(--r-full);
  background: var(--subject, var(--brand));
}
.upcoming__main { flex: 1; min-width: 0; }
.upcoming__main strong {
  display: block; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.upcoming__go { flex: none; color: var(--ink-faint); display: grid; place-items: center; }
.upcoming__row:hover .upcoming__go { color: var(--brand); }

/* ---------- daily goal ring ---------- */
.ring--goal { width: 34px; height: 34px; }
.ring--goal .ring__fg { stroke: var(--brand); }
.ring--goal .ring__label { font-size: calc(13px * var(--fs-scale, 1)); fill: var(--ink); }
/* Goal met: full ring goes green and the count is replaced by a check (the
   number moves to the label beside the ring). */
.ring--goal-done .ring__fg { stroke: var(--ok); }
.ring--goal .ring__check { stroke: var(--ok); }
.tile--goal .ring { flex: none; }

/* ---------- calendar (js/components/calendar.js) ---------- */
.cal__nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.cal__month {
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm);
  letter-spacing: .01em;
}
/* Only the first letter: "Oktober 2026", but a week range keeps Swedish lowercase months ("5 okt. – 11 okt."). */
.cal__month::first-letter { text-transform: uppercase; }
.cal__navbtn {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-soft); cursor: pointer; font-size: calc(18px * var(--fs-scale, 1)); line-height: 1;
  display: grid; place-items: center;
}
@media (hover: hover) { .cal__navbtn:hover { background: var(--surface-sunk); color: var(--ink); } }
.cal__week, .cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal__week { margin-bottom: 4px; }
.cal__wd {
  text-align: center; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--ink-faint); padding: 4px 0;
}
.cal__grid { gap: 2px; }
.cal__cell {
  position: relative; aspect-ratio: 1; min-height: 34px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; font: inherit; font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
  color: var(--ink); cursor: default;
}
button.cal__cell { cursor: pointer; }
@media (hover: hover) { button.cal__cell:hover:not(:disabled) { background: var(--surface-sunk); } }
.cal__cell.is-outside { color: var(--ink-faint); }
.cal__cell.is-today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--line-strong); }
.cal__cell.is-selected {
  background: var(--brand); color: #fff; font-weight: 700;
  box-shadow: none;
}
.cal__cell:disabled { color: var(--ink-faint); opacity: .55; }
.cal__cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.cal__dot {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: var(--r-full); background: var(--brand);
}
/* More than one deadline that day — a wider pill hints "there's a few". */
.cal__dot--multi { width: 12px; }
.cal__cell.is-marked { color: var(--brand-ink); font-weight: 700; }
@media (hover: hover) { .cal--mini .cal__cell.is-marked:hover { background: var(--brand-tint); } }

/* Empty future day — a faint "+" on hover/focus says "tap to add a set here". */
.cal__cell.is-addable .cal__add {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  font-size: calc(12px * var(--fs-scale, 1)); line-height: 1; color: var(--ink-faint); opacity: 0;
  transition: opacity var(--dur-fast);
}
.cal__cell.is-addable:hover .cal__add,
.cal__cell.is-addable:focus-visible .cal__add { opacity: 1; }
@media (hover: hover) { .cal__cell.is-addable:hover { background: var(--brand-tint); color: var(--brand-ink); } }

.datepick { display: block; }
.datepick__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s-3); }
.datepick__chip {
  font-size: var(--fs-sm); font-weight: 600; font-family: var(--font-display);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-soft); padding: 5px var(--s-3); border-radius: var(--r-full);
  cursor: pointer; transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast);
}
@media (hover: hover) { .datepick__chip:hover { transform: translateY(-1px); border-color: var(--brand); color: var(--ink); } }

/* ---------- search & sort ---------- */
/* Tabs on the left, search + sort on the right, wrapping to two rows when
   there is not enough width for both. */
.librarybar {
  display: flex; align-items: center; gap: var(--s-3);
  flex-wrap: wrap; margin-bottom: var(--s-3);
}
.librarybar .tabs { flex: none; }
/* Phone: the tabs and Filter share the first row, the search takes the whole second one. */
@media (max-width: 560px) {
  .librarybar .search { order: 3; flex: 1 0 100%; }
  .librarybar .tabs { flex: 1; }
  .librarybar .tab { flex: 1; }
  /* Studera: the tabs get the first row; search, Filter and Välj share the second, so Välj isn't left alone. */
  .study-page .librarybar .tabs { flex: 1 0 100%; }
  .study-page .librarybar .search { flex: 1 1 120px; min-width: 0; }
  .study-page .librarybar > .btn { order: 4; }
}
/* The Studera page (#/study): the title and its "+ New" button share a row. */
.study-page__sub { margin: 4px 0 18px; }
.librarybar .tools { flex: 1; min-width: 260px; margin-bottom: 0; justify-content: flex-end; }
.tools { display: flex; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 180px; color: var(--ink-faint); }
.search svg { position: absolute; left: 12px; pointer-events: none; }
.search__input {
  width: 100%; font: inherit; color: var(--ink);
  padding: var(--s-2) var(--s-3) var(--s-2) 38px;
  border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface);
}
.search__input:focus-visible { border-color: var(--brand); box-shadow: none; }
.linkbtn {
  font: inherit; font-size: inherit; padding: 0; border: none; background: none;
  color: var(--brand-ink); text-decoration: underline; cursor: pointer;
  position: relative;
}
/* Text-sized buttons (.linkbtn, .auth__link) are only ~21px tall. An invisible hit area around them
   reaches the 24px minimum target (WCAG 2.5.8) without moving anything — they often sit in a line
   of text, where padding would push the line apart. */
.linkbtn::after, .auth__link::after { content: ""; position: absolute; inset: -4px -2px; }
@media (hover: hover) { .linkbtn:hover { color: var(--brand); } }

.sortsel {
  font: inherit; padding: var(--s-2) var(--s-3); border-radius: var(--r-full);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-4); }

.acard {
  position: relative; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 6px solid var(--subject, var(--brand));
  border-radius: var(--r-md); padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-3); min-height: 148px;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-mid) var(--ease-spring), box-shadow var(--dur-mid);
  animation: pop-in var(--dur-mid) var(--ease-out) both;
}
@media (hover: hover) { .acard:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); } }
.acard:hover .acard__go { transform: translateX(3px); }
.acard__tag {
  align-self: flex-start; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--r-full);
  background: var(--subject-tint, var(--brand-tint)); color: var(--subject-text, var(--subject-ink, var(--brand-ink)));
}
.acard__title {
  font-family: var(--font-display); font-weight: 600; font-size: 1.125rem; line-height: 1.3;   /* 18: two lines hold most titles */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  -webkit-hyphens: auto; hyphens: auto;   /* a long compound breaks (with a hyphen where it can) instead of being cut off */
}
/* The card's top row: the subject (a dot in its colour, the name trimmed to one line) and the AI chip. */
.acard__top { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 22px; padding-right: 28px; }
.acard__subject {
  flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 7px;
  font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-soft);
}
.acard__dot { flex: none; width: 8px; height: 8px; border-radius: 3px; background: var(--subject, var(--brand)); }
.acard__subjectname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The bottom: a deadline and a run left part-way (with how far it got), then the count and the ring. */
.acard__foot { margin-top: auto; display: grid; gap: 8px; }
.acard__status { display: flex; align-items: center; gap: 6px; font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-soft); }
.acard__status svg { flex: none; color: var(--ink-faint); }
.acard__status.is-open, .acard__status.is-open svg { color: var(--brand-ink); }
.acard__status.is-late, .acard__status.is-late svg { color: var(--retry-ink); }
.acard__progress { height: 4px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; margin-top: -2px; }
.acard__progress i { display: block; height: 100%; border-radius: inherit; background: var(--subject, var(--brand)); }
.acard__meta { display: flex; align-items: center; justify-content: space-between; color: var(--ink-faint); font-size: var(--fs-sm); }
.acard__go { transition: transform var(--dur-mid) var(--ease-spring); }

.acard--new {
  border: 2px dashed var(--line-strong); border-left: 2px dashed var(--line-strong);
  align-items: center; justify-content: center; color: var(--ink-soft);
  font-family: var(--font-display); font-weight: 600; gap: var(--s-2); box-shadow: none;
}
@media (hover: hover) { .acard--new:hover { border-color: var(--brand); color: var(--brand-ink); } }

.empty { text-align: center; color: var(--ink-soft); padding: var(--s-7) var(--s-4); }
.empty svg { margin-bottom: var(--s-3); }
.empty > :is(h2, h3) + p { margin-top: var(--s-2); }

/* ---------- card ⋮ menu ---------- */
.acard { position: relative; }
.acard__menu {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 30px; height: 30px; border-radius: var(--r-full);
  display: grid; place-items: center; cursor: pointer;
  border: none; background: transparent; color: var(--ink-faint);
  opacity: 0; transition: opacity var(--dur-fast), background var(--dur-fast);
}
.acard:hover .acard__menu, .acard__menu:focus-visible { opacity: 1; }
/* The title is the card's button (views/menu.js): a plain-looking button whose ::after covers the whole card, so
   a tap anywhere opens the set, with the ⋮ menu (z-index 2) above it. The focus ring is drawn inside the card on
   that cover, since the card clips what is outside it. */
.acard__open {
  appearance: none; background: none; border: 0; padding: 0; margin: 0; color: inherit; text-align: left;
  cursor: pointer; width: 100%;
}
.acard__open::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.acard__open:focus-visible { outline: none; box-shadow: none; }
.acard__open:focus-visible::after { box-shadow: inset 0 0 0 3px var(--focus-color, var(--brand)); border-radius: var(--r-lg); }
@media (hover: hover) { .acard__menu:hover { background: var(--surface-sunk); color: var(--ink); } }
@media (hover: none) { .acard__menu { opacity: 1; } }

.cardmenu {
  position: absolute; z-index: 60; min-width: 180px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.cardmenu__item {
  display: flex; align-items: center; gap: var(--s-3);
  font: inherit; font-size: var(--fs-sm); text-align: left;
  padding: var(--s-2) var(--s-3); border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--ink); cursor: pointer;
}
@media (hover: hover) { .cardmenu__item:hover { background: var(--surface-sunk); } }
a.cardmenu__item { text-decoration: none; }   /* a link in a menu is a row, not underlined text */
.cardmenu__item--danger { color: var(--retry-ink); }
@media (hover: hover) { .cardmenu__item--danger:hover { background: var(--retry-tint); } }

.iconbtn--sm { width: 30px; height: 30px; }

/* ---------- mastery ring (small, on cards) ---------- */
.ring { --v: 0; width: 38px; height: 38px; flex: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring__label {
  font-family: var(--font-display); font-weight: 700; font-size: calc(12px * var(--fs-scale, 1));
  fill: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.ring .ring__bg { stroke: var(--line); }
.ring .ring__fg { stroke: var(--subject, var(--ok)); stroke-linecap: round;
  stroke-dasharray: 100 100; stroke-dashoffset: calc(100 - var(--v));
  transition: stroke-dashoffset var(--dur-slow) var(--ease-out); }

/* ---------- session ---------- */
.session__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-2); flex-wrap: wrap;
}
.session__headright { display: flex; align-items: center; gap: var(--s-2); }
/* Phones: when the controls wrap under a long title, keep them close to it, not a full gap away. */
@media (max-width: 899.98px) { .session__head { row-gap: var(--s-1); } }
/* The shortcuts button is the only affordance for the keyboard layer, so it
   stays visible at every width rather than hiding on small screens. */
.shortcutsbtn, .readingbtn { width: 36px; height: 36px; flex: none; }
/* Keyboard shortcuts are desktop-only value; on a phone the reading control
   is the one that earns its place. */
@media (max-width: 560px) { .shortcutsbtn { display: none; } }

/* Reading-comfort popover (anchored from the session header) */
.reading__t { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); padding: 4px 6px 6px; margin: 0; }
.reading__themes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 0 4px 6px; }
.reading__sw {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 4px 6px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; font: inherit; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-soft);
}
.reading__chip { width: 100%; height: 20px; border-radius: 6px; border: 1px solid var(--line); }
.reading__sw--light .reading__chip { background: #F5F7FC; }
.reading__sw--paper .reading__chip { background: #F1E7D0; }
.reading__sw--dark  .reading__chip { background: #0A0C11; }
.reading__sw.is-on { border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 1px var(--brand); }
.reading__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 8px 6px; border-top: 1px solid var(--line); }
.reading__k { font-size: var(--fs-sm); color: var(--ink-soft); }
.reading__seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-full); background: var(--surface-sunk); }
.reading__seg button { min-width: 30px; padding: 3px 0; border: none; background: transparent; border-radius: var(--r-full); cursor: pointer; color: var(--ink-faint); font-family: var(--font-display); line-height: 1; }
.reading__seg button.is-on { background: var(--surface); color: var(--brand-ink); font-weight: 700; box-shadow: var(--shadow-1); }
.reading__toggle { width: 40px; height: 22px; border-radius: var(--r-full); border: none; background: var(--line-strong); cursor: pointer; position: relative; flex: none; transition: background var(--dur-fast); }
.reading__toggle.is-on { background: var(--brand); }
.reading__knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--dur-fast); }
.reading__toggle.is-on .reading__knob { transform: translateX(18px); }

.session { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s-5); align-items: start; }
/* The empty track was 1.05:1 against the page — invisible until it had fill.
   The border gives the shape an edge without shouting. */
.progressbar {
  height: 10px; border-radius: var(--r-full); overflow: hidden; margin-bottom: var(--s-2);
  background: var(--surface); background: color-mix(in srgb, var(--ink) 20%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ink) 52%, var(--surface));
}
.progressbar__fill { height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--c-sky), var(--c-grape));
  width: 0%; transition: width var(--dur-slow) var(--ease-spring); }
.progress-label { font-size: var(--fs-sm); color: var(--ink-faint); }
/* One dot per question: done, saved for later (a skip), the current one.
   Empty dots use the same track contrast as .progressbar so they're visible. */
.progress-dots { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--s-2); }
.progress-dots span {
  flex: 1 1 0; min-width: 10px; max-width: 56px; height: 8px; border-radius: var(--r-full);
  background: var(--surface); background: color-mix(in srgb, var(--ink) 28%, var(--surface));
  transition: background var(--dur-fast);
}
.progress-dots .is-done { background: var(--ok); }
.progress-dots .is-now { background: var(--brand); }
.progress-dots .is-saved { background: transparent; box-shadow: inset 0 0 0 1.5px var(--retry); }

/* Bottom of every page — About/Terms/Privacy, deliberately not in the main
   nav. Shares .content's max-width by living inside it. */
.sitefooter {
  margin-top: auto; padding-top: var(--s-5); border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  font-size: var(--fs-sm); color: var(--ink-faint);
}
.sitefooter__brand {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display); font-weight: 700; color: var(--ink-soft);
}
.sitefooter__brand img { width: 20px; height: 20px; }
.sitefooter__links { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.sitefooter__links a { color: var(--ink-faint); text-decoration: none; }
@media (hover: hover) { .sitefooter__links a:hover { color: var(--ink-soft); text-decoration: underline; } }
/* Two tidy rows: logo, links and the social icon on the first; the small print on its own line. */
.sitefooter__copy { width: 100%; font-size: calc(12px * var(--fs-scale, 1)); order: 3; }
.sitefooter__social { display: flex; gap: var(--s-2); }

/* ---------- front page (#/welcome) ----------
   Rendered without the app shell, so this section owns its own header,
   footer and rhythm. Everything still comes from the app's tokens, so it
   follows theme (light / paper / dark) like every other screen. The one loud
   thing is the playable question card; everything around it stays quiet. */
.btn--lg { padding: 13px 24px; min-height: 50px; font-size: 1.0625rem; border-radius: 12px; }

.lp { position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow-x: clip; }

/* header */
.lp-head { padding: var(--s-5) var(--s-4) 0; }
.lp-head__inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
}
.lp-brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg);
  letter-spacing: -.01em; color: var(--ink); text-decoration: none;
}
.lp-brand img { width: 30px; height: 30px; }
.lp-head__actions { display: flex; align-items: center; gap: var(--s-3); }
.lp-head__actions .btn { white-space: nowrap; }
/* Phones: the front page header keeps the name at the size of the text around it (the larger size is for the rest of the
   app), and tighter buttons, so the logo, the name, the language pill and the buttons still fit in one row. */
@media (max-width: 480px) {
  .lp-brand .wordmark__text { font-size: 1em; }
}
@media (max-width: 420px) {
  .lp-brand { gap: 6px; }
  .lp-brand .wordmark__text { padding-right: 0; }
  .lp-head__actions { gap: var(--s-2); }
  .lp-head__actions .btn { padding-inline: 12px; }
  .lp-head__actions .lp-lang { padding-inline: 8px; }
}
/* On the narrowest phones the logo, language pill and "Open the app" no longer
   fit in one row — the wordmark steps aside (still read by screen readers). */
@media (max-width: 389.98px) {
  .lp-brand { position: relative; }
  .lp-brand span {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
}
.lp-lang {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-full);
  border: 1px solid var(--line-strong); background: var(--surface);
  font: inherit; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .03em;
  color: var(--ink-soft); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .lp-lang:hover { background: var(--surface-sunk); color: var(--ink); } }
.lp-lang__flag svg { width: 18px; height: auto; display: block; border-radius: 2px; }

.lp-main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--s-4); }

/* hero */
.lp-hero {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-7);
  align-items: start; padding: var(--s-7) 0 var(--s-8);
}
@media (min-width: 960px) {
  .lp-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 470px); gap: 64px; padding: 76px 0 88px; align-items: center; }
}
.lp-h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.4rem, 5.4vw, 3.6rem); line-height: 1.04; letter-spacing: -.04em;
  text-wrap: balance; color: var(--ink); margin: 0;
}
.lp-lead {
  margin-top: var(--s-5); max-width: 33em;
  font-size: clamp(1.02rem, 1.5vw, 1.2rem); line-height: 1.65; color: var(--ink-soft);
}
.lp-cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }
.lp-fineprint { margin-top: var(--s-4); max-width: 44ch; font-size: var(--fs-sm); line-height: 1.55; color: var(--ink-faint); }

/* A soft brand glow and a faint dot grid behind the hero, full-bleed like the trust bar. Behind
   everything (isolation keeps z-index:-1 inside the hero), and purely decorative. */
.lp-hero { position: relative; isolation: isolate; }
.lp-hero::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  top: -140px; bottom: 0; left: calc(50% - 50vw); right: calc(50% - 50vw);
  background:
    radial-gradient(40% 55% at 78% 42%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%),
    radial-gradient(30% 40% at 12% 18%, color-mix(in srgb, var(--c-sky, var(--brand)) 10%, transparent), transparent 70%);
}
.lp-hero::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  top: -140px; bottom: 0; left: calc(50% - 50vw); right: calc(50% - 50vw);
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 11%, transparent) 1px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(55% 70% at 75% 45%, #000 20%, transparent 75%);
          mask-image: radial-gradient(55% 70% at 75% 45%, #000 20%, transparent 75%);
}
.lp-hero__art { position: relative; }

/* the two notes floating around the question card (desktop only — on a phone they'd cover it) */
.lp-badge { display: none; }
@media (min-width: 1080px) {
  .lp-badge {
    position: absolute; z-index: 2; display: flex; align-items: center; gap: 10px; max-width: 260px;
    padding: 10px 14px; border-radius: var(--r-md); background: var(--surface);
    border: 1px solid var(--line); box-shadow: var(--shadow-2);
    font-size: var(--fs-sm); line-height: 1.35; color: var(--ink-soft);
  }
  .lp-badge b { display: block; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink); }
  .lp-badge__icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-ink); }
  /* Both hang off the card's corners, over the gap and the margin — never over the card's
     answers or the headline text to the left. */
  .lp-badge--hint { top: -52px; right: -34px; transform: rotate(2deg); }
  .lp-badge--repeat { bottom: -30px; left: -30px; transform: rotate(-1.5deg); }
  .lp-badge--repeat .lp-badge__icon { background: var(--ok-tint); color: var(--ok-ink); }
}

/* the playable question card */
.lp-q {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-2);
}
.lp-q__meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); }
.lp-q__meta b { font-weight: 700; color: var(--c-leaf-ink); }
.lp-q__count { font-weight: 600; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.lp-q__track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: var(--s-3) 0 var(--s-5); }
.lp-q__track i { height: 5px; border-radius: 3px; background: var(--surface-sunk); }
.lp-q__track i.is-done { background: var(--ok); }
.lp-q__track i.is-now { background: var(--brand); }
.lp-q__prompt {
  font-family: var(--font-display); font-weight: 700; font-size: 1.28rem;
  line-height: 1.32; letter-spacing: -.01em; color: var(--ink); margin: 0 0 var(--s-5);
}
.lp-q__opts { display: flex; flex-direction: column; gap: var(--s-2); }
.lp-q__opt {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left;
  padding: 13px var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1rem; cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .lp-q__opt:hover:not([aria-disabled="true"]) { border-color: var(--brand); background: var(--brand-tint); } }
.lp-q__opt:focus-visible { outline: none; box-shadow: var(--ring); }
.lp-q__opt b {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 800;
  background: var(--surface-sunk); color: var(--ink-soft);
}
.lp-q__opt.is-right { border-color: var(--ok); background: var(--ok-tint); color: var(--ok-ink); font-weight: 600; }
.lp-q__opt.is-right b { background: var(--ok); color: #fff; }
.lp-q__opt.is-right svg { margin-left: auto; }
.lp-q__opt.is-wrong { border-color: var(--retry); background: var(--retry-tint); color: var(--retry-ink); }
.lp-q__opt[aria-disabled="true"] { cursor: default; }
.lp-q__opt[aria-disabled="true"]:not(.is-right):not(.is-wrong) { opacity: .55; }
.lp-q__fb {
  display: flex; align-items: flex-start; gap: 8px; margin: var(--s-4) 0 0; min-height: 3.1em;
  font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-soft);
}
.lp-q__fb svg { flex: none; margin-top: 3px; }
.lp-q__fb.is-right { color: var(--brand-ink); }
.lp-q__fb.is-wrong { color: var(--retry-ink); }

/* trust bar — full-bleed edge to edge even though .lp-main itself is a
   centered, max-width column; the standard break-out-of-the-container trick
   rather than a second <main> landmark. calc(50% - 50vw) on both margins,
   not width:100vw + transform:translateX(-50%): that pairing mixes two
   different reference boxes (100vw is measured against the initial
   containing block, which on a platform with a classic, space-reserving
   scrollbar is wider than the visible viewport the transform then has to
   cancel out against) — a known source of a stray sliver at one edge or a
   horizontal scrollbar. calc(50% - 50vw) sidesteps it by never computing an
   explicit width at all. */
/* the browser-frame bar over the front page's app screenshot */
.lp-frame__bar {
  display: flex; align-items: center; gap: 7px; padding: 10px 14px;
  background: var(--surface-sunk); border-bottom: 1px solid var(--line);
}
.lp-frame__bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.lp-frame__bar span {
  margin: 0 auto; padding: 2px 40px; border-radius: 6px; background: var(--surface);
  font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); letter-spacing: .02em;
}

/* sections */
.lp-sec { padding: 56px 0 0; }
.lp-h2 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem); line-height: 1.1; letter-spacing: -.03em;
  text-wrap: balance; color: var(--ink); margin: 0;
}
.lp-sub { margin-top: var(--s-3); max-width: 52ch; color: var(--ink-soft); }

/* feature rows — text on one side, the thing itself on the other */
.lp-rows { margin-top: var(--s-6); }
.lp-row {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5);
  padding: 40px 0; border-top: 1px solid var(--line);
}
@media (min-width: 900px) {
  .lp-row { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 72px; align-items: center; }
}
.lp-row h3 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.4rem, 2.4vw, 1.85rem); line-height: 1.15; letter-spacing: -.02em;
  color: var(--ink); margin: 0 0 var(--s-3);
}
.lp-row p { max-width: 38ch; font-size: 1.05rem; line-height: 1.65; color: var(--ink-soft); margin: 0; }

/* library: the real subjects, then the four levels — one pill family for
   both, so the level row reads as part of the same system instead of a
   separate, disconnected element underneath. */
.lp-subjects { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.lp-subjects li {
  display: inline-flex; align-items: center;
  padding: 7px 15px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: -.005em;
  background: var(--subj-tint); color: var(--subj-ink);
}
.lp-levels {
  list-style: none; margin: var(--s-5) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px;
}
.lp-levels li {
  padding: 7px 15px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink);
  background: var(--surface-sunk);
}
/* The last level is the highest one — lp.levels is always ordered low to
   high — so it's the one worth a brand accent, not a decorative choice. */
.lp-levels li:last-child { background: var(--brand); color: #fff; }

/* own material: three inputs in, questions out */
.lp-src { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.lp-src ul { list-style: none; margin: 0; padding: 0; }
.lp-src li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); font-weight: 600; color: var(--ink); }
.lp-src li + li { border-top: 1px solid var(--line); }
.lp-src li svg { flex: none; color: var(--c-ocean-ink); }
.lp-src__out {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5);
  background: var(--brand-tint); color: var(--brand-ink); font-weight: 700; border-top: 1px solid var(--line);
}

/* repetition: the forgetting curve, with and without review */
.lp-curve { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.lp-curve__legend {
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-bottom: var(--s-3);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft);
}
.lp-curve__legend span { display: inline-flex; align-items: center; gap: 8px; }
.lp-curve__legend i { width: 26px; height: 0; border-top: 3px solid var(--brand); }
.lp-curve__legend i.is-dashed { border-top: 3px dashed var(--ink-faint); }
.lp-curve svg { display: block; width: 100%; height: auto; }
.lp-curve .grid { stroke: var(--line); stroke-width: 1; }
.lp-curve .without { fill: none; stroke: var(--ink-faint); stroke-width: 2.5; stroke-dasharray: 6 6; stroke-linecap: round; }
.lp-curve .with { fill: none; stroke: var(--brand); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.lp-curve .dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.lp-curve__axis { display: flex; justify-content: space-between; margin-top: var(--s-2); font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.lp-curve__note { margin: var(--s-2) 0 0; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }

/* Högskoleprovet: the eight delprov as an answer sheet */
.lp-sheet { display: grid; gap: var(--s-5); }
.lp-sheet h4 { margin: 0 0 var(--s-2); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); }
.lp-sheet__cells { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); }
@media (max-width: 520px) { .lp-sheet__cells { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lp-sheet__cell { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: var(--s-3); }
.lp-sheet__cell b { display: block; margin-bottom: var(--s-2); font-size: 1.05rem; font-weight: 800; letter-spacing: .01em; color: var(--ink); }
.lp-sheet__bubbles { display: flex; flex-wrap: wrap; gap: 4px; }
.lp-sheet__bubbles span {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint);
}
.lp-sheet__bubbles span.is-on { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* steps — a real sequence, so a real numeral */
.lp-steps { list-style: none; margin: var(--s-6) 0 0; padding: 0; display: grid; gap: var(--s-6); }
@media (min-width: 820px) { .lp-steps { grid-template-columns: repeat(3, 1fr); gap: var(--s-7); } }
.lp-step { border-top: 2px solid var(--ink); padding-top: var(--s-4); }
.lp-step__n {
  display: block; margin-bottom: var(--s-3); font-size: 2.4rem; font-weight: 800; line-height: 1;
  letter-spacing: -.04em; color: var(--brand); font-variant-numeric: tabular-nums;
}
.lp-step h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; color: var(--ink); margin: 0 0 8px; }
.lp-step p { font-size: 1rem; line-height: 1.6; color: var(--ink-soft); margin: 0; }

/* reviews — real quotes only, see js/data/reviews.js */
.lp-reviews { list-style: none; margin: var(--s-6) 0 0; padding: 0; display: grid; gap: var(--s-5); }
@media (min-width: 820px) { .lp-reviews { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.lp-review {
  margin: 0; height: 100%; display: flex; flex-direction: column; gap: var(--s-3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5);
}
.lp-review__stars { margin: 0; color: var(--brand); letter-spacing: .12em; font-size: 1rem; line-height: 1; }
.lp-review blockquote { margin: 0; flex: 1; }
.lp-review blockquote p { margin: 0; font-size: 1.02rem; line-height: 1.55; color: var(--ink); overflow-wrap: anywhere; }
.lp-review figcaption { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: var(--fs-sm); color: var(--ink-soft); }
.lp-review figcaption b { color: var(--ink); font-weight: 700; }

.lp-reviews__cta { margin-top: var(--s-5); font-size: var(--fs-sm); }

/* #/rate — star picker built from real radios */
.rate-stars { border: 0; margin: 0 0 var(--s-4); padding: 0; min-width: 0; }
.rate-stars legend { font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--s-2); padding: 0; }
.rate-stars__row { display: flex; gap: 4px; }
.rate-stars__star { position: relative; display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; border-radius: var(--r-sm); }
.rate-stars__star > span[aria-hidden] { font-size: calc(30px * var(--fs-scale, 1)); line-height: 1; color: var(--line-strong); transition: color .12s, transform .12s; }
.rate-stars__star.is-on > span[aria-hidden] { color: var(--brand); }
.rate-stars__star:hover > span[aria-hidden] { transform: scale(1.1); }
.rate-stars__input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.rate-stars__star:has(.rate-stars__input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.rate-count { display: block; margin-top: 4px; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); text-align: right; font-variant-numeric: tabular-nums; }
.field small.note { display: block; margin-top: 4px; }

/* #/admin/reviews */
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-review { display: grid; gap: var(--s-3); }
.admin-review blockquote { margin: 0; }
.admin-error { display: grid; gap: var(--s-2); }
.admin-error__head, .admin-error__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }
.admin-error__count { font-variant-numeric: tabular-nums; }
.admin-error__msg { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.admin-error__src { margin: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); overflow-wrap: anywhere; }
.admin-error__stack pre { margin: var(--s-2) 0 0; padding: var(--s-3); max-height: 260px; overflow: auto; font-size: calc(12px * var(--fs-scale, 1)); white-space: pre; background: var(--surface-sunk); border-radius: var(--r-md); }
.admin-review blockquote p { margin: 0; line-height: 1.55; overflow-wrap: anywhere; }
.admin-review .note { margin: 0; }

/* closer */
.lp-closer {
  display: grid; gap: var(--s-5); margin: var(--s-8) 0; padding-top: var(--s-7); border-top: 1px solid var(--line);
}
@media (min-width: 820px) { .lp-closer { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--s-7); } }
.lp-closer .lp-h2 { font-size: clamp(2rem, 4.6vw, 3.4rem); letter-spacing: -.035em; }

/* footer */
.lp-foot { border-top: 1px solid var(--line); padding: var(--s-6) var(--s-4); }
.lp-foot__inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-5);
  font-size: var(--fs-sm); color: var(--ink-faint);
}
.lp-foot__brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display); font-weight: 700; color: var(--ink-soft);
}
.lp-foot__brand img { width: 20px; height: 20px; }
.lp-foot__links { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.lp-foot__links a { color: var(--ink-faint); text-decoration: none; }
@media (hover: hover) { .lp-foot__links a:hover { color: var(--ink-soft); text-decoration: underline; } }
.lp-foot__social { display: flex; gap: var(--s-2); }
.lp-foot__social-link, .sitefooter__social-link {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-sunk); color: var(--ink-faint);
  transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .lp-foot__social-link:hover, .sitefooter__social-link:hover { background: var(--brand-tint); color: var(--brand-ink); } }
.lp-foot__social-link:focus-visible, .sitefooter__social-link:focus-visible { outline: none; box-shadow: var(--ring); }
.lp-foot__copy { width: 100%; font-size: calc(12px * var(--fs-scale, 1)); }
@media (min-width: 760px) { .lp-foot__copy { width: auto; } }

/* The chat bubble is app furniture — it has no place on the front page. */
body.no-chrome .sitechat__fab,
body.no-chrome .sitechat__panel { display: none; }

@media (prefers-reduced-motion: reduce) {
  .lp-q__opt, .lp-lang { transition: none; }
}

.question { margin-top: var(--s-4); }
/* Which subject and set a question in a mixed run (Repetition, weak spots) comes from. */
.question__from { margin: var(--s-3) 0 0; color: var(--ink-soft); font-size: var(--fs-sm); font-weight: 600; }
.question__from + .question { margin-top: var(--s-2); }
.question__again { display: inline-flex; align-items: center; gap: 6px; margin: var(--s-3) 0 0; padding: 4px 10px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); background: var(--c-tangerine-tint); }
.question__again + .question { margin-top: var(--s-2); }

/* ---------- Högskoleprovet: figure + stimulus + KVA/NOG panels ---------- */
.question__figure { margin: 0 0 var(--s-4); }
/* The SVG figures pick their ink with prefers-color-scheme (an <img> can't see
   the app's own theme toggle), so the ground has to follow the OS too — else
   an OS-dark visitor on the light theme gets pale ink on white, and vice versa. */
.question__figure img {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: var(--r-md); background: #fff;
}
@media (prefers-color-scheme: dark) {
  .question__figure img { background: #161a23; }
}
/* Tap to enlarge (questions.js openFigure): the picture is a pointer target; the button under it, on
   phones only (where the labels are small), is the control. Under it, not on it: any corner of a
   chart can hold an axis label. */
.question__figure img { cursor: zoom-in; }
.question__figzoom {
  display: flex; align-items: center; gap: 6px; width: fit-content; min-height: 36px; margin: 4px 0 0 auto; padding: 0 8px;
  border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--brand-ink);
}
@media (hover: hover) { .question__figzoom:hover { background: var(--brand-tint); } }
.question__figzoom:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (min-width: 900px) { .question__figzoom { display: none; } }
.figview {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column;
  background: #0a0d14; animation: sitechat-in var(--dur-mid) var(--ease-out);
}
.figview__bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--s-4) 10px;
}
.figview__hint { margin: 0; font-size: calc(13.5px * var(--fs-scale, 1)); color: #c3c9d6; }
.figview__close { width: 44px; height: 44px; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.figview__scroll {
  flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain;
  display: flex; padding: var(--s-4); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s-4));
}
.figview__img {
  flex: none; margin: auto; width: min(100%, 960px); height: auto; max-height: 100%; object-fit: contain;
  border-radius: var(--r-md); background: #fff; cursor: zoom-in;
}
/* Zoomed: twice the fitted size (and never so small that the labels stay tiny), panned by scrolling. */
.figview.is-zoomed .figview__img { width: max(200%, 680px); max-width: none; max-height: none; cursor: zoom-out; }
@media (prefers-color-scheme: dark) { .figview__img { background: #161a23; } }
@media (prefers-reduced-motion: reduce) { .figview { animation: none; } }
.question__figure figcaption { font-size: var(--fs-sm); color: var(--ink-faint); margin-top: var(--s-2); }
.question__figure--missing {
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4); background: var(--surface-sunk); color: var(--ink-soft);
  font-size: var(--fs-sm);
}
.question__figure--missing b {
  display: block; text-transform: uppercase; letter-spacing: .05em; font-size: calc(12px * var(--fs-scale, 1));
  color: var(--ink-faint); margin-bottom: var(--s-1);
}
.question__stimulus {
  margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--r-sm); background: var(--surface-sunk);
  max-height: 42vh; overflow: auto;
}
.question__stimulus-label {
  margin: 0 0 var(--s-2); font-size: calc(12px * var(--fs-scale, 1)); letter-spacing: .06em; text-transform: uppercase;
  color: var(--brand-ink); font-weight: 700;
}
.question__stimulus-body { font-size: var(--fs-sm); line-height: 1.6; color: var(--ink-soft); }
.question__stimulus-body br { content: ""; display: block; margin-bottom: .5em; }
/* The shared text above a follow-up question: the same panel as a stimulus, but it can be folded away. */
.question__passage {
  margin: 0 0 var(--s-4); padding: var(--s-2) var(--s-4);
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--r-sm); background: var(--surface-sunk);
}
.question__passage > summary { cursor: pointer; padding: var(--s-1) 0; font-weight: 700; color: var(--brand-ink); }
.question__passage[open] > summary { margin-bottom: var(--s-2); }
.question__passage .question__stimulus-body { max-height: 38vh; overflow: auto; padding-bottom: var(--s-2); white-space: pre-line; }

.hp-kva {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden;
  margin: 0 0 var(--s-4);
}
.hp-kva__col { padding: var(--s-3) var(--s-4); background: var(--surface-sunk); }
.hp-kva__col h2 {   /* h2, not h4: the part's title is level 1, so these are its sections */
  margin: 0 0 var(--s-1); font-size: calc(12px * var(--fs-scale, 1)); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700;
}
.hp-kva__q { font-size: var(--fs-lg); color: var(--ink); }
.hp-kva__div { width: 1px; background: var(--line-strong); }
.hp-kva__given {
  grid-column: 1 / -1; border-top: 1px dashed var(--line-strong);
  padding: var(--s-2) var(--s-4); font-size: var(--fs-sm); color: var(--ink-soft); background: var(--surface);
}
@media (max-width: 480px) {
  .hp-kva { grid-template-columns: 1fr; }
  .hp-kva__div { width: auto; height: 1px; }
}

.hp-nog__stmts { display: flex; flex-direction: column; gap: var(--s-2); margin: 0 0 var(--s-4); }
.hp-nog__stmt {
  display: flex; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-sunk);
  font-size: var(--fs-sm); color: var(--ink-soft);
}
.hp-nog__stmt b { flex: none; color: var(--ink); }

/* the normed-score reveal, sibling of .gradereveal */
.gradereveal--hp .gradereveal__letter { font-variant-numeric: tabular-nums; }
.gradereveal--hp:not(.gradereveal--low):not(.gradereveal--high) {
  background: var(--brand-tint); border-color: var(--brand);
}

/* #/hp dashboard (views/hp.js): an overview card (the estimate on the test's own 0,0–2,0 scale,
   the test day as a calendar page, next steps), then the eight delprov laid out as the test is —
   a verbal and a quantitative half, each in its own colour (--c / --c-ink, set per half in the JS). */
.hp-dash { display: grid; gap: var(--s-5); }
.hp-dash__intro h1 { margin: 0; }
.hp-dash__intro p { margin: 6px 0 0; max-width: 62ch; color: var(--ink-soft); }
.hp-dash__body { display: grid; gap: var(--s-6); min-width: 0; }

.hp-hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.hp-hero__main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); }
.hp-hero__score { padding: var(--s-5) var(--s-6) var(--s-5) var(--s-5); min-width: 0; }
.hp-hero__date { padding: var(--s-5); border-left: 1px solid var(--line); display: grid; align-content: start; gap: var(--s-3); min-width: 0; }
.hp-hero__label { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.hp-hero__figure { display: flex; align-items: flex-end; gap: var(--s-5); margin-top: 2px; }
.hp-hero__big {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(3rem, 7vw, 4.25rem); line-height: 1;
  letter-spacing: -.035em; color: var(--ink); font-variant-numeric: tabular-nums;
}
.hp-hero__empty { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); letter-spacing: -.015em; color: var(--ink-faint); padding-block: 14px 6px; }
.hp-hero__trend { width: 150px; max-width: 40%; padding-bottom: 6px; }
.hp-hero__trend .sparkline { height: 34px; }
.hp-hero__parts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-4); font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-part { display: inline-flex; align-items: center; gap: 8px; }
.hp-part i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.hp-part b { color: var(--ink); font-variant-numeric: tabular-nums; }
.hp-hero__hint { margin: var(--s-4) 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-hero__caption { margin: var(--s-2) 0 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }

/* The scale: a track with the estimate filled in, a needle for the total and a dot per half, over a
   ruler with a tick every 0,1 and a labelled one every 0,5. */
.hp-scale { margin-top: var(--s-5); padding-top: 10px; }
.hp-scale__track { position: relative; height: 12px; border-radius: var(--r-full); background: var(--surface-sunk); }
.hp-scale__fill {
  position: absolute; inset: 0 auto 0 0; width: var(--x); border-radius: inherit;
  background: var(--surface-sunk); background: color-mix(in oklab, var(--brand) 30%, var(--surface-sunk));
}
.hp-scale__dot {
  position: absolute; top: 50%; left: var(--x); width: 14px; height: 14px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--c); box-shadow: 0 0 0 2.5px var(--surface);
}
.hp-scale__needle {
  position: absolute; top: -10px; bottom: -10px; left: var(--x); width: 3px; border-radius: 2px;
  transform: translateX(-50%); background: var(--ink); box-shadow: 0 0 0 2px var(--surface);
}
.hp-scale__labels { position: relative; height: 34px; margin-top: 12px; }
.hp-scale__labels::before, .hp-scale__labels::after { content: ""; position: absolute; left: 0; top: 0; width: calc(100% + 1px); }
.hp-scale__labels::before { height: 5px; background: repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 5%); }
.hp-scale__labels::after { height: 9px; background: repeating-linear-gradient(90deg, var(--ink-faint) 0 1px, transparent 1px 25%); }
.hp-scale__labels span {
  position: absolute; top: 14px; left: var(--x); transform: translateX(-50%);
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.hp-scale__labels span:first-child { transform: none; }
.hp-scale__labels span:last-child { transform: translateX(-100%); }

/* The test day as a small calendar page. */
.hp-day { display: flex; align-items: center; gap: var(--s-4); }
.hp-day__page {
  flex: none; width: 66px; display: grid; justify-items: center; overflow: hidden;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-1);
}
.hp-day__month {
  justify-self: stretch; text-align: center; padding: 3px 0 2px; text-transform: capitalize;
  font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 700; color: #fff; background: var(--brand);
}
.hp-day__num { font-family: var(--font-display); font-size: calc(28px * var(--fs-scale, 1)); line-height: 1.05; margin-top: 4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.hp-day__wday { font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); margin-bottom: 6px; }
.hp-day__txt { display: grid; gap: 2px; min-width: 0; }
.hp-day__txt strong { font-family: var(--font-display); font-size: var(--fs-lg); letter-spacing: -.01em; color: var(--ink); }
.hp-day__txt > span { font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-day__edit { justify-self: start; margin-top: 4px; font-size: var(--fs-sm); }
.hp-hero__prompt { margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-hero__pick { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: flex-start; }

.hp-hero__next {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line);
  background: var(--surface); background: color-mix(in oklab, var(--surface-sunk) 45%, var(--surface));
}

/* The dated plan and the weak topics, side by side when there are both. */
.hp-side { display: grid; gap: var(--s-4); align-items: start; }
@media (min-width: 900px) { .hp-side.is-two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.hp-dash .exam-prep__day[hidden] { display: none; }
.hp-plan__more { padding: 6px 10px; }
.hp-plan__more .linkbtn { font-size: var(--fs-sm); }

/* The delprov: eight tiles in the test's two halves. A tile names the delprov, its level and its
   calibration, and opens the delprov's own page (#/hp/<dp>). */
.hp-board { display: grid; gap: var(--s-5); }
.hp-board__head h2 { margin: 0; font-size: var(--fs-xl); letter-spacing: -.015em; }
.hp-board__head p { margin: 4px 0 0; max-width: 70ch; font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-group { display: grid; gap: var(--s-3); }
.hp-group__title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: var(--fs-md); }
.hp-group__title i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }

/* The knowledge map on the HP hub (views/hp.js knowledgeMap): a row per delprov, a chip per topic, coloured by
   how the latest answers went. The colour is never the only cue: each chip shows its score, and the legend
   and the screen-reader label name the level. */
.hp-map__rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.hp-map__row { display: grid; grid-template-columns: 3.4em minmax(0, 1fr); align-items: start; gap: var(--s-3); }
.hp-map__dp { font-weight: 700; font-family: var(--font-display); color: var(--c-ink, var(--ink)); text-decoration: none; padding-top: 7px; }
.hp-map__dp:hover { text-decoration: underline; }
.hp-map__chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.hp-mapchip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px;
  border-radius: var(--r-full); border: 1.5px solid var(--line-strong); background: var(--surface);
  color: var(--ink); text-decoration: none; font-size: var(--fs-sm); line-height: 1.2;
}
.hp-mapchip b { font-variant-numeric: tabular-nums; font-weight: 700; font-size: calc(12.5px * var(--fs-scale, 1)); }
@media (hover: hover) { .hp-mapchip:hover { border-color: var(--brand); } }
/* Text stays ink on every level (the tinted inks fall under 4.5:1 on their tints in the dark theme); the fill and
   the border carry the level: berry for weak, the "try again" amber for getting there, green for strong. */
.hp-mapchip.is-weak { background: var(--c-berry-tint); border-color: var(--c-berry); border-width: 2px; }
.hp-mapchip.is-mid { background: var(--retry-tint); border-color: var(--retry); border-width: 2px; }
.hp-mapchip.is-strong { background: var(--ok-tint); border-color: var(--ok); border-width: 2px; }
.hp-mapchip.is-few { border-style: dashed; }
.hp-mapchip.is-none { background: var(--surface-sunk); border-color: var(--line); color: var(--ink-soft); }
.hp-map__next { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-sunk); }
.hp-map__next p { margin: 0; font-weight: 600; }
.hp-map__legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.hp-map__legend span { display: inline-flex; align-items: center; gap: 6px; }
.hp-mapdot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface); }
.hp-mapdot.is-weak { background: var(--c-berry-tint); border-color: var(--c-berry); }
.hp-mapdot.is-mid { background: var(--retry-tint); border-color: var(--retry); }
.hp-mapdot.is-strong { background: var(--ok-tint); border-color: var(--ok); }
.hp-mapdot.is-few { border-style: dashed; }
.hp-mapdot.is-none { background: var(--surface-sunk); border-color: var(--line); }
.hp-group__tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); }
@media (max-width: 899.98px) { .hp-group__tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.hp-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 118px; min-width: 0; text-decoration: none;
  padding: var(--s-4); text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .hp-tile:hover { border-color: var(--line); border-color: color-mix(in oklab, var(--c) 60%, var(--line)); background: var(--surface); background: color-mix(in oklab, var(--c) 4%, var(--surface)); } }
.hp-tile:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.hp-tile__code { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; line-height: 1.1; letter-spacing: .02em; color: var(--c-ink); }
.hp-tile__name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; color: var(--ink); overflow-wrap: break-word; -webkit-hyphens: manual; hyphens: manual; }
.hp-tile__status { margin-top: auto; padding-top: var(--s-2); font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.hp-tile__status.is-none { font-weight: 500; color: var(--ink-faint); }

@media (max-width: 760px) {
  .hp-hero__main { grid-template-columns: minmax(0, 1fr); }
  .hp-hero__score { padding: var(--s-4); }
  .hp-hero__date { padding: var(--s-4); border-left: 0; border-top: 1px solid var(--line); }
  .hp-hero__next { padding: var(--s-3) var(--s-4); }
  .hp-hero__next .btn { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 420px) {
  .hp-tile { min-height: 108px; padding: var(--s-3) var(--s-4); }
}

/* print */
.psheet__stimulus {
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px;
  margin: 0 0 8px; font-size: calc(13px * var(--fs-scale, 1)); background: #f6f6f6;
}
.psheet__fig { display: block; max-width: 100%; max-height: 110mm; margin: 0 0 8px; }

.question__topline { display: flex; align-items: flex-start; gap: var(--s-3); margin-bottom: var(--s-4); }
.question__topline .question__prompt { margin-bottom: 0; flex: 1; min-width: 0; }
.question__prompt { font-size: var(--fs-lg); font-family: var(--font-display); font-weight: 600; margin-bottom: var(--s-4); }
/* Read-aloud button on the question card. */
.q-speak {
  flex: none; width: 32px; height: 32px; border-radius: var(--r-full);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  display: grid; place-items: center; cursor: pointer; margin-top: 2px;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
@media (hover: hover) { .q-speak:hover { color: var(--brand); border-color: var(--brand); } }
.q-speak.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
/* Read / Listen / Speak tools on a language-set question. */
.langbar { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.langbar__row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.langbar__modes { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; }
.langbar__modes button {
  border: 0; background: transparent; color: var(--ink-soft); cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: 700; padding: 4px 12px;
}
.langbar__modes button + button { border-left: 1px solid var(--line-strong); }
.langbar__modes button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.langbar__modes button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.langbar__note { margin: 0; }
.langbar__speak { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.langbar__speak .btn.is-on { background: var(--retry); border-color: var(--retry); color: var(--ink-on-color); }
.langbar__out { font-size: var(--fs-sm); color: var(--ink-soft); }
.langbar__out.is-good { color: var(--ok-ink); font-weight: 700; }
.langbar__out.is-close { color: var(--ink); font-weight: 700; }
.langbar__out.is-off { color: var(--retry-ink); }
.reading__row--stack { flex-direction: column; align-items: stretch; gap: 6px; }
.reading__voice { width: 100%; font: inherit; font-size: var(--fs-sm); padding: 6px 8px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }

/* read-aloud voice controls (Settings + the reading popover): voice list, play sample, speed, tips */
.voicectl { display: flex; flex-direction: column; gap: var(--s-2); }
.voicectl [hidden] { display: none !important; }
.voicectl__body { display: flex; flex-direction: column; gap: var(--s-2); }
.voicectl__row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.voicectl__speed { display: flex; align-items: center; gap: var(--s-2); flex: 1 1 140px; min-width: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.voicectl__speed > span { flex: none; }
.voicectl__speed input[type=range] { flex: 1; min-width: 60px; height: 24px; accent-color: var(--brand); }   /* 24px: WCAG 2.5.8 target */
.voicectl__rate { flex: none; min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.voicectl__opt { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--ink-soft); cursor: pointer; }
.voicectl__opt input[type=checkbox] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }
.voicectl__tip { margin: 0; font-size: var(--fs-sm); line-height: 1.4; }
.voicectl--compact .voicectl__tip { font-size: calc(12px * var(--fs-scale, 1)); }
.voicectl--compact .voicectl__row { gap: var(--s-2); }
.voicectl--compact .voicectl__speed > span { display: none; }

.choices { display: flex; flex-direction: column; gap: var(--s-3); }
.choice {
  text-align: left; font: inherit; cursor: pointer;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  border: 2px solid var(--line-strong); background: var(--surface);
  display: flex; align-items: center; gap: var(--s-3);
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
}
@media (hover: hover) { .choice:hover { transform: translateY(-1px); border-color: var(--brand); } }
.choice__key {
  width: 28px; height: 28px; flex: none; border-radius: var(--r-full);
  display: grid; place-items: center; font-weight: 700; font-family: var(--font-display);
  background: var(--surface-sunk); color: var(--ink-soft);
}
.choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-tint); }
.choice.is-correct { border-color: var(--ok); background: var(--ok-tint); animation: pop var(--dur-mid) var(--ease-spring); }
.choice.is-wrong  { border-color: var(--retry); background: var(--retry-tint); animation: nudge var(--dur-mid) var(--ease-out); }
.choice.is-correct .choice__key { background: var(--ok); color: #fff; }
.choice.is-wrong .choice__key { background: var(--retry); color: var(--ink-on-color); }
/* A disabled button's text defaults to 30 % ink, which left the option you picked wrong at 2:1 on its tint.
   The picked and the right option keep full ink; the others are left as they were. */
.choice.is-wrong:disabled, .choice.is-correct:disabled { color: var(--ink); }

/* Högskoleprovet: a ✕ beside each option crosses it out (questions.js mc, strikable). The row is what the
   .choices list and grid lay out; the option fills it and the ✕ sits at its right edge. */
.choicerow { display: flex; align-items: stretch; gap: var(--s-2); min-width: 0; }
.choicerow > .choice { flex: 1 1 auto; min-width: 0; }
.choice__strike {
  flex: none; width: 40px; min-height: 44px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  display: grid; place-items: center; cursor: pointer; font: inherit;
}
@media (hover: hover) { .choice__strike:hover { color: var(--ink); border-color: var(--line-strong); } }
.choice__strike[aria-pressed="true"] { color: var(--ink); background: var(--surface-sunk); border-color: var(--line-strong); }
.choice.is-struck { border-style: dashed; background: var(--surface-sunk); }
.choice.is-struck > span:not(.choice__key) { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink-soft); }
.choice.is-struck .choice__key { opacity: .55; }

.answerbox {
  width: 100%; font: inherit; padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); border: 2px solid var(--line-strong);
  background: var(--surface); resize: vertical; min-height: 92px;
}
.answerbox:focus-visible { border-color: var(--brand); box-shadow: none; }
/* A slim scrollbar in the theme's own colours, instead of the system's wide bar with arrow buttons (which
   is bright white on the dark theme). Only shows when the answer outgrows the box. */
.answerbox, .field textarea, .contact__textarea { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.feedback { margin-top: var(--s-4); padding: var(--s-4); border-radius: var(--r-md); font-size: var(--fs-sm); }
.feedback.ok { background: var(--ok-tint); color: var(--ok-ink); }
.feedback.retry { background: var(--retry-tint); color: var(--retry-ink); }

.flashcard { perspective: 1200px; }
/* Both faces share one grid cell, so the card is always as tall as its taller
   face — text can't spill out of it. The text itself is capped (see
   .flashcard__text) and "Show more" lifts the cap. */
.flashcard__inner {
  position: relative; display: grid; min-height: 200px; border-radius: var(--r-lg);
  transition: transform var(--dur-slow) var(--ease-spring); transform-style: preserve-3d; cursor: pointer;
}
.flashcard.is-flipped .flashcard__inner { transform: rotateY(180deg); }
.flashcard__face {
  grid-area: 1 / 1; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--s-5);
  border-radius: var(--r-lg); border: 2px solid var(--line-strong); background: var(--surface);
  font-size: var(--fs-lg); font-family: var(--font-display); font-weight: 600;
}
.flashcard__face--back { transform: rotateY(180deg); background: var(--brand-tint); }
.flashcard__text { max-height: clamp(140px, 30vh, 260px); overflow: hidden; }
.flashcard.is-expanded .flashcard__text { max-height: none; }
.flashcard:not(.is-expanded) .flashcard__text.is-clamped {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
}
.flashcard__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin-top: 10px; }
.flashcard__meta .note { margin: 0; }
.selfrate { display: flex; gap: var(--s-2); margin-top: var(--s-4); flex-wrap: wrap; }
.selfrate .btn { min-height: 44px; }   /* the four flashcard ratings and the worked-problem marks: a thumb's size */

/* "how sure were you?" row after a practice answer */
.confrow { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-4); flex-wrap: wrap; }
.confrow__q { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); }
.confrow .btn.is-picked { background: var(--brand); color: #fff; border-color: transparent; }

/* cloze fill-in-the-blank */
.cloze { font-size: var(--fs-md); line-height: 2.1; }
.cloze__blank {
  font: inherit; width: auto; min-width: 60px;
  border: none; border-bottom: 2px solid var(--brand);
  background: var(--surface-sunk); border-radius: var(--r-sm) var(--r-sm) 0 0;
  padding: 2px 6px; margin: 0 2px; color: var(--ink);
}
.cloze__blank:focus-visible { outline: none; background: var(--brand-tint); }
.cloze__blank.is-correct { border-color: var(--ok); background: var(--ok-tint); color: var(--ok-ink); }
.cloze__blank.is-wrong { border-color: var(--retry); background: var(--retry-tint); color: var(--retry-ink); }

/* math keypad */
.mathpad {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px; margin-top: var(--s-3); max-width: 340px;
}
.mathpad__key {
  font: inherit; font-size: var(--fs-md); cursor: pointer;
  aspect-ratio: 1; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
}
@media (hover: hover) { .mathpad__key:hover { background: var(--surface-sunk); border-color: var(--brand); } }

/* adaptive-pacing note in a session */
.adaptive:not(:empty) { margin-bottom: var(--s-3); }
/* Wide screens show the tutor beside the question already; the link is for the phone's slide-up sheet. */
@media (min-width: 861px) { .adaptive__ask { display: none; } }

/* test-mode banner + its "turn off / turn on" toggle */
.testbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px 16px; flex-wrap: wrap; margin-bottom: var(--s-3);
}
.testbar .btn { flex: none; }
/* Phone: the banner stays a short strip beside its button, so the first answer clears the bottom bar. */
@media (max-width: 560px) {
  .testbar { flex-wrap: nowrap; gap: 10px; padding: 8px 10px 8px 12px; font-size: calc(13px * var(--fs-scale, 1)); line-height: 1.35; }
  .testbar .btn { padding: 6px 10px; font-size: calc(12.5px * var(--fs-scale, 1)); min-height: 0; }
}

/* Pomodoro countdown in the session header */
.pomo {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-sm);
  padding: 4px var(--s-2); border-radius: var(--r-sm);
  background: var(--surface-sunk); color: var(--ink-soft);
}
.pomo.is-up { background: var(--retry-tint); color: var(--retry-ink); }

/* exam clock in the session header */
.examtimer {
  display: inline-flex; align-items: center; gap: 5px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-sm);
  padding: 4px var(--s-2); border-radius: var(--r-sm);
  background: var(--surface-sunk); color: var(--ink-soft);
}
.examtimer--warn { background: var(--retry-tint); color: var(--retry-ink); }
.examtimer svg { flex: none; }
/* The floating copy (views/session.js): phones only, centred under the top bar while the header's
   clock is scrolled out of view. */
.examtimer--float { display: none; }
@media (max-width: 899.98px) {
  .examtimer--float {
    display: inline-flex; position: fixed; z-index: 19; left: 50%; transform: translateX(-50%);
    top: calc(env(safe-area-inset-top, 0px) + 78px);
    padding: 6px 12px; border-radius: var(--r-full); font-size: calc(15px * var(--fs-scale, 1));
    background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2);
    pointer-events: none;
  }
  .examtimer--float.examtimer--warn { background: var(--retry-tint); color: var(--retry-ink); border-color: var(--retry); }
}

/* editor: drag handle + reorder */
.qedit__bar { display: flex; justify-content: flex-end; margin-bottom: var(--s-2); }
.qedit__toggle { flex: none; width: 28px; height: 28px; border: 0; background: transparent; color: var(--ink-soft); font-size: calc(14px * var(--fs-scale, 1)); cursor: pointer; border-radius: var(--r-sm); }
@media (hover: hover) { .qedit__toggle:hover { background: var(--surface-2, var(--line)); color: var(--ink); } }
.qedit__toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.qedit.is-collapsed { padding-top: var(--s-2); padding-bottom: var(--s-2); }
.qedit.is-collapsed .qedit__folded { margin-bottom: 0; }
.qedit__summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.qedit__summary.is-empty { color: var(--ink-faint); font-style: italic; }
.qedit__grip { cursor: grab; color: var(--ink-faint); font-size: calc(16px * var(--fs-scale, 1)); user-select: none; padding: 0 4px; }
.qedit.is-dragging { opacity: .5; }
.qedit.is-dragover { outline: 2px dashed var(--brand); outline-offset: 2px; }

/* practice library */
/* Library, step 1: one card per level with its size and subjects */
.levelcards { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); }
.levelcard {
  display: flex; flex-direction: column; gap: var(--s-3); text-align: left; cursor: pointer;
  padding: var(--s-5); border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; box-shadow: var(--shadow-1);
  transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
@media (hover: hover) { .levelcard:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow-2); } }
.levelcard:focus-visible { outline: none; box-shadow: var(--ring); }
.levelcard__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.levelcard__top svg { color: var(--ink-faint); transition: transform var(--dur-fast), color var(--dur-fast); }
.levelcard:hover .levelcard__top svg { color: var(--brand); transform: translateX(3px); }
.levelcard__name { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.levelcard__stats { font-size: var(--fs-sm); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.levelcard__marks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.levelcard__marks .subjmark {
  width: 34px; height: 34px; font-size: calc(13px * var(--fs-scale, 1)); border-radius: 9px;
  box-shadow: 0 0 10px -3px color-mix(in srgb, var(--subject, var(--brand)) 55%, transparent);
}
.levelcard__marks .subjmark small { font-size: calc(12px * var(--fs-scale, 1)); }
.levelcard__marks .subjmark--more { --subject: var(--ink-faint); font-size: calc(12px * var(--fs-scale, 1)); box-shadow: none; }

.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-3); margin-top: var(--s-4); }
.libcard {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4);
  background: var(--surface); display: flex; flex-direction: column; gap: var(--s-3);
  justify-content: space-between; min-width: 0;
}
.libcard__title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); }
.libcard__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; }
/* An already-added set: clear "in your library" state + Study as the primary. */
.libcard--added { border-color: var(--line); border-color: color-mix(in srgb, var(--ok-bright) 38%, var(--line)); }
.libcard__added { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 700; color: var(--ok-ink); }
.libcard__added svg { flex: none; }
.libcard__count { font-weight: 400; color: var(--ink-faint); }
/* Per-set progress: right-last-time bar, last-studied, weakest topic. */
.libprog { display: flex; flex-direction: column; gap: var(--s-2); }
.libprog__bar { height: 6px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.libprog__bar > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.libprog__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-1) var(--s-3); flex-wrap: wrap; font-size: var(--fs-sm); font-weight: 600; }
.libprog__row .note { font-weight: 400; margin: 0; }
.libprog__weak {
  align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-sm); padding: 2px 10px; border-radius: var(--r-full);
  background: var(--retry-tint); color: var(--retry-ink);
}
/* Questions-per-session switch on an added set. */
.libseg { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.libseg__label { font-size: var(--fs-sm); color: var(--ink-soft); }
.libseg__group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; }
.libseg__group button {
  border: 0; background: transparent; color: var(--ink-soft); cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: 700; min-width: 40px; padding: 4px 12px;
}
.libseg__group button + button { border-left: 1px solid var(--line-strong); }
.libseg__group button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.libseg__group button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
/* "Exam-mode options" disclosure above the set grid. */
.libexam { margin-top: var(--s-3); }
.libexam summary, .set-ai-how summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: var(--fs-sm); color: var(--ink-soft);
}
.libexam summary::-webkit-details-marker, .set-ai-how summary::-webkit-details-marker { display: none; }
.libexam summary::before, .set-ai-how summary::before {
  content: "▸"; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); transition: transform var(--dur-fast);
}
.libexam[open] summary::before, .set-ai-how[open] summary::before { transform: rotate(90deg); }
.libexam summary svg { flex: none; }

/* first-run walkthrough */
/* ---------- welcome quiz (first run; Settings can reopen it) ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 90; overflow-y: auto;
  background: var(--canvas); color: var(--ink);
  display: flex; flex-direction: column;
}
body.has-welcome { overflow: hidden; }
.welcome__bar { position: sticky; top: 0; z-index: 2; height: 4px; background: var(--line); flex: none; }
.welcome__bar i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 0 var(--r-full) var(--r-full) 0; transition: width var(--dur-mid) ease; }
.welcome__top {
  display: flex; align-items: center; gap: var(--s-4); flex: none;
  max-width: 720px; width: 100%; margin: 0 auto; padding: var(--s-4) var(--s-4) 0;
}
.welcome__brand { display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-display); font-weight: 800; letter-spacing: -.01em; margin-right: auto; }
.welcome__brand img { width: 24px; height: 24px; }
.welcome__step { font-size: var(--fs-sm); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
/* On a 375 px phone the brand, "Fråga 1 av 7" and "Hoppa över allt" share one row: keep each on a single line.
   Narrower than 360 px there isn't room, and wrapping beats pushing "Hoppa över allt" off the screen. */
@media (min-width: 360px) {
  .welcome__step, .welcome__top .linkbtn { white-space: nowrap; }
}
.welcome__stage { flex: 1; display: grid; align-items: center; justify-items: center; padding: var(--s-5) var(--s-4) var(--s-7); }
.welcome__card { width: 100%; max-width: 620px; }
.welcome__card.is-entering { animation: welcome-in var(--dur-slow) var(--ease-out, ease) both; }
@keyframes welcome-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.welcome h2 { font-size: clamp(1.6rem, 4.6vw, 2.15rem); line-height: 1.12; letter-spacing: -.02em; font-weight: 800; text-wrap: balance; outline: none; }
.welcome__body { color: var(--ink-soft); margin: var(--s-3) 0 var(--s-5); max-width: 52ch; }

.welcome__opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.welcome__opt {
  position: relative; display: flex; align-items: center; gap: var(--s-3); text-align: left; cursor: pointer;
  padding: var(--s-4); border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .welcome__opt:hover { transform: translateY(-2px); border-color: var(--brand); } }
.welcome__opt[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-tint); }
.welcome__opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.welcome__opt-text b { font-family: var(--font-display); font-weight: 700; }
.welcome__opt-text small { color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.35; }
.welcome__ic { flex: none; width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); }
.welcome__opt[aria-pressed="true"] .welcome__ic { background: var(--brand); color: #fff; }
.welcome__dot { flex: none; width: 14px; height: 14px; border-radius: var(--r-full); }
.welcome__tick { flex: none; width: 22px; height: 22px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--brand); color: #fff; opacity: 0; transform: scale(.6); transition: opacity var(--dur-fast), transform var(--dur-fast) var(--ease-spring); }
.welcome__opt[aria-pressed="true"] .welcome__tick { opacity: 1; transform: none; }

.welcome__input {
  width: 100%; font: inherit; font-size: 1.25rem; padding: var(--s-4); margin-bottom: var(--s-5);
  border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.welcome__input:focus-visible { outline: none; border-color: var(--brand); }
.welcome__date { display: flex; flex-direction: column; gap: var(--s-2); margin: 0 0 var(--s-5); font-weight: 600; font-size: var(--fs-sm); }
/* Inside the option list (right under the chosen goal) it spans the row and the list's own gap spaces it. */
.welcome__opts > .welcome__date { grid-column: 1 / -1; margin: 0; }
.welcome__date input { font: inherit; padding: var(--s-3); max-width: 260px; border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.welcome__date input:focus-visible { outline: none; border-color: var(--brand); }

.welcome__chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-5); }
.welcome__chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font: inherit; font-weight: 600;
  padding: 10px var(--s-4); border-radius: var(--r-full); border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .welcome__chip:hover { transform: translateY(-1px); border-color: var(--brand); } }
.welcome__chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: #fff; }
/* Picking a chip must not change its width: the check mark (12px + the 6px gap) takes room that an unpicked chip
   holds as extra side padding, 9px a side. When the picked chip grew, the row re-wrapped under the finger and the
   next tap landed on a different subject. */
.welcome__chip { padding-left: calc(var(--s-4) + 9px); padding-right: calc(var(--s-4) + 9px); }
.welcome__chip[aria-pressed="true"] { padding-left: var(--s-4); padding-right: var(--s-4); }
.welcome__chip-mark { display: none; width: 12px; flex: none; }
.welcome__chip[aria-pressed="true"] .welcome__chip-mark { display: inline-flex; }

/* Pinned to the bottom of the screen, so a tall question (six options and a date) never pushes Continue out of sight. */
.welcome__nav { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; position: sticky; bottom: 0; z-index: 3; background: var(--canvas); padding: var(--s-3) 0 calc(var(--s-3) + env(safe-area-inset-bottom, 0px)); }
.welcome__spacer { flex: 1; }

.welcome__done { width: 52px; height: 52px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--ok-tint); color: var(--ok); margin-bottom: var(--s-4); }
.welcome__recap { list-style: none; margin: 0 0 var(--s-5); padding: 0; display: grid; gap: var(--s-2); }
.welcome__recap li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.welcome__recap li svg { color: var(--brand); flex: none; }
.welcome__cta { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.welcome__acct { margin: 0 0 var(--s-5); padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); }
.welcome__acct h3 { font-size: var(--fs-lg); margin-bottom: var(--s-1); }
.welcome__acct .note { margin: 0 0 var(--s-3); }
.welcome__acct-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--s-2); align-items: center; }
.welcome__acct-fields input { font: inherit; padding: 11px var(--s-3); border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--canvas); color: var(--ink); min-width: 0; }
.welcome__acct-fields input:focus-visible { outline: none; border-color: var(--brand); }
.welcome__acct-done { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; color: var(--ok); }
@media (max-width: 620px) {
  .welcome__acct-fields { grid-template-columns: 1fr; }
  .welcome__opts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .welcome__card.is-entering { animation: none; }
  .welcome__opt, .welcome__chip, .welcome__tick, .welcome__bar i { transition: none; }
}

/* command palette */
.cmd { align-items: flex-start; padding-top: 12vh; }
.cmd__card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-2); width: 100%; max-width: 480px; overflow: hidden; }
.cmd__input { width: 100%; border: none; border-bottom: 1px solid var(--line); padding: var(--s-4); font: inherit; font-size: var(--fs-md); background: var(--surface); color: var(--ink); }
.cmd__input:focus-visible { outline: none; }
.cmd__list { max-height: 320px; overflow-y: auto; }
.cmd__row { width: 100%; display: flex; justify-content: space-between; gap: var(--s-3); align-items: center; padding: 10px var(--s-4); border: none; background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.cmd__row.is-sel { background: var(--brand-tint); }
.cmd__empty { padding: var(--s-4); color: var(--ink-soft); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.cmd__sub { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); flex: none; }

.nav-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-5); }
.nav-row > div { flex-wrap: wrap; justify-content: flex-end; }
/* The edit screen's Cancel / Add question / Save row stays at the bottom of the screen however long the
   set is. On a phone it sits above the fixed tab bar (about 60px). */
.editbar {
  position: sticky; bottom: 0; z-index: 15;
  margin-top: var(--s-5); padding: var(--s-3) 0 calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  background: var(--canvas); border-top: 1px solid var(--line);
}
.editbar__actions { display: flex; gap: 10px; }
/* A field scrolled into view (a tap on a question near the bottom) must land above the bar, not under it. */
html:has(.editbar) { scroll-padding-bottom: 160px; }
@media (max-width: 899px) { .editbar { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); padding-bottom: var(--s-3); } }
@media (min-width: 380px) and (max-width: 899px) {
  /* One row, not three, where the three buttons fit: the bar must not take a sixth of a phone screen.
     Narrower than that they wrap rather than run off the side. */
  .editbar { flex-wrap: nowrap; gap: 6px; }
  .editbar__actions { flex-wrap: nowrap; gap: 6px; }
  .editbar .btn { padding-left: 8px; padding-right: 8px; white-space: nowrap; }
}

/* ===== The AI's mark =====
   The tile, soft shadow and halo from the PluggEra AI page's greeting (.solve-hero below), reused wherever the
   AI is the one acting: the sidebar item, the tutor, the help chat, a set it wrote, the buttons that start it.
   Plain flat icons stay for everything else, so this keeps meaning "the AI". The halo is the loud part — it
   lives only on the active sidebar row and the tutor's header. components/ai-mark.js builds the tile. */
.ai-tile {
  --s: 40px; width: var(--s); height: var(--s); border-radius: calc(var(--s) * .28); display: grid; place-items: center; flex: none; color: #fff;
  /* Deep blue: the brand blue darkened, lit at the top-left corner and deepening toward indigo, with a
     light top edge and a soft shadow of its own colour. */
  background: linear-gradient(140deg, var(--brand), color-mix(in oklab, var(--brand) 72%, #000) 55%, color-mix(in oklab, var(--brand) 55%, #1E1470));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 calc(var(--s) * .16) calc(var(--s) * .4) calc(var(--s) * -.2) color-mix(in srgb, var(--brand) 55%, transparent);
}
.ai-tile svg { width: 48%; height: 48%; stroke-width: 2.1; }
.ai-halo { position: relative; isolation: isolate; }
.ai-halo::before {
  content: ""; position: absolute; z-index: -1; left: var(--hx, 50%); top: var(--hy, 50%); width: var(--hw, 240px); height: var(--hh, 150px);
  transform: translate(-50%, -50%); pointer-events: none; filter: blur(14px); animation: ai-breathe 7s ease-in-out infinite alternate;
  background:
    radial-gradient(48% 48% at 40% 50%, color-mix(in srgb, var(--brand) 30%, transparent), transparent 72%),
    radial-gradient(42% 44% at 64% 44%, color-mix(in srgb, #7650FF 24%, transparent), transparent 72%);
}
@keyframes ai-breathe { from { opacity: .6; scale: .94; } to { opacity: 1; scale: 1.06; } }
/* While the AI is thinking (mascot.js setMood) the tile pulses and a halo behind it speeds up. */
.mascot.is-thinking .ai-tile { animation: ai-nudge 1.8s ease-in-out infinite alternate; }
.ai-halo:has(.mascot.is-thinking)::before { animation-duration: 1.8s; }
@keyframes ai-nudge { from { scale: 1; } to { scale: 1.07; } }
@media (prefers-reduced-motion: reduce) { .ai-halo::before, .mascot.is-thinking .ai-tile { animation: none; } }

/* Sidebar: the AI's row has the tile instead of a flat icon; on its own page it also gets the halo and a
   faint blue wash across the row. (More specific than .sidebar__link.is-active so the design layer can't undo it.) */
.sidebar__link--ai .ai-tile { margin: -3px; border-radius: 7px; }   /* 24px (main.js): 3px past the 18px icons on each side, so labels still line up */
/* The sidebar and phone menu colour (and size) every row's icon, active and hovered rows included — including
   design.css's `.sidebar__link.is-active svg { color: var(--brand) }`, which made the sparkle blue on the blue
   tile. The tile's sparkle stays white, at its own size, whatever the row is doing. */
/* At 24px the sparkle needs to fill more of the tile, at a firmer stroke than the rows' thin 1.8px icons, to read as
   a mark rather than a smudge. */
.sidebar__link.sidebar__link--ai .ai-tile svg, .topmenu__item.topmenu__item .ai-tile svg { width: 56%; height: 56%; stroke-width: 2.2; color: #fff; }
.sidebar__link.sidebar__link--ai.is-active { background: linear-gradient(90deg, color-mix(in srgb, var(--brand) 22%, var(--brand-tint)), var(--brand-tint) 70%); }
.sidebar__link--ai.ai-halo { --hx: 22px; --hw: 130px; --hh: 70px; }
.topmenu__item .ai-tile { --s: 20px; margin: -2px; }

/* The tutor's header: the glow sits behind its tile, clipped to the header. */
.tutor__head.ai-halo { --hx: 34px; --hw: 220px; --hh: 100px; overflow: hidden; }
/* The tutor's (and help chat's) replies carry a thin blue edge, so who is talking reads at a glance. */
.tutor .msg.ai, .sitechat__log .msg.ai { background: var(--surface-sunk); background: color-mix(in srgb, var(--brand) 7%, var(--surface-sunk)); border: 1px solid color-mix(in srgb, var(--brand) 26%, var(--line)); }

/* Buttons that start the AI: the same gradient as the tile. */
.btn.btn--ai {
  background: linear-gradient(140deg, color-mix(in oklab, var(--brand) 78%, #fff), var(--brand) 48%, color-mix(in oklab, var(--brand) 55%, #7650FF));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 10px 22px -10px color-mix(in srgb, var(--brand) 80%, transparent);
}
@media (hover: hover) { .btn.btn--ai:hover:not(:disabled) { background: linear-gradient(140deg, color-mix(in oklab, var(--brand) 78%, #fff), var(--brand) 48%, color-mix(in oklab, var(--brand) 55%, #7650FF)); filter: brightness(1.08); } }
.ai-send, button.sitechat__send {
  background: linear-gradient(140deg, color-mix(in oklab, var(--brand) 78%, #fff), var(--brand));
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--brand) 80%, transparent);
}
.iconbtn.ai-send { width: 36px; height: 36px; border: 0; border-radius: var(--r-full); color: #fff; }
@media (hover: hover) { .iconbtn.ai-send:hover:not(:disabled) { background: linear-gradient(140deg, color-mix(in oklab, var(--brand) 78%, #fff), var(--brand)); filter: brightness(1.08); border-color: transparent; } }
.iconbtn.ai-send svg { stroke-width: 2.2; }

/* A set the AI wrote: a faint blue wash behind the card (no badge: the card reads the same as any other). */
.acard--ai { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 9%, var(--surface)), var(--surface) 70%); }

/* ---------- tutor chat ---------- */
.mascot { position: relative; display: inline-flex; flex: none; }
.mascot__dot {
  position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px;
  border-radius: var(--r-full); border: 2px solid var(--surface);
}
.mascot__dot--pulse { animation: mascot-pulse 1.1s ease-in-out infinite; }
@keyframes mascot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.tutor { position: sticky; top: 76px; display: flex; flex-direction: column; max-height: calc(100vh - 100px); }
.tutor__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); border-bottom: 1px solid var(--line); }
.tutor__title { font-family: var(--font-display); font-weight: 600; }
.tutor__sub { font-size: var(--fs-sm); color: var(--ink-faint); }
.tutor__log { flex: 1; overflow-y: auto; padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
/* Nothing inside a bubble may push past its edge: long URLs and words break, wide code, tables and
   display equations scroll on their own, and anything else that cannot wrap (a very long inline
   formula) scrolls the bubble instead of giving the whole chat a sideways scrollbar. */
.msg { flex: none; max-width: 92%; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; overflow-x: auto; overflow-y: hidden; }
.msg pre { max-width: 100%; overflow-x: auto; margin: .5em 0; padding: .5em .75em; border-radius: var(--r-sm); background: rgba(0,0,0,.08); font-size: .92em; line-height: 1.45; }
.msg pre code { padding: 0; background: none; white-space: pre; overflow-wrap: normal; }
.msg .katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
/* KaTeX puts an absolutely positioned (visually hidden) MathML copy inside every
   formula. Its containing block would otherwise be the nearest positioned
   ancestor — e.g. the sticky .tutor, outside the scrolling .tutor__log — so the
   log can't clip it, and a long thread of formulas pushed those copies below the
   page: the document grew taller than the shell and the sticky sidebar and topbar
   scrolled away. Anchoring each copy to its own formula keeps it in place. */
.katex { position: relative; }
.msg .mdtable { max-width: 100%; margin: .5em 0; overflow-x: auto; }
.msg table { border-collapse: collapse; min-width: 100%; font-size: .95em; }
.msg th, .msg td { padding: 6px 10px; border: 1px solid var(--line-strong); text-align: left; vertical-align: top; overflow-wrap: normal; }
.msg th { background: color-mix(in srgb, var(--brand) 10%, transparent); font-weight: 600; }
.msg blockquote { margin: .5em 0; padding-left: .75em; border-left: 3px solid var(--line-strong); color: var(--ink-soft); }
.msg hr { margin: .75em 0; border: 0; border-top: 1px solid var(--line-strong); }
.msg--error { font-style: italic; color: var(--ink-soft); }
.msg :is(p, ul, ol) + :is(p, ul, ol) { margin-top: .5em; }
.msg li + li { margin-top: .25em; }
/* The global `* { padding: 0 }` reset strips a list's indent, so its markers hang outside the
   box and poke out of the bubble. Restore it for the class-less lists markdown() emits;
   class-based / scoped lists (.lp-src ul, .rulesheet ul, …) still win on specificity. */
:where(ul, ol):not([class]) { padding-left: 1.4em; }
.msg.ai { background: var(--surface-sunk); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.ai code, .msg.me code { background: rgba(0,0,0,.08); padding: 1px 4px; border-radius: 4px; }

/* typing indicator — the tutor thread and the site help chat both use it */
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- site help chat (floating widget, any page) ---------- */
.sitechat__fab {
  position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 40;
  width: 56px; height: 56px; border-radius: var(--r-full);
  display: grid; place-items: center; border: none; cursor: pointer;
  background: linear-gradient(140deg, color-mix(in oklab, var(--brand) 78%, #fff), var(--brand) 48%, color-mix(in oklab, var(--brand) 55%, #7650FF));
  color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), var(--shadow-2), 0 12px 28px -10px color-mix(in srgb, var(--brand) 80%, transparent);
  transition: transform var(--dur-fast) var(--ease-spring);
}
@media (hover: hover) { .sitechat__fab:hover { transform: translateY(-2px) scale(1.05); } }
.sitechat__panel {
  position: fixed; right: var(--s-4); bottom: calc(var(--s-4) + 56px + var(--s-3)); z-index: 40;
  width: min(380px, calc(100vw - var(--s-4) * 2));
  height: min(560px, calc(100vh - 160px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 60px -16px rgba(16, 24, 40, .35), var(--shadow-2); overflow: hidden;
  transform-origin: bottom right; animation: sitechat-in var(--dur-mid) var(--ease-out);
}
@keyframes sitechat-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.sitechat__head {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 7%, var(--surface)), var(--surface));
}
.sitechat__id { flex: 1; min-width: 0; }
.sitechat__title { font-family: var(--font-display); font-weight: 700; color: var(--ink); }
.sitechat__sub { display: flex; align-items: center; gap: 6px; margin-top: 1px; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.sitechat__sub .solvehead__livedot { margin: 0; }
.sitechat__log { flex: 1; overflow-y: auto; padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.sitechat__log > .msg { max-width: 86%; }
/* The helper's replies sit beside a small sparkles avatar. */
.sitechat__row { display: flex; align-items: flex-end; gap: 8px; align-self: flex-start; max-width: 100%; }
.sitechat__row .msg { max-width: calc(100% - 32px); }
.sitechat__av {
  flex: none; width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand);
}
/* Common questions under the greeting — one tap asks it. */
.sitechat__suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-left: 32px; }
.sitechat__suggest p { margin: 2px 0; font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.sitechat__chip {
  max-width: 100%; text-align: left; font: inherit; font-size: var(--fs-sm); line-height: 1.35; cursor: pointer;
  padding: 7px 12px; border-radius: 12px; border: 1px solid color-mix(in oklab, var(--brand) 30%, var(--line));
  background: var(--surface); color: var(--brand-ink);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
@media (hover: hover) { .sitechat__chip:hover { background: var(--brand-tint); border-color: var(--line); border-color: color-mix(in oklab, var(--brand) 55%, var(--line)); } }
.sitechat__chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Composer: one rounded field with the send button inside it. */
.sitechat__form { padding: var(--s-3) var(--s-3) 0; border-top: 1px solid var(--line); }
.sitechat__composer {
  display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-full); background: var(--surface-sunk);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.sitechat__composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.sitechat__input { flex: 1; min-width: 0; font: inherit; font-size: var(--fs-sm); padding: 8px 0; border: 0; background: none; color: var(--ink); outline: none; }
.sitechat__input:focus-visible { outline: none; box-shadow: none; }
.sitechat__send {
  flex: none; width: 36px; height: 36px; border-radius: var(--r-full); border: 0; display: grid; place-items: center;
  background: var(--brand); color: #fff; cursor: pointer; transition: opacity var(--dur-fast), transform var(--dur-fast);
}
@media (hover: hover) { .sitechat__send:hover:not(:disabled) { transform: scale(1.05); } }
.sitechat__send:disabled { opacity: .35; cursor: default; }
.sitechat__send:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sitechat__fine { margin: 0; padding: 8px var(--s-4) 10px; text-align: center; font-size: calc(11.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.sitechat__dormant { padding: var(--s-4); text-align: center; color: var(--ink-soft); }
.sitechat__dormant p:first-child { font-family: var(--font-display); font-weight: 600; margin-bottom: var(--s-2); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .sitechat__panel { animation: none; } }
/* Out of the way during a running session / worksheet. */
body.route-immersive .sitechat__fab,
body.route-immersive .sitechat__panel,
body.route-chat .sitechat__fab,
body.route-chat .sitechat__panel { display: none; }
/* Clear of the fixed bottom tab bar on mobile. */
@media (max-width: 899.98px) {
  /* The floating bubble sat on top of cards, progress rings and buttons: the chat opens from the top
     bar here instead (main.js, .topbar__chat). */
  .sitechat__fab { display: none; }
  .topbar__chat { display: inline-grid; }
  .sitechat__panel { bottom: calc(70px + var(--s-3) + env(safe-area-inset-bottom, 0)); }
  /* The calculator's keypad fills the bottom of a phone screen, and a session or the AI page has its
     own help: no chat there, and so no button for it. */
  body:has(.calc) .sitechat__panel,
  body:has(.calc) .topbar__chat,
  body.route-immersive .topbar__chat,
  body.route-chat .topbar__chat { display: none; }
}
@media (max-width: 480px) {
  .sitechat__panel { right: var(--s-3); left: var(--s-3); width: auto; }
}
.tutor__form { display: flex; gap: var(--s-2); padding: var(--s-3); border-top: 1px solid var(--line); }
.tutor__input { flex: 1; min-width: 0; font: inherit; padding: var(--s-2) var(--s-3); border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface); }
.tutor__input:focus-visible { border-color: var(--brand); box-shadow: none; }
.voice-btn { position: relative; color: var(--ink-faint); }
@media (hover: hover) { .voice-btn:hover { color: var(--ink-soft); } }
.voice-btn:disabled { opacity: .4; cursor: not-allowed; }
.voice-btn.is-listening {
  color: var(--retry-ink); background: var(--retry);
  animation: voicepulse 1.3s ease-in-out infinite;
}
@keyframes voicepulse { 0%, 100% { box-shadow: 0 0 0 0 var(--retry); } 50% { box-shadow: 0 0 0 5px transparent; } }
@media (prefers-reduced-motion: reduce) { .voice-btn.is-listening { animation: none; } }
.voice-soon {
  position: absolute; bottom: -3px; right: -3px;
  font-size: calc(8px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  background: var(--retry); color: #2B2B3A; padding: 1px 4px; border-radius: var(--r-full);
  line-height: 1.3;
}
.tooltip { position: relative; }
.tooltip[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); right: 0;
  background: var(--ink); color: #fff; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap;
}
.tutor__locked { padding: var(--s-4); text-align: center; color: var(--ink-soft); }
.tutor__locked p:first-child { font-family: var(--font-display); font-weight: 600; margin-bottom: var(--s-2); }

.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

/* ---------- results ---------- */
.results { text-align: center; max-width: 560px; margin: 0 auto; }
/* A wide screen: the score and what to do next on the left, the details beside them (views/results.js
   groups them) — instead of one 560px column down the middle of the window. The buttons sit under the
   score. Below 1100px, and for a result with no details, it stays the one column above. */
@media (min-width: 1100px) {
  .results.results--wide {
    width: 100%; max-width: 1180px; display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
    grid-template-areas: "summary details" "actions details"; column-gap: var(--s-7); align-items: start;
    /* The first row hugs the score; the details' extra height goes to the second, so the buttons sit
       right under the score rather than halfway down the page. */
    grid-template-rows: auto 1fr;
  }
  .results--wide .results__summary { grid-area: summary; }
  .results--wide .results__actions { grid-area: actions; margin-top: var(--s-4); }
  .results--wide .results__details {
    grid-area: details; display: grid; gap: var(--s-6);
    padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  }
  .results--wide .results__details > * { margin-top: 0 !important; }
  .results--wide .results__details .delta-list { margin-bottom: 0; }
  /* The rows are inside a card already: flat, not cards on a card. */
  .results--wide .results__details .delta { background: var(--surface-sunk); border-color: transparent; }
}
.results__actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
/* Phone: the main action across the full width, the rest in even pairs, "back to the menu" last on its
   own row — not three ragged centred rows. */
@media (max-width: 560px) {
  .results__actions { gap: 10px; }
  .results__actions > .btn { flex: 1 1 40%; justify-content: center; }
  .results__actions > .btn:not(.btn--ghost), .results__actions > .btn:last-child { flex-basis: 100%; }
}
.scorering { width: 180px; height: 180px; margin: var(--s-4) auto; }
.scorering circle { fill: none; stroke-width: 14; }
.scorering .bg { stroke: var(--surface-sunk); }
.scorering .fg { stroke: var(--ok); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset 900ms var(--ease-out); }
.scorering text { font-family: var(--font-display); font-weight: 700; fill: var(--ink); }
.delta-list { display: flex; flex-direction: column; gap: var(--s-2); margin: var(--s-5) 0; text-align: left; }
.delta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
/* Topic rows line up as columns — name, bar, change — so every bar starts at the same x
   however long the topic name is. The review list below reuses .delta as a plain stack. */
.delta-list:not(.delta-list--review) .delta { display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr) 3.2em; }
/* Phone: the name takes the free width and the bar shrinks, so a Swedish compound does not break mid-word. */
@media (max-width: 480px) { .delta-list:not(.delta-list--review) .delta { grid-template-columns: minmax(0, 1fr) 96px 44px; } }
.delta__topic { min-width: 0; overflow-wrap: break-word; overflow-wrap: anywhere; hyphens: auto; }
.delta__bar { flex: 1; height: 8px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; margin: 0 var(--s-3); }
.delta__bar i { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width var(--dur-slow) var(--ease-out); }
.delta__n { font-size: var(--fs-sm); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.delta__n.up { color: var(--ok); } .delta__n.down { color: var(--retry-ink); }

/* Wrong-answer review on the results screen — the correct answer + any
   authored explanation, reusing the .delta-list card look but stacked
   instead of the topic-mastery rows' left/right layout. */
.delta-list--review .delta--review { flex-direction: column; align-items: flex-start; gap: 6px; }
.delta__prompt { font-weight: 600; }
.delta__answer, .delta__explain { margin: 0; font-size: var(--fs-sm); }
.delta__given { color: var(--ink-soft); overflow-wrap: anywhere; }
.delta__missed ul { margin: 2px 0 0; padding-left: 1.2em; }
.delta__missed li { margin: 2px 0; }
.delta__explain { color: var(--ink-faint); }

/* "Scheduled for review" summary on the results screen. */
.results .srs-next { color: var(--ink); font-weight: 700; }

/* ---------- progress dashboard ---------- */
.dash { display: grid; gap: var(--s-5); }

/* Achievements shelf */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s-3); }
.badge-card {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
}
.badge-card__emoji { font-size: calc(26px * var(--fs-scale, 1)); flex: none; line-height: 1; }
.badge-card__text { display: flex; flex-direction: column; min-width: 0; }
.badge-card__text strong { font-family: var(--font-display); font-size: var(--fs-md); }
.badge-card.is-locked { background: var(--surface-sunk); border-style: dashed; }
.badge-card.is-locked .badge-card__emoji { filter: grayscale(1); opacity: .45; }
.badge-card.is-locked .badge-card__text strong { color: var(--ink-soft); }

.meter { display: grid; grid-template-columns: 120px 1fr 44px 26px; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.meter__track { height: 10px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.meter__fill { height: 100%; border-radius: inherit; background: var(--subject, var(--brand)); transition: width var(--dur-slow) var(--ease-out); }

/* Results "what you'll still remember" — two forgetting curves. */
.retention { width: 100%; max-width: 380px; height: auto; display: block; }
.retention__grid { stroke: var(--line); stroke-width: 1; }
.retention__lab { fill: var(--ink-faint); font-size: calc(9px * var(--fs-scale, 1)); font-family: var(--font-body); }
.retention__without { fill: none; stroke: var(--retry); stroke-width: 2; stroke-dasharray: 4 3; stroke-linecap: round; }
.retention__with { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linecap: round; }
.retention__dot { fill: var(--brand); }
.retention__legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 4px; }
.retention__k { display: inline-block; width: 16px; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.retention__k--without { border-top-style: dashed; color: var(--retry); }
.retention__k--with { color: var(--brand); }
.retention__cap { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); margin-top: 6px; }

/* Review-recall sparkline — bare line chart, scales to the panel width. */
.sparkline { width: 100%; height: auto; display: block; }
.sparkline polyline { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sparkline circle { fill: var(--brand); }
.sparkline circle.last { fill: var(--ok); }

/* ---------- exam prep ---------- */
.exam-prep { display: grid; gap: var(--s-5); }
.exam-prep h1 { margin: 0; }
.exam-prep .panel { margin: 0; }
.exam-prep__cols { display: grid; gap: var(--s-4); align-items: start; }
.exam-prep__col { display: grid; gap: var(--s-4); min-width: 0; }
@media (min-width: 1100px) {
  .exam-prep__cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
.exam-dot {
  display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px;
  background: var(--subject, var(--brand));
}

/* Hero: the countdown and today's session, the readiness ring beside it. */
.exam-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-5); align-items: center;
  padding: var(--s-5) var(--s-6, 28px);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--subject) 14%, transparent), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow-1);
}
.exam-hero__main { min-width: 0; }
.exam-hero__eyebrow {
  display: flex; align-items: center; gap: 8px; margin: 0 0 6px;
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft);
}
.exam-hero__title {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -.025em; line-height: 1.05;
  font-size: clamp(30px, 4.2vw, 44px); text-wrap: balance;
}
.exam-hero__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin: 10px 0 0; font-size: var(--fs-sm); color: var(--ink-soft);
}
.exam-hero__meta .linkbtn { display: inline-flex; align-items: center; gap: 4px; }
.exam-hero__lede { margin: 10px 0 0; max-width: 58ch; color: var(--ink-soft); }
.exam-hero__cta { margin-top: var(--s-4); }
.exam-hero__side { display: grid; justify-items: center; gap: 8px; }
.exam-hero__cover { margin: 0; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); text-align: center; }

.exam-ring { position: relative; width: 136px; aspect-ratio: 1; }
.exam-ring svg { display: block; width: 100%; height: 100%; }
.exam-ring__track { fill: none; stroke: var(--surface-sunk); stroke-width: 8; }
.exam-ring__fill {
  fill: none; stroke: var(--subject, var(--brand)); stroke-width: 8; stroke-linecap: round;
  transition: stroke-dasharray var(--dur-slow) var(--ease-out);
}
.exam-ring__val {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1;
}
.exam-ring__val b { font-family: var(--font-display); font-size: calc(30px * var(--fs-scale, 1)); font-weight: 800; letter-spacing: -.02em; }
.exam-ring__val span { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); }

/* Today's session — the one thing to do now. */
.exam-today {
  display: flex; align-items: center; gap: var(--s-3) var(--s-4); flex-wrap: wrap;
  margin-top: var(--s-4); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.exam-today__text { display: grid; gap: 2px; flex: 1 1 220px; min-width: 0; }
.exam-today__label {
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint);
}
.exam-today__task { font-weight: 650; color: var(--ink); }
.exam-today .btn { flex: none; }
.exam-today.is-done { border-color: var(--line); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: var(--ok-tint); }
.exam-today.is-done .exam-today__label { color: var(--ok-ink); }
.exam-today.is-done .exam-today__task { font-weight: 500; color: var(--ink-soft); }
.exam-today__check {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--r-full); background: var(--ok); color: #fff;
}

/* Panels below the hero. */
.exam-panel__head { margin: 0 0 4px; font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; }
.exam-sub { margin: var(--s-5) 0 var(--s-2); font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }

/* The plan, today → test day. */
.exam-plan { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: 2px; }
.exam-plan__day {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center;
  gap: var(--s-3); min-height: 40px; padding: 6px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm);
}
.exam-plan__day.is-folded { display: none; }
.exam-plan__when { color: var(--ink-faint); font-weight: 700; font-size: calc(12px * var(--fs-scale, 1)); text-transform: capitalize; }
.exam-plan__task { min-width: 0; color: var(--ink-soft); }
.exam-plan__min { color: var(--ink-faint); font-size: calc(12px * var(--fs-scale, 1)); }
.exam-plan__day.is-today { background: var(--brand-tint); }
.exam-plan__day.is-today .exam-plan__when { color: var(--brand-ink); }
.exam-plan__day.is-today .exam-plan__task { color: var(--ink); font-weight: 600; }
.exam-plan__day.is-done { background: var(--ok-tint); }
.exam-plan__day.is-done .exam-plan__when, .exam-plan__tick { color: var(--ok-ink); }
.exam-plan__tick { display: grid; place-items: center; padding-right: 6px; }
.exam-plan__day.is-test .exam-plan__task { color: var(--ink); font-weight: 600; }
.exam-plan__day .btn--sm { padding: 4px 12px; white-space: nowrap; }
.exam-plan__more { padding: 2px 10px; font-size: var(--fs-sm); }

/* Mock exam. */
.exam-mock__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-3); }
.exam-mock__last { margin: 6px 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.exam-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-full); background: var(--surface-sunk); }
.exam-seg__opt {
  min-height: 34px; padding: 0 14px; border: 0; border-radius: var(--r-full); background: transparent;
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
@media (hover: hover) { .exam-seg__opt:hover { color: var(--ink); } }
.exam-seg__opt[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Where you stand: one row per set on the test. */
.exam-sets { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-3); }
.exam-set {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: var(--s-3);
  padding: 10px 10px 10px var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.exam-set__main { display: grid; gap: 4px; min-width: 0; }
.exam-set__title { font-weight: 600; overflow-wrap: break-word; }
.exam-set__meta { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.exam-set__pct { min-width: 38px; text-align: right; font-weight: 700; color: var(--ink-soft); }
.exam-bar { height: 6px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.exam-bar i {
  display: block; height: 100%; border-radius: inherit; background: var(--subject, var(--brand));
  transition: width var(--dur-slow) var(--ease-out);
}
.exam-others { margin: var(--s-2) 0 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.exam-weak { display: grid; gap: var(--s-3); justify-items: start; }
.exam-weak__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.exam-chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); text-decoration: none;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .exam-chip:hover { border-color: var(--subject, var(--brand)); color: var(--ink); } }
.exam-due { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: var(--s-4) 0 0; font-size: var(--fs-sm); }
.exam-due svg { color: var(--brand-ink); }
.exam-topics { margin-top: var(--s-4); border-top: 1px solid var(--line); padding-top: var(--s-3); }
.exam-topics summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); min-height: 24px; }
@media (hover: hover) { .exam-topics summary:hover { color: var(--ink); } }
.exam-topics__list { display: grid; gap: 8px; margin-top: var(--s-3); }
.exam-topic {
  display: grid; grid-template-columns: minmax(0, 1fr) 36% 40px; align-items: center; gap: var(--s-3); font-size: var(--fs-sm);
}
.exam-topic__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.exam-topic__pct { text-align: right; font-weight: 700; color: var(--ink-soft); }

/* #/exam-prep — coming tests as cards, other subjects as rows. */
.exam-lede { margin: -8px 0 0; max-width: 62ch; color: var(--ink-soft); }
.exam-section { display: grid; gap: var(--s-3); }
.exam-section__head { margin: 0; font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; }
.exam-cards { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.exam-card {
  display: grid; gap: var(--s-3); align-content: start;
  padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg);
  background:
    radial-gradient(90% 120% at 0% 0%, color-mix(in srgb, var(--subject) 10%, transparent), transparent 55%),
    var(--surface);
}
.exam-card__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.exam-card__name {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0;
  font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; color: var(--ink); text-decoration: none;
}
@media (hover: hover) { .exam-card__name:hover { text-decoration: underline; text-underline-offset: 3px; } }
.exam-card__meta { margin: -6px 0 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.exam-pill {
  flex: none; padding: 3px 10px; border-radius: var(--r-full);
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; background: var(--surface-sunk); color: var(--ink-soft);
}
.exam-pill.is-soon { background: var(--retry-tint); color: var(--retry-ink); }
.exam-card__ready { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); }
.exam-card__ready span { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.exam-card__today {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding-top: var(--s-3); border-top: 1px solid var(--line);
}
.exam-card__task { min-width: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.exam-card__task b { color: var(--ink); }
.exam-card__done { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--ok-ink); }
.exam-card__today .btn--sm { flex: none; padding: 4px 12px; white-space: nowrap; }

/* #/exam-prep — your tests: a head with the one action, then the tests. */
.exam-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3) var(--s-5); }
.exam-head .exam-lede { margin: 8px 0 0; }
.exam-head > .btn { flex: none; }
.exam-count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 8px; padding: 0 6px;
  border-radius: var(--r-full); background: var(--surface-sunk); color: var(--ink-soft);
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; vertical-align: 2px;
}
.exam-emptyhero {
  display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-7, 40px) var(--s-5); text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  background: radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--brand) 8%, transparent), transparent 60%), var(--surface);
}
.exam-emptyhero__ic {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: var(--brand-tint); color: var(--brand-ink);
}
.exam-emptyhero h2 { margin: 4px 0 0; font-size: var(--fs-lg); font-weight: 750; letter-spacing: -.015em; }
.exam-emptyhero p { margin: 0 0 var(--s-2); max-width: 52ch; color: var(--ink-soft); }
.exam-hp {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  color: inherit; text-decoration: none; transition: border-color var(--dur-fast);
}
@media (hover: hover) { .exam-hp:hover { border-color: var(--line-strong); } }
.exam-hp__ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-sunk); color: var(--ink-soft); flex: none; }
.exam-hp > span:nth-child(2) { display: grid; gap: 1px; flex: 1; min-width: 0; }
.exam-hp b { font-size: var(--fs-sm); }
.exam-hp small { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.exam-hp > svg:last-child { color: var(--ink-faint); flex: none; }
.exam-dlg__subject { display: grid; gap: 0; margin-top: var(--s-2); }
.exam-dlg__subject select {
  height: 40px; padding: 0 var(--s-3); border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit;
}
@media (max-width: 620px) {
  .exam-head > .btn { width: 100%; justify-content: center; }
}

/* How it works — a real sequence, so it's numbered. */
.exam-how {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}
.exam-how__step {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.exam-how__n {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-full);
  background: var(--brand-tint); color: var(--brand-ink); font-weight: 800; font-size: var(--fs-sm);
}
.exam-how__text { display: grid; gap: 2px; min-width: 0; }
.exam-how__text b { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.exam-how__text b svg { color: var(--ink-faint); }
.exam-how__text span { font-size: var(--fs-sm); color: var(--ink-soft); }

/* "Lägg till prov" dialog. */
.modal__card.exam-dlg { max-width: 880px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.exam-dlg__label {
  display: flex; align-items: center; gap: 6px; margin: var(--s-4) 0 var(--s-2);
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink);
}
.exam-dlg__label--row { justify-content: space-between; }
.exam-dlg__all { font-size: var(--fs-sm); font-weight: 600; }
.exam-dlg__sets {
  display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto;
  padding: 4px; border: 1px solid var(--line); border-radius: var(--r-md);
}
.exam-dlg__set {
  display: flex; align-items: center; gap: var(--s-3); min-height: 40px; padding: 6px 10px;
  border-radius: var(--r-sm); font-size: var(--fs-sm); cursor: pointer;
}
@media (hover: hover) { .exam-dlg__set:hover { background: var(--surface-sunk); } }
.exam-dlg__set input { flex: none; width: 18px; height: 18px; accent-color: var(--brand); }
.exam-dlg__set > span:first-of-type { flex: 1; min-width: 0; }
.exam-dlg__n { flex: none; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.exam-dlg__err { margin: var(--s-2) 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--retry-ink); }
.exam-dlg__err:empty { display: none; }
.exam-dlg > .dlgfoot {
  position: sticky; bottom: calc(-1 * var(--s-5)); z-index: 1;
  margin-bottom: calc(-1 * var(--s-5)); padding-bottom: var(--s-5); background: var(--surface);
}
.exam-dlg__remove { color: var(--retry-ink); }

@media (max-width: 700px) {
  .exam-hero { grid-template-columns: minmax(0, 1fr); padding: var(--s-4); gap: var(--s-4); }
  .exam-hero__side { grid-row: 1; grid-template-columns: auto 1fr; justify-items: start; align-items: center; }
  .exam-hero__cover { text-align: left; }
  .exam-ring { width: 84px; }
  .exam-ring__val b { font-size: calc(20px * var(--fs-scale, 1)); }
  .exam-ring__val span { display: none; }
  .exam-today .btn { width: 100%; justify-content: center; }
  .exam-set { grid-template-columns: minmax(0, 1fr) auto auto; }
  .exam-set__pct { display: none; }
}

/* The Högskoleprov hub (views/hp.js) still lays its dated plan out with the
   old exam-prep plan markup. */
.exam-prep__day {
  display: grid; grid-template-columns: 66px 1fr auto; align-items: center;
  gap: var(--s-3); padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm);
}
.exam-prep__actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.exam-prep__mastery-head { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }
.exam-prep__pct { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); color: var(--ink-soft); }
.exam-prep__days { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: 2px; }
.exam-prep__day-when { color: var(--ink-faint); font-weight: 700; font-size: calc(12px * var(--fs-scale, 1)); text-transform: capitalize; }
.exam-prep__day-task { min-width: 0; color: var(--ink-soft); }
.exam-prep__day-min { color: var(--ink-faint); font-size: calc(12px * var(--fs-scale, 1)); flex: none; }
.exam-prep__day.is-today { background: var(--brand-tint); }
.exam-prep__day.is-today .exam-prep__day-task { color: var(--ink); font-weight: 600; }
.exam-prep__day.is-today .exam-prep__day-when { color: var(--brand-ink); }
.exam-prep__day.is-test .exam-prep__day-task { color: var(--ink-faint); font-style: italic; }
.exam-prep__day .btn--sm { padding: 4px 12px; white-space: nowrap; }

/* ---------- formula sheet (views/reference.js) ----------
   Subject tabs with an icon and a count, a level filter, then the subject's groups of formula
   cards; a sticky contents list beside them on wide screens. --c is the subject's colour. */
.ref { max-width: 1120px; display: grid; gap: var(--s-4); }
.ref__head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.ref__head h1 { margin: 0; }
.ref__sub { margin: 4px 0 0; max-width: 62ch; color: var(--ink-soft); }
.ref__controls { display: grid; gap: var(--s-3); }
.ref__search { max-width: 640px; }

.ref__tabs { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ref__tab {
  display: inline-flex; align-items: center; gap: 10px; min-height: 50px; padding: 8px 16px 8px 9px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-weight: 600; color: var(--ink-soft); text-align: left; cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.ref__tabic {
  flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface); background: color-mix(in oklab, var(--c) 13%, var(--surface)); color: var(--c);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.ref__tabcount { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .ref__tab:hover { border-color: var(--line); border-color: color-mix(in oklab, var(--c) 50%, var(--line)); color: var(--ink); } }
.ref__tab:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.ref__tab[aria-selected="true"] { border-color: var(--c); background: var(--surface); background: color-mix(in oklab, var(--c) 7%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 1px var(--c); }
.ref__tab[aria-selected="true"] .ref__tabic { background: var(--c); color: #fff; }

.ref__levels { display: flex; flex-wrap: wrap; gap: 6px; }
.ref__level {
  min-height: 34px; padding: 0 14px; border-radius: var(--r-full); border: 1px solid var(--line-strong); background: transparent;
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .ref__level:hover { color: var(--ink); border-color: var(--ink-faint); } }
.ref__level:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ref__level[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.ref__result { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.ref__result[hidden] { display: none; }

.ref__layout { display: grid; gap: var(--s-6); align-items: start; }
.ref__toc { display: none; }
@media (min-width: 1280px) {
  .ref__layout { grid-template-columns: 196px minmax(0, 1fr); }
  .ref__layout:has(> .ref__toc[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .ref__toc:not([hidden]) { display: block; position: sticky; top: 90px; }
}
.ref__tochead { margin: 0 0 8px 10px; font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); }
.ref__toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ref__toc button {
  width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; font: inherit; font-size: var(--fs-sm); color: var(--ink-soft); text-align: left; cursor: pointer;
}
@media (hover: hover) { .ref__toc button:hover { background: var(--surface-sunk); color: var(--ink); } }
.ref__toc button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ref__toccount { color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.ref__body { display: grid; gap: var(--s-6); min-width: 0; }
.ref__group { display: grid; gap: var(--s-3); scroll-margin-top: 90px; }
.ref__grouphead { display: flex; align-items: baseline; gap: 10px; }
.ref__grouphead h2 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: var(--fs-lg); letter-spacing: -.01em; }
.ref__grouphead i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.ref__grouphead > span { font-size: var(--fs-sm); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.ref__grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

.ref__card {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.ref__cardhead { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.ref__name { margin: 0; font-size: var(--fs-md); font-weight: 700; line-height: 1.3; }
.ref__lvl { flex: none; margin-top: 2px; padding: 2px 8px; border-radius: var(--r-full); font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; white-space: nowrap; }
.ref__lvl.is-hs { background: var(--surface-sunk); color: var(--ink-soft); }
.ref__lvl.is-gy { border: 1px solid var(--line-strong); color: var(--ink-soft); }
/* The formula itself: overflow-y hidden, or a tall fraction gives the panel its own little scrollbar. */
.ref__math {
  padding: 16px 14px; border-radius: var(--r-md); text-align: center; font-size: 1.22rem; color: var(--ink);
  background: var(--surface-sunk); background: color-mix(in oklab, var(--c) 6%, var(--surface-sunk)); overflow-x: auto; overflow-y: hidden;
}
.ref__math { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 28px; }
.ref__part .katex { white-space: nowrap; }
.ref__vars { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: var(--fs-sm); align-items: baseline; }
.ref__vars dt { color: var(--ink); white-space: nowrap; }
.ref__vars dd { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; color: var(--ink-soft); }
.ref__unit { padding: 0 6px; border-radius: 6px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-soft); background: var(--surface-sunk); }
.ref__note { margin: 0; font-size: calc(12.5px * var(--fs-scale, 1)); line-height: 1.5; color: var(--ink-faint); }
.ref__table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.ref__table th { padding: 0 8px 6px; text-align: left; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); border-bottom: 1px solid var(--line); }
.ref__table td { padding: 6px 8px; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.ref__table tr:last-child td { border-bottom: 0; }
.ref__sym { width: 3.5em; font-weight: 700; color: var(--ink); }
.ref mark { padding: 0 1px; border-radius: 3px; color: inherit; background: color-mix(in oklab, var(--c, var(--brand)) 30%, transparent); }

@media (max-width: 560px) {
  .ref__tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ref__tab { padding-right: 10px; font-size: var(--fs-sm); }
  .ref__tabname { flex: 1; min-width: 0; line-height: 1.2; }
  .ref__math { font-size: 1.1rem; padding: 14px 10px; }
  .ref__print { display: none; }
}
/* The smallest phones (and small phones with large text): two tabs side by side leave the name too little
   room next to the count, so the count moves under the name and the icon tile shrinks a little. */
@media (max-width: 359px) {
  .ref__tab { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 2px 8px; align-content: center; padding-left: 8px; }
  .ref__tabic { grid-row: span 2; width: 28px; height: 28px; border-radius: 8px; }
  .ref__tabcount { line-height: 1.2; }
}
@media (min-width: 360px) and (max-width: 419px) {
  :root[data-textsize="l"] .ref__tab { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 2px 8px; align-content: center; padding-left: 8px; }
  :root[data-textsize="l"] .ref__tabic { grid-row: span 2; width: 28px; height: 28px; border-radius: 8px; }
  :root[data-textsize="l"] .ref__tabcount { line-height: 1.2; }
}

@media print {
  body:has(.ref) :is(.sidebar, .tabbar, .sitefooter, .sitechat__fab, .topbar, .homebtn) { display: none !important; }
  .ref__controls, .ref__toc, .ref__print, .ref__result { display: none !important; }
  .ref { max-width: none; gap: 6px; }
  .ref__layout { display: block; }
  .ref__body { gap: 14px; }
  .ref__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ref__card { break-inside: avoid; gap: 6px; padding: 10px; border-color: #bbb; }
  .ref__math { padding: 4px 0; background: none; font-size: 1.05rem; }
  .ref__grouphead h2 { font-size: calc(15px * var(--fs-scale, 1)); }
}

/* ---------- calculator & graph plotter ---------- */
.calc { max-width: 560px; }
.calc__screen { background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3); }
.calc__screentop { display: flex; gap: var(--s-2); align-items: center; }
.calc__input {
  flex: 1; min-width: 0; font: inherit; font-size: var(--fs-md); font-family: ui-monospace, "SF Mono", Menlo, monospace;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px;
  background: var(--surface); color: var(--ink);
}
.calc__output {
  margin-top: var(--s-2); text-align: right; font-size: var(--fs-xl); font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--ink);
  overflow-x: auto; min-height: 1.4em;
}
.calc__output.is-error { color: var(--retry-ink); font-size: var(--fs-md); font-weight: 500; }
.calc__pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: var(--s-3); }
.calc__key {
  font: inherit; font-size: var(--fs-md); font-weight: 600; padding: 12px 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: background var(--dur-fast);
}
@media (hover: hover) { .calc__key:hover { background: var(--surface-sunk); } }
.calc__key--op { color: var(--brand-ink); }
.calc__key--eq { background: var(--brand); color: #fff; border-color: var(--brand); }
@media (hover: hover) { .calc__key--eq:hover { background: var(--brand-bright); } }
.calc__history { margin-top: var(--s-3); display: grid; gap: 4px; }
.calc__hrow {
  display: flex; justify-content: space-between; gap: var(--s-3); width: 100%;
  border: none; background: none; cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-soft); text-align: left;
}
@media (hover: hover) { .calc__hrow:hover { background: var(--surface-sunk); } }
.calc__hval { color: var(--ink); font-weight: 700; flex: none; }
.calc.calc--wide { max-width: 1120px; }

/* Grafräknare (components/graph-calc.js): the rows on the left, the graph on the right; on a
   phone the graph comes first and the rows follow. */
.gcalc { display: grid; grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.gcalc__rows { display: flex; flex-direction: column; gap: 6px; }
.gcalc__row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px 4px 4px 10px; }
.gcalc__row:focus-within { border-color: var(--brand); }
.gcalc__line { display: flex; align-items: center; gap: 8px; }
.gcalc__swatch {
  flex: none; width: 16px; height: 16px; padding: 0; border-radius: var(--r-full);
  border: 2px solid var(--c); background: var(--c); cursor: pointer;
}
.gcalc__swatch[aria-pressed="false"] { background: transparent; }
.gcalc__swatch:disabled { border-color: var(--line-strong); background: transparent; cursor: default; }
.gcalc__swatch:focus-visible { outline: none; box-shadow: var(--ring); }
.gcalc__input {
  flex: 1; min-width: 0; padding: 7px 2px; border: none; outline: none; background: transparent;
  font: inherit; font-size: calc(15px * var(--fs-scale, 1)); color: var(--ink); font-variant-numeric: tabular-nums;
}
/* The row's border already shows where you're typing (.gcalc__row:focus-within): no second ring inside it. */
.gcalc__input:focus-visible { outline: none; box-shadow: none; }
.gcalc__input::placeholder { color: var(--ink-faint); }
.gcalc__row.is-hidden .gcalc__input { color: var(--ink-faint); }
.gcalc__del {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: none; border-radius: var(--r-sm); background: none; color: var(--ink-faint); cursor: pointer;
}
@media (hover: hover) { .gcalc__del:hover { color: var(--ink); background: var(--surface-sunk); } }
.gcalc__extras:empty { display: none; }
.gcalc__err { margin: 2px 0 6px 24px; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--retry-ink); }
.gcalc__slider {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto 4ch; align-items: center; gap: 6px;
  margin: 2px 6px 6px 24px; font-size: calc(11.5px * var(--fs-scale, 1)); color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.gcalc__range { width: 100%; margin: 0; accent-color: var(--brand); }
.gcalc__val { font-size: calc(13px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink); text-align: right; }
.gcalc__tools { margin: 0; }
/* Small headings over the tools, the folded examples and the folded list of points. */
.gcalc__label { margin: 0 0 6px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
summary.gcalc__label {
  display: flex; align-items: center; gap: 7px; width: fit-content; min-height: 24px; margin: 0;
  list-style: none; cursor: pointer;
}
summary.gcalc__label::-webkit-details-marker { display: none; }
summary.gcalc__label::before {
  content: ""; width: 5px; height: 5px; margin-left: 1px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--dur-fast);
}
details[open] > summary.gcalc__label { margin-bottom: 6px; }
details[open] > summary.gcalc__label::before { transform: rotate(45deg); }
@media (hover: hover) { summary.gcalc__label:hover { color: var(--ink-soft); } }
summary.gcalc__label:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.gcalc__exlist { display: grid; gap: 4px; }
.gcalc__exbtn {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
  font: inherit; text-align: left; color: var(--ink); cursor: pointer;
}
@media (hover: hover) { .gcalc__exbtn:hover { border-color: var(--brand); } }
.gcalc__exbtn:focus-visible { outline: none; box-shadow: var(--ring); }
.gcalc__exbtn code { font-family: inherit; font-size: calc(14px * var(--fs-scale, 1)); font-variant-numeric: tabular-nums; }
.gcalc__exbtn span { flex: none; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.gcalc__stage {
  position: relative; height: 460px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.gcalc__canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.gcalc__canvas:active { cursor: grabbing; }
.gcalc__canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.gcalc__readout {
  position: absolute; left: 8px; top: 8px; max-width: calc(100% - 64px); padding: 4px 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
  font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; pointer-events: none;
}
.gcalc__zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.gcalc__zbtn {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
}
@media (hover: hover) { .gcalc__zbtn:hover { border-color: var(--brand); } }
.gcalc__zbtn:focus-visible { outline: none; box-shadow: var(--ring); }
.gcalc__hint { margin: 6px 0 0; font-size: calc(12.5px * var(--fs-scale, 1)); }
.gcalc__side { grid-row: span 2; display: grid; gap: var(--s-4); }
.gcalc__points { grid-column: 2; }
.gcalc__plist { margin: 0; padding-left: 18px; columns: 2 240px; column-gap: var(--s-5); font-size: calc(13.5px * var(--fs-scale, 1)); font-variant-numeric: tabular-nums; }
@media (max-width: 800px) {
  .gcalc { grid-template-columns: minmax(0, 1fr); }
  .gcalc__side { grid-row: auto; }
  .gcalc__main { order: -1; }
  .gcalc__points { grid-column: auto; }
  .gcalc__stage { height: min(380px, 78vw); }
}

/* The same, as a dialog over a practice session. */
.modal.gcalc-modal { place-items: start center; padding: 12px; }
.modal__card.gcalc-modal__card {
  max-width: 1120px; width: min(1120px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  padding: var(--s-4);
}
.gcalc-modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.gcalc-modal__head h2 { margin: 0; font-size: var(--fs-lg, 1.25rem); }

/* ---------- create flow ---------- */
.create-title { margin-bottom: var(--s-3); }
/* The three steps as a stepper: numbered dots joined by a line; done ones get a check. */
.steps { display: flex; align-items: center; gap: 0; margin: 0 0 var(--s-5); padding: 0; list-style: none; flex-wrap: wrap; row-gap: var(--s-2); }
.step { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-faint); }
.step + .step::before {
  content: ""; width: 36px; height: 2px; margin: 0 12px; border-radius: 2px; background: var(--line-strong);
}
.step.on, .step.is-done { color: var(--ink); }
.step.on + .step::before, .step.is-done + .step::before { background: var(--line-strong); background: color-mix(in oklab, var(--brand) 55%, var(--line-strong)); }
.step__n {
  width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center; flex: none;
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; background: var(--surface-sunk); color: var(--ink-faint); border: 1px solid var(--line-strong);
}
.step.on .step__n { background: var(--brand); color: #fff; border-color: transparent; box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.step.is-done .step__n { background: var(--brand-tint); color: var(--brand-ink); border-color: transparent; }

/* Step 1 — where the questions come from: two groups of sources. */
.srcpanel { display: grid; gap: var(--s-5); padding: var(--s-5); }
.srcpanel__q { margin: 0; font-family: var(--font-display); font-size: var(--fs-lg, 1.2rem); font-weight: 700; color: var(--ink); }
/* A draft or restored changes, offered above the source choice in Skapa and at the top of the set editor. */
.draftcard { display: grid; gap: var(--s-3); margin-bottom: var(--s-4); }
.draftcard h2 { margin: 0; font-size: var(--fs-lg); }
.draftcard .note { margin: 0; }
.draftcard__actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.srcgroup { display: grid; gap: var(--s-3); }
.srcgroup + .srcgroup { padding-top: var(--s-5); border-top: 1px solid var(--line); }
.srcgroup__head { display: flex; align-items: center; gap: 10px; }
.srcgroup__ic {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand-ink);
}
.srcgroup__head h2 { margin: 0; font-size: var(--fs-md); font-weight: 700; color: var(--ink); }
.srcgroup__head p { margin: 1px 0 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.srcgroup__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--s-3); }
.srcpick {
  --c: var(--brand);   /* each source sets its own colour (views/create.js) */
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 14px 14px 16px; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); background: color-mix(in oklab, var(--c) 6%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--c) 28%, var(--line)); border-radius: var(--r-md);
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
@media (hover: hover) { .srcpick:hover {
  border-color: var(--line); border-color: color-mix(in oklab, var(--c) 65%, var(--line)); background: var(--surface); background: color-mix(in oklab, var(--c) 10%, var(--surface));
  transform: translateY(-1px); box-shadow: var(--shadow-1);
} }
.srcpick:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.srcpick__ic {
  flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--c); color: #fff; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--c) 70%, transparent);
}
.srcpick__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.srcpick__text strong { font-size: var(--fs-md); font-weight: 700; color: var(--ink); }
.srcpick__text small { font-size: var(--fs-sm); line-height: 1.4; color: var(--ink-soft); }
.srcpick__go { flex: none; color: var(--ink-faint); opacity: 0; transform: translateX(-4px); transition: opacity var(--dur-fast), transform var(--dur-fast); }
.srcpick:hover .srcpick__go, .srcpick:focus-visible .srcpick__go { opacity: 1; transform: none; color: var(--c); }
.srcpick__tag {
  justify-self: start; margin-top: 4px; padding: 2px 8px; border-radius: var(--r-full);
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); background: var(--surface-sunk);
}
/* An AI source with nothing to run it — still openable (you can prepare the
   material), just clearly not ready to generate. */
.srcpick.is-locked { border-style: dashed; background: var(--surface); }
.srcpick.is-locked .srcpick__ic { background: var(--surface); background: color-mix(in oklab, var(--c) 14%, var(--surface)); color: var(--c); box-shadow: none; }
@media (max-width: 560px) {
  .srcpanel { padding: var(--s-4); }
  .step + .step::before { width: 16px; margin: 0 8px; }
}
@media (prefers-reduced-motion: reduce) { @media (hover: hover) { .srcpick:hover { transform: none; } } }

/* Step 2 — the material and the settings (views/create.js inputStep): one card with the chosen source
   at the top, its material, the settings as rows (the same .set-row as Settings), then Back and the
   main button. Every source is laid out the same way; each shows only the parts it needs. */
.mk { padding: 0; overflow: hidden; }
.mk [hidden] { display: none !important; }
.mk__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5); border-bottom: 1px solid var(--line); }
.mk__ic {
  flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-tint); background: color-mix(in oklab, var(--c, var(--brand)) 14%, var(--surface)); color: var(--c, var(--brand));
}
.mk__head h2 { margin: 0; font-size: var(--fs-lg); letter-spacing: -.01em; }
.mk__head p { margin: 2px 0 0; max-width: 64ch; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-soft); }
.mk__body { display: grid; gap: var(--s-5); padding: var(--s-5); }
.mk__group { display: grid; gap: var(--s-2); }
.mk__label { margin: 0; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.mk__field { display: grid; gap: var(--s-3); min-width: 0; }
.mk .set-seg { justify-self: start; }
.mk__text {
  width: 100%; min-height: 200px; resize: vertical; padding: 14px 16px;
  font: inherit; line-height: 1.55; color: var(--ink);
  background: var(--surface-sunk); border: 1px solid var(--line-strong); border-radius: var(--r-md);
}
.mk__text:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.mk__meta { display: flex; justify-content: flex-end; margin-top: calc(-1 * var(--s-2)); }
.mk__count { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.mk__hint { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-faint); }
.mk__status { margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.mk__status:empty { display: none; }
.mk__status.is-ok { color: var(--ok-ink); font-weight: 600; }
.mk__status.is-warn { color: var(--retry-ink); font-weight: 600; }
/* "Ser ut som 3 avsnitt": one set per section, offered under the text. */
.mk__split {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-sunk);
}
.mk__splittext { display: grid; gap: 6px; min-width: 0; font-size: var(--fs-sm); }
.mk__splittags { display: flex; flex-wrap: wrap; gap: 6px; }
.mk__settings { display: grid; padding: var(--s-4) var(--s-5) var(--s-2); border-top: 1px solid var(--line); }
.mk__head + .mk__settings { border-top: 0; }
.mk__settings > .mk__label + .set-row { border-top: 0; }
.mk__settings .set-row { flex-wrap: wrap; }
.mk__settings > .note { margin: var(--s-2) 0 var(--s-3); }
.mk__locked {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: var(--r-full);
  background: var(--surface-sunk); font-size: var(--fs-sm); font-weight: 600; color: var(--ink);
}
.mk__locked svg { color: var(--ink-faint); }
.mk__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line);
  background: var(--surface-sunk); background: color-mix(in oklab, var(--surface-sunk) 45%, var(--surface));
}
/* Nationellt prov: where to get the exam, and what has already been made from it. */
.npcard { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-sunk); }
.npcard__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); }
.npcard__name { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.npcard__badge {
  padding: 2px 8px; border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface);
  font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-soft);
}
.npcard__note { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-soft); }
.npcard__mine { display: grid; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--line); }
.npcard__label { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.npcard__sets { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.npcard__sets li { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); }
.npcard__sets span { flex: none; color: var(--ink-faint); }
.npcard__mix { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); font-size: var(--fs-sm); }
@media (max-width: 560px) {
  .mk__head, .mk__body, .mk__settings, .mk__foot { padding-inline: var(--s-4); }
  .mk__head { align-items: flex-start; }
}
/* On a phone the Back / Create row stays in reach just above the tab bar: with pasted text, the subjects and
   settings pushed the one button the page exists for far below the screen. (clip, not hidden, so the row can stick.) */
@media (max-width: 899.98px) {
  @supports (overflow: clip) {
    .mk { overflow: clip; }
    .mk__foot { position: sticky; bottom: calc(60px + env(safe-area-inset-bottom, 0px)); z-index: 6; }
  }
}
@media (max-width: 899.98px) and (max-height: 500px) {
  body:has(:is(input, textarea, [contenteditable="true"]):focus) .mk__foot { bottom: 0; }   /* the tab bar steps aside while typing (see .solve-dock) */
}

.source-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); }
.source-opt { position: relative; cursor: pointer; padding: var(--s-5) var(--s-4); border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--surface); text-align: center; font-family: var(--font-display); font-weight: 600; transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast); }
@media (hover: hover) { .source-opt:hover { transform: translateY(-2px); border-color: var(--brand); } }
.source-opt svg { display: block; margin: 0 auto var(--s-2); }
/* Library's subject picker only — every subject otherwise looked identical
   (same brand-blue book icon), which read as flat. Same colour-accent idiom
   .acard already uses (a solid stripe, not a full-saturation border all
   round), so it matches how subjects look everywhere else in the app. */
.source-opt--subject { border-left: 6px solid var(--subject, var(--line-strong)); }
.source-opt--subject svg { color: var(--subject, var(--brand)); }
@media (hover: hover) { .source-opt--subject:hover { border-color: var(--subject, var(--brand)); } }

/* Library's subject picker on a phone: the big centred cards meant three
   subjects filled the screen and åk 9 (thirteen subjects) was ~4 screens of
   scrolling. Collapse to single-line rows — colour stripe + icon + name; the
   blurb shows on the set-list header you land on. Desktop keeps the cards. */
@media (max-width: 560px) {
  .source-grid--subjects { display: flex; flex-direction: column; gap: var(--s-2); }
  .source-grid--subjects .source-opt--subject {
    display: flex; align-items: center; gap: var(--s-3);
    text-align: left; padding: var(--s-3) var(--s-4);
  }
  .source-grid--subjects .source-opt--subject svg { margin: 0; flex: none; width: 20px; height: 20px; }
  .source-grid--subjects .source-opt--subject .note { display: none; }
}

/* Subject picker (components/subject-field.js): a short row of subjects, then "+ Nytt ämne". */
.subjectfield { display: flex; flex-direction: column; gap: var(--s-3); }
.subjpick { display: flex; flex-wrap: wrap; gap: 8px; }
.subjpick__chip {
  padding: 7px 14px; border-radius: var(--r-full); cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .subjpick__chip:hover { border-color: var(--brand); } }
.subjpick__chip:focus-visible { outline: none; box-shadow: var(--ring); }
.subjpick__chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.subjpick__chip--new { border-style: dashed; color: var(--brand-ink); }
.subjpick__chip--new[aria-pressed="true"] { background: transparent; border-style: solid; border-color: var(--brand); color: var(--brand-ink); }
.subjpick__more {
  padding: 7px 4px; border: none; background: none; cursor: pointer; font: inherit; font-size: var(--fs-sm);
  font-weight: 600; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px;
}
@media (hover: hover) { .subjpick__more:hover { color: var(--ink); } }
.subjpick__new[hidden] { display: none; }
/* Styled here rather than through .field, so it looks the same in any form (Skapa's settings rows too). */
.subjpick__input {
  width: 100%; max-width: 380px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
}
.subjpick__input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
/* Remove mode: the subjects of your own turn into remove buttons, the rest step back. */
.subjpick__chip:disabled { opacity: .4; cursor: default; }
@media (hover: hover) { .subjpick__chip:disabled:hover { border-color: var(--line-strong); } }
.subjpick__chip--remove { border-color: var(--retry); color: var(--retry-ink); background: var(--retry-tint); }
@media (hover: hover) { .subjpick__chip--remove:hover { border-color: var(--retry-ink); } }
.subjpick__x { margin-left: 8px; font-weight: 700; }
.subjpick__manage { margin-left: auto; color: var(--ink-faint); font-weight: 500; }

/* Sign in with Google: Google's own button (its size/colours are fixed by
   Google), centred above the email form with an "or" rule beneath. The button
   lives in Google's iframe, whose page is light-scheme; on a dark theme the
   iframe would inherit color-scheme: dark, and that mismatch makes browsers
   paint its canvas opaque white — a white box around the dark pill.
   Fixed height, clipped: while it loads, Google's script shows its own
   placeholder button with the iframe stacked underneath, and the iframe grows
   to full size a moment before the placeholder is hidden — so for a second or
   two there were two buttons and the form below jumped down and back. Clipped
   to one button's height, only the top one ever shows. */
.gbtn { display: flex; justify-content: center; height: 44px; overflow: hidden; color-scheme: light; }
.field { display: block; margin-bottom: var(--s-4); }
.field > span { display: block; font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--s-2); }
/* passwordRow: the <label> sits inside the row's text line (not around the field), so it fills the line and a tap
   anywhere on it still puts the cursor in the field. */
.field > span > label, .auth__field > span > label { display: block; }
.field input[type=text], .field input[type=number], .field input[type=email], .field input[type=password], .field select, .field textarea {
  width: 100%; font: inherit; padding: var(--s-3); border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface);
}
.field textarea { min-height: 160px; resize: vertical; }

/* ---------- file drop zone ----------
   One control for every "give me a file" moment. The dashed edge is the cue
   that you can drag onto it; the whole zone fills with the brand tint (and
   says so) while a file is over the page, wherever it's dropped. */
.drop {
  position: relative; display: grid; justify-items: center; gap: var(--s-2);
  padding: var(--s-6) var(--s-5); text-align: center;
  border: 2px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-sunk);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.drop [hidden] { display: none !important; }
.drop.is-over { border-style: solid; border-color: var(--brand); }
.drop.has-file { padding: var(--s-4) var(--s-5); border-style: solid; border-color: var(--line); background: var(--surface); }
.drop.has-file .drop__ic { display: none; }
.drop__ic {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); color: var(--brand-ink);
}
.drop__idle { display: grid; justify-items: center; gap: var(--s-2); max-width: 100%; }
.drop__done { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-3); max-width: 100%; }
.drop__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-2) var(--s-3); margin: 0; }
.drop__lead { font-weight: 600; color: var(--ink); }
.drop__hint { margin: 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.drop__file {
  display: inline-flex; align-items: center; gap: var(--s-2); max-width: 100%;
  padding: 5px 6px 5px 8px; border: 1px solid var(--line-strong); border-radius: var(--r-full);
  background: var(--surface); font-weight: 600;
}
.drop__thumb { width: 34px; height: 34px; flex: none; border-radius: 8px; object-fit: cover; }
.drop__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.drop__x {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: var(--surface-sunk); color: var(--ink-soft); cursor: pointer;
}
@media (hover: hover) { .drop__x:hover { background: var(--line); color: var(--ink); } }
.drop__x:focus-visible { outline: none; box-shadow: var(--ring); }
.drop__msg { margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.drop__msg:empty { display: none; }
.drop__msg.is-warn { color: var(--retry-ink); font-weight: 600; }
.drop__release {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit;
  background: var(--brand-tint); color: var(--brand-ink); font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-fast);
}
.drop.is-over .drop__release { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .drop, .drop__release { transition: none; } }

/* ---------- question editor ---------- */
.qedit { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); margin-bottom: var(--s-3); background: var(--surface); }
.qedit__row { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-2); }
.qedit__head { flex-wrap: wrap; row-gap: var(--s-2); }
.qedit__row input[type=text] { min-width: 0; }   /* lets an answer box shrink instead of pushing the × off a small screen */
/* Every control in a question gets the same look as the app's other fields,
   instead of the browser's stock select and text box. */
.qedit select, .qedit input[type=text], .qedit textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 8px 12px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.qedit select { padding-right: 8px; cursor: pointer; }
.qedit__head select, .qedit__head input[type=text] { padding: 6px 10px; font-size: var(--fs-sm); }
@media (hover: hover) { .qedit select:hover, .qedit input[type=text]:hover, .qedit textarea:hover { border-color: var(--ink-faint); } }
.qedit select:focus-visible, .qedit input[type=text]:focus-visible, .qedit textarea:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
.qedit textarea, .qedit .field textarea { width: 100%; min-height: 84px; line-height: 1.5; resize: vertical; }
/* Which choice is right: a real radio underneath, drawn as the choice's letter. */
.qedit__pick { position: relative; flex: none; display: grid; place-items: center; width: 32px; height: 32px; cursor: pointer; }
.qedit__pick input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.qedit__pick span {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--surface-sunk); color: var(--ink-soft);
  font-size: calc(13px * var(--fs-scale, 1)); font-weight: 800; transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.qedit__pick:hover span { border-color: var(--ok); }
.qedit__pick input:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.qedit__pick input:focus-visible + span { box-shadow: var(--ring); }

/* A deadline folded into one row — the month grid opens on demand. */
.deadline-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-2); margin-bottom: var(--s-4); }
.deadline { flex: 1 1 240px; max-width: 360px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); }
.deadline > summary {
  display: flex; align-items: center; gap: var(--s-3); padding: 10px var(--s-4);
  font-weight: 700; font-size: var(--fs-sm); cursor: pointer; list-style: none;
}
.deadline > summary::-webkit-details-marker { display: none; }
.deadline > summary::after { content: "▾"; margin-left: auto; color: var(--ink-faint); transition: transform var(--dur-fast); }
.deadline[open] > summary::after { transform: rotate(180deg); }
.deadline > summary:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-md); }
.deadline__value { font-weight: 600; color: var(--brand-ink); }
.deadline > .datepick { padding: 0 var(--s-4) var(--s-4); }
.badge { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: var(--r-full); background: var(--surface-sunk); color: var(--ink-soft); }
.dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; }

.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--surface-sunk); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: var(--s-6) auto; }

/* ---------- settings ---------- */

/* The three "how it looks and sounds" controls sit side by side and wrap on
   narrow screens, instead of stacking as three separate panels. */
/* Offline-library download progress in Settings. */
.offline-bar { height: 8px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; margin-bottom: var(--s-3); }
.offline-bar i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: inherit; transition: width var(--dur-mid) var(--ease-out); }

/* Sub-heading inside a merged panel: a hairline rule carries the grouping so
   the panel does not need to become two panels again. */
.settings__sub {
  font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700;
  margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line);
}
.panel > .settings__sub:first-of-type { margin-top: var(--s-4); padding-top: 0; border-top: none; }

/* Not a panel — the roadmap is information, not something you can change. */
.roadmapbox > h3 { font-size: var(--fs-md); color: var(--ink-soft); margin-bottom: var(--s-3); }
/* ---------- Settings: cards of rows, like a real settings screen ---------- */
.settings { display: grid; gap: var(--s-5); max-width: 1100px; }
.settings__head h1 { margin: 0; }
.settings__head p { margin: 6px 0 0; color: var(--ink-soft); }
.settings__layout { display: grid; gap: var(--s-5); align-items: start; }
.settings__sections { display: grid; gap: var(--s-5); min-width: 0; }
.settings__nav {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--s-4)); padding: 0 var(--s-4);
  /* a row that scrolls sideways with no scrollbar: the fade at its right edge says there is more */
  -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); mask-image: linear-gradient(90deg, #000 90%, transparent);
}
.settings__navlink {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 9px 12px; border-radius: var(--r-md); white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.settings__navlink svg { flex: none; color: var(--ink-faint); }
@media (hover: hover) { .settings__navlink:hover { color: var(--ink); background: var(--surface-sunk); } }
.settings__navlink.is-active { color: var(--brand-ink); background: var(--brand-tint); }
.settings__navlink.is-active svg { color: var(--brand); }
@media (max-width: 540px) {
  /* Wrap instead of scrolling sideways: the fade alone didn't show that "Konto" and "Din data" were there. */
  .settings__nav { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; -webkit-mask-image: none; mask-image: none; }
}
@media (min-width: 1100px) {
  .settings__layout { grid-template-columns: 210px minmax(0, 1fr); gap: var(--s-6, 28px); }
  .settings__nav { flex-direction: column; gap: 2px; overflow: visible; margin: 0; padding: 0; position: sticky; top: 90px; -webkit-mask-image: none; mask-image: none; }
}
/* One section at a time: the menu picks which one shows. */
.settings__sections > [id^="settings-"]:not(.is-open) { display: none; }
.settings__navtext { display: flex; flex-direction: column; min-width: 0; }
.settings__navtext small { display: none; }
.settings__back, .settings__navchev { display: none; }
@media (max-width: 699px) {
  /* A phone starts on a list of the sections, each saying what is set now; a tap opens one, Back returns. */
  .settings[data-open=""] .settings__nav {
    flex-direction: column; flex-wrap: nowrap; gap: 0; margin: 0; padding: 0 var(--s-4);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  }
  .settings[data-open=""] .settings__navlink { padding: 14px 0; border-radius: 0; border-top: 1px solid var(--line); white-space: normal; font-size: var(--fs-base, 15px); color: var(--ink); }
  .settings[data-open=""] .settings__navlink:first-child { border-top: 0; }
  .settings[data-open=""] .settings__navchev { display: grid; margin-left: auto; flex: none; }
  .settings[data-open=""] .settings__navchev svg { color: var(--ink-faint); }
  .settings[data-open=""] .settings__navlink > svg { color: var(--brand); }
  .settings[data-open=""] .settings__navtext small { display: block; margin-top: 2px; font-size: var(--fs-sm); font-weight: 400; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .settings[data-open=""] .settings__navlink.is-active { background: none; }
  .settings:not([data-open=""]) .settings__nav,
  .settings:not([data-open=""]) .settings__head,
  .settings:not([data-open=""]) > .homebtn { display: none; }
  .settings:not([data-open=""]) .settings__back {
    display: inline-flex; align-items: center; gap: 6px; justify-self: start; padding: 6px 0;
    background: none; border: 0; font: inherit; font-weight: 600; color: var(--brand-ink); cursor: pointer;
  }
}
/* "Fler inställningar": the settings few students change, folded under the main ones. */
.set-more { border-top: 1px solid var(--line); }
.set-more > summary {
  display: flex; align-items: center; gap: 8px; padding: var(--s-4) 0; cursor: pointer; list-style: none;
  font-weight: 600; color: var(--brand-ink);
}
.set-more > summary::-webkit-details-marker { display: none; }
.set-more > summary::after {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform var(--dur-fast);
}
.set-more[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.set-more > .set-row:first-of-type { border-top: 1px solid var(--line); }

.set-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: 0 var(--s-5) var(--s-2); scroll-margin-top: 90px;
}
.set-card__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) 0 var(--s-4); border-bottom: 1px solid var(--line); }
.set-card__ic {
  flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand-ink);
}
.set-card__head h2 { margin: 0; font-size: var(--fs-md); font-weight: 700; letter-spacing: -.01em; }
.set-card__head p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.set-card__foot { margin: 0; padding: var(--s-3) 0; border-top: 1px solid var(--line); font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }

.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-6, 28px);
  padding: var(--s-4) 0; border-top: 1px solid var(--line);
}
.set-card__head + .set-row, .set-acct > :first-child, .set-recovery[hidden] + .set-row { border-top: 0; }
.set-row--stack { flex-direction: column; align-items: stretch; }
/* In a column the flex-basis would become a height — size the text to its content. */
.set-row--stack .set-row__text { flex: none; max-width: none; }
.set-row__text { flex: 1 1 260px; min-width: 0; max-width: 560px; }
.set-row__label { display: block; font-weight: 600; color: var(--ink); }
.set-row__note { margin: 3px 0 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-faint); }
.set-row__note.note--warn { padding: 6px 10px; }
.set-row__ctl { flex: none; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-2); }
.set-row--stack .set-row__ctl { justify-content: flex-start; }
.set-row--stack .set-row__ctl > .set-themes, .set-row--stack .set-row__ctl > .set-preview { width: 100%; }
.set-row--stack .voicectl { max-width: 560px; }
.set-row--danger .set-row__label { color: var(--retry-ink); }
.btn.set-danger { color: var(--retry-ink); }
@media (hover: hover) { .btn.set-danger:hover { border-color: var(--retry); } }
.set-recovery { margin: var(--s-3) 0 0; }

/* On/off switch. */
.set-switch {
  position: relative; flex: none; width: 46px; height: 28px; padding: 0; border: 0; border-radius: var(--r-full);
  background: var(--line-strong); cursor: pointer; transition: background var(--dur-fast);
}
.set-switch__knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: var(--r-full);
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--dur-fast) var(--ease-out);
}
.set-switch[aria-checked="true"] { background: var(--brand); }
.set-switch[aria-checked="true"] .set-switch__knob { transform: translateX(18px); }
.set-switch:disabled { opacity: .45; cursor: not-allowed; }
.set-switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Segmented choice. */
.set-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-sunk); }
.set-seg__opt {
  min-height: 34px; padding: 0 14px; border: 0; border-radius: calc(var(--r-md) - 3px); background: transparent;
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .set-seg__opt:hover { color: var(--ink); } }
.set-seg__opt[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.set-seg__opt:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Daily-goal stepper. */
.set-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; }
.set-stepper button {
  width: 38px; border: 0; background: var(--surface-sunk); color: var(--ink); font: inherit; font-size: calc(18px * var(--fs-scale, 1)); cursor: pointer;
}
@media (hover: hover) { .set-stepper button:hover { background: var(--line); } }
.set-stepper button:disabled { color: var(--ink-faint); cursor: default; }
@media (hover: hover) { .set-stepper button:disabled:hover { background: var(--surface-sunk); } }
.set-stepper input {
  width: 60px; height: 38px; border: 0; border-inline: 1px solid var(--line); border-radius: 0;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; text-align: center;
  -moz-appearance: textfield; appearance: textfield;
}
.set-stepper input::-webkit-inner-spin-button, .set-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Status pill, usage bar. */
.set-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-full);
  background: var(--surface-sunk); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); white-space: nowrap;
}
.set-usage { width: 200px; height: 8px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.set-usage i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.set-details { padding: var(--s-3) 0; border-top: 1px solid var(--line); }
.set-details summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.set-card .preset-table { margin-top: var(--s-2); }

/* Account: who you are, then a row per thing you can do. */
.set-profile { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-3); padding: var(--s-4) 0; }
.set-profile .set-row__ctl { margin-left: auto; }
.set-avatar {
  flex: none; width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center;
  /* A per-name hue (components/set-ui.js avatar()), tinted so it reads on both themes. */
  background: var(--surface); background: color-mix(in srgb, hsl(var(--hue, 222) 70% 55%) 22%, var(--surface));
  /* 30% of the name's hue, the rest ink: measured at every 2 degrees of hue (180 hues) in the light, paper and dark themes, the
     initials stay at 5.2:1 or better. At 62% the worst was 2.6:1 (paper), 3.1:1 (light), 4.0:1 (dark). */
  color: color-mix(in srgb, hsl(var(--hue, 222) 70% 50%) 30%, var(--ink));
  font-weight: 800; font-size: calc(14px * var(--fs-scale, 1)); letter-spacing: .02em;
}
.set-avatar--sq { border-radius: 11px; }
.set-profile .set-avatar { width: 46px; height: 46px; font-size: calc(19px * var(--fs-scale, 1)); }
.set-profile__text { min-width: 0; display: grid; gap: 6px; }
.set-profile__text strong { overflow-wrap: anywhere; }
.set-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.set-chip {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--r-full);
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; background: var(--surface-sunk); color: var(--ink-soft);
}
.set-chip.is-ok { background: var(--ok-tint); color: var(--ok-ink); }
.set-chip.is-warn { background: var(--retry-tint); color: var(--retry-ink); }

/* "Sparat ✓" beside a row's name — fades in, then out. */
.set-saved {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; vertical-align: 1px;
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ok-ink); opacity: 0; transition: opacity var(--dur-fast);
}
.set-saved.is-on { opacity: 1; }

/* Theme picker: a painted thumbnail of each palette. */
.set-themes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); max-width: 600px; }
.set-theme {
  display: grid; gap: 8px; padding: 8px 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font: inherit; color: inherit; cursor: pointer; text-align: left;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
@media (hover: hover) { .set-theme:hover { border-color: var(--line-strong); } }
.set-theme[aria-checked="true"] { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.set-theme:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.set-theme__art {
  position: relative; display: block; height: 56px; border-radius: 7px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .25);
}
.set-theme__art i { position: absolute; left: 10px; right: 10px; top: 12px; bottom: 0; border-radius: 5px 5px 0 0; }
.set-theme__art b { position: absolute; left: 18px; top: 22px; width: 34%; height: 6px; border-radius: 3px; }
.set-theme__name { font-size: var(--fs-sm); font-weight: 600; padding-left: 2px; }
.set-theme[aria-checked="true"] .set-theme__name { color: var(--brand-ink); }

/* Live type preview: a question as the app shows one. */
.set-preview {
  max-width: 600px; padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-sunk);
}
.set-preview__tag {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-full); font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; background: var(--brand-tint); color: var(--brand-ink);
}
.set-preview__q { margin: 10px 0 12px; font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.set-preview__opts { display: grid; gap: 6px; }
.set-preview__opts span {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
}
.set-preview__opts .is-right { border-color: var(--line); border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); background: var(--ok-tint); color: var(--ok-ink); font-weight: 600; }

.set-pill.is-on { background: var(--ok-tint); color: var(--ok-ink); }
.set-usage__pct { min-width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }

@media (max-width: 620px) {
  .set-themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .set-card { padding: 0 var(--s-4) var(--s-2); }
  .set-row { flex-direction: column; align-items: stretch; }
  .set-row__text { flex: none; max-width: none; }
  .set-row__main { flex: none; }
  .set-row__ctl { justify-content: flex-start; }
  .set-profile .set-row__ctl { margin-left: 0; }
  .set-usage { width: 100%; }
}
.keyrow { display: flex; gap: var(--s-2); }
.note { font-size: var(--fs-sm); color: var(--ink-soft); }
.note--warn { background: var(--retry-tint); color: var(--retry-ink); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); }
.welcome__acct-confirm { margin: var(--s-2) 0 0; font-weight: 600; }
/* Home: the slim line for an account whose email is not confirmed yet. */
.verifybar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--retry-tint); color: var(--retry-ink); font-size: var(--fs-sm); }
.verifybar p { margin: 0; flex: 1 1 220px; }
.preset-table { width: 100%; border-collapse: collapse; margin-top: var(--s-3); font-size: var(--fs-sm); }
.preset-table th, .preset-table td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); }
.preset-table th { font-weight: 600; color: var(--ink-soft); width: 40%; }
/* On a phone the three columns do not fit (357px wide, so it ran past its card at 360px with large text):
   each row becomes the job and its model on one line and when it is used under them. */
@media (max-width: 520px) {
  .preset-table, .preset-table tbody { display: block; }
  .preset-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s-3); padding: 8px 0; border-top: 1px solid var(--line); }
  .preset-table th, .preset-table td { border: 0; padding: 0; width: auto; }
  .preset-table th { grid-column: 1; grid-row: 1; }
  .preset-table td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; }
  .preset-table td.note { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Klasser + Förälder / lärare, on the same cards and rows ---------- */
.settings--narrow { max-width: 900px; }
/* The teacher's class page on a phone: the results are what the page is opened for, so they sit right under the
   heading instead of below the code, the link and two forms (a class of 36 had them 2,300 px down). */
@media (max-width: 700px) {
  .settings--narrow:has(> .classresults) > .set-back { order: -3; }
  .settings--narrow:has(> .classresults) > .settings__head { order: -2; }
  .settings--narrow > .classresults { order: -1; }
}
/* Grid children default to min-width:auto — a wide results table would push the
   whole page sideways instead of scrolling inside its card. */
.settings > *, .set-card > * { min-width: 0; }
.set-back { justify-self: start; }
.set-row__main { display: flex; align-items: center; gap: var(--s-3); flex: 1 1 260px; min-width: 0; }
.set-row__main > .set-row__text { flex: 1; }
.set-row__link { color: var(--ink); text-decoration: none; }
@media (hover: hover) { .set-row__link:hover { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; } }
.set-list > .set-row:first-child, .set-list > .set-group:first-child > .set-row:first-child,
.set-card > div > .set-list:first-child > :first-child,
.set-card > div > .set-group:first-child > .set-row:first-child { border-top: 0; }
.set-group + .set-group { border-top: 1px solid var(--line); }
.set-group > .set-row { border-top: 0; }
.set-list > .set-group:not(:first-child) { border-top: 1px solid var(--line); }

/* A class's handed-out sets, tucked under the class. */
.set-sublist {
  margin: 0 0 var(--s-4) 52px; padding: 0 var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-sunk);
}
.set-sublist > .set-row { padding: var(--s-3) 0; }
.set-sublist > .set-row:first-child { border-top: 0; }
.set-sublist .set-chip:not(.is-ok):not(.is-warn):not(.is-brand) { background: var(--surface); }
.set-chip.is-brand { background: var(--brand-tint); color: var(--brand-ink); }
.set-sublist__empty { margin: -6px 0 var(--s-4) 52px; font-size: var(--fs-sm); color: var(--ink-faint); }

/* Nothing here yet. */
.set-empty { display: grid; justify-items: center; gap: 8px; padding: var(--s-6, 28px) var(--s-4); text-align: center; }
.set-empty__ic {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-full);
  background: var(--surface-sunk); color: var(--ink-faint);
}
.set-empty p { margin: 0; max-width: 46ch; font-size: var(--fs-sm); color: var(--ink-soft); }
/* A section with nothing in it yet (no classes joined) takes a line, not a card's worth of space. */
.set-empty--compact { display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 6px 12px; padding: var(--s-2) 0; text-align: left; }
.set-empty--compact .set-empty__ic { width: 32px; height: 32px; }
.set-empty--compact p { max-width: none; }
.set-empty + .set-row { border-top: 1px solid var(--line); }
.set-loading { margin: 0; padding: var(--s-5) 0; font-size: var(--fs-sm); color: var(--ink-faint); }

/* An input with its button beside it. */
.set-inline { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.set-code { display: flex; align-items: center; gap: var(--s-2); }
/* Same look as the app's .field inputs — these sit outside a label.field. */
.set-inline input, .set-inline select, .set-code__input, .classgrid-search input {
  height: 40px; margin: 0; padding: 0 var(--s-3); border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.set-inline input:focus-visible, .set-inline select:focus-visible, .set-code__input:focus-visible, .classgrid-search input:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.set-inline input, .set-inline select { width: 260px; max-width: 100%; }
.set-inline .btn, .set-code .btn { height: 40px; }
.set-code__input {
  width: 170px; text-transform: uppercase; letter-spacing: .14em; font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.set-code__input::placeholder { letter-spacing: .14em; font-weight: 500; }
/* A link to copy (join links): the whole row, not the narrow uppercase box a code gets. */
.set-linkbox { display: grid; gap: var(--s-2); justify-items: start; padding: var(--s-2) 0 var(--s-3); }
.set-linkbox .set-code { flex-wrap: wrap; width: 100%; }
.set-code__input--link { flex: 1 1 240px; width: auto; min-width: 0; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: var(--fs-sm); }
.set-join__title { margin: 0 0 var(--s-2); font-size: var(--fs-lg, 1.15em); }
.set-codechip {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--r-sm);
  border: 1px dashed var(--line-strong); color: var(--ink-soft); font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .1em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* A code to read out or copy — class code, invite code. */
.set-bigcode { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3); padding: var(--s-5) 0 var(--s-3); }
.set-bigcode__code {
  padding: 10px 18px; border-radius: var(--r-md); border: 1px dashed var(--line-strong); background: var(--surface-sunk);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: calc(28px * var(--fs-scale, 1)); font-weight: 800; letter-spacing: .22em; color: var(--ink);
}
.set-bigcode__note { margin: 0 0 var(--s-4); font-size: var(--fs-sm); color: var(--ink-faint); }

/* A form inside a card (assigning a set to a class). */
.set-form { display: grid; gap: var(--s-3); padding: var(--s-4) 0 var(--s-4); }
.set-form__grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.set-form .field { margin: 0; }
.set-subpanel { margin: 0 0 var(--s-4) 52px; }
.set-misses { padding: var(--s-4) 0; border-top: 1px solid var(--line); }
.set-misses h3 { margin: 0; font-size: var(--fs-sm); font-weight: 700; }
.set-misses .set-row__note { margin-bottom: var(--s-2); }
.set-card .classgrid-wrap { margin: var(--s-4) 0; }
.classgrid__student .set-avatar { width: 26px; height: 26px; font-size: calc(10.5px * var(--fs-scale, 1)); }

/* A student's overview: three figures side by side. */
.set-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); padding: var(--s-4) 0; }
.set-stat { display: grid; gap: 2px; padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-sunk); }
.set-stat__ic { color: var(--brand-ink); margin-bottom: 6px; }
.set-stat b { font-size: calc(22px * var(--fs-scale, 1)); font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.set-stat span:last-child { font-size: var(--fs-sm); color: var(--ink-faint); }
.set-meters { padding: var(--s-3) 0; }

/* The class wizard and daily-question panels sit among these cards. */
.settings--narrow > .panel { margin: 0; }
.settings--narrow > .panel > h3:first-child { font-size: var(--fs-md); font-weight: 700; letter-spacing: -.01em; }

@media (max-width: 620px) {
  /* After .set-row__main's own rule, so this wins: in a column its flex-basis would be a height. */
  .set-row__main { flex: none; }
  .set-sublist, .set-sublist__empty, .set-subpanel { margin-left: 0; }
  .set-code, .set-inline { width: 100%; }
  .set-inline input, .set-inline select { flex: 1; width: auto; }
  .set-code__input { flex: 1; width: auto; }
  .set-stats { grid-template-columns: 1fr; }
  .set-bigcode__code { font-size: calc(22px * var(--fs-scale, 1)); }
}

/* ---------- Signed-out gate (Klasser, Förälder / lärare) ---------- */
/* components/signin-gate.js: the pitch on the left, a made-up preview of the
   page on the right (.gart, drawn by each view), stacked on narrow screens. */
.gate {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.gate__copy { display: flex; flex-direction: column; align-items: flex-start; padding: clamp(24px, 4vw, 48px); }
.gate__eyebrow {
  display: inline-flex; align-items: center; gap: 7px; margin: 0 0 var(--s-4); padding: 5px 12px 5px 10px;
  border-radius: var(--r-full); background: var(--brand-tint); color: var(--brand-ink);
  font-size: calc(13px * var(--fs-scale, 1)); font-weight: 650;
}
.gate__title { margin: 0; font-size: clamp(1.75rem, 1.25rem + 1.5vw, 2.45rem); line-height: 1.1; letter-spacing: -.03em; text-wrap: balance; }
.gate__lead { margin: var(--s-3) 0 0; max-width: 46ch; color: var(--ink-soft); font-size: calc(1.0625rem * var(--fs-scale, 1)); line-height: 1.55; }
.gate__points { list-style: none; margin: var(--s-6) 0 0; padding: 0; display: grid; gap: var(--s-4); }
.gate__points li { display: flex; align-items: flex-start; gap: var(--s-3); }
.gate__ptic {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-sunk); color: var(--brand);
}
.gate__points li > div { display: grid; gap: 2px; padding-top: 1px; }
.gate__points strong { font-weight: 650; }
.gate__points li > div > span { color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.5; max-width: 52ch; }
.gate__cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }
.gate__fine { display: inline-flex; align-items: center; gap: 6px; margin: var(--s-3) 0 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.gate__fine svg { color: var(--ok); }
.gate__foot { align-self: stretch; margin: var(--s-5) 0 0; padding-top: var(--s-4); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-soft); }
.gate__foot a { font-weight: 600; }

/* The preview's stage: a quiet dotted ground with a wash of brand colour in one corner. */
.gate__art {
  position: relative; isolation: isolate; display: grid; place-items: center;
  padding: clamp(28px, 4vw, 52px) clamp(20px, 3vw, 40px);
  border-left: 1px solid var(--line);
  background:
    radial-gradient(110% 80% at 100% 0%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 62%),
    var(--surface-sunk);
}
.gate__art::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(circle at 1px 1px, var(--line-strong) 1px, transparent 1.6px) 0 0 / 18px 18px;
  -webkit-mask-image: radial-gradient(75% 75% at 50% 50%, #000, transparent);
          mask-image: radial-gradient(75% 75% at 50% 50%, #000, transparent);
}
.gart {
  position: relative; width: min(100%, 370px); display: grid; gap: var(--s-3); padding: var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-2);
  font-size: var(--fs-sm); user-select: none;
}
.gart__head { display: flex; align-items: center; gap: var(--s-3); }
.gart__ic {
  flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand-ink);
}
.gart__who { flex: 1; min-width: 0; display: grid; }
.gart__who strong { font-size: var(--fs-md); }
.gart__who span { color: var(--ink-faint); font-size: calc(12.5px * var(--fs-scale, 1)); }
.gart__code { display: grid; justify-items: end; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: .08em; }
.gart__code small { font-family: var(--font-body); font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--ink-faint); }
.gart__box { display: grid; gap: 10px; padding: var(--s-3); border: 1px solid var(--line); border-radius: 12px; }
.gart__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.gart__label { margin: 0; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.gart__bar { display: block; height: 8px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.gart__bar > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.gart__bar.is-ok > span { background: var(--ok); }
.gart__bar.is-warn > span { background: var(--retry); }
.gart__faces { display: flex; padding-left: 6px; }
.gart__faces > span { width: 30px; height: 30px; margin-left: -6px; border: 2px solid var(--surface); font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; }
.gart__more { display: grid; place-items: center; border-radius: var(--r-full); background: var(--surface-sunk); color: var(--ink-soft); }
.gart__soft { color: var(--ink-soft); }
.gart__miss { padding: 1px 9px; border-radius: var(--r-full); background: var(--retry-tint); color: var(--retry-ink); font-size: 12px; font-weight: 650; }
.gart__streak {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-full);
  background: var(--c-tangerine-tint); color: var(--c-tangerine-text); font-size: 12px; font-weight: 650;
}
.gart__week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.gart__day { display: grid; justify-items: center; gap: 5px; }
.gart__day > span { display: flex; align-items: flex-end; width: 100%; max-width: 24px; height: 56px; }
.gart__day i { display: block; width: 100%; border-radius: 5px; background: var(--brand); }
.gart__day.is-off i { background: var(--line-strong); }
.gart__day small { font-size: 12px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; }
.gart__subj { display: grid; grid-template-columns: 84px 1fr 42px; align-items: center; gap: var(--s-2); }
.gart__subj b { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.gart__due { margin: 0; display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-weight: 600; }
.gart__due svg { color: var(--retry); }

@media (max-width: 899.98px) {
  .gate { grid-template-columns: 1fr; }
  .gate__art { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .gate__cta { align-self: stretch; flex-direction: column; }
  .gate__cta .btn { justify-content: center; }
}

/* ---------- Profile picture ---------- */
/* The account avatar in Settings opens the picker; a camera shows on hover/focus. */
.set-avatar--photo { position: relative; padding: 0; border: 0; cursor: pointer; overflow: hidden; font: inherit; }
.set-avatar--photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.set-avatar__cam {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
  background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity var(--dur-fast);
}
.set-avatar--photo:hover .set-avatar__cam, .set-avatar--photo:focus-visible .set-avatar__cam { opacity: 1; }
.set-avatar--photo:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* The topbar account button wears the picture edge to edge. */
.topbar__profile.has-avatar { padding: 0; overflow: hidden; border-radius: var(--r-full); }
.topbar__avatar { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
/* The account menu (main.js shellActions): who is signed in, the pages as menu rows, then Logga ut. */
.acctmenu__head { display: flex; align-items: center; gap: 10px; padding: var(--s-2) var(--s-3); }
.acctmenu__avatar { width: 36px; height: 36px; flex: none; border-radius: var(--r-full); object-fit: cover; }
.acctmenu__avatar--icon { display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-ink); }
.acctmenu__who { display: grid; min-width: 0; line-height: 1.35; }
.acctmenu__who span { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.acctmenu__who strong { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acctmenu__sep { height: 1px; margin: 4px 6px; background: var(--line); }
.acctmenu .cardmenu__item { min-height: 40px; font-weight: 500; }
.acctmenu .cardmenu__item > svg { flex: none; color: var(--ink-soft); }
.acctmenu .cardmenu__item--danger > svg { color: inherit; }
.acctmenu__link > span { flex: 1; }
.acctmenu__link > svg:last-child { color: var(--ink-faint); transition: transform var(--dur-fast); }
.acctmenu__link:hover > svg:last-child { transform: translateX(2px); }
@media (prefers-reduced-motion: reduce) { .acctmenu__link:hover > svg:last-child { transform: none; } }

/* The framing dialog. */
.avatared { max-width: 340px; display: grid; gap: var(--s-3); }
.avatared h3 { margin: 0; }
.avatared .note { margin: -6px 0 0; }
.avatared__stage { display: grid; place-items: center; padding: var(--s-2) 0; }
.avatared__canvas {
  width: 260px; height: 260px; border-radius: var(--r-md); background: var(--surface-sunk);
  cursor: grab; touch-action: none;
}
.avatared__canvas:active { cursor: grabbing; }
.avatared__canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.avatared__zoomrow { display: flex; align-items: center; gap: 10px; }
.avatared__zbtn { flex: none; color: var(--ink-soft); }
.avatared__zoom { flex: 1; accent-color: var(--brand); }
.avatared__actions { display: flex; justify-content: flex-end; gap: var(--s-2); }

/* ---------- FAQ accordion ---------- */
.faq-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.faq-item { border-top: 1px solid var(--line); }
.faq-item:first-child { border-top: none; }
.faq-item__q {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); cursor: pointer; list-style: none;
  font-weight: 700; color: var(--ink);
}
.faq-item__q::-webkit-details-marker { display: none; }
@media (hover: hover) { .faq-item__q:hover { background: var(--surface-sunk); } }
.faq-item__q:focus-visible { outline: none; box-shadow: inset var(--ring); }
.faq-item__q svg { flex: none; color: var(--ink-faint); transition: transform var(--dur-fast); }
.faq-item[open] .faq-item__q svg { transform: rotate(180deg); }
.faq-item__a { padding: 0 var(--s-5) var(--s-4); color: var(--ink-soft); }
.faq-item__a p { margin: 0; }
.preset-table td:nth-child(2) { font-weight: 700; }

.roadmap { list-style: none; display: grid; gap: var(--s-2); }
.roadmap li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink-soft); }
.roadmap li::before { content: "🔜"; }

.toast {
  /* --toast-lift (set by toast() in dom.js) is how far a bar along the bottom reaches up; the toast rides above it. */
  position: fixed; left: 50%; bottom: max(calc(var(--s-5) + env(safe-area-inset-bottom, 0px)), calc(var(--toast-lift, 0px) + var(--s-2))); transform: translateX(-50%) translateY(20px);
  /* Fixed dark pill regardless of theme — var(--ink) flips to near-white in
     dark mode, which left the hardcoded white text unreadable against it. */
  background: #2B2B3A; color: #fff; padding: var(--s-3) var(--s-5); border-radius: var(--r-lg);
  font-weight: 600; font-size: var(--fs-sm); box-shadow: var(--shadow-2);
  /* A long message wraps inside the screen instead of running off it as one stretched oval. */
  width: max-content; max-width: min(560px, calc(100vw - 2 * var(--s-4))); text-align: center; overflow-wrap: anywhere;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-mid), transform var(--dur-mid) var(--ease-spring);
  z-index: 50;
}
/* On a phone the tab bar sits at the bottom edge (about 56px); the toast rides above it, not over it. */
@media (max-width: 899px) { .toast { bottom: max(calc(68px + var(--s-2) + env(safe-area-inset-bottom, 0px)), calc(var(--toast-lift, 0px) + var(--s-2))); } }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast:has(.toast__action) { display: flex; align-items: center; gap: var(--s-3); }
.toast:has(.toast__action).show { pointer-events: auto; }
.toast__action {
  font: inherit; font-weight: 700; cursor: pointer;
  background: none; border: none; color: #9FBCFF;
  text-decoration: underline; text-underline-offset: 3px; padding: 0;
}
@media (hover: hover) { .toast__action:hover { color: #fff; } }

/* Persistent top banner (js/lib/dom.js showBanner) — unlike .toast, never
   auto-dismisses. Reserved for things the student must actually see, like a
   failed save. */
.savebar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 110;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--retry-tint); color: var(--retry-ink);
  font-weight: 600; font-size: var(--fs-sm);
  transform: translateY(-100%); transition: transform var(--dur-mid) var(--ease-out);
}
.savebar.show { transform: translateY(0); }
.savebar--update { background: var(--brand-tint); color: var(--brand-ink); }
.savebar__action {
  margin-left: auto; font: inherit; font-weight: 700; cursor: pointer;
  background: none; border: none; color: inherit;
  text-decoration: underline; text-underline-offset: 3px; padding: 0;
}
.savebar__close {
  font: inherit; cursor: pointer; background: none; border: none; color: inherit;
  font-size: calc(18px * var(--fs-scale, 1)); line-height: 1; padding: 0 2px; flex: none;
}

/* ---------- animations ---------- */
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes nudge { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- shortcuts modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 18, 28, .5); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: var(--s-4);
}
.modal__card {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: var(--s-5); max-width: 420px; width: 100%;
}
/* The frame every dialog shares (dialogHead / dialogFoot in components/set-ui.js): the title and a
   close cross at the top, the buttons at the bottom right with the main one last. */
.dlghead { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.dlghead__txt { min-width: 0; }
.dlghead__title {
  margin: 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700;
  line-height: 1.3; letter-spacing: -.01em; text-wrap: balance;
}
.dlghead__sub { margin: 4px 0 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-soft); }
.iconbtn.dlghead__x { width: 34px; height: 34px; margin: -4px -6px 0 0; border-color: transparent; background: none; }
@media (hover: hover) { .iconbtn.dlghead__x:hover { background: var(--surface-sunk); } }
.dlgfoot {
  display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: var(--s-2);
  margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line);
}
.dlgfoot__left { margin-right: auto; }
/* Phones: buttons wide enough to hit with a thumb, sharing the row; an alternative gets a row of its own. */
@media (max-width: 480px) {
  .dlgfoot .btn { flex: 1 1 auto; justify-content: center; }
  .dlgfoot .dlgfoot__left { flex-basis: 100%; margin-right: 0; }
}

/* The shortcuts themselves: grouped lists, what a key does on the left and the key on the right. */
.modal__card.keysheet { max-width: 460px; }
.keysheet__group + .keysheet__group { margin-top: var(--s-4); }
.keysheet__label { margin: 0 0 var(--s-2); font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); }
.keysheet__list { margin: 0; border: 1px solid var(--line); border-radius: var(--r-md); }
.keysheet__row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px var(--s-4); padding: 10px var(--s-4);
}
.keysheet__row + .keysheet__row { border-top: 1px solid var(--line); }
.keysheet__row dt { font-size: var(--fs-sm); line-height: 1.4; color: var(--ink); }
.keysheet__row dd { flex: none; margin: 0; display: flex; align-items: center; gap: 4px; }
.keysheet kbd {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px;
  font-family: inherit; font-weight: 600; line-height: 1;
  /* The brand's soft blue, like the tiles on Hem, rather than grey caps. */
  background: color-mix(in oklab, var(--brand) 11%, var(--surface));
  border-color: color-mix(in oklab, var(--brand) 40%, var(--surface));
  color: var(--brand-ink);
}
.keysheet__left svg { transform: scaleX(-1); }
.keysheet__sep { padding-inline: 2px; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }

/* "Review answered" panel — practice / review look-back at what's been done. */
.review-so-far { max-width: 560px; max-height: 82vh; display: flex; flex-direction: column; }
.review-so-far__list { overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-3); }
.review-so-far__item {
  border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: var(--r-md); padding: var(--s-3) var(--s-4); background: var(--surface);
}
.review-so-far__item.is-ok { border-left-color: var(--ok); }
.review-so-far__item.is-miss { border-left-color: var(--retry); }
.review-so-far__q { display: flex; gap: var(--s-2); font-weight: 600; font-size: var(--fs-sm); }
.review-so-far__n { flex: none; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.review-so-far__verdict { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-soft); }
.review-so-far__item.is-ok .review-so-far__verdict { color: var(--ok-ink); }
.review-so-far__item.is-miss .review-so-far__verdict { color: var(--retry-ink); }
.review-so-far__ans { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--ink); }
.review-so-far__exp { margin: 4px 0 0; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-soft); line-height: 1.5; }

/* "This is a test" toggle in the Deadline dialog. */
.due-dialog__test { display: flex; align-items: flex-start; gap: var(--s-2); margin-top: var(--s-3); font-size: var(--fs-sm); color: var(--ink-soft); cursor: pointer; }
.due-dialog__test input { margin-top: 2px; flex: none; }
.due-dialog__test span { display: flex; align-items: flex-start; gap: 6px; }
.due-dialog__test svg { flex: none; margin-top: 2px; color: var(--ink-faint); }

/* Centred yes/no dialog — replaces window.confirm. */
.confirmdlg__card { max-width: 400px; }
.confirmdlg__body {
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-lg);
  line-height: 1.3; color: var(--ink);
}
.confirmdlg__note {
  margin-top: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); background: var(--ok-tint); color: var(--ok-ink);
  font-size: var(--fs-sm); line-height: 1.4;
}
.confirmdlg--danger .confirmdlg__note, .confirmdlg--warn .confirmdlg__note { background: var(--retry-tint); color: var(--retry-ink); }
/* A warning straight under a dialog's title ("Radera konto"): the title row already spaces it. */
.dlghead + .confirmdlg__note { margin-top: 0; }
.confirmdlg__input {
  width: 100%; margin-top: var(--s-3); padding: var(--s-3) var(--s-4); font: inherit; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--r-md);
}
.confirmdlg__input:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.confirmdlg__actions {
  display: flex; justify-content: flex-end; gap: var(--s-3);
  margin-top: var(--s-5); flex-wrap: wrap;
}
.confirmdlg__actions .btn { flex: 1 1 auto; justify-content: center; min-width: 120px; }

/* Class mode: the hub rows, and a teacher's results grid. */
.classrow {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md);
}
.classcode { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: calc(30px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .14em; }
.classgrid-wrap { overflow-x: auto; }
/* A big class: the table scrolls inside its own box, header kept in view (views/classes.js BIG_CLASS). */
.classgrid-wrap--tall { max-height: 70vh; overflow: auto; }
.classgrid-wrap--tall thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.classgrid-search { margin: var(--s-3) 0; }
.classgrid-search input { width: 100%; max-width: 360px; }
.classgrid { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.classgrid th, .classgrid td { padding: 6px 8px; text-align: left; vertical-align: middle; }
.classgrid thead th { font-weight: 600; color: var(--ink-soft); vertical-align: bottom; min-width: 132px; }
.classgrid thead th:first-child { min-width: 190px; }
.classgrid tbody tr + tr td { border-top: 1px solid var(--line); }
.classgrid__title { font-weight: 700; color: var(--ink); margin-bottom: 2px; }
/* The skip link carries both languages (index.html); only the page language's shows. */
html[lang="sv"] .skiplink [lang="en"], html[lang="en"] .skiplink [lang="sv"] { display: none; }
.classgrid__student { display: flex; align-items: center; gap: var(--s-2); overflow-wrap: anywhere; }
.classgrid__student > span:not(.set-avatar) { min-width: 0; flex: 1 1 auto; text-align: left; }
.classgrid__student > button, .classgrid__student > .iconbtn { margin-left: auto; flex: none; }
.classcell { display: block; min-width: 56px; text-align: center; border-radius: var(--r-sm); padding: 3px 6px; font-weight: 700; }
.classcell--hi { background: var(--ok-tint); color: var(--ok-ink); }
.classcell--mid { background: var(--surface-sunk); color: var(--ink); }
.classcell--lo { background: var(--retry-tint); color: var(--retry-ink); }
.classcell--none { color: var(--ink-faint); font-weight: 400; }
.classmiss { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-sm); padding: 3px 0; }
.classmiss__topic { flex: 0 0 34%; min-width: 0; }
.classmiss__bar { flex: 1; height: 6px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.classmiss__bar > i { display: block; height: 100%; background: var(--retry); border-radius: inherit; }

/* Challenge a friend: the share dialog, the friend's landing card, and the
   comparison on the results screen. */
.challengedlg { max-width: 440px; }
.challengedlg__title { margin: 0 0 var(--s-2); font-family: var(--font-display); font-size: var(--fs-lg); line-height: 1.3; }
.challengedlg__body { margin: 0 0 var(--s-4); color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.5; }
.challengedlg__error { margin: calc(-1 * var(--s-2)) 0 var(--s-3); color: var(--retry-ink); font-size: var(--fs-sm); }
.challengedlg__actions { display: flex; justify-content: flex-end; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-4); }
.challengedlg__actions .btn { flex: 1 1 auto; justify-content: center; min-width: 110px; }
.challenge { max-width: 560px; margin: 0 auto; }
.challenge__card { text-align: left; }
.challenge__from { margin: 0 0 var(--s-1); color: var(--ink-soft); font-weight: 700; }
.challenge__title { margin: 0 0 var(--s-4); font-size: var(--fs-xl); line-height: 1.2; }
.challenge__score { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-3); }
.challenge__pct { font-family: var(--font-display); font-weight: 700; font-size: calc(44px * var(--fs-scale, 1)); line-height: 1; color: var(--brand); }
.challenge__actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.challengecard { margin: var(--s-4) 0; padding: var(--s-4); border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); text-align: center; }
.challengecard h3 { margin: 0 0 var(--s-3); }
.challengecard--win { border-color: var(--ok); background: var(--ok-tint); }
.challengecard--win h3 { color: var(--ok-ink); }
.challengecard--lose { border-color: var(--line-strong); }
.challengecard__vs { display: flex; align-items: center; justify-content: center; gap: var(--s-4); flex-wrap: wrap; }
.challengecard__side { display: flex; flex-direction: column; align-items: center; min-width: 88px; }
.challengecard__pct { font-family: var(--font-display); font-weight: 700; font-size: calc(32px * var(--fs-scale, 1)); line-height: 1.1; }
.challengecard__side.is-me .challengecard__pct { color: var(--brand); }
.challengecard__dash { color: var(--ink-faint); font-weight: 700; font-size: var(--fs-sm); }

/* "You've used this month's AI allowance" prompt. */
.upgradedlg { max-width: 400px; }
.upgradedlg__body { margin: 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.5; }
.upgradedlg__need { margin: var(--s-4) 0 0; font-weight: 700; font-size: var(--fs-sm); }
kbd {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: calc(12px * var(--fs-scale, 1));
  background: var(--surface); background: color-mix(in srgb, var(--ink) 20%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ink) 52%, var(--surface));
  border-bottom-width: 2px; border-radius: 6px; padding: 2px 6px; color: var(--ink);
  white-space: nowrap;
}
/* .kbdhint removed — the shortcuts button in the session header replaced it. */

/* The floating hint button only exists on narrow screens. */
.hintfab { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .session { grid-template-columns: minmax(0, 1fr); }

  /* Tutor becomes a slide-up sheet so a stuck student never has to scroll
     away from the question to reach help. */
  .tutor {
    /* top: auto matters — the desktop rule sets top for sticky, and a fixed
       box with both top and bottom set ignores bottom. */
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 70;
    max-height: min(70vh, 520px);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: none;
    box-shadow: var(--shadow-2);
    transform: translateY(101%);
    /* Closed, the sheet is hidden as well as moved off-screen, so a keyboard or screen reader can't
       land in a chat nobody can see. visibility flips at the end of the slide down, at its start going up. */
    visibility: hidden;
    transition: transform var(--dur-mid) var(--ease-out), visibility 0s linear var(--dur-mid);
  }
  .tutor.is-open { transform: translateY(0); visibility: visible; transition-delay: 0s; }

  /* In the page, right under the question: a floating button sat on top of Skip / Next. */
  .hintfab {
    display: inline-flex; align-items: center; gap: 8px; margin-top: var(--s-4);
    font-family: var(--font-display); font-weight: 600; font-size: var(--fs-sm);
    min-height: 40px; padding: 8px 16px; border-radius: var(--r-full);
    border: 1px solid color-mix(in oklab, var(--brand) 45%, var(--line)); background: var(--brand-tint); color: var(--brand-ink);
    cursor: pointer;
  }
  .hintfab[hidden] { display: none; }
  /* "1 ny": the tutor answered while its sheet was closed. Last in the row whatever the DOM order. */
  .hintfab__badge { order: 3; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: var(--r-full); background: var(--brand); color: white; }
  .hintfab__badge[hidden] { display: none; }
}
/* Nothing to hint at or move on to while the "continue where you left off" card is up. */
.session:has(.resume, .hp-intro) :is(.hintfab, .nav-row > div:last-child > .btn) { display: none; }
/* Nothing to hand in before an HP run has started. */
body:has(.hp-intro) .session__headright > .btn { display: none; }
@media (max-width: 540px) {
  .content { padding: var(--s-5) var(--s-3) var(--s-7); }
  h1 { font-size: 1.6rem; }
  /* One set per row: two ~150px columns broke a title like "Bråk, decimaler och procent" into
     one word per line. The "new set" card shrinks to a slim row so it doesn't cost a full card. */
  .grid { grid-template-columns: 1fr; gap: var(--s-3); }
  .acard--new { min-height: 0; flex-direction: row; padding: var(--s-3) var(--s-4); }
  /* Set cards: as tall as their content, not a fixed 148px. */
  .acard { min-height: 0; gap: var(--s-2); padding: var(--s-3) var(--s-4); }
  .acard__title { font-size: var(--fs-md); padding-right: 28px; }
  /* Study session: Skip / Next as the full-width primary row, the lesser actions (Leave,
     overview, flag) underneath instead of wrapping into three ragged rows. Scoped to .session
     specifically — .nav-row is shared with create/edit, whose two children aren't both <div>s
     wrapping button groups, so the same column-reverse would silently flip their button order. */
  .session .nav-row { flex-direction: column-reverse; align-items: stretch; }
  .session .nav-row > div:last-child { width: 100%; }
  .session .nav-row > div:last-child > .btn { flex: 1; justify-content: center; }
  .session .nav-row > div:first-child { justify-content: flex-start; }
  /* Footer links: tappable height, tighter rows. */
  .sitefooter__links, .lp-foot__links { gap: 0 var(--s-4); }
  .sitefooter__links a, .lp-foot__links a { display: inline-block; padding: 8px 0; }
  .meter { grid-template-columns: 88px 1fr 40px 26px; gap: var(--s-2); }
}

/* ---------- print worksheet ---------- */
.psheet__bar { display: flex; gap: 10px; margin-bottom: var(--s-5); }
.psheet__title { font-size: var(--fs-xl); margin-bottom: 4px; }
.psheet__meta { color: var(--ink-soft); font-size: var(--fs-sm); margin-bottom: var(--s-5); }
.psheet__item { margin-bottom: var(--s-5); break-inside: avoid; }
.psheet__q { margin-bottom: 8px; }
.psheet__choices { margin: 4px 0 0 22px; }
.psheet__choices li { list-style: upper-alpha; margin: 2px 0; }
.psheet__lines { height: 64px; border-bottom: 1px solid var(--line-strong);
  background: repeating-linear-gradient(var(--surface), var(--surface) 27px, var(--line) 28px); }
.psheet__break { break-before: page; margin-top: var(--s-8); }
.psheet__akey { margin: 3px 0; font-size: var(--fs-sm); }

/* ---------- shell: leaderboard + bell + account actions ---------- */
.topbar__actions { display: flex; align-items: center; gap: var(--s-2); }
.topbar__actions .iconbtn.is-active { color: var(--brand); border-color: var(--brand); }
.topbar__bell { position: relative; }
@media (min-width: 900px) { .topbar__chat { display: none; } }
.topbar__dot {
  position: absolute; top: 5px; right: 5px; width: 9px; height: 9px;
  border-radius: var(--r-full); background: var(--retry); border: 2px solid var(--surface);
}

.popover {
  position: absolute; z-index: 60; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.popover .note { margin: 0; }

/* ---------- notification panel ---------- */
.notifpanel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-3); }
.notifpanel__head h3 { font-size: var(--fs-md); }
.notiftabs { display: flex; gap: 4px; padding: 0 var(--s-1) var(--s-2); border-bottom: 1px solid var(--line); margin-bottom: var(--s-2); }
.notiftab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: var(--fs-sm); font-weight: 600;
  padding: var(--s-2) var(--s-3); border: none; border-radius: var(--r-full);
  background: transparent; color: var(--ink-soft); cursor: pointer;
}
.notiftab[aria-selected="true"] { background: var(--surface-sunk); color: var(--ink); }
.notiftab__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--brand); color: #fff; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700;
}
.notifpanel__body { max-height: min(420px, 60vh); overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.notifcard { display: flex; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-md); background: transparent; }
.notifcard--unread { background: var(--brand-tint); }
.notifcard__icon {
  flex: none; width: 34px; height: 34px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-sunk); color: var(--ink-soft);
}
.notifcard--unread .notifcard__icon { background: var(--brand); color: #fff; }
.notifcard__main { flex: 1; min-width: 0; }
.notifcard__title { font-weight: 700; font-size: var(--fs-sm); margin-bottom: 2px; }
.notifcard__text { font-size: var(--fs-sm); color: var(--ink-soft); margin-bottom: var(--s-2); }
.notifcard__footer { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-sm); flex-wrap: wrap; }
.notifcard__link { color: var(--brand-ink); font-weight: 600; text-decoration: underline; }
.notifcard__meta { color: var(--ink-faint); white-space: nowrap; }
.notifcard__mark {
  flex: none; align-self: flex-start; width: 30px; height: 30px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
@media (hover: hover) { .notifcard__mark:hover { background: var(--ok); color: #fff; border-color: transparent; } }
/* Phones: the 360px dropdown sat off-centre with the page showing round it. Here the panel spans the
   screen just under the bell's row, over a dimmed page; the tabs read as a switch and the action is a
   real button. A tap on the dimmed page closes it (popover.js), without reaching what is underneath. */
@media (max-width: 560px) {
  body:has(.popover--notif)::after { content: ""; position: fixed; inset: 0; z-index: 59; background: rgba(20, 18, 28, .38); }
  .popover--notif {
    position: fixed !important; top: var(--notif-top, 72px) !important; left: 12px !important; right: 12px; width: auto !important; max-width: none;
    max-height: calc(100vh - var(--notif-top, 72px) - 16px); max-height: calc(100dvh - var(--notif-top, 72px) - 16px); overflow-y: auto;
    border-radius: 18px; border-color: var(--line); padding: 8px 4px 10px; box-shadow: var(--shadow-2);
  }
  .popover--notif .notifpanel__head { padding: 6px 8px 10px 12px; }
  .popover--notif .notiftabs { background: var(--surface-sunk); border: 0; border-radius: var(--r-full); padding: 4px; margin: 2px 8px 12px; }
  .popover--notif .notiftab { padding: 9px 12px; }
  .popover--notif .notiftab[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow-1); }
  .popover--notif .notifpanel__body { max-height: none; padding: 0 8px 4px; }
  .popover--notif .notifcard { border: 1px solid var(--line); background: var(--surface); padding: 14px; }
  .popover--notif .notifcard--unread { background: var(--brand-tint); border-color: transparent; }
  .popover--notif .notifcard__footer { margin-top: 4px; }
  .popover--notif .notifcard__link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: var(--r-full); background: var(--brand); color: #fff; text-decoration: none; }
}

/* ---------- achievements page ---------- */
.achievements-page { display: flex; flex-direction: column; gap: var(--s-5); }
.achievements-head h1 { margin-bottom: 4px; }
.achievements-head .note { margin: 0; max-width: 62ch; }

/* The board's head: ring · a count per metal · Next up. */
.ach-overview {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.15fr); gap: var(--s-5); align-items: center;
  padding: var(--s-5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.ach-ring {
  --p: 0; width: 120px; height: 120px; border-radius: var(--r-full); display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-sunk) 0);
}
.ach-ring__inner {
  width: 100px; height: 100px; border-radius: var(--r-full); background: var(--surface);
  display: grid; place-content: center; text-align: center;
}
.ach-ring__inner strong { font-family: var(--font-display); font-size: calc(32px * var(--fs-scale, 1)); line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.ach-ring__inner span { font-size: var(--fs-sm); color: var(--ink-faint); margin-top: 2px; }
.ach-tiers { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-2); }
.ach-tiercount {
  display: grid; justify-items: center; gap: 2px; padding: 10px 4px; border-radius: var(--r-md);
  background: var(--surface-sunk); border: 1px solid var(--line);
}
.ach-tiercount__medal {
  width: 34px; height: 34px; border-radius: var(--r-full); display: grid; place-items: center; color: var(--ink-on-color); margin-bottom: 2px;
  background: linear-gradient(145deg, color-mix(in oklab, var(--m) 60%, #fff), var(--m) 55%, color-mix(in oklab, var(--m) 72%, #000));
}
.ach-tiercount--platinum .ach-tiercount__medal { background: var(--ach-platinum-sheen); color: #34506A; }
.ach-tiercount--milestone .ach-tiercount__medal { color: #fff; }   /* brand blue: white reads best there (5:1) */
.ach-tiercount__medal svg { width: 17px; height: 17px; }
.ach-tiercount b { font-size: calc(19px * var(--fs-scale, 1)); line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.ach-tiercount small { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-soft); font-weight: 600; }
.ach-overview .ach-hero { min-width: 0; }
@media (max-width: 1000px) {
  .ach-overview { grid-template-columns: auto minmax(0, 1fr); }
  .ach-overview .ach-hero { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .ach-overview { grid-template-columns: 1fr; justify-items: center; padding: var(--s-4); gap: var(--s-4); }
  /* The last tile (milestones) gets more room: "Milstolpar" is wider than a fifth of a small phone. */
  .ach-tiers { width: 100%; gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.5fr); }
  .ach-tiercount { padding: 8px 2px; }
  /* Five captions across a small phone leave no room for the large text size; the counts above them still scale. */
  :root[data-textsize="l"] .ach-tiercount small { font-size: 12px; }
  .ach-overview .ach-hero { width: 100%; }
}
.achgroup__title { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); color: var(--ink); font-size: var(--fs-md); }
.achgroup__ic {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-sunk); color: var(--ink-soft);
}

/* A track as one compact row: title and the next step on one line, a thin bar, four small medals. */
.achgroup--compact { padding: var(--s-4); }
.achgroup__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.achgroup--compact .achgroup__title { margin: 0; font-size: var(--fs-base, 15px); gap: var(--s-2); }
.achgroup--compact .achgroup__ic { width: 28px; height: 28px; border-radius: 8px; }
.achgroup__next { font-size: var(--fs-sm); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.achgroup__need { margin: var(--s-2) 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.achgroup__bar { height: 5px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; margin-top: var(--s-3); }
.achgroup__bar i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--brand)); transition: width var(--dur-slow) var(--ease-out); }
.achmedals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); margin-top: var(--s-3); }
.achmedal {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  padding: 4px 2px; background: none; border: 0; border-radius: var(--r-md); font: inherit; color: inherit;
}
button.achmedal { cursor: pointer; }
@media (hover: hover) { button.achmedal:hover { background: var(--surface-sunk); } }
.achmedal__icon {
  position: relative; width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center;
  background: var(--surface-sunk); color: var(--ink-faint); border: 1px dashed var(--line-strong, var(--line));
}
.achmedal--next .achmedal__icon { border: 2px solid var(--c); color: var(--c); background: var(--surface); }
.achmedal--unlocked .achmedal__icon { background: var(--c); color: white; border: 0; }
.achmedal__check {
  position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: var(--r-full);
  display: grid; place-items: center; background: var(--ok); color: white; border: 2px solid var(--surface);
}
.achmedal__name { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); text-align: center; line-height: 1.25; hyphens: auto; -webkit-hyphens: auto; }
.achmedal--unlocked .achmedal__name, .achmedal--next .achmedal__name { color: var(--ink); }

/* "Next up" hero — leads the page so day one isn't just a wall of locked
   grey. The one badge closest to earned (nextAchievement), with its bar. */
.ach-hero {
  display: flex; gap: var(--s-3); align-items: center;
  padding: var(--s-4); border-radius: var(--r-md);
  background: linear-gradient(120deg, color-mix(in oklab, var(--c, var(--brand)) 16%, var(--surface)), var(--surface) 75%);
  border: 1px solid color-mix(in oklab, var(--c, var(--brand)) 40%, var(--line));
}
.ach-hero__icon {
  flex: none; width: 44px; height: 44px; border-radius: var(--r-full);
  display: grid; place-items: center; background: var(--c, var(--brand)); color: #fff;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--c, var(--brand)) 70%, transparent);
}
.ach-hero__body { min-width: 0; flex: 1; }
.ach-hero__eyebrow { margin: 0; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: color-mix(in oklab, var(--c, var(--brand)) 75%, var(--ink)); }
.ach-hero__name { display: block; font-family: var(--font-display); margin: 2px 0; }
.ach-hero__desc { margin: 0 0 var(--s-2); font-size: var(--fs-sm); color: var(--ink-soft); }
.ach-hero__bar { height: 6px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; margin-bottom: 3px; }
.ach-hero__bar i { display: block; height: 100%; background: var(--c, var(--brand-bright)); transition: width var(--dur-slow) var(--ease-out); }

.achtoast--milestone .achtoast__icon { background: var(--brand); color: #fff; }

/* Unlock celebration — dropped in from the top, appended to <body> so it
   survives the navigation to the results page. */
.achtoast {
  position: fixed; left: 50%; top: var(--s-5); z-index: 90;
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 280px; max-width: min(400px, calc(100vw - 32px));
  padding: var(--s-4) var(--s-5); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2);
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  transition: transform var(--dur-mid) var(--ease-spring), opacity var(--dur-mid);
}
.achtoast.show { transform: translate(-50%, 0); opacity: 1; }
.achtoast__icon { flex: none; width: 48px; height: 48px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--surface-sunk); color: var(--ink-soft); }
.achtoast__eyebrow { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin: 0; }
.achtoast__name { font-family: var(--font-display); font-weight: 700; margin: 1px 0; }
.achtoast__desc { font-size: var(--fs-sm); color: var(--ink-soft); margin: 0; }
.achtoast--bronze .achtoast__icon { background: var(--ach-bronze); color: var(--ink-on-color); }
.achtoast--silver .achtoast__icon { background: var(--ach-silver); color: var(--ink-on-color); }
.achtoast--gold .achtoast__icon { background: var(--ach-gold); color: var(--ink-on-color); }
.achtoast--platinum .achtoast__icon { background: var(--ach-platinum-sheen); color: #34506A; }
.achtoast--gold { border-color: var(--ach-gold); }
.achtoast--platinum { border-color: var(--ach-platinum); }

/* ---------- estimated grade ---------- */
.gradepill {
  display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: var(--r-full); font-family: var(--font-display); font-weight: 700; font-size: calc(13px * var(--fs-scale, 1));
  background: var(--surface-sunk); color: var(--ink-soft); cursor: default;
}
.gradepill--low { background: var(--retry-tint); color: var(--retry-ink); }
.gradepill--high { background: var(--ok-tint); color: var(--ok-ink); }

.gradereveal {
  display: inline-block; margin: var(--s-2) auto var(--s-5); padding: var(--s-5) var(--s-6);
  min-width: 220px; border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--surface-sunk);
  animation: pop-in var(--dur-slow) var(--ease-spring) 650ms both;
}
.gradereveal--low { background: var(--retry-tint); border-color: var(--retry); }
.gradereveal--high { background: var(--ok-tint); border-color: var(--ok); }
.gradereveal__eyebrow { display: block; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); }
.gradereveal__letter { font-family: var(--font-display); font-weight: 700; font-size: 4rem; line-height: 1.2; color: var(--ink); }
.gradereveal--low .gradereveal__letter { color: var(--retry-ink); }
.gradereveal--high .gradereveal__letter { color: var(--ok-ink); }
.gradereveal__compare { font-weight: 600; margin-top: var(--s-1); }
.gradereveal__compare.up { color: var(--ok-ink); }
.gradereveal__compare.down { color: var(--ink-soft); }
.gradereveal__caption { font-size: var(--fs-sm); color: var(--ink-faint); margin-top: 2px; }
.gradereveal__caption--note { max-width: 46ch; margin-inline: auto; margin-top: 6px; }

/* ---------- instant solve: a chat from the first load ---------- */
.solve-chat__log {
  display: flex; flex-direction: column; gap: var(--s-3); text-align: left;
  min-height: clamp(300px, 52vh, 560px); max-height: 68vh; overflow-y: auto; padding: var(--s-2) 2px;
}
/* A photo sent inside a bubble — small enough to stay a supporting thumbnail
   next to whatever the student typed, not the whole message. */
.msg__img { display: block; max-width: 160px; max-height: 160px; border-radius: var(--r-sm); margin-bottom: var(--s-2); object-fit: cover; }
/* The attached-but-not-sent photo, previewed above the composer so it's
   clear what "send" is about to include. */
.solve-chat__pending {
  display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2);
  padding: var(--s-2); border-radius: var(--r-md); background: var(--surface-sunk);
}
.solve-chat__pending img { width: 40px; height: 40px; object-fit: cover; border-radius: var(--r-sm); flex: none; }
.solve-chat__pending .iconbtn { margin-left: auto; }
/* Dragging a picture over the page: the whole chat panel becomes the target. */
.solve-chat__panel { position: relative; }
.solve-chat__drop {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; text-align: center; padding: var(--s-5);
  border: 2px solid var(--brand); border-radius: inherit; background: var(--brand-tint); color: var(--brand-ink);
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity var(--dur-fast);
}
.solve-chat__panel.is-over .solve-chat__drop { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .solve-chat__drop { transition: none; } }

/* ---------- calendar quick-add dialog ---------- */
/* Quick-add from a calendar day: a head with the day as a small calendar page, three fields,
   and a footer with the actions on the right. */
.quickadd { max-width: 560px; padding: 0; overflow: hidden; animation: quickadd-in var(--dur-mid) var(--ease-out); }
@keyframes quickadd-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.quickadd__head {
  display: flex; align-items: center; gap: 14px; padding: var(--s-5) var(--s-5) var(--s-4);
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 7%, var(--surface)), var(--surface));
  border-bottom: 1px solid var(--line);
}
.quickadd__date {
  flex: none; width: 58px; display: grid; justify-items: center; overflow: hidden;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-1);
}
.quickadd__month {
  justify-self: stretch; text-align: center; padding: 3px 0 2px;
  font-size: calc(10.5px * var(--fs-scale, 1)); font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: #fff; background: var(--brand); transition: background var(--dur-mid);
}
.quickadd__date strong { font-family: var(--font-display); font-size: calc(24px * var(--fs-scale, 1)); line-height: 1.05; margin-top: 4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.quickadd__wday { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); margin-bottom: 5px; text-transform: lowercase; }
.quickadd__date.is-test .quickadd__month { background: var(--c-tangerine, #F0913C); }
.quickadd__headtxt { flex: 1; min-width: 0; }
.quickadd__headtxt h3 { margin: 0; font-size: var(--fs-lg, 1.2rem); letter-spacing: -.01em; }
.quickadd__headtxt p { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 3px 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.quickadd__when {
  padding: 1px 8px; border-radius: var(--r-full); font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700;
  background: var(--brand-tint); color: var(--brand-ink);
}
.quickadd__close { align-self: flex-start; margin: 0 -6px 0 0; }

.quickadd__body { display: grid; gap: var(--s-4); padding: var(--s-4) var(--s-5) var(--s-5); }
.quickadd__field { display: grid; gap: var(--s-2); min-width: 0; }
.quickadd__field > label, .quickadd__label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.quickadd__input,
.quickadd .subjectfield input {
  width: 100%; box-sizing: border-box; font: inherit; color: var(--ink);
  padding: 11px 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-sunk);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.quickadd__input:focus-visible,
.quickadd .subjectfield input:focus-visible {
  outline: none; border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.quickadd__types { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.quickadd__type {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 12px; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface);
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
}
@media (hover: hover) { .quickadd__type:hover { border-color: var(--line-strong); border-color: color-mix(in oklab, var(--brand) 45%, var(--line-strong)); } }
.quickadd__type:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.quickadd__typeic {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-sunk); color: var(--ink-soft); transition: background var(--dur-fast), color var(--dur-fast);
}
.quickadd__typetxt { display: grid; gap: 1px; min-width: 0; }
.quickadd__typetxt strong { font-size: var(--fs-sm); color: var(--ink); }
.quickadd__typetxt small { font-size: calc(12px * var(--fs-scale, 1)); line-height: 1.3; color: var(--ink-faint); }
.quickadd__check {
  position: absolute; top: 8px; right: 8px; width: 18px; height: 18px; border-radius: var(--r-full);
  display: grid; place-items: center; color: #fff; background: var(--brand);
  opacity: 0; transform: scale(.6); transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.quickadd__type[aria-checked="true"] {
  border-color: var(--brand); background: var(--surface); background: color-mix(in oklab, var(--brand) 7%, var(--surface));
  box-shadow: 0 0 0 1px var(--brand);
}
.quickadd__type[aria-checked="true"] .quickadd__typeic { background: var(--brand); color: #fff; }
.quickadd__type[aria-checked="true"] .quickadd__check { opacity: 1; transform: none; }

.quickadd__foot { margin-top: 0; padding: var(--s-4) var(--s-5); }
@media (max-width: 420px) {
  .quickadd__head, .quickadd__body { padding-inline: var(--s-4); }
  .quickadd__foot { padding-inline: var(--s-4); }
  .quickadd__typetxt small { display: none; }
}
@media (prefers-reduced-motion: reduce) { .quickadd { animation: none; } }

/* ---------- friend leaderboard ---------- */
.lbrows { display: flex; flex-direction: column; gap: var(--s-2); }
.lbrow {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.lbrow--me { border-color: var(--brand); background: var(--brand-tint); }
/* Same gold/silver/bronze as the achievement badges — one ranked-tier
   visual language for the whole app. */
.lbrank {
  flex: none; width: 28px; height: 28px; border-radius: var(--r-full);
  display: grid; place-items: center; font-weight: 700; font-family: var(--font-display);
  background: var(--surface-sunk); color: var(--ink-soft); font-size: var(--fs-sm);
}
.lbrank--gold { background: var(--ach-gold); color: var(--ink-on-color); }
.lbrank--silver { background: var(--ach-silver); color: var(--ink-on-color); }
.lbrank--bronze { background: var(--ach-bronze); color: var(--ink-on-color); }
/* A profile picture in place of the rank number; the tier colour becomes the ring. The number circle
   gets margin to the picture's 36px footprint, so names line up whichever a row shows. */
.lbrank { margin: 4px; }
.lbavatar {
  flex: none; position: relative; width: 36px; height: 36px; border-radius: var(--r-full);
  overflow: hidden; background: var(--surface-sunk); box-shadow: 0 0 0 1px var(--line);
}
.lbavatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lbavatar--gold { box-shadow: 0 0 0 2px var(--ach-gold); }
.lbavatar--silver { box-shadow: 0 0 0 2px var(--ach-silver); }
.lbavatar--bronze { box-shadow: 0 0 0 2px var(--ach-bronze); }
.lbrow__who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lbrow__handle { font-weight: 700; font-family: var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbrow__stats { display: flex; align-items: center; gap: var(--s-4); flex: none; }
.lbrow__streak { display: inline-flex; align-items: center; gap: 4px; color: var(--retry-ink); font-weight: 700; font-size: var(--fs-sm); }
.lbrow__questions { font-weight: 700; font-size: var(--fs-sm); color: var(--ink-soft); white-space: nowrap; }
/* The signed-out page's preview (views/leaderboard.js boardPreview): the same rows, tighter, one line each. */
.lbprev { gap: 6px; }
.lbprev .lbrow { flex-wrap: nowrap; padding: 8px 12px; gap: var(--s-2); }
.lbprev .lbrank { margin: 0; width: 26px; height: 26px; }
.lbprev .lbrow__stats { gap: var(--s-3); }
/* Phones: the stats move under the name so the name gets the row's width - two friends whose names
   start the same (anna.l, anna.lindberg) would otherwise both cut to "anna…". */
@media (max-width: 520px) {
  .lbrow {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: var(--s-3); row-gap: 2px; align-items: center;
  }
  .lbrow > .lbavatar, .lbrow > .lbrank { grid-column: 1; grid-row: 1 / span 2; }
  .lbrow__who { grid-column: 2; grid-row: 1; }
  .lbrow__handle { white-space: normal; overflow-wrap: anywhere; }
  .lbrow__stats { grid-column: 2; grid-row: 2; gap: var(--s-3); }
  .lbrow > .iconbtn { grid-column: 3; grid-row: 1 / span 2; }
}
.lbcode {
  font-size: calc(22px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .12em; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--surface-sunk); border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  padding: var(--s-3); text-align: center; margin: var(--s-2) 0 var(--s-3);
}

/* ---------- share card ---------- */
.sharecard { text-align: center; position: relative; max-width: 380px; }
.sharecard__close { position: absolute; top: var(--s-2); right: var(--s-2); }
.sharecard__preview { width: 100%; border-radius: var(--r-md); margin: var(--s-3) 0; display: block; }
.sharecard__actions { display: flex; gap: var(--s-3); justify-content: center; flex-wrap: wrap; }

@media print {
  .topbar, .hintfab, [data-noprint], .toast, .savebar, .achtoast, .popover, .sharecard-backdrop { display: none !important; }
  body:has(.printsheet) :is(.sidebar, .tabbar, .sitefooter, .sitechat__fab, .homebtn) { display: none !important; }
  body { background: #fff; color: #000; }
  .content { max-width: none; padding: 0; }
  .psheet__lines { background: none; height: 60px; border-bottom: 1px solid #999; }
  a[href]::after { content: ""; }
}

/* Phones: the primary action gets its own full-width row, where thumbs reach. */
@media (max-width: 520px) {
  .welcome__nav .btn--ghost { order: 1; }
  .welcome__spacer { order: 2; }
  .welcome__nav .linkbtn { order: 3; }
  .welcome__nav .btn:not(.btn--ghost) { flex: 1 1 100%; order: 4; justify-content: center; }
  .welcome__cta .btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------- the desktop sidebar on every window size ----------
   The list always fills the height from the logo down to the footer (design.css): its rows share the
   window's height, between 28px and a comfortable cap, every section keeps its heading, and nothing folds
   into an unlabelled icon grid. Its width, row height and icons grow on big screens (--sidebar-w, --sb-row,
   --sb-ic). */
@media (min-width: 900px) {
  .sidebar__more { display: contents; }
  .sidebar__morecap { display: none; }
}

/* ===== polish ===== */

/* chat button: away while scrolling down on phones */
@media (max-width: 899px) {
  .sitechat__fab { transition: transform var(--dur-mid) var(--ease-out), opacity var(--dur-mid) var(--ease-out), visibility 0s; }
  body.fab-away .sitechat__fab { transform: translateY(12px) scale(.6); opacity: 0; visibility: hidden; pointer-events: none; transition-delay: 0s, 0s, var(--dur-mid); }
}

/* home, first run: nothing to search or filter yet */
body:has(.empty--first) :is(.search, .filtertoggle, .filterdrawer, .tabs) { display: none; }

/* phones: readable labels and touch-sized controls */
@media (max-width: 899px) {
  .tabbar__item span { font-size: calc(12px * var(--fs-scale, 1)); }
  .tabbar__item { padding: 10px 0 9px; }
  .libcard .btn, .libcard .libseg__group button { min-height: 44px; }
  .libseg__group button { min-width: 52px; }
  .libcard:not(.libcard--added) .libcard__foot > div { width: 100%; justify-content: space-between; }
  .sitefooter__links a { display: inline-block; padding: 12px 4px; }
  summary { padding-block: 11px; }
  .btn--sm, .lp-lang { min-height: 40px; }
  .iconbtn:not(.iconbtn--sm), .homebtn { min-width: 44px; min-height: 44px; }
}

/* home, first run: a compact, balanced empty state */
.empty--first { padding-block: var(--s-5); }
.empty--first h3 { text-wrap: balance; }

/* library on phones: the Add button spans the card, easy to hit with a thumb */
@media (max-width: 899px) {
  .libcard:not(.libcard--added) .libcard__foot > div > .btn:not(.btn--ghost) { flex: 1 1 100%; justify-content: center; }
}

/* progress: caption under the day strip */

/* ===== subject picker: book covers ===== */
.source-grid--subjects { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.source-opt--subject { display: grid; grid-template-columns: 56px minmax(0, 1fr); column-gap: 14px; align-items: center; align-content: start; text-align: left; padding: 16px 16px 14px 18px; }
/* A subject's mark in the library, in the home page tiles' subtle neon (.home-tile): a faint tint of the
   subject's colour (views/library.js SUBJECT_COLORS), a neon edge with a soft glow, and letters in the
   colour. Mixed with the theme's surface and ink, so it is lighter on the dark theme and deeper on the light. */
.subjmark {
  width: 56px; height: 56px; border-radius: var(--r-md);
  background: var(--surface);
  background: color-mix(in oklab, var(--subject, var(--brand)) 12%, var(--surface));
  border: 1.5px solid var(--subject, var(--brand));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--subject, var(--brand)) 22%, transparent), 0 0 14px -4px color-mix(in srgb, var(--subject, var(--brand)) 55%, transparent);
  color: var(--brand-ink);
  color: color-mix(in srgb, var(--subject, var(--brand)) 40%, var(--ink));   /* 70 % left the gold and light marks at 3:1 */
  display: grid; place-items: center; align-content: center; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: calc(21px * var(--fs-scale, 1)); letter-spacing: -.02em; line-height: 1.05;
}
.subjmark small { display: block; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; letter-spacing: 0; opacity: .9; }
.subjtext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.subjname { font-size: var(--fs-md); font-weight: 600; }
.subjmeta { font-size: calc(13px * var(--fs-scale, 1)); font-weight: 400; color: var(--ink-soft); }
.source-opt--subject .subjdesc { grid-column: 1 / -1; margin: 12px 0 0; text-align: left; font-weight: 400; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 560px) {
  .source-grid--subjects .source-opt--subject { padding: 8px 16px 8px 14px; }
  .subjmark { width: 38px; height: 38px; font-size: calc(15px * var(--fs-scale, 1)); flex: none; border-radius: var(--r-sm); }
  .subjmark small { font-size: calc(12px * var(--fs-scale, 1)); }
  .subjtext { flex: 1; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 10px; }
}

/* ===== minnesregler: rule prompt, "your rule" line, and the rules page ===== */
.rulecard { margin-top: var(--s-4); padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.rulecard__q { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--brand-ink); margin-bottom: 10px; }
.rulecard__field { position: relative; }
.rulecard__input { width: 100%; min-height: 46px; font: inherit; font-weight: 500; padding: 10px 14px; border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.rulecard__input:focus-visible { border-color: var(--brand); box-shadow: none; outline: none; }
.rulecard__count { position: absolute; right: 12px; bottom: -18px; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.rulecard__hint { margin: 10px 0 12px; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); }
.rulecard__actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rulecard__actions .btn, .rulecard__actions .linkbtn { min-height: 44px; }
.rulecard__actions .linkbtn { padding-inline: 4px; }
.rulecard__rule { margin: 0 0 12px; font-weight: 600; color: var(--ink); }
.rulecard--saved { display: flex; align-items: center; gap: 10px; background: var(--ok-tint); border-color: transparent; color: var(--ok-ink); font-weight: 500; }
.rulecard--saved svg { flex: none; }
.rulecard--saved a { color: inherit; text-decoration: underline; white-space: nowrap; }

.rulepeek { margin-bottom: var(--s-3); border-radius: var(--r-md); background: var(--brand-tint); color: var(--brand-ink); }
.rulepeek__btn { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 0; background: none; color: inherit; font: inherit; font-size: calc(13.5px * var(--fs-scale, 1)); font-weight: 600; text-align: left; cursor: pointer; border-radius: var(--r-md); }
.rulepeek__btn svg { flex: none; }
.rulepeek__label { flex: 1; min-width: 0; }
.rulepeek__cta { font-weight: 600; text-decoration: underline; }
.rulepeek__btn[aria-expanded="true"] .rulepeek__cta { display: none; }
.rulepeek__body { padding: 0 14px 12px 37px; }
.rulepeek__list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rulepeek__list li { font-size: calc(17px * var(--fs-scale, 1)); font-weight: 600; line-height: 1.35; color: var(--ink); }
.rulepeek__note { margin: 8px 0 0; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-soft); }

/* "Mina regler" (views/rules.js): each rule as a card in the student's own words, opened by a quote
   mark in its subject's colour (--subject, set per group); grouped by subject in a two-up grid.
   With no rules, the three steps that make one and a sample card. */
.rules-page { max-width: 1040px; }
.rules-screen { display: grid; gap: var(--s-5); }
.rules-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-5); flex-wrap: wrap; }
.rules-head h1 { margin: 0; }
.rules-head__sub { margin: 6px 0 0; max-width: 60ch; color: var(--ink-soft); }
.rules-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.rules-actions .btn { display: inline-flex; align-items: center; gap: 8px; }

.rules-tools { display: grid; gap: var(--s-3); }
.rules-tools__search { max-width: 520px; }
.rules-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rules-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.rules-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--subject); }
.rules-chip b { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .rules-chip:hover { color: var(--ink); border-color: var(--ink-faint); } }
.rules-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.rules-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.rules-chip[aria-pressed="true"] b { color: inherit; opacity: .7; }
.rules-nomatch { margin: 0; color: var(--ink-soft); }

.rules-groups { display: grid; gap: var(--s-6); }
.rules-group { display: grid; gap: var(--s-3); }
.rules-group__head { display: flex; align-items: center; gap: 10px; margin: 0; font-size: var(--fs-lg); letter-spacing: -.01em; }
.rules-group__dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--subject); }
.rules-group__n { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-faint); }
.rules-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }

.myrule {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 16px 18px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: border-color var(--dur-fast);
}
@media (hover: hover) { .myrule:hover { border-color: var(--line-strong); } }
.myrule__quote {
  height: 22px; margin-bottom: -4px; font-family: Georgia, "Times New Roman", serif; font-size: calc(52px * var(--fs-scale, 1)); line-height: .8;
  font-weight: 700; color: var(--subject);
}
.myrule__text { margin: 0; font-size: 1.08rem; font-weight: 600; line-height: 1.45; color: var(--ink); overflow-wrap: anywhere; }
.myrule__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: auto; padding-top: 4px; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.myrule__topic { padding: 2px 10px; border-radius: var(--r-full); font-weight: 600; background: var(--subject-tint, var(--brand-tint)); color: var(--subject-text, var(--subject-ink, var(--brand-ink))); }
/* Edit and delete sit at the end of the bottom row, out of the way until the card is hovered or
   focused; always there on touch. */
.myrule__acts { display: flex; gap: 4px; margin-left: auto; opacity: 0; transition: opacity var(--dur-fast); }
.myrule:hover .myrule__acts, .myrule:focus-within .myrule__acts { opacity: 1; }
@media (hover: none) { .myrule__acts { opacity: 1; } }
@media (hover: hover) { .myrule__del:hover { color: var(--retry-ink); border-color: var(--retry); } }

.myrule--edit { gap: 12px; }
.myrule__field { position: relative; }
.myrule__input {
  display: block; width: 100%; min-height: 84px; resize: vertical; font: inherit; font-size: 1.02rem; font-weight: 600; line-height: 1.45;
  padding: 10px 12px 22px; border-radius: var(--r-md); border: 2px solid var(--subject, var(--brand)); background: var(--surface); color: var(--ink);
}
.myrule__input:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--subject, var(--brand)) 18%, transparent); }
.myrule__count { position: absolute; right: 10px; bottom: 6px; font-size: calc(11.5px * var(--fs-scale, 1)); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.myrule__editacts { display: flex; gap: 8px; justify-content: flex-end; }

/* No rules yet: how one comes about, beside one to look at. */
.rules-empty {
  display: grid; gap: var(--s-6); align-items: center; padding: var(--s-6);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
@media (min-width: 860px) { .rules-empty { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.rules-empty__text { display: grid; gap: var(--s-4); justify-items: start; }
.rules-empty__text h2 { margin: 0; font-size: var(--fs-xl); letter-spacing: -.015em; }
.rules-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rules-steps li { display: flex; align-items: flex-start; gap: 12px; color: var(--ink-soft); line-height: 1.5; }
.rules-steps__n {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: calc(13px * var(--fs-scale, 1)); font-weight: 800; background: var(--brand-tint); color: var(--brand-ink);
}
.rules-empty__sample {
  position: relative; display: grid; gap: 10px; padding: var(--s-5); border-radius: var(--r-lg);
  background: var(--surface-sunk); background: color-mix(in oklab, var(--brand) 6%, var(--surface-sunk));
}
.rules-empty__tag { justify-self: start; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); }
.rules-empty__sample .myrule { box-shadow: var(--shadow-2); transform: rotate(-1.2deg); }

@media (max-width: 560px) {
  .rules-actions { width: 100%; }
  .rules-actions .btn { flex: 1 1 auto; justify-content: center; }
  .rules-empty { padding: var(--s-5) var(--s-4); }
  .rules-empty__sample { padding: var(--s-4); }
}
@media (prefers-reduced-motion: reduce) { .rules-empty__sample .myrule { transform: none; } }

/* Printed sheet: hidden on screen, the only thing shown when printing. */
.rulesheet { display: none; }
@media print {
  body:has(.rules-page) :is(.sidebar, .tabbar, .sitefooter, .sitechat__fab, .topbar) { display: none !important; }
  .rules-page .rules-screen { display: none !important; }
  .rules-page .rulesheet { display: block; color: #000; }
  .rulesheet h1 { font-size: calc(26px * var(--fs-scale, 1)); margin: 0 0 4px; }
  .rulesheet__meta { margin: 0 0 20px; font-size: calc(13px * var(--fs-scale, 1)); }
  .rulesheet__group { margin-bottom: 18px; break-inside: avoid; }
  .rulesheet h2 { font-size: calc(17px * var(--fs-scale, 1)); margin: 0 0 6px; border-bottom: 1px solid #999; padding-bottom: 3px; }
  .rulesheet ul { margin: 0; padding: 0; list-style: none; }
  .rulesheet li { display: flex; gap: 10px; align-items: flex-start; margin: 7px 0; font-size: calc(15px * var(--fs-scale, 1)); line-height: 1.4; }
  .rulesheet li small { color: #555; }
  .rulesheet__box { flex: none; width: 13px; height: 13px; margin-top: 3px; border: 1.5px solid #000; border-radius: 2px; }
}

/* ===== kvällen före provet: a calm, dark panel with a short checklist =====
   (The card on the home page, .tonightcard, is not one of these: it follows the active theme.) */
.tonight, .bus {
  --canvas: #0C1226; --surface: #141C36; --surface-sunk: #1B2545;
  --line: #263153; --line-strong: #37446E; --brand-tint: #1A2A55;
  background: radial-gradient(120% 100% at 100% 0%, #1B2A5C 0%, rgba(27,42,92,0) 58%), var(--canvas);
  color: var(--ink);
  border-radius: var(--r-lg);
}
.tonight-page { max-width: 640px; }
.tonight-page > .homebtn { margin-bottom: var(--s-4); }
.tonight { padding: 32px 28px 28px; display: flex; flex-direction: column; }
.tonight__moon { width: 48px; height: 48px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-ink); display: grid; place-items: center; }
.tonight__eyebrow { margin: 16px 0 0; font-size: calc(13px * var(--fs-scale, 1)); font-weight: 500; color: var(--ink-faint); }
.tonight__title { margin: 4px 0 0; font-size: clamp(28px, 7vw, 38px); line-height: 1.08; font-weight: 600; letter-spacing: -.015em; }
.tonight__lead { margin: 10px 0 0; max-width: 46ch; font-size: calc(16px * var(--fs-scale, 1)); line-height: 1.5; color: var(--ink-soft); }
.tsteps { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tstep { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.tstep__head { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 0; background: none; color: inherit; font: inherit; font-weight: 500; text-align: left; cursor: pointer; border-radius: var(--r-md); }
.tstep__mark { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; }
.tstep.is-done .tstep__mark { background: var(--ok-bright); border-color: transparent; color: #0A0C11; }
.tstep.is-done .tstep__mark svg { stroke-width: 3; }
.tstep__title { flex: 1; min-width: 0; }
.tstep__min { flex: none; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.tstep__body { padding: 0 14px 14px 52px; }
.tstep__hint { margin: 0 0 12px; font-size: calc(14px * var(--fs-scale, 1)); line-height: 1.5; color: var(--ink-soft); }
.tstep__rules { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tstep__rules li { padding-left: 12px; border-left: 3px solid var(--brand-bright); font-size: calc(16px * var(--fs-scale, 1)); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.tstep__body .btn { min-height: 44px; }
.tmeter { height: 8px; margin-top: 22px; border-radius: 999px; background: var(--surface-sunk); overflow: hidden; }
.tmeter__fill { height: 100%; border-radius: 999px; background: var(--brand-bright); transition: width var(--dur-slow) var(--ease-out); }
.tonight__minutes { margin: 6px 0 0; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.tonight__sleep { margin-top: 18px; padding: 14px 16px; background: var(--surface-sunk); border-radius: var(--r-md); display: flex; flex-direction: column; gap: 2px; }
.tonight__sleep span { font-size: calc(14px * var(--fs-scale, 1)); line-height: 1.45; color: var(--ink-soft); }
.tonight__actions { margin-top: 20px; display: flex; gap: 12px; flex-wrap: wrap; }
.tonight__finish { flex: 1 1 100%; justify-content: center; min-height: 52px; }
.tonight--done { min-height: 320px; }
.tonight--done .tonight__actions { margin-top: 28px; }
.tonight__quiet { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 20px 0 0; font-size: calc(14px * var(--fs-scale, 1)); color: var(--ink-soft); }
.tonight__quiet svg { flex: none; }
.tonight__quiet .linkbtn { color: var(--brand-ink); min-height: 32px; }
.tonight__also { margin: 14px 4px 0; font-size: calc(14px * var(--fs-scale, 1)); color: var(--ink-soft); }

@media (max-width: 560px) {
  .tonight { padding: 24px 18px 20px; }
  .tstep__body { padding-left: 14px; }

}

/* ===== solve tabs + kolla min uträkning ===== */
.solvetabs { display: flex; width: fit-content; max-width: 100%; gap: 4px; padding: 4px; margin: 12px 0 var(--s-3); background: var(--surface-sunk); border-radius: var(--r-full); }
.solvetab { min-height: 40px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); text-decoration: none; }
@media (hover: hover) { .solvetab:hover { color: var(--ink); } }
.solvetab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Matches .solve's width so the two /solve tabs don't visibly jump size when you switch between
   them; the actual reading content (intro, working, result) stays capped for legibility. */
.check { width: 100%; max-width: 1180px; }
.check-intro, .check-busy, .check-result { max-width: 760px; }
.check-lead { margin: 0 0 var(--s-4); color: var(--ink-soft); line-height: 1.55; }
.check-intro { display: flex; flex-direction: column; gap: var(--s-4); align-items: stretch; }
.check-drop { width: 100%; min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; border: 2px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); font: inherit; text-align: center; cursor: pointer; transition: border-color var(--dur-fast), background var(--dur-fast); }
.check-drop svg { color: var(--brand); margin-bottom: 4px; }
.check-drop strong { font-size: var(--fs-md); font-weight: 600; }
.check-drop span { font-size: var(--fs-sm); color: var(--ink-faint); }
.check.is-over .check-drop { border-color: var(--brand); background: var(--brand-tint); }
@media (hover: hover) { .check-drop:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-tint); } }
.check-drop:disabled { cursor: not-allowed; color: var(--ink-faint); }
.check-tips { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--ink-soft); }
.check-photo { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.check-photo img, .check-thumb { display: block; max-width: 100%; max-height: 300px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.check-thumb { margin-bottom: var(--s-4); }
.check-problem > summary { min-height: 40px; display: flex; align-items: center; cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--brand-ink); }
.check-problem textarea { margin-top: 8px; min-height: 72px; }
.check-go { align-self: flex-start; min-height: 48px; }
.check-btn { min-height: 44px; }
.check-busy { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3); }
.check-busy img { max-width: 100%; max-height: 240px; border-radius: var(--r-md); border: 1px solid var(--line); opacity: .75; }
.check-busy p { margin: 0; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }

.check-result { display: flex; flex-direction: column; align-items: stretch; }
.check-linehead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); }
.check-linehead h2 { font-size: var(--fs-md); font-weight: 600; margin: 0; }
.check-linehead .linkbtn { font-size: var(--fs-sm); min-height: 40px; }
.check-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-line { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.check-line__mark { flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; background: var(--surface-sunk); }
.check-line.is-ok .check-line__mark { background: var(--ok-tint); color: var(--ok-ink); }
.check-line.is-turn { background: var(--retry-tint); border-color: var(--retry); }
.check-line.is-turn .check-line__mark { background: var(--retry); color: var(--ink-on-color); }
.check-line.is-after { border-style: dashed; }
.check-line__body { flex: 1; min-width: 0; }
.check-line__text { font-size: calc(17px * var(--fs-scale, 1)); line-height: 1.5; overflow-wrap: anywhere; }
.check-line__turn { margin-top: 8px; color: var(--retry-ink); }
.check-line__turn strong { display: block; font-weight: 700; }
.check-line__turn p { margin: 6px 0 0; font-size: calc(15px * var(--fs-scale, 1)); line-height: 1.5; }
.check-line__after { display: block; margin-top: 2px; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.check-good { display: flex; gap: 12px; align-items: flex-start; margin-bottom: var(--s-4); padding: 14px 16px; background: var(--ok-tint); color: var(--ok-ink); border-radius: var(--r-md); }
.check-good svg { flex: none; margin-top: 2px; }
.check-good p { margin: 6px 0 0; }
.check-card { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.check-card h2 { font-size: var(--fs-md); margin: 0 0 6px; }
.check-card p { margin: 0; color: var(--ink-soft); line-height: 1.5; }
.check-edit { display: flex; flex-direction: column; gap: 8px; }
.check-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: var(--s-4); }
.check-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.check-solution { margin-top: var(--s-5); padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.check-solution h2 { font-size: var(--fs-md); margin: 0 0 8px; }
.check-solution .note { margin-top: 10px; }
.check-usage { margin: var(--s-5) 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
@media (max-width: 560px) {
  .check-go, .check-actions .btn { width: 100%; justify-content: center; }
}

/* ===== bussläge: read aloud, answer by voice or tap ===== */
.session--bus > .session__head, .session--bus > .testbar, .session--bus > .progressbar, .session--bus > .progress-dots,
.session--bus > .progress-label, .session--bus > .adaptive, .session--bus .hintfab, .session--bus .tutor { display: none !important; }
.session--bus .session { display: block; }
.session--bus .nav-row { justify-content: flex-start; margin-top: var(--s-4); }
.session--bus .nav-row > div:last-child, .session--bus .nav-row .btn--sm { display: none; }
.session--bus > .homebtn { margin-bottom: var(--s-3); }

.bus { max-width: 640px; margin-inline: auto; padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.bus__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bus__chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-full); background: var(--brand-tint); color: var(--brand-ink); font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600; }
.bus__count { font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.bus__q { margin: 4px 0 2px; font-size: clamp(21px, 5.5vw, 26px); line-height: 1.3; font-weight: 600; text-wrap: balance; overflow-wrap: anywhere; }
.bus__opts { display: flex; flex-direction: column; gap: 10px; }
.bus-opt { width: 100%; min-height: 60px; display: flex; align-items: center; gap: 14px; padding: 10px 16px; text-align: left; font: inherit; font-size: calc(17px * var(--fs-scale, 1)); color: var(--ink); background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--r-md); cursor: pointer; transition: border-color var(--dur-fast), background var(--dur-fast); }
@media (hover: hover) { .bus-opt:hover:not(:disabled) { border-color: var(--brand-bright); } }
.bus-opt__key { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunk); font-size: calc(14px * var(--fs-scale, 1)); font-weight: 700; }
.bus-opt__text { min-width: 0; overflow-wrap: anywhere; }
.bus-opt:disabled { cursor: default; }
.bus-opt:disabled:not(.is-correct):not(.is-wrong) { opacity: .55; }
.bus-opt.is-correct { border-color: var(--ok-bright); background: var(--ok-tint); }
.bus-opt.is-correct .bus-opt__key { background: var(--ok-bright); color: #0A0C11; }
.bus-opt.is-wrong { border-color: var(--retry); background: var(--retry-tint); }
.bus-opt.is-wrong .bus-opt__key { background: var(--retry); color: #0A0C11; }

.bus__start { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bus__start p { margin: 0; font-size: calc(14px * var(--fs-scale, 1)); line-height: 1.5; color: var(--ink-soft); }
.bus__start .bus__privacy { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.bus__go { justify-content: center; min-height: 56px; font-size: calc(17px * var(--fs-scale, 1)); }

.bus__voice { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 8px; }
.bus-orb { width: 78px; height: 78px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; cursor: pointer; box-shadow: 0 0 0 10px var(--brand-tint); transition: opacity var(--dur-fast), transform var(--dur-fast); }
@media (hover: hover) { .bus-orb:hover { transform: scale(1.03); } }
.bus-orb.is-busy { opacity: .6; }
.bus-orb.is-listening { animation: bus-pulse 1.6s ease-in-out infinite; }
@keyframes bus-pulse { 0%, 100% { box-shadow: 0 0 0 10px var(--brand-tint); } 50% { box-shadow: 0 0 0 20px rgba(58, 106, 224, .18); } }
.bus-wave { display: flex; align-items: center; justify-content: center; gap: 4px; height: 52px; }
.bus-wave i { display: block; width: 5px; height: 10px; border-radius: 3px; background: var(--brand-bright); opacity: .35; }
.bus-wave.is-on i { opacity: 1; animation: bus-wave 900ms ease-in-out infinite; animation-delay: calc(var(--i) * 70ms); }
@keyframes bus-wave { 0%, 100% { height: 10px; } 50% { height: 44px; } }
.bus__status { margin: 0; min-height: 1.4em; font-size: calc(16px * var(--fs-scale, 1)); font-weight: 600; text-align: center; }
.bus__note { margin: 0; min-height: 1.4em; max-width: 46ch; font-size: calc(13.5px * var(--fs-scale, 1)); line-height: 1.45; text-align: center; color: var(--ink-soft); }
.bus__controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.bus__ctl { min-height: 44px; padding-inline: 18px; }
.bus__prefs { display: flex; justify-content: center; }
.bus__toggle { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: var(--r-full); background: none; color: var(--ink-soft); font: inherit; font-size: calc(14px * var(--fs-scale, 1)); cursor: pointer; }
.bus__toggle-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); }
.bus__toggle[aria-checked="true"] { color: var(--ink); border-color: var(--ok-bright); }
.bus__toggle[aria-checked="true"] .bus__toggle-dot { background: var(--ok-bright); border-color: var(--ok-bright); }
@media (prefers-reduced-motion: reduce) {
  .bus-orb.is-listening { animation: none; }
  .bus-wave.is-on i { animation: none; height: 30px; }
}
@media (max-width: 560px) {
  .bus { padding: 16px 14px 20px; }
}

/* ===== dagens fråga (klassläget) ===== */
.daily-slot { margin: 0 0 var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); }
/* Utdelat till dig: sets a teacher or parent handed out, on the home page (components/handed-out-card.js). */
.handed-slot { margin: 0 0 var(--s-5); }
.handedcard { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 10px; }
.handedcard__head { display: flex; align-items: center; gap: 12px; }
.handedcard__head strong { font-size: var(--fs-md); font-weight: 600; line-height: 1.25; }
.handedcard__avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--c-grape-tint); color: var(--c-grape-ink); }
.handedcard__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.handedcard__main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.handedcard__title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.handedcard__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); }
.handedcard__row .btn { flex: none; }
.handedcard__more { align-self: flex-start; }
.dailycard { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.dailycard__head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.dailycard__head strong { display: block; font-size: var(--fs-md); font-weight: 600; line-height: 1.25; }
.dailycard__head span:not(.dailycard__avatar) { font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); }
.dailycard__avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--c-grape-tint); color: var(--c-grape-ink); }
.dailycard__q { margin-bottom: 12px; font-size: calc(17px * var(--fs-scale, 1)); line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; }
.dailycard__opts { display: flex; flex-direction: column; gap: 8px; }
.dailycard__opts .choice { min-height: 48px; padding: 8px 12px; }
.dailycard__hint { margin: 10px 0 0; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); }
.dailycard__result { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.dailycard__verdict { margin: 0; font-size: var(--fs-md); line-height: 1.4; }
.dailycard__why { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-soft); }
.dailycard__privacy { margin: 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.dailyspread { display: flex; flex-direction: column; gap: 8px; }
.dailyspread__row { display: flex; align-items: center; gap: 10px; font-size: calc(14px * var(--fs-scale, 1)); }
.dailyspread__key { flex: none; width: 22px; font-weight: 600; }
.dailyspread__bar { flex: 1; height: 14px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.dailyspread__bar i { display: block; height: 100%; border-radius: var(--r-full); background: var(--line-strong); }
.dailyspread__row.is-correct .dailyspread__bar i { background: var(--ok-bright); }
.dailyspread__pct { flex: none; width: 46px; text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.dailycard__streak { margin-top: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: calc(13.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.dailydots { display: inline-flex; gap: 4px; }
.dailydots i { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-sunk); }
.dailydots i.is-on { background: var(--brand); }

.dailyform { display: flex; flex-direction: column; gap: 14px; }
.dailyform .field { margin: 0; }
.dailyform textarea { min-height: 72px; }
.dailyform__choices { border: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dailyform__choices legend { padding: 0; margin-bottom: 4px; font-size: var(--fs-sm); font-weight: 600; }
.dailyform__choice { display: flex; align-items: center; gap: 10px; }
.dailyform__choice > input[type="text"] { flex: 1; min-width: 0; }
.dailyform__correct { flex: none; min-width: 64px; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 8px; border-radius: var(--r-md); font-weight: 600; cursor: pointer; }
.dailyform__correct input { width: 18px; height: 18px; accent-color: var(--ok); }
.dailyform__choices .linkbtn { align-self: flex-start; min-height: 40px; }
.dailyform__from > summary { min-height: 40px; display: flex; align-items: center; cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--brand-ink); }
.dailyform__from select { margin-top: 8px; width: 100%; }
.dailyform__actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dailyitem { padding: 12px 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.dailyitem__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.dailyitem__q { margin: 0 0 8px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.dailyitem__opts { list-style: upper-alpha; margin: 0 0 8px 24px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dailyitem__opts li { padding-left: 4px; font-size: var(--fs-sm); color: var(--ink-soft); }
.dailyitem__opts li.is-correct { color: var(--ok-ink); font-weight: 600; }
.dailyitem__pct { margin-left: 10px; font-variant-numeric: tabular-nums; color: var(--ink-faint); font-weight: 500; }
.dailyitem__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
@media (max-width: 560px) {
  .dailycard { padding: 14px; }
  .dailyitem__actions .btn { min-height: 40px; }
}

/* the daily-question form: same look as the other settings fields, plus dates and the option rows */
.dailyform input[type=text], .dailyform input[type=date], .dailyform select {
  width: 100%; min-height: 44px; font: inherit; padding: 8px var(--s-3); border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.dailyform input[type=date] { width: auto; min-width: 200px; }
.dailyform textarea { border-radius: var(--r-md); }
.dailyform input[type=radio] { width: 18px; min-height: 0; padding: 0; }

/* sign-up consent (login.js): checkbox + sentence with links */
.field.consentrow { display: flex; align-items: flex-start; gap: var(--s-3); }
.field.consentrow > input { flex: 0 0 auto; width: 20px; height: 20px; margin: 2px 0 0; }
.field.consentrow > span { font-weight: 400; margin: 0; line-height: 1.45; }

/* ===== "för lärare" front page (#/teachers) — reuses the consumer front
   page's .lp-* layout scaffolding (header, hero grid, section/steps/closer
   rhythm), with its own hero art and feature illustrations. ===== */
.teach-eyebrow {
  margin: 0 0 var(--s-3); font-size: calc(13px * var(--fs-scale, 1)); font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase; color: var(--brand-ink);
}
.lp-teachnote { margin: var(--s-4) 0 0; font-size: calc(13.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.lp-teachnote a { color: var(--brand-ink); font-weight: 600; }

/* hero art: a teacher's view of one day's question, already answered */
.teach-daily {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; gap: var(--s-4);
}
.teach-daily__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.teach-daily__chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: var(--r-full); background: var(--brand-tint); color: var(--brand-ink);
  font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 700;
}
.teach-daily__class { font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); }
.teach-daily__q {
  margin: 0; font-family: var(--font-display); font-weight: 700;
  font-size: 1.1rem; line-height: 1.35; color: var(--ink);
}
.teach-daily__opts { display: flex; flex-direction: column; gap: 8px; }
.teach-daily__opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); font-size: calc(15px * var(--fs-scale, 1)); font-weight: 500; color: var(--ink);
}
.teach-daily__key {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; background: var(--surface-sunk); color: var(--ink-soft);
}
.teach-daily__opt.is-right { border-color: var(--ok-bright); background: var(--ok-tint); color: var(--ok-ink); }
.teach-daily__opt.is-right .teach-daily__key { background: var(--ok); color: #fff; }   /* --ok-bright under white was 2.3:1 */
.teach-daily__opt.is-right svg { margin-left: auto; }
.teach-daily__result {
  display: flex; align-items: flex-start; gap: 10px;
  padding-top: var(--s-3); border-top: 1px solid var(--line); color: var(--ok-ink);
}
.teach-daily__result svg { flex: none; margin-top: 2px; }
.teach-daily__result strong { display: block; font-size: calc(15px * var(--fs-scale, 1)); }
.teach-daily__result p { margin: 2px 0 0; font-size: calc(13.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.teach-daily__privacy { display: flex; align-items: center; gap: 6px; margin: 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }

/* feature row 1: assign, as a numbered flow */
.teach-assign { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.teach-assign li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); font-weight: 600; color: var(--ink); }
.teach-assign li + li { border-top: 1px solid var(--line); }
.teach-assign__n {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand-ink); font-size: calc(13px * var(--fs-scale, 1)); font-weight: 800;
}

/* feature row 2: writing a question, "mark the correct one" */
.teach-compose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.teach-compose__q { margin: 0 0 var(--s-4); font-weight: 600; font-size: 1.02rem; color: var(--ink); }
.teach-compose__opts { display: flex; flex-direction: column; gap: 8px; }
.teach-compose__row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); font-size: calc(14.5px * var(--fs-scale, 1)); color: var(--ink-soft);
}
.teach-compose__radio { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); }
.teach-compose__row.is-marked { border-color: var(--ok-bright); background: var(--ok-tint); color: var(--ok-ink); font-weight: 600; }
.teach-compose__row.is-marked .teach-compose__radio { border-color: var(--ok-bright); background: var(--ok-bright); }
.teach-compose__tag { margin-left: auto; font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ok-ink); }

/* feature row 3: results as counts, never names */
.teach-results { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.teach-results__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); }
.teach-results__cell {
  display: grid; place-items: center; min-height: 56px; border-radius: var(--r-md);
  font-weight: 700; font-size: calc(15px * var(--fs-scale, 1)); font-variant-numeric: tabular-nums;
  background: var(--surface-sunk); color: var(--ink-faint);
}
.teach-results__cell.is-hi { background: var(--ok-tint); color: var(--ok-ink); }
.teach-results__cell.is-mid { background: var(--retry-tint); color: var(--retry-ink); }
.teach-results__caption { display: flex; align-items: center; gap: 6px; margin: var(--s-4) 0 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }

/* ===== class wizard: the "get this class going" checklist ===== */
.classwiz { border-color: var(--brand-tint); }
.classwiz__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.classwiz__head h3 { margin: 0; }
.classwiz__dismiss { font-size: calc(13px * var(--fs-scale, 1)); }
.classwiz__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.classwiz__step { display: flex; gap: var(--s-3); }
.classwiz__mark {
  flex: none; width: 28px; height: 28px; margin-top: 1px; border-radius: 50%;
  display: grid; place-items: center; font-size: calc(13px * var(--fs-scale, 1)); font-weight: 700;
  background: var(--surface-sunk); color: var(--ink-soft);
}
.classwiz__step.is-done .classwiz__mark { background: var(--ok-bright); color: var(--ink-on-color); }
.classwiz__step.is-done .classwiz__body { opacity: .7; }
.classwiz__body h4 { margin: 0; font-size: var(--fs-md); font-weight: 700; color: var(--ink); }
.classwiz__body p { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.classwiz__cta { margin-top: var(--s-3); }

/* ===== share slide: the class code, big enough to read off a projector ===== */
.shareslide { position: relative; max-width: 460px; text-align: center; padding: var(--s-7) var(--s-6); }
.shareslide__close { position: absolute; top: var(--s-4); right: var(--s-4); }
.shareslide__title { margin: 0 0 var(--s-3); font-family: var(--font-display); font-size: 1.4rem; }
.shareslide__how { margin: 0 0 var(--s-5); font-size: var(--fs-sm); color: var(--ink-soft); }
.shareslide__code {
  margin: 0; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 4rem); letter-spacing: .08em; color: var(--brand-ink);
}
.shareslide__url { margin: var(--s-3) 0 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.shareslide__actions { margin-top: var(--s-6); }
@media print {
  body:has(.shareslide-modal) * { visibility: hidden; }
  body:has(.shareslide-modal) .shareslide-modal,
  body:has(.shareslide-modal) .shareslide-modal * { visibility: visible; }
  .shareslide-modal { position: fixed; inset: 0; background: #fff; backdrop-filter: none; }
  .shareslide-modal [data-noprint] { display: none !important; }
}
@media (max-width: 560px) {
  .shareslide { padding: 56px var(--s-4) var(--s-5); }
  .teach-results__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Password show/hide toggle (login.js, reset-password.js) — an eye button glued to the input's
   right edge; the extra padding-right on the input keeps its own text clear of the button. */
.pwfield { position: relative; }
.pwfield input[type=password], .pwfield input[type=text] { padding-right: 44px; }
.pwtoggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 8px; display: flex; color: var(--ink-faint);
  cursor: pointer; border-radius: var(--r-sm);
}
@media (hover: hover) { .pwtoggle:hover { color: var(--ink); background: var(--surface-sunk); } }

/* The welcome quiz's account card carries the same consent box as the sign-in page. */
.welcome__acct .consentrow { margin: var(--s-3) 0 var(--s-2); font-size: var(--fs-sm); }

/* Study chat (#/chat) and the home page's AI study help strip: the one-tap ways to study. */
.chatmodes { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-3); }
.chatmode {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  font: inherit; font-size: var(--fs-sm); font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-full);
}
@media (hover: hover) { .chatmode:hover { color: var(--ink); border-color: var(--brand-bright, var(--brand)); } }
.chatmode.is-on { color: var(--brand-ink, var(--brand)); background: var(--brand-tint); border-color: var(--brand); }
.chatmode svg { flex: none; }
.chatmode:disabled { opacity: .5; cursor: not-allowed; }
@media (hover: hover) { .chatmode:disabled:hover { border-color: var(--line-strong); color: var(--ink-soft); } }
.solve .msg.me { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Left-aligned with the page, wide, and the chat fills the screen: the composer sits at the bottom of
   the viewport and only the message list scrolls, so the footer is a scroll away instead of in view. */
.solve { width: 100%; max-width: 1180px; }
/* A minimum height, not a fixed one: the chat fills the screen, but a tall composer (a long paste, an
   attached set) makes the page a little longer instead of squeezing the conversation to nothing. */
.solve-chat { display: flex; flex-direction: column; gap: var(--s-3); border-radius: var(--r-lg); min-height: max(380px, calc(100dvh - 400px)); }
@media (min-width: 900px) { .solve-chat { min-height: max(420px, calc(100dvh - 340px)); } }
.solve .solve-chat__log { flex: 1 1 0; min-height: 180px; max-height: none; }
.solve .msg { max-width: min(92%, 760px); }

/* Exam mode: question map (overview), flag button, flagged dots. */
.progress-dots .is-flag { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--retry); }
.flagbtn.is-on { color: var(--retry); border-color: var(--retry); }
.examoverview { max-width: 520px; max-height: 84vh; overflow-y: auto; }
.examgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: var(--s-2); }
.examcell {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-height: 44px; padding: 0 6px; font: inherit; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--ink-soft); background: var(--surface);
  border: 2px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer;
}
@media (hover: hover) { .examcell:hover { border-color: var(--brand-bright, var(--brand)); } }
.examcell.is-done { color: var(--ink); background: var(--surface); background: color-mix(in srgb, var(--ok) 16%, var(--surface)); border-color: var(--ok); }
.examcell.is-flag { border-color: var(--retry); }
.examcell.is-flag svg { color: var(--retry); }
.examcell.is-now { outline: 3px solid var(--brand); outline-offset: 2px; }
.examlegend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-bottom: var(--s-3); font-size: var(--fs-sm); color: var(--ink-faint); }
.examlegend span { display: inline-flex; align-items: center; gap: 6px; }
.examlegend .examcell { width: 16px; height: 16px; min-height: 0; padding: 0; border-radius: 4px; cursor: default; }

/* PluggEra AI's head (components/ai-head.js): a slim bar like the top of a chat app — the AI's tile, the
   name with a small AI tag, one quiet status line, and the new-chat and history buttons. Shared with
   "Kolla min uträkning". */
.solvehead {
  display: flex; align-items: center; gap: var(--s-3); margin: 8px 0 var(--s-3);
  padding-bottom: var(--s-3); border-bottom: 1px solid var(--line);
}
.solvehead__id { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
/* The name (the wordmark inside is 1.2em of this) with the AI tag centred on it. */
.solvehead__name { margin: 0; font-size: var(--fs-lg); line-height: 1.1; display: flex; align-items: center; gap: .45em; white-space: nowrap; }
.solvehead__tag {
  font-style: normal; font-family: var(--font-body); font-size: .5em; font-weight: 700; letter-spacing: .06em; line-height: 1;
  color: var(--brand-ink); border: 1px solid color-mix(in srgb, var(--brand-ink) 50%, transparent); border-radius: 5px; padding: 3px 5px;
}
.solvehead__status {
  display: flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; margin: 0;
  font-size: calc(12.5px * var(--fs-scale, 1)); line-height: 1.3; color: var(--ink-soft); white-space: nowrap;
}
/* The same status as a quiet line, centred in the greeting under the intro text. */
.solvehead__status--line { justify-content: center; margin-top: 4px; }
/* Only the words trim: clipping the whole line cut the live dot's pulse ring (it grows 6px around the dot). */
.solvehead__statustext { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.solvehead__livedot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok-bright); flex: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok-bright) 55%, transparent);
  animation: solvehead-pulse 2.2s ease-out infinite;
}
.solvehead__livedot.is-off { background: var(--ink-faint); box-shadow: none; animation: none; }
@keyframes solvehead-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok-bright) 55%, transparent); }
  70%  { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ok-bright) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok-bright) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .solvehead__livedot { animation: none; } }
.solvehead__actions { flex: none; display: flex; gap: 4px; }
.solvehead__actions .iconbtn { border-color: transparent; background: none; box-shadow: none; color: var(--ink-soft); }
/* The plain look drops the shadow, and with it the focus ring every other button has: give that back. */
.solvehead__actions .iconbtn:focus-visible { box-shadow: var(--ring); }
@media (hover: hover) { .solvehead__actions .iconbtn:hover:not(:disabled) { background: var(--surface-sunk); color: var(--ink); } }
@media (max-width: 560px) {
  .solvehead { margin-top: 0; }
  .solvehead__name { font-size: var(--fs-md); }
}

/* ---------- sign in / create account (#/login) ----------
   Full screen, no app shell: the form on the left, a brand panel on the right on wide screens
   (the logo's navy tile and its three bar colours), just the form on a phone. */
.auth {
  min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr);
  background: var(--canvas);
}
@media (min-width: 960px) { .auth { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.auth__main { display: flex; flex-direction: column; padding: var(--s-4) var(--s-4) var(--s-5); min-width: 0; }
.auth__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.auth__back {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink-soft); text-decoration: none; transition: background var(--dur-fast), color var(--dur-fast);
}
@media (hover: hover) { .auth__back:hover { background: var(--surface-sunk); color: var(--ink); } }
.auth__back:focus-visible { outline: none; box-shadow: var(--ring); }

.auth__card { width: 100%; max-width: 420px; margin: auto; padding: var(--s-7) 0 var(--s-6); display: grid; gap: var(--s-4); }
.auth__brand {
  display: inline-flex; align-items: center; gap: 10px; justify-self: start; margin-bottom: var(--s-2);
  font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}
@media (min-width: 960px) { .auth__brand { display: none; } }
.auth__title {
  margin: 0; font-family: var(--font-display); font-weight: 800; letter-spacing: -.035em;
  font-size: clamp(2rem, 4vw, 2.6rem); line-height: 1.05; text-wrap: balance; color: var(--ink);
}
.auth__sub { margin: -6px 0 var(--s-2); color: var(--ink-soft); font-size: 1rem; line-height: 1.5; }

.auth__link {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent);
}
@media (hover: hover) { .auth__link:hover { text-decoration-color: currentColor; } }
.auth__link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.auth__form > .auth__link { justify-self: center; margin-top: var(--s-1); }

.auth__google { min-height: 44px; }
.auth__or {
  display: flex; align-items: center; gap: var(--s-3); margin: var(--s-4) 0 var(--s-1);
  color: var(--ink-faint); font-size: var(--fs-sm); font-weight: 600;
}
.auth__or::before, .auth__or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.auth__form { display: grid; gap: var(--s-4); }
.auth__field { display: grid; gap: 8px; margin: 0; }
.auth__field > span, .auth__labelrow label { font-weight: 700; font-size: var(--fs-sm); color: var(--ink); }
.auth__labelrow { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.auth__forgot { font-size: var(--fs-sm); font-weight: 600; }

.auth__control { position: relative; }
.auth__icon {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%); z-index: 1;
  color: var(--ink-faint); pointer-events: none; display: grid;
}
.auth__control input {
  width: 100%; height: 52px; padding: 0 var(--s-4) 0 46px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  font: inherit; font-size: 1rem; color: var(--ink);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.auth__control .pwfield input { padding-right: 48px; }
.auth__control input::placeholder { color: var(--ink-faint); }
@media (hover: hover) { .auth__control input:hover:not(:disabled) { border-color: var(--line-strong); border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); } }
.auth__control input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.auth__control:focus-within .auth__icon { color: var(--brand); }
.auth__control .pwtoggle { right: 8px; }

.auth__consent {
  display: flex; align-items: flex-start; gap: var(--s-3); margin: 0;
  font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-soft);
}
.auth__consent input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); }
.auth__consent a { color: var(--brand-ink); font-weight: 600; }

.auth__submit {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  height: 54px; border: 0; border-radius: 12px; cursor: pointer;
  font: inherit; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: #fff;
  background: linear-gradient(100deg, #2C5CD6 0%, #4B6CF0 55%, #6E5CF0 100%);
  box-shadow: 0 1px 2px rgba(20,24,60,.12), 0 10px 24px -10px rgba(60,80,220,.55);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast), filter var(--dur-fast);
}
.auth__submit svg { transition: transform var(--dur-fast); }
@media (hover: hover) { .auth__submit:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 1px 2px rgba(20,24,60,.12), 0 14px 28px -10px rgba(60,80,220,.6); } }
.auth__submit:hover:not(:disabled) svg { transform: translateX(3px); }
.auth__submit:active:not(:disabled) { transform: translateY(1px); }
.auth__submit:focus-visible { outline: none; box-shadow: var(--ring); }
.auth__submit:disabled { opacity: .55; cursor: default; }

.auth__error {
  margin: 0; padding: 10px 14px; border-radius: 10px; font-size: var(--fs-sm); line-height: 1.45;
  background: var(--retry-tint); color: var(--retry-ink);
}
.auth__notice {
  display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: 10px;
  background: var(--ok-tint); color: var(--ok-ink); font-size: var(--fs-sm); line-height: 1.45;
}
.auth__notice svg { flex: none; margin-top: 1px; }
.auth__optional { margin: var(--s-2) 0 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-faint); text-align: center; }
.auth__legal { margin: 0; text-align: center; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); }
.auth__legal a { color: var(--ink-soft); text-decoration: none; display: inline-block; padding: 6px 2px; }
@media (hover: hover) { .auth__legal a:hover { color: var(--ink); text-decoration: underline; } }

/* ---------- lightweight form card (#/premium, #/reset) ----------
   A single polished card inside the normal app shell, borrowing the sign-in
   page's field styling (.auth__field etc.) without its full-screen layout —
   for pages that are a form, not a whole "screen" of their own. */
.formcard { max-width: 440px; }
.formcard__lead { margin: 0 0 var(--s-4); font-size: 1.05rem; line-height: 1.55; color: var(--ink-soft); }
.formcard__form { display: grid; gap: var(--s-4); }
.formcard__fine { margin: var(--s-3) 0 0; text-align: center; }

/* the brand panel: headline, a question from the app, three facts — left-aligned */
.auth__panel { display: none; }
@media (min-width: 960px) {
  .auth__panel {
    position: relative; overflow: hidden; isolation: isolate;
    display: flex; flex-direction: column; gap: 40px; justify-content: space-between;
    padding: 44px clamp(40px, 5vw, 72px) 40px; color: #fff;
    background: linear-gradient(165deg, #1F2A52 0%, #172042 50%, #121831 100%);
  }
  /* the logo's three bars as long soft stripes behind everything */
  .auth__panel::before {
    content: ""; position: absolute; z-index: -1; pointer-events: none; right: -8%; top: 30%; width: 70%; height: 46%;
    background:
      linear-gradient(90deg, transparent, rgba(91,140,255,.22)) 0 0 / 100% 22% no-repeat,
      linear-gradient(90deg, transparent, rgba(122,107,255,.20)) 12% 50% / 100% 22% no-repeat,
      linear-gradient(90deg, transparent, rgba(56,210,255,.18)) 24% 100% / 100% 22% no-repeat;
    border-radius: 999px; filter: blur(18px); transform: skewY(-8deg);
  }
}
.auth__panelbrand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.auth__panelbrand img { border-radius: 9px; }
.auth__pitch { max-width: 30rem; }
.auth__pitch h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(2rem, 3.2vw, 2.9rem); line-height: 1.04; letter-spacing: -.04em; color: #fff; text-wrap: balance; }
.auth__pitch p { margin: 14px 0 0; font-size: 1.02rem; line-height: 1.6; color: rgba(214,224,255,.78); }

.authq { position: relative; max-width: 400px; margin: 0 0 0 auto; width: 100%; }
.authq__card {
  background: #fff; color: #191D28; border-radius: 18px; padding: 20px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06);
}
.authq__meta { display: flex; justify-content: space-between; font-size: calc(13px * var(--fs-scale, 1)); }
.authq__meta b { color: #1C6B45; } .authq__meta span { color: #5B6372; font-weight: 600; }
.authq__track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: 10px 0 16px; }
.authq__track i { height: 5px; border-radius: 3px; background: #EDF0F7; } .authq__track i.is-done { background: #1B7A50; }
.authq__prompt { margin: 0 0 14px; font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; line-height: 1.35; }
.authq__opts { display: grid; gap: 7px; }
.authq__opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid #C8CDDA; font-size: .95rem; }
.authq__opt b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: calc(12px * var(--fs-scale, 1)); background: #EDF0F7; color: #4B5362; }
.authq__opt.is-right { border-color: #1B7A50; background: #E4F5EC; color: #1C6B45; font-weight: 600; }
.authq__opt.is-right b { background: #1B7A50; color: #fff; } .authq__opt svg { margin-left: auto; }
.authq__fb { display: flex; gap: 8px; margin: 12px 0 0; font-size: calc(13px * var(--fs-scale, 1)); line-height: 1.45; color: #1F44A8; } .authq__fb svg { flex: none; margin-top: 2px; }
.authq__note {
  position: absolute; display: flex; align-items: center; gap: 10px; max-width: 230px; padding: 10px 13px;
  background: #fff; color: #4B5362; border-radius: 12px; font-size: calc(13px * var(--fs-scale, 1)); line-height: 1.35;
  box-shadow: 0 16px 36px -10px rgba(0,0,0,.5);
}
.authq__note b { display: block; font-size: calc(12px * var(--fs-scale, 1)); color: #191D28; }
.authq__noteicon { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #E7EDFD; color: #1F44A8; }
.authq__note--hint { top: -50px; left: -56px; transform: rotate(-2deg); }
.authq__note--repeat { bottom: -40px; right: -20px; transform: rotate(1.5deg); }
.authq__note--repeat .authq__noteicon { background: #E4F5EC; color: #1C6B45; }

.auth__facts { list-style: none; margin: 0; padding: 18px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; border-top: 1px solid rgba(255,255,255,.12); }
.auth__facts b { display: block; font-size: .98rem; color: #fff; }
.auth__facts span { display: block; font-size: calc(12.5px * var(--fs-scale, 1)); line-height: 1.4; color: rgba(214,224,255,.65); }

/* About, FAQ, Terms, Privacy: read like a document — one text column, sections divided by a
   hairline, no card around every paragraph. */
.docpage { max-width: 72ch; }
.docpage > h1 { margin-bottom: var(--s-2); }
.docpage > .note:not(.note--warn) { font-size: 1.08rem; line-height: 1.6; color: var(--ink-soft); margin-bottom: var(--s-3) !important; }
.docpage > .panel { background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: var(--s-5) 0 var(--s-2); box-shadow: none; }
.docpage > .panel h3 { font-size: 1.15rem; letter-spacing: -.01em; }
.docpage > .panel p { line-height: 1.7; color: var(--ink-soft); max-width: 68ch; }

/* ---------- Studify AI: chat history, bookmarks, attached material ---------- */
.solvehead__hist { flex: none; }
.solvehead__hist[aria-pressed="true"] { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-ink); }

.matchip { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); padding: 6px 8px 6px 10px; border-radius: var(--r-md); background: var(--brand-tint); color: var(--brand-ink); }
.matchip__txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; font-size: var(--fs-sm); }
.matchip__txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matchip__txt small { color: var(--ink-soft); font-size: .72rem; }
.matchip .iconbtn { margin-left: auto; }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-full); background: var(--brand-tint); color: var(--brand-ink); font-size: .72rem; font-weight: 600; line-height: 1.5; }
.msg__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-top: var(--s-2); }
/* A passage tag of an attached text opens the passage under the reply. */
.tag--btn { border: 0; font-family: inherit; cursor: pointer; }
.tag--btn:hover, .tag--btn[aria-expanded="true"] { background: var(--brand); color: var(--brand-on, #fff); }
.tag--btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.msg__passage { margin: var(--s-2) 0 0; padding: var(--s-2) var(--s-3); border-left: 3px solid var(--brand); background: var(--surface-sunk); border-radius: 0 var(--r-md, 8px) var(--r-md, 8px) 0; font-size: .85rem; line-height: 1.5; color: var(--ink-soft); white-space: pre-wrap; }
.msg__sources { display: flex; flex-wrap: wrap; gap: 4px; }
.msg__save { flex: none; margin-left: auto; display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r-full); background: transparent; color: var(--ink-faint); cursor: pointer; }
@media (hover: hover) { .msg__save:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); } }
.msg__save.is-on { color: var(--brand-ink); background: var(--brand-tint); }
.msg__save.is-on svg { fill: currentColor; }
/* A mid-stream error or truncation note, kept under whatever real text already streamed in rather
   than replacing it — the answer stays readable, the note just explains why it stops there. */
.msg__errnote { margin: var(--s-2) 0 0; font-size: var(--fs-sm); font-style: italic; color: var(--ink-faint); }

/* "Create the set" card under an AI reply that proposes a practice set (components/set-proposal-card.js) */
.setcard { margin: var(--s-3) 0 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.setcard p { margin: 0; }
.setcard__title { display: flex; align-items: center; gap: 6px; font-family: var(--font-display); font-weight: 700; line-height: 1.3; }
.setcard__title svg { flex: none; color: var(--brand); }
.setcard--done { border-color: var(--ok); }
.setcard--done .setcard__title svg { color: var(--ok); }
.setcard__topic { font-size: var(--fs-sm); color: var(--ink-soft); }
.setcard__facts { font-size: .78rem; color: var(--ink-faint); }
.setcard__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.setcard__actions .btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.setcard__hint { margin-top: 2px; font-size: .75rem; color: var(--ink-faint); }
.setcard__status { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--ink-soft); }
.setcard__error { margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--retry-ink, var(--ink)); }
.setcard--superseded { opacity: .6; }

.history { display: flex; flex-direction: column; gap: var(--s-3); flex: 1; min-height: 0; overflow-y: auto; }
.history__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.history__count { margin: 0; color: var(--ink-faint); font-size: var(--fs-sm); }
.history__search input { width: 100%; box-sizing: border-box; font: inherit; padding: 8px 14px; border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.history__h { display: flex; align-items: center; gap: 6px; margin: var(--s-2) 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-faint); }
.history__list { display: flex; flex-direction: column; gap: var(--s-2); }
.history__item { display: flex; align-items: center; gap: var(--s-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.history__item.is-active { border-color: var(--brand); }
.history__open { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.history__ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand-tint); color: var(--brand-ink); flex: none; }
.history__txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.history__txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.history__txt small { color: var(--ink-faint); font-size: .75rem; }
.history__del { margin-right: var(--s-2); }
.history__saved { border-top: 1px solid var(--line); padding-top: var(--s-2); }
.history__answer { margin-top: var(--s-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.history__answer summary { cursor: pointer; padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); }
.history__answerbody { padding: 0 var(--s-3) var(--s-2); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.history__answeractions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: 0 var(--s-3) var(--s-3); }
.history__answeractions small { margin-right: auto; color: var(--ink-faint); }

.matpick { max-width: 440px; width: 100%; }
/* The set search: a type=search the app's .field rules don't cover, so it fell back to the browser's own
   grey box. Same look as the other inputs (surface, line-strong edge, brand focus ring), plus a search glyph. */
.matpick__search { position: relative; margin-bottom: var(--s-2); }
.matpick__search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; }
.matpick__search input {
  width: 100%; box-sizing: border-box; height: 42px; margin: 0; padding: 0 var(--s-3) 0 38px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit;
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.matpick__search input::placeholder { color: var(--ink-faint); }
@media (hover: hover) { .matpick__search input:hover { border-color: var(--ink-faint); } }
.matpick__search input:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.matpick__search input::-webkit-search-cancel-button { -webkit-appearance: none; }
/* The list's scrollbar: thin and in the theme's line colours instead of the browser's grey trough. */
.matpick__list {
  display: flex; flex-direction: column; gap: var(--s-2); max-height: 300px; overflow-y: auto;
  padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.matpick__list::-webkit-scrollbar { width: 8px; }
.matpick__list::-webkit-scrollbar-track { background: transparent; }
.matpick__list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
@media (hover: hover) { .matpick__list::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); } }
.matpick__item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); font: inherit; color: inherit; text-align: left; cursor: pointer; }
@media (hover: hover) { .matpick__item:hover { border-color: var(--brand); } }
.matpick__name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.matpick__name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matpick__name small { color: var(--ink-faint); }

/* ---------- Home: "Nästan där" ---------- */

/* ---------- Listen as a conversation ---------- */
.talk { max-width: 460px; width: 100%; }
.talk__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.talk__head h3 { margin: 0; }
.talk__actions { margin-top: var(--s-3); }
.talk__meta { text-align: center; color: var(--ink-faint); font-size: var(--fs-sm); }
.talk__cast { display: flex; justify-content: center; gap: var(--s-5); margin: var(--s-2) 0 var(--s-3); }
.talk__who { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; font-size: var(--fs-sm); }
.talk__avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; font-weight: 700; }
.talk__avatar--a { background: var(--c-grape-tint); color: var(--c-grape-ink); }
.talk__avatar--s { background: var(--c-leaf-tint); color: var(--c-leaf-ink); }
.talk__who.is-on .talk__avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand); }
.talk__lines { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.talk__line button { width: 100%; padding: 6px 10px; border: 0; border-radius: var(--r-sm); background: none; font: inherit; line-height: 1.4; text-align: left; color: var(--ink-faint); cursor: pointer; }
.talk__line b { margin-right: 6px; font-size: var(--fs-sm); color: var(--ink-soft); }
.talk__line.is-cur button { background: var(--brand-tint); color: var(--ink); }
.talk__ctl { display: flex; align-items: center; justify-content: center; gap: var(--s-3); margin: var(--s-3) 0 var(--s-2); }
.talk__play { width: 48px; height: 48px; background: var(--brand); border-color: var(--brand); color: #fff; }
.talk__speed { padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-full); background: var(--surface); font: inherit; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.talk__speed.is-on { border-color: var(--brand); color: var(--brand-ink); }
.talk__ctl { flex-wrap: wrap; }
/* the Alex / Sam voice picker, shown in place under the controls */
.talk__voices { margin: var(--s-2) 0; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-sunk); }
.talkvoices__row { display: flex; align-items: center; gap: var(--s-2); }
.talkvoices__who { flex: none; width: 3.2em; font-weight: 600; font-size: var(--fs-sm); }
.talkvoices__row .reading__voice { flex: 1; min-width: 0; }
.talk__hint { font-size: var(--fs-sm); }

/* subject picker: courses grouped under their subject ("Matematik" → 1 · 2 · 3) */
.subjgroup + .subjgroup { margin-top: var(--s-5); }
.subjgroup__title { font-size: var(--fs-sm); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 var(--s-2); }

/* ---------- Progress (#/progress) ---------- */
/* Key figures across the top, then two columns of cards (activity and level
   per subject; review, achievements, trends), then what's due. Cards reuse
   the Settings card head (.set-card). */
.pg { max-width: 1240px; }
.pg-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); }
.pg-kpi {
  display: flex; align-items: center; gap: var(--s-3); min-width: 0;
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.pg-kpi__main { min-width: 0; flex: 1; }
.pg-kpi__label {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint);
}
.pg-kpi__ic {
  flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface); background: color-mix(in oklab, var(--k) 14%, var(--surface)); color: var(--k);
}
.pg-kpi__value {
  display: block; margin: 8px 0 2px; font-family: var(--font-display); font-size: calc(26px * var(--fs-scale, 1)); line-height: 1.1;
  letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pg-kpi__sub { margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.pg-kpi.is-warn { border-color: var(--line); border-color: color-mix(in oklab, var(--warn, var(--c-tangerine)) 55%, var(--line)); }
.pg-kpi .ring { flex: none; width: 46px; height: 46px; }
.pg-chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: var(--r-full);
  background: var(--info-tint); color: var(--info); font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; vertical-align: 1px;
}
.pg-help { cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }

.pg-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.pg-col { display: grid; gap: var(--s-5); min-width: 0; }
.pg-card { padding-bottom: var(--s-5); }
.pg-card .set-card__head { flex-wrap: wrap; }
.pg-card__titles { flex: 1; min-width: 180px; }
.pg-card__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.pg-card__body { display: grid; gap: var(--s-3); padding-top: var(--s-4); min-width: 0; }
.pg-card__body > .note { margin: 0; }
.pg-foot { margin: 0; font-size: var(--fs-sm); color: var(--ink-faint); }
.pg-empty { margin: 0; color: var(--ink-soft); }
.pg-more { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; }
.pg-big { display: flex; align-items: baseline; gap: 8px; }
.pg-big strong { font-family: var(--font-display); font-size: calc(34px * var(--fs-scale, 1)); line-height: 1; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.pg-big span { color: var(--ink-soft); font-size: var(--fs-sm); }
.pg-fullbtn { justify-content: center; }
/* This week's review: a bar per day for the questions that came due then, today last. */
.pg-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: var(--s-1); }
.pg-week__day { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.pg-week__n { min-height: 15px; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; line-height: 15px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.pg-week__bar { display: flex; align-items: flex-end; width: 100%; max-width: 30px; height: 52px; border-radius: 7px; background: var(--surface-sunk); overflow: hidden; }
.pg-week__bar i { display: block; width: 100%; height: 0; border-radius: 7px; background: var(--brand-bright); transition: height .6s cubic-bezier(.2, .8, .2, 1); }
.pg-week__lbl { max-width: 100%; overflow: hidden; white-space: nowrap; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.pg-week__day.is-today .pg-week__bar i { background: var(--brand); }
.pg-week__day.is-today .pg-week__lbl { font-weight: 700; color: var(--brand-ink); }
.pg-week__day.is-leaving .pg-week__bar i { background: var(--retry); }
.pg-week__day.is-leaving .pg-week__n { color: var(--retry-ink); }
.pg-leaving { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--retry-ink); }
@media (prefers-reduced-motion: reduce) { .pg-week__bar i { transition: none; } }
/* The week's review by subject: a row each, a link while the subject has questions left. */
.pg-rsubs { display: grid; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pg-rsubs li + li { border-top: 1px solid var(--line); }
.pg-rsub { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 8px 2px; color: var(--ink); text-decoration: none; }
.pg-rsub strong { flex: 1; min-width: 0; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-rsub__n { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.pg-rsub > svg { flex: none; color: var(--ink-faint); }
a.pg-rsub:hover strong, a.pg-rsub:hover > svg { color: var(--brand-ink); }
.pg-rsub.is-done strong { color: var(--ink-soft); }
.pg-rsub.is-done .pg-rsub__n { font-weight: 600; color: var(--ok-ink); }

/* Activity map: month names over the weeks, day names down the side. */
.pg-heat { display: grid; gap: var(--s-3); }
.pg-heat__scroll { overflow-x: auto; padding-bottom: 2px; }
.pg-heat__grid {
  --cell: clamp(12px, 1.45vw, 21px); --gap: 4px;
  display: grid; grid-template-columns: auto auto; gap: 6px 8px; width: max-content;
}
.pg-heat__months { display: grid; grid-template-columns: repeat(var(--weeks), var(--cell)); gap: var(--gap); }
.pg-heat__months span { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); white-space: nowrap; overflow: visible; width: var(--cell); text-transform: capitalize; }
.pg-heat__days { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: var(--gap); }
/* The day names stay put while the weeks scroll on a narrow screen. */
.pg-heat__days, .pg-heat__corner { position: sticky; left: 0; z-index: 1; background: var(--surface); padding-right: 4px; }
.pg-heat__days span { font-size: calc(12px * var(--fs-scale, 1)); line-height: var(--cell); color: var(--ink-faint); text-transform: capitalize; }
.pg-heat__cells { display: grid; grid-template-rows: repeat(7, var(--cell)); grid-auto-flow: column; grid-auto-columns: var(--cell); gap: var(--gap); }
.pg-heat__cell { display: block; width: var(--cell, 12px); height: var(--cell, 12px); border-radius: 4px; background: var(--surface-sunk); }
.pg-heat__cell.lv1 { background: var(--surface-sunk); background: color-mix(in oklab, var(--ok) 30%, var(--surface-sunk)); }
.pg-heat__cell.lv2 { background: var(--surface-sunk); background: color-mix(in oklab, var(--ok) 55%, var(--surface-sunk)); }
.pg-heat__cell.lv3 { background: var(--surface-sunk); background: color-mix(in oklab, var(--ok) 78%, var(--surface-sunk)); }
.pg-heat__cell.lv4 { background: var(--ok); }
.pg-heat__cell.is-frozen { background: var(--info); }
.pg-heat__cell.is-today { outline: 2px solid var(--brand); outline-offset: 1px; }
.pg-heat__legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.pg-heat__legend .pg-heat__cell { --cell: 12px; border-radius: 3px; }
.pg-heat__legend span { margin: 0 4px; }
.pg-heat__legend .pg-heat__gap { margin-left: var(--s-3); }

/* Level per subject */
.pg-subjects { display: grid; }
.pg-subj {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(90px, 1.3fr) 48px 28px;
  align-items: center; gap: var(--s-3); padding: 12px 0;
}
.pg-subj + .pg-subj { border-top: 1px solid var(--line); }
.pg-subj__dot { width: 10px; height: 10px; border-radius: var(--r-full); }
.pg-subj__name { min-width: 0; }
.pg-subj__name strong { display: block; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-subj__name small { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.pg-subj__name small:empty { display: none; }
.pg-subj__name .linkbtn { display: inline-flex; align-items: center; gap: 3px; font-size: calc(12px * var(--fs-scale, 1)); }
.pg-subj__track { height: 8px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.pg-subj__track i { display: block; height: 100%; border-radius: inherit; transition: width var(--dur-slow) var(--ease-out); }
.pg-subj__pct { text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* What's due, question by question */
.pg-due { display: grid; gap: var(--s-4); }
.pg-dgroup { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.pg-dgroup__head {
  display: flex; align-items: center; gap: 10px; padding: 10px var(--s-4);
  background: var(--surface-sunk); border-bottom: 1px solid var(--line);
}
.pg-dgroup__head strong { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-dgroup__head > span:last-child { flex: none; font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.pg-drow { display: flex; align-items: center; gap: var(--s-4); padding: 11px var(--s-4); }
.pg-drow + .pg-drow { border-top: 1px solid var(--line); }
.pg-drow__q {
  flex: 1; min-width: 0; color: var(--ink); font-size: var(--fs-sm); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.pg-drow__why {
  flex: none; padding: 2px 9px; border-radius: var(--r-full); font-size: calc(12px * var(--fs-scale, 1)); font-weight: 600; white-space: nowrap;
  background: var(--surface-sunk); color: var(--ink-soft);
}
.pg-drow__why.is-missed { background: var(--c-berry-tint); color: var(--c-berry-text, var(--c-berry-ink)); }
.pg-drow__why.is-solid { background: var(--ok-tint); color: var(--ok-ink); }

@media (max-width: 1100px) {
  .pg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pg-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .pg-kpi { padding: var(--s-3) var(--s-4); }
  .pg-kpi__value { font-size: calc(22px * var(--fs-scale, 1)); }
  .pg-kpi .ring { display: none; }
  .pg-subj { grid-template-columns: 10px minmax(0, 1fr) 44px 26px; row-gap: 6px; }
  .pg-subj__track { grid-column: 2 / -1; grid-row: 2; }
  .pg-drow { flex-direction: column; align-items: flex-start; gap: 6px; }
  .pg-drow__q { -webkit-line-clamp: 2; }
}

/* ===== PluggEra AI (#/solve): greeting, messages, composer =====
   A chat room: the slim head, the conversation, one composer bar at the bottom. Before the first message
   the log holds a centred greeting — a heading, the intro, four ways to start and a row of the other ways
   to study — with every way in shown once. */
.solve-hero {
  margin-block: auto; display: grid; justify-items: center; gap: 8px; text-align: center;
  padding: var(--s-5) var(--s-3) var(--s-3);
  animation: solve-rise .5s var(--ease-out) both;
}
/* Before the first message the log grows with the greeting instead of scrolling inside itself. */
.solve:not(.is-chatting) .solve-chat__log { overflow: visible; min-height: 0; flex: 1 0 auto; }
.solve-hero__mark { margin-bottom: 6px; }
/* Computers: the greeting's tile, larger, with a slow, soft glow breathing behind it. */
@media (min-width: 900px) {
  .solve-hero { position: relative; isolation: isolate; }
  .solve-hero::before {
    content: ""; position: absolute; z-index: -1; top: 0; left: 50%; width: min(360px, 100%); height: 220px; pointer-events: none;
    transform: translate(-50%, -26%);
    background:
      radial-gradient(48% 48% at 40% 50%, color-mix(in srgb, var(--brand) 30%, transparent), transparent 72%),
      radial-gradient(42% 44% at 64% 44%, color-mix(in srgb, #7650FF 24%, transparent), transparent 72%);
    filter: blur(22px);
    animation: solve-breathe 7s ease-in-out infinite alternate;
  }
  .solve-hero__mark.ai-tile {
    border-radius: 18px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 12px 30px -12px color-mix(in srgb, var(--brand) 75%, transparent);
  }
}
@keyframes solve-breathe {
  from { opacity: .6; transform: translate(-50%, -26%) scale(.94); }
  to   { opacity: 1;  transform: translate(-50%, -26%) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) { .solve-hero::before { animation: none; } }
.solve-hero__title {
  margin: 0; font-family: var(--font-display); font-size: clamp(1.4rem, 2vw, 1.8rem);
  letter-spacing: -.02em; line-height: 1.2; color: var(--ink); text-wrap: balance;
}
.solve-hero__sub { max-width: 52ch; color: var(--ink-soft); line-height: 1.55; }
.solve-hero__sub p { margin: 0; }
.solve-starts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); width: min(100%, 980px); margin-top: var(--s-4); }
.solve-start {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .solve-start:hover { border-color: var(--line-strong); border-color: color-mix(in oklab, var(--brand) 45%, var(--line)); background: var(--surface-sunk); } }
.solve-start:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.solve-start__ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-ink); }
.solve-start__txt { display: grid; gap: 1px; min-width: 0; }
.solve-start__txt strong { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.solve-start__txt small { font-size: calc(12.5px * var(--fs-scale, 1)); line-height: 1.4; color: var(--ink-soft); }
/* The other ways to study, as quiet chips under the starts. */
.solve-more { display: grid; justify-items: center; gap: var(--s-2); width: min(100%, 980px); margin-top: var(--s-4); }
.solve-more__label { margin: 0; font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint); }
.solve-more .chatmodes { justify-content: center; margin: 0; }
.solve-more .chatmode { min-height: 34px; padding: 0 12px; font-size: calc(13px * var(--fs-scale, 1)); border-color: var(--line); }
@keyframes solve-rise { from { opacity: 0; transform: translateY(8px); } }

/* Messages: the student's in a bubble on the right; the assistant's on the page beside its tile,
   so a long answer reads like a document rather than a cramped speech bubble. */
.solve .msg.me {
  border-radius: 18px 18px 6px 18px; padding: 10px 16px; font-size: .95rem; line-height: 1.5;
  animation: solve-rise .25s var(--ease-out) both;
}
.solve .msgrow { display: flex; align-items: flex-start; gap: 12px; align-self: flex-start; width: min(100%, 820px); animation: solve-rise .3s var(--ease-out) both; }
.solve .msgrow > .ai-tile { margin-top: 2px; }
/* Under a reply: its sources, then the bookmark, right where the reply ends. */
.solve .msgrow .msg__foot { justify-content: flex-start; gap: var(--s-2); }
.solve .msgrow .msg__foot > span:empty { display: none; }
.solve .msgrow .msg__save { margin-left: -6px; }
.solve .msgrow .msg.ai {
  flex: 1; min-width: 0; max-width: none; padding: 4px 0 0; border-radius: 0; background: none;
  font-size: .97rem; line-height: 1.65; color: var(--ink);
}

/* The composer: anything attached (a set, a picture, the way of studying) above one bar — "+", the box, send. */
.solve-dock {
  position: relative; padding: 6px; border: 1px solid var(--line-strong); border-radius: 24px; background: var(--surface);
  box-shadow: 0 14px 34px -20px rgba(16, 24, 40, .5), var(--shadow-1);
  transition: border-color var(--dur-mid), box-shadow var(--dur-mid);
}
.solve-dock:focus-within {
  border-color: color-mix(in oklab, var(--brand) 60%, var(--line-strong));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent), 0 14px 34px -20px rgba(16, 24, 40, .5);
}
.solve-dock .matchip, .solve-dock .solve-chat__pending { margin: 0 0 6px; }
.solve-dock__bar { display: flex; align-items: flex-end; gap: 6px; }
.solve-dock__input {
  flex: 1; min-width: 0; box-sizing: border-box; min-height: 40px; max-height: min(180px, 28dvh); padding: 9px 4px;
  font: inherit; font-size: 1rem; line-height: 1.45; color: var(--ink); background: transparent;
  border: 0; resize: none; overflow-y: auto;
}
.solve-dock__input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.solve-dock__input:focus-visible { outline: none; box-shadow: none; }
.iconbtn.solve-dock__add { width: 40px; height: 40px; border-radius: var(--r-full); border-color: transparent; background: var(--surface-sunk); color: var(--ink-soft); }
@media (hover: hover) { .iconbtn.solve-dock__add:hover:not(:disabled) { color: var(--ink); background: color-mix(in srgb, var(--ink) 10%, var(--surface-sunk)); } }
.iconbtn.solve-dock__send { width: 40px; height: 40px; border-radius: var(--r-full); border: 0; color: #fff; background: var(--brand); transition: opacity var(--dur-fast); }
@media (hover: hover) { .iconbtn.solve-dock__send:hover:not(:disabled) { background: var(--brand); filter: brightness(1.1); } }
.iconbtn.solve-dock__send:disabled { opacity: .4; cursor: not-allowed; }
/* The way of studying that's on, with a cross back to the default help. */
.solve-modepill {
  display: inline-flex; align-items: center; gap: 6px; margin: 2px 2px 6px; padding: 3px 3px 3px 10px;
  border-radius: var(--r-full); background: var(--brand-tint); color: var(--brand-ink);
  font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600;
}
.solve-modepill__x {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: inherit; cursor: pointer;
}
@media (hover: hover) { .solve-modepill__x:hover { background: color-mix(in srgb, var(--brand) 18%, transparent); } }
.solve-addmenu .cardmenu__item svg { color: var(--ink-soft); }
/* Computers only: a phone has no Shift key to remember. */
.solve-dock__hint { margin: calc(var(--s-2) * -1) 0 0; text-align: center; font-size: .72rem; color: var(--ink-faint); }
/* Signed out, in the composer's place: why, and the way in. */
.solve-signin {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border: 1px solid var(--line-strong); border-radius: 24px; background: var(--surface);
  box-shadow: 0 14px 34px -20px rgba(16, 24, 40, .5), var(--shadow-1);
}
.solve-signin p { flex: 1 1 200px; margin: 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-soft); }
.solve-gate .note { margin: 0; }

/* Computers: the conversation and the composer share one centred, readable column (the log still scrolls
   at the page's edge), instead of the student's bubbles far right and the replies far left. */
@media (min-width: 900px) {
  .solve.is-chatting .solve-chat__log { padding-inline: max(2px, calc((100% - 840px) / 2)); }
  .solve-dock, .solve-gate { width: min(100%, 880px); margin-inline: auto; box-sizing: border-box; }
}
@media (max-width: 899px) {
  .solve.is-chatting > .homebtn { display: none; }
  .solve-dock__hint { display: none; }
  /* A chat room ends at its composer: the site's footer links stay on the other pages, and the page keeps
     only the room the tab bar needs below it. */
  body.route-chat .sitefooter { display: none; }
  body.route-chat .shell:not(.shell--immersive) .content { padding-bottom: calc(60px + var(--s-2) + env(safe-area-inset-bottom, 0px)); }
  /* "Kolla min uträkning" shares the route but has no composer: its last button gets breathing room above the tab bar. */
  body.route-chat:has(.check) .shell:not(.shell--immersive) .content { padding-bottom: calc(60px + var(--s-6) + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 560px) {
  /* The chat fills the screen between its head and the tab bar, so the composer rests just above the
     tab bar like any messaging app's (171px above it: the top bar, the page's padding and the head). */
  .solve-chat { min-height: max(320px, calc(100dvh - 171px - 60px - var(--s-2) - env(safe-area-inset-bottom, 0px))); }
}
@media (max-width: 1100px) {
  .solve-starts { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 720px); }
  .solve-start { flex-direction: row; align-items: center; }
}
@media (max-width: 560px) {
  /* Four starts in a 2×2 grid of icon + name, no mark, no back link (the tab bar has Hem). */
  .solve > .homebtn, .solve-hero__mark { display: none; }
  .solve-hero { padding-top: var(--s-3); gap: 6px; }
  .solve-hero__title { font-size: 1.3rem; }
  .solve-hero__sub { font-size: var(--fs-sm); }
  .solve-starts { gap: var(--s-2); margin-top: var(--s-3); }
  .solve-start { gap: 10px; padding: 10px 12px; }
  .solve-start small { display: none; }
  .solve-start__ic { width: 30px; height: 30px; border-radius: 9px; }
  .solve-start__txt strong { font-size: calc(13.5px * var(--fs-scale, 1)); line-height: 1.25; }
  /* The other ways to study: one row that scrolls sideways, not three rows of chips. */
  .solve-more { justify-items: stretch; margin-top: var(--s-3); }
  .solve-more__label { text-align: left; }
  .solve-more .chatmodes {
    flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .solve-more .chatmodes::-webkit-scrollbar { display: none; }
  .solve-more .chatmode { flex: none; }
  /* A reply's "Rapportera" is the flag alone; the word stays its name. */
  .solve .msgrow .aireport span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
/* Computers and tablets: the ways in lay out exactly as before; the phone's quick row and halo aren't there. */
.solve-ways, .solve-hero__glow { display: contents; }
.solve-quick, .solve-hero__glow::before { display: none; }
/* PluggEra AI on a phone: before the first message, the greeting (the AI's tile with its glow and the
   heading) sits alone in the middle, and the two most-used ways in sit just above the composer with "Fler",
   which opens every other way in as a panel above them. The mode's own intro still shows once one is on. */
@media (max-width: 560px) {
  .solve:not(.is-chatting) .solve-chat__log { display: flex; flex-direction: column; }
  .solve-hero--home { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0; padding: var(--s-3) 0 0; }
  .solve-hero--home .solve-hero__glow { display: grid; margin: auto 0 4px; --hw: 220px; --hh: 170px; }
  .solve-hero--home .solve-hero__glow::before { display: block; }
  .solve-hero--home .solve-hero__mark { display: grid; margin: 0; }
  .solve-hero--home .solve-hero__title { margin-bottom: auto; }
  .solve-hero--home .solve-hero__sub { display: none; }
  /* The status stays with the heading in the middle: it takes over the space that pushes the ways in down. */
  .solve-hero--home .solve-hero__title:has(~ .solvehead__status--line:not([hidden])) { margin-bottom: 0; }
  .solve-hero--home .solvehead__status--line { margin: 0 0 auto; }
  .solve-quick { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; width: 100%; margin-top: var(--s-3); }
  .solve-quick .chatmode { justify-content: center; min-height: 36px; padding: 0 12px; border-color: var(--line); background: var(--surface); }
  .solve-quick .chatmode svg { color: var(--brand-ink); }
  .solve-quick__more { color: var(--ink-soft); }
  .solve-quick__more[aria-expanded="false"] svg { rotate: 180deg; }   /* the panel opens upward */
  .solve-quick__more[aria-expanded="true"] { color: var(--ink); border-color: var(--line-strong); }
  /* The panel: the other two starts and the other ways to study, as one even 2-column list. */
  .solve-hero--home .solve-ways { display: none; }
  .solve-hero--home.is-open .solve-ways {
    /* In the flow just above the quick row (whatever its height at any text size); it shrinks and scrolls
       on a short screen instead of covering the row. */
    flex: 0 1 auto; min-height: 0; width: 100%; box-sizing: border-box; margin-top: var(--s-3);
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px; overflow-y: auto;
    padding: var(--s-3); border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
    box-shadow: 0 18px 40px -20px rgba(16, 24, 40, .6), var(--shadow-1); text-align: left;
    animation: solve-rise .2s var(--ease-out) both;
  }
  .solve-hero--home.is-open :is(.solve-starts, .solve-more, .solve-more .chatmodes) { display: contents; }
  .solve-hero--home.is-open .solve-more__label { order: -1; grid-column: 1 / -1; margin: 0 2px 4px; text-align: left; }
  .solve-hero--home.is-open :is(.solve-start, .solve-more .chatmode) {
    display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; min-height: 44px; margin: 0;
    padding: 8px 10px; border: 0; border-radius: 12px; background: var(--surface-sunk);
    font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink); text-align: left;
  }
  .solve-hero--home.is-open .solve-start__ic { width: auto; height: auto; background: none; color: var(--brand-ink); }
  .solve-hero--home.is-open .solve-start__ic svg { width: 16px; height: 16px; }
  .solve-hero--home.is-open .solve-start__txt strong { font-size: inherit; font-weight: inherit; line-height: 1.3; }
  .solve-hero--home.is-open .solve-more .chatmode svg { color: var(--brand-ink); }
  /* Förhör mig and Förklara already sit in the quick row. */
  .solve-hero--home.is-open .solve-starts > .solve-start:nth-child(n+3) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .solve-hero, .solve .msgrow, .solve .msg.me { animation: none; }
}

/* "Lägg till prov" dialog, wide: fields and the sets on the left, the calendar on the right, the
   material sources (the same ones as Skapa) full width below. Fields use the app's .field styling. */
.exam-dlg__cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s-5); margin-top: var(--s-4); align-items: start; }
@media (max-width: 760px) { .exam-dlg__cols { grid-template-columns: minmax(0, 1fr); } }
.exam-dlg .field { margin-bottom: var(--s-4); }
.exam-dlg .field > .exam-dlg__label, .exam-dlg .field > div > .exam-dlg__label { display: flex; margin: 0 0 var(--s-2); }
.exam-dlg .field textarea { min-height: 84px; }
.exam-dlg__material { margin-top: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.exam-dlg__material > .exam-dlg__label { margin-top: 0; }
.exam-src { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-2); }
.exam-src__tile {
  --c: var(--brand);
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); background: color-mix(in oklab, var(--c) 6%, var(--surface)); border: 1px solid color-mix(in oklab, var(--c) 28%, var(--line));
  border-radius: var(--r-md); transition: border-color var(--dur-fast), background var(--dur-fast);
}
@media (hover: hover) { .exam-src__tile:hover { border-color: var(--line); border-color: color-mix(in oklab, var(--c) 65%, var(--line)); background: var(--surface); background: color-mix(in oklab, var(--c) 10%, var(--surface)); } }
.exam-src__tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.exam-src__tile.is-on { border-color: var(--c); background: var(--surface); background: color-mix(in oklab, var(--c) 14%, var(--surface)); box-shadow: 0 0 0 1px var(--c); }
.exam-src__tile.is-locked { border-style: dashed; background: var(--surface); }
.exam-src__ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--c); color: #fff; }
.exam-src__tile.is-locked .exam-src__ic { background: var(--surface); background: color-mix(in oklab, var(--c) 14%, var(--surface)); color: var(--c); }
.exam-src__text { display: grid; gap: 1px; min-width: 0; }
.exam-src__text strong { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.exam-src__text small { font-size: calc(12px * var(--fs-scale, 1)); line-height: 1.3; color: var(--ink-soft); }
.exam-dlg__srcpanel { margin-top: var(--s-4); }
.exam-dlg__srcpanel:empty { display: none; }
.exam-dlg__build { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.exam-dlg__build .exam-dlg__err { margin: 0; }
.exam-dlg__howmany { max-width: 160px; }

/* A new test is made in steps, one question at a time (components/exam-dialog.js). */
.modal__card.exam-dlg--wiz { max-width: 560px; display: flex; flex-direction: column; min-height: min(640px, calc(100dvh - 32px)); }
.exam-wiz__bars { display: flex; gap: 6px; margin: var(--s-3) 0 var(--s-5); }
.exam-wiz__bars i { flex: 1; height: 5px; border-radius: 3px; background: var(--line-strong); transition: background var(--dur-fast); }
.exam-wiz__bars i.is-on { background: var(--brand); }
.exam-wiz__step { flex: 1; }
.exam-wiz__q { margin: 0 0 var(--s-1); font-size: clamp(1.4rem, 4.6vw, 1.75rem); font-weight: 800; line-height: 1.15; letter-spacing: -.01em; outline: none; }
.exam-wiz__sub { margin: 0 0 var(--s-4); color: var(--ink-soft); }
.exam-dlg--wiz > .dlgfoot { margin-top: auto; }
.exam-dlg--wiz .field { margin-bottom: var(--s-4); }
.exam-dlg--wiz .exam-dlg__srcpanel { margin-top: var(--s-3); }
.exam-dlg--wiz .exam-dlg__sets { max-height: 220px; }
/* On a phone the six buttons sit two by two, icon over text, so the list of sets under them stays in reach. */
@media (max-width: 480px) {
  .exam-dlg--wiz .exam-src { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exam-dlg--wiz .exam-src__tile { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; }
}
.exam-hero__note { margin: 6px 0 0; max-width: 60ch; color: var(--ink-soft); font-size: var(--fs-sm); }

.exam-addrow { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.exam-addrow__hint { margin: var(--s-2) 0 0; }

/* Inför provet: today's tasks, plan coverage, the time-sized pass, the session's test line, results' next step */
.exam-today__list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.exam-today__list li { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ink); }
.exam-today__list li.is-done { color: var(--ink-faint); text-decoration: line-through; }
.exam-today__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--line-strong); }
.exam-today__tick { flex: none; display: inline-grid; color: var(--ok, var(--brand)); }
.exam-plan__tasks { display: grid; gap: 2px; min-width: 0; }
.exam-plan__task.is-done { color: var(--ink-faint); }
.exam-plan__task svg { vertical-align: -2px; margin-right: 4px; color: var(--ok, var(--brand)); }
.exam-cover { margin: 4px 0 6px; }
.exam-cover__bar { display: flex; gap: 3px; }
.exam-cover__bar i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.exam-cover__bar i.on { background: var(--ok, var(--brand)); }
.exam-cover.is-short .exam-cover__bar i.on { background: var(--retry, var(--brand)); }
.exam-cover__text { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.exam-pass .exam-seg { margin: 4px 0 8px; }
.exam-pass .note { margin: 0 0 10px; }
.session__examctx { margin: -4px 0 10px; font-size: var(--fs-sm); color: var(--ink-soft); }
.session__examctx a { color: inherit; text-decoration: none; }
@media (hover: hover) { .session__examctx a:hover { text-decoration: underline; } }
.badge.badge--exam { background: var(--brand-tint); color: var(--brand-ink); }
.results__examnext { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 16px 0 8px; }

/* Live-test fixes: the tutor sheet on phones, the hint under a wrong pick, worked solutions, retry row,
   the chat's suggestion chips, and the next test on home. */
.tutor__close { display: none; margin-left: auto; }
@media (max-width: 860px) {
  .tutor__close { display: inline-grid; }
  /* The sheet closes from its own head; the floating button would sit on its input. */
  body:has(.tutor.is-open) .hintfab { display: none; }
  /* Room to scroll the question's buttons above the open sheet. */
  body:has(.tutor.is-open) .content { padding-bottom: calc(min(70vh, 520px) + var(--s-5)); }
}
.feedback__hint { margin: 8px 0 0; font-weight: 400; color: var(--ink); }
.feedback__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.solution__steps { margin: 4px 0 6px; padding-left: 1.4em; }
.solution__steps li { margin: 2px 0; }
.solution__answer { margin: 4px 0 0; font-weight: 600; }
.chatdef { display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: var(--r-full); background: var(--brand-tint); color: var(--brand-ink); font-size: .9em; font-weight: 600; }
.chatquick { margin-top: 10px; }

/* The countdown and the × that hides the card until tomorrow (nextTestCard in views/menu.js). */
.exam-card__end { display: flex; align-items: center; gap: 4px; flex: none; }

/* Mobile audit: small controls get a finger-sized hit area on touch screens. The ::after is invisible
   and doesn't move anything; :where() keeps position at zero specificity so an element that is
   already absolutely placed stays where it is. */
@media (pointer: coarse) {
  :where(.brand, .house-ad__x, .exam-card__name, .chip, .datepick__chip, .cal__navbtn, .plan-nav__btn, .iconbtn--sm) { position: relative; }
  :is(.brand, .house-ad__x, .exam-card__name, .cal__navbtn, .plan-nav__btn, .iconbtn--sm, .acard__menu, .set-switch)::after {
    content: ""; position: absolute; inset: -7px;
  }
  /* The logo and the switches reach 44px. The two week arrows are 4px apart: wider, the second takes taps on the edge of the first. */
  .topbar .brand::after { inset: -9px; }
  .set-switch::after { inset: -8px -2px; }
  .plan-nav__btn::after { inset: -7px -2px; }
  /* Chips sit 8px apart in wrapping rows: grow up and down, barely sideways. */
  :is(.chip, .datepick__chip)::after { content: ""; position: absolute; inset: -6px -3px; }
  .linkbtn::after { inset: -10px -4px; }
  /* The test banner's Stäng av / Sätt på is 29px drawn. */
  .testbar .btn { position: relative; }
  .testbar .btn::after { content: ""; position: absolute; inset: -8px -2px; }
}

/* Phones and touch screens, continued (from a full mobile audit). A dialog taller than the screen
   (a short phone, or the keyboard up) scrolls inside the backdrop instead of running off both edges
   with its buttons out of reach; margin-block: auto still centres it when it fits. */
.modal { place-items: start center; overflow-y: auto; overscroll-behavior: contain; }
.modal > .modal__card { margin-block: auto; }

@media (pointer: coarse) {
  /* iOS zooms the whole page into any field set under 16px when it's tapped — and leaves it zoomed.
     (The :not()s only lift the specificity over component rules like `.qedit select`.) */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]),
  select:not([multiple]):not([hidden]), textarea:not([readonly]):not([hidden]) { font-size: max(16px, 1em); }
  .langbar__modes button { min-height: 36px; padding-inline: 14px; }
  .auth__link::after { inset: -10px -4px; }
  .lp-more, .pg-more, .set-row__link { padding-block: 8px; margin-block: -8px; }
  .lp-more { margin-top: 12px; }
  /* Settings: the option buttons (34px) and the section links (40px) reach 44px without moving anything. */
  .set-seg__opt, .settings__navlink { position: relative; }
  .set-seg__opt::after { content: ""; position: absolute; inset: -5px 0; }

  /* Second mobile run-through: the remaining controls under 44px. Each grows into at most half the gap
     to its neighbour, so two hit areas never meet. */
  :where(.qedit__toggle, .q-speak, .subjpick__chip, .subjpick__more, .hp-fchip, .ref__level, .tab, .chatmode,
    .idcard__edit, .idcard__addname) { position: relative; }
  :is(.qedit__toggle, .q-speak, .subjpick__chip, .subjpick__more, .hp-fchip, .ref__level, .tab, .chatmode,
    .idcard__edit, .idcard__addname)::after { content: ""; position: absolute; }
  .qedit__toggle::after { inset: -8px; }                       /* 28px */
  .q-speak::after { inset: -6px; }                             /* 32px */
  :is(.subjpick__chip, .hp-fchip, .chatmode)::after { inset: -4px -3px; }   /* 33–36px, rows 8px apart */
  /* Two of those chip rows scroll sideways on a phone, and a scroller clips (and would scroll up and down
     to) anything past its edge: room above and below, given back with a negative margin. */
  .solve-more .chatmodes { padding-block: 4px; margin-block: -4px; }
  .subjpick__more::after { inset: -4px 0 -6px; }
  .ref__level::after { inset: -6px -3px -4px; }                /* 34px, 6px above the formulas */
  .tab::after { inset: -6px -2px -5px; }                       /* 33px, 4px apart in their pill */
  :is(.idcard__edit, .idcard__addname)::after { inset: -3px 0; }   /* 38px, 16px apart */
  /* Calendar month arrows: 8px further apart so each can be 42px wide without taking the other's taps. */
  .plan-nav { gap: 12px; }
  .plan-nav__btn::after { inset: -7px -6px; }
  /* Steppers clip their buttons (overflow: hidden) and a select or slider has no ::after: these grow instead
     (the HP ones sit with their own rules). The 1/2/3 options were 34px wide. */
  .set-stepper button { width: 44px; }
  .set-stepper input { height: 44px; }
  .reading__voice, input[type=range] { min-height: 44px; }
  .set-seg__opt { min-width: 44px; }
}
/* Only where the section links wrap: wider, their row scrolls sideways and the taller hit area would make
   it scroll up and down too. */
@media (pointer: coarse) and (max-width: 540px) {
  .settings__navlink::after { content: ""; position: absolute; inset: -2px 0; }
}
/* Touch tablets (an iPad on its side): an invisible hit area above and below brings the footer links from
   20px to 44px; the row gap keeps two wrapped rows from overlapping. Phones give them padding instead. */
@media (pointer: coarse) and (min-width: 900px) {
  .sitefooter .sitefooter__links { row-gap: 24px; }   /* design.css sets the gap; this outranks it */
  .sitefooter__links a { position: relative; }
  .sitefooter__links a::after { content: ""; position: absolute; inset: -12px -6px; }
}
@media (max-width: 899.98px) {
  /* PluggEra AI: the composer stays in reach just above the tab bar as the conversation grows. */
  .solve-dock, .solve-gate { position: sticky; bottom: calc(60px + var(--s-2) + env(safe-area-inset-bottom, 0px)); z-index: 6; }
}
/* Typing on a phone whose page shrinks above the keyboard (Android: interactive-widget in index.html): the tab
   bar steps aside so the keyboard, the box and the conversation get the room, as in any messaging app. */
@media (max-width: 899.98px) and (max-height: 500px) {
  body:has(:is(input, textarea, [contenteditable="true"]):focus) .tabbar { display: none; }
  body:has(:is(input, textarea, [contenteditable="true"]):focus) :is(.solve-dock, .solve-gate) { bottom: var(--s-2); }
  body.route-chat:has(:is(input, textarea, [contenteditable="true"]):focus) .shell:not(.shell--immersive) .content { padding-bottom: var(--s-2); }
}
@media (max-width: 560px) { .ach-tiercount small { font-size: calc(11.5px * var(--fs-scale, 1)); } }

/* ===== Contact (#/contact) ===== */
/* Who to write to on the left, the form on a raised card on the right; stacked on a phone. */
.contact { display: grid; gap: var(--s-5); max-width: 1040px; }
.contact__grid { display: grid; gap: var(--s-6); align-items: center; }
@media (min-width: 900px) {
  .contact__grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--s-7); padding-block: var(--s-5); }
}
.contact__intro { display: grid; justify-items: center; text-align: center; gap: var(--s-3); }
.contact__mark { line-height: 0; margin-bottom: var(--s-2); filter: drop-shadow(0 8px 18px color-mix(in srgb, var(--brand) 26%, transparent)); }
.contact__intro h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.5rem); letter-spacing: -.02em; }
.contact__lead { margin: 0; max-width: 34ch; color: var(--ink-soft); font-size: var(--fs-md); line-height: 1.6; text-wrap: balance; }
.contact__direct { display: grid; justify-items: center; gap: 6px; margin-top: var(--s-5); max-width: 100%; }
.contact__directlabel { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.contact__addr { display: flex; align-items: center; gap: 2px; max-width: 100%; }
.contact__mail {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 8px; border-radius: var(--r-sm);
  font-weight: 700; color: var(--ink); text-decoration: none;
}
.contact__mail svg { flex: none; color: var(--brand); }
.contact__mail span { overflow-wrap: anywhere; }
.contact__mail:hover span { text-decoration: underline; text-underline-offset: 3px; }
.contact__copy { flex: none; color: var(--ink-faint); }

.contact__card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: var(--s-6); }
.contact__form { display: grid; gap: var(--s-4); }
.contact__field { display: grid; gap: 6px; min-width: 0; }
.contact__field > label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.contact__input {
  width: 100%; box-sizing: border-box; font: inherit; color: var(--ink);
  padding: 13px 16px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); background: color-mix(in oklab, var(--surface-sunk) 45%, var(--surface));
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.contact__input::placeholder { color: var(--ink-faint); }
@media (hover: hover) { .contact__input:hover { border-color: var(--line-strong); } }
.contact__input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.contact__textarea { resize: vertical; min-height: 150px; line-height: 1.5; }
/* The honeypot: off-screen rather than display:none, which some bots know to skip. */
.contact__hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.contact__send { width: 100%; justify-content: center; min-height: 52px; margin-top: var(--s-1); font-size: 1rem; }
.contact__send svg { transition: transform var(--dur-fast) var(--ease-out); }
.contact__send:hover:not(:disabled) svg { transform: translateX(3px); }
.contact__send.is-busy { cursor: progress; opacity: .75; }
.contact__fine { margin: 0; text-align: center; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.contact__note {
  display: grid; gap: var(--s-3); justify-items: start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--retry-tint); color: var(--retry-ink); font-size: var(--fs-sm); line-height: 1.5;
}
.contact__note[hidden] { display: none; }
.contact__note p { margin: 0; }
.contact__done { display: grid; justify-items: center; text-align: center; gap: var(--s-3); padding-block: var(--s-6); }
.contact__doneic {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-tint); color: var(--ok); animation: contact-pop var(--dur-mid) var(--ease-out);
}
@keyframes contact-pop { from { transform: scale(.6); opacity: 0; } }
.contact__done h2 { margin: var(--s-2) 0 0; font-size: var(--fs-xl); }
.contact__done p { margin: 0 0 var(--s-3); max-width: 36ch; color: var(--ink-soft); overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .contact__grid { gap: var(--s-5); }
  .contact__intro { gap: var(--s-2); }
  .contact__mark svg { width: 60px; height: 47px; }
  .contact__direct { margin-top: var(--s-3); }
  .contact__card { padding: var(--s-5) var(--s-4); }
}
@media (prefers-reduced-motion: reduce) { .contact__doneic { animation: none; } }

/* ---------- Högskoleprovet: delprov pages, practice setup, the HP session bar ---------- */
.hp-calib__bar { display: inline-block; width: 64px; height: 6px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; vertical-align: middle; }
.hp-calib__bar i { display: block; height: 100%; background: var(--c, var(--brand)); border-radius: inherit; }
.hp-tile .hp-calib__bar { width: 100%; margin-top: 6px; }
.hp-tile__status strong { font-size: 1rem; color: var(--ink); }
.hp-hero__range { margin: var(--s-2) 0 0; font-size: var(--fs-sm); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.hp-hero__calib { display: flex; align-items: center; gap: 8px; margin: var(--s-2) 0 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.hp-sitting { justify-self: start; }
.hp-hero__or { margin: 0; font-size: calc(12.5px * var(--fs-scale, 1)); }

.hp-dp { display: grid; gap: var(--s-4); max-width: 900px; }
.hp-dp__head { display: grid; gap: 6px; }
.hp-dp__head .homebtn { justify-self: start; }
.hp-dp__head h1 { margin: 0; }
.hp-dp__code { margin: var(--s-2) 0 0; font-family: var(--font-display); font-weight: 800; letter-spacing: .03em; color: var(--c-ink, var(--c)); }
.hp-dp__about { margin: 0; color: var(--ink-soft); max-width: 62ch; }
.hp-dp__level { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-dp__level strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.hp-calib { display: inline-flex; align-items: center; gap: 8px; }
.hp-dp__tabs { display: flex; gap: 4px; margin-top: var(--s-3); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.hp-dp__tabs::-webkit-scrollbar { display: none; }
.hp-dp__tab { border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink-soft); padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.hp-dp__tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--c); }
.hp-dp__tab { white-space: nowrap; flex: none; }
/* Four tabs on a small phone: closer together, so all four show without scrolling (the row still scrolls as a fallback). */
@media (max-width: 400px) { .hp-dp__tab { padding-inline: 9px; } }

/* Strategi tab (views/hp-delprov.js strategyCards): numbered steps, the fixed options with their letters, traps. */
.hp-strat h2 { margin: 0 0 var(--s-2); font-size: var(--fs-md); }
.hp-strat p { margin: 0; max-width: 65ch; }
.hp-strat p + p { margin-top: var(--s-2); }
.hp-strat__steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: var(--s-3); max-width: 65ch; }
.hp-strat__steps li { counter-increment: step; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--s-3); align-items: start; line-height: 1.5; }
.hp-strat__steps li::before {
  content: counter(step); width: 28px; height: 28px; border-radius: var(--r-full); display: grid; place-items: center;
  font-weight: 700; font-family: var(--font-display); background: var(--surface-sunk); color: var(--c-ink, var(--ink));
}
.hp-strat__opts { margin: var(--s-3) 0 0; padding: 0; list-style: none; display: grid; gap: var(--s-2); }
.hp-strat__opts li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.hp-strat__traps { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s-2); max-width: 65ch; line-height: 1.5; }
.hp-strat__traps li::marker { color: var(--retry); }
.hp-strat__go { display: flex; justify-content: flex-start; }
.hp-dp__body { display: grid; gap: var(--s-4); }
.hp-dp__body .set-card { padding: var(--s-5); }
.hp-dp__body h2 { margin: 0 0 4px; font-size: var(--fs-md); }

.hp-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-sunk); margin-top: var(--s-3); }
.hp-seg__opt { border: 0; background: transparent; font: inherit; font-weight: 600; padding: 8px 16px; border-radius: calc(var(--r-md) - 3px); color: var(--ink-soft); cursor: pointer; }
.hp-seg__opt[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.hp-setup__modehint { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--s-3); }
.hp-count { min-width: 48px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer; }
.hp-count[aria-pressed="true"] { border-color: var(--c); background: var(--surface); background: color-mix(in oklab, var(--c) 10%, var(--surface)); color: var(--ink); }
.hp-stepper { display: inline-flex; align-items: stretch; min-height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.hp-stepper:focus-within { border-color: var(--c); }
.hp-stepper__btn { width: 38px; border: 0; background: transparent; color: var(--ink-soft); font: inherit; font-size: 1.15rem; font-weight: 600; cursor: pointer; }
@media (hover: hover) { .hp-stepper__btn:hover:not(:disabled) { background: var(--surface-sunk); color: var(--ink); } }
.hp-stepper__btn:disabled { opacity: .35; cursor: default; }
.hp-stepper__input { width: 3.2em; border: 0; border-inline: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.hp-stepper__input::-webkit-outer-spin-button, .hp-stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hp-stepper__input:focus { outline: none; background: var(--surface-sunk); }
.hp-toggles { display: grid; gap: 8px; margin-top: var(--s-3); }
.hp-toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.hp-toggle input { margin-top: 3px; }
.hp-toggle span { display: grid; }
.hp-toggle small { color: var(--ink-soft); }
.hp-setup__go { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-4); }

.hp-list__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); }
/* The list's filters: status as one-tap chips with counts, the topic as a rounded dropdown. */
.hp-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); margin: var(--s-4) 0 var(--s-3); }
.hp-fchips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.hp-fchip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.hp-fchip b { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .hp-fchip:hover { border-color: var(--line-strong); border-color: color-mix(in oklab, var(--brand) 55%, var(--line-strong)); color: var(--ink); } }
.hp-fchip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hp-fchip.is-empty { color: var(--ink-faint); }
.hp-fchip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.hp-fchip[aria-pressed="true"] b { color: inherit; }   /* the chip's own white: a dimmed white was 4.3:1 on the brand blue */
.hp-fselect { position: relative; display: inline-flex; align-items: center; }
.hp-fselect select {
  appearance: none; -webkit-appearance: none; min-height: 36px; max-width: 260px; padding: 0 38px 0 14px;
  border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); cursor: pointer; text-overflow: ellipsis;
}
/* Touch: the question-count stepper's buttons (38px) and the topic filter (36px) reach 44px, as in the mobile
   block above; the stepper's 46px is its 1px border around 44px buttons. */
@media (pointer: coarse) {
  .hp-stepper, .hp-count { min-height: 46px; }   /* the 5 / 10 / 20 / 40 buttons beside it keep its height */
  .hp-stepper__btn { width: 44px; }
  .hp-fselect select { min-height: 44px; }
}
@media (hover: hover) { .hp-fselect select:hover { border-color: var(--line-strong); border-color: color-mix(in oklab, var(--brand) 55%, var(--line-strong)); } }
.hp-fselect select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hp-fselect select option { color: var(--ink); background: var(--surface); }
.hp-fselect svg { position: absolute; right: 13px; pointer-events: none; color: var(--ink-soft); }
@media (max-width: 560px) {
  /* One swipeable row of chips on a phone instead of three wrapped ones; the fade says there's more. */
  .hp-fchips {
    /* contain: the row's own width can't widen the page (its chips would otherwise set the column's minimum). */
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; contain: inline-size; padding: 2px 24px 2px 2px; margin: -2px;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
  .hp-fchips::-webkit-scrollbar { display: none; }
  .hp-fchip { flex: none; }
}
/* Touch: the row clips (and would scroll up and down to) anything past its edge, so it gets room above and
   below for its chips' taller hit areas, given back with a negative margin. */
@media (max-width: 560px) and (pointer: coarse) { .hp-fchips { padding-block: 6px; margin-block: -6px; } }
.hp-qlist { list-style: none; margin: 0; padding: 0; display: grid; }
.hp-qrow { display: flex; align-items: center; gap: var(--s-2); padding: 10px 0; border-top: 1px solid var(--line); }
.hp-qrow__main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.hp-qrow__prompt { overflow-wrap: anywhere; }
.hp-qrow__chips { display: flex; flex-wrap: wrap; gap: 4px; }
.hp-chip { display: inline-block; padding: 1px 8px; border-radius: var(--r-full); font-size: calc(11.5px * var(--fs-scale, 1)); font-weight: 600; background: var(--surface-sunk); color: var(--ink-soft); }
.hp-chip.is-wrong { background: var(--retry-tint); color: var(--retry-ink); }
.hp-chip.is-right { background: var(--ok-tint); color: var(--ok-ink); }
.hp-chip.is-ai { background: var(--brand-tint); color: var(--brand-ink); }
.hp-qrow .iconbtn[aria-pressed="true"], .hp-qbar__save[aria-pressed="true"] { color: var(--brand); border-color: var(--brand); }
.hp-hist { list-style: none; margin: var(--s-2) 0 0; padding: 0; }
.hp-hist__row { display: flex; align-items: center; gap: var(--s-3); padding: 10px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
@media (hover: hover) { .hp-hist__row:hover { color: var(--brand-ink); } }
.hp-hist__date { min-width: 110px; color: var(--ink-soft); }
.hp-hist__row svg { margin-left: auto; }

.hp-intro { display: grid; gap: var(--s-2); }
.hp-intro h2 { margin: 0; font-size: var(--fs-lg); }   /* an h2 after the page h1, sized like the h3 it was */
.hp-intro p { margin: 0; }
.hp-intro__code { font-family: var(--font-display); font-weight: 800; color: var(--brand-ink); letter-spacing: .03em; }
.hp-intro__tip { display: flex; gap: 6px; align-items: flex-start; }
.hp-intro__facts { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--s-4); margin: var(--s-2) 0; font-size: var(--fs-sm); }
.hp-intro__facts dt { color: var(--ink-soft); }
.hp-intro__facts dd { margin: 0; font-weight: 600; }
.hp-intro .btn { justify-self: start; }
.hp-intro__parts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hp-intro__parts li { padding: 2px 10px; border-radius: var(--r-full); background: var(--surface-sunk); font-size: calc(12.5px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-soft); }
/* A mixed run (snabbprognos, provpass): the delprov's instruction where its questions begin. */
.hp-dpstart { display: grid; gap: 2px; margin: 0 0 var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--brand-tint); }
.hp-dpstart strong { color: var(--brand-ink); font-size: var(--fs-sm); }
.hp-dpstart span { font-size: var(--fs-sm); color: var(--ink); }

.hp-qbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-2); }
.hp-qbar__src { padding: 2px 10px; border-radius: var(--r-full); background: var(--warn-tint, var(--surface-sunk)); color: var(--warn-ink, var(--ink-soft)); font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; }
.hp-qbar__tools { display: inline-flex; gap: 6px; margin-left: auto; }
.examtimer__pace { margin-left: 6px; font-weight: 600; color: var(--ok-ink); }
.examtimer__pace.is-behind { color: var(--retry-ink); }

.session__stage { position: relative; }
.session__stage.is-drawing { touch-action: none; }
.scratch { position: absolute; left: 0; top: 0; width: 100%; z-index: 5; cursor: crosshair; touch-action: none; }
.scratch__clear { position: absolute; top: 0; right: 84px; z-index: 6; }   /* left of the pen and bookmark, which must stay reachable */

/* Four short options two by two, as on a test page. */
.choices--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 380px) { .choices--grid { grid-template-columns: 1fr; } }

/* ---------- HP tests page, analysis ---------- */
.hp-prov { display: grid; gap: var(--s-4); max-width: 820px; }
.hp-prov > .homebtn { justify-self: start; }
.hp-prov__head h1 { margin: 0; }
.hp-prov__head p { margin: 6px 0 0; color: var(--ink-soft); }
.hp-prov__card { padding: var(--s-5); display: grid; gap: var(--s-3); }
.hp-prov__card h2 { margin: 0; font-size: var(--fs-md); }
.hp-prov__card .note { margin: 0; }
.hp-prov__card > .btn { justify-self: start; }
.hp-prov__card.is-open { border-color: var(--brand); }
.hp-prov__pair { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.hp-prov__open { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.hp-prov__open li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.hp-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); margin-top: var(--s-3); }
.hp-stat { display: grid; gap: 2px; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-sunk); }
.hp-stat span { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.hp-stat strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.hp-weeks { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s-2); align-items: end; height: 150px; margin-top: var(--s-3); }
.hp-weeks__col { display: grid; grid-template-rows: 1fr auto auto; height: 100%; text-align: center; gap: 2px; }
.hp-weeks__bar { align-self: end; display: flex; align-items: flex-end; width: 70%; margin: 0 auto; min-height: 2px; border-radius: 6px 6px 0 0; background: var(--surface-sunk); background: color-mix(in oklab, var(--c, var(--brand)) 22%, var(--surface-sunk)); overflow: hidden; }
.hp-weeks__bar i { display: block; width: 100%; background: var(--c, var(--brand)); }
.hp-weeks__n { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; font-variant-numeric: tabular-nums; }
.hp-weeks__w { font-size: calc(12px * var(--fs-scale, 1)); color: var(--ink-faint); }
.hp-topics { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: 10px; }
.hp-topics li { display: grid; grid-template-columns: minmax(0, 1fr) 40% auto; align-items: center; gap: var(--s-3); }
.hp-topics__bar { width: 100%; }
.hp-topics__n { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Results of an HP run: time per question against the test's pace (results.js hpPace). The bar runs from 0
   to twice the test's pace, so the line in its middle is the pace itself. */
.hp-pace { margin-top: 24px; text-align: left; }
.hp-pace > h3 { margin-bottom: 4px; }
.hp-pace > .note { margin: 0 0 8px; }
.hp-pace__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hp-pace__row { display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); }
.hp-pace__dp { font-weight: 700; font-family: var(--font-display); }
.hp-pace__bar { position: relative; height: 8px; border-radius: var(--r-full); background: var(--surface-sunk); }
.hp-pace__bar i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.hp-pace__bar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink-soft); border-radius: 1px; }
.hp-pace__row.is-slow .hp-pace__bar i { background: var(--retry); }
.hp-pace__n { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); font-variant-numeric: tabular-nums; text-align: right; }
.hp-pace__n small { display: block; font-size: inherit; }
.hp-pace__row.is-slow .hp-pace__n small { color: var(--retry-ink, var(--ink)); font-weight: 600; }
.hp-pace__sub { margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-sm); }
.hp-pace__slow { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.hp-pace__slow li { display: grid; gap: 2px; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-sunk); }
.hp-pace__slow .note { margin: 0; }
@media (max-width: 480px) { .hp-stats { grid-template-columns: 1fr 1fr; } }

/* ===== Min profil (#/profile, views/profile.js) ===== */
.profile { display: grid; gap: var(--s-5); max-width: 1040px; }
.profile__title { margin: 0; }
.profile__grid { display: grid; gap: var(--s-5); align-items: stretch; }
@media (min-width: 900px) { .profile__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* The student card: the one bold object on the page. A plastic card's deep blue, the picture where an
   ID photo sits, the record along its foot. Fixed colours: it is an object, the same in both themes. */
.idcard {
  position: relative; isolation: isolate; overflow: hidden; display: grid; gap: var(--s-5);
  padding: var(--s-5) var(--s-6) 0; border-radius: 22px; color: #fff;
  background: var(--brandcard-bg); box-shadow: var(--brandcard-shadow);
}
/* Two faint rings in the corner, like the print on a card (the page band wears them too). */
.idcard::before, .pageband::before {
  content: ""; position: absolute; z-index: -1; right: -110px; top: -150px; width: 360px; height: 360px;
  border-radius: 50%; border: 44px solid rgba(255, 255, 255, .055); box-shadow: 0 0 0 44px rgba(255, 255, 255, .03);
}
.idcard__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.idcard__brand { display: inline-flex; align-items: center; gap: 8px; font-size: calc(15px * var(--fs-scale, 1)); color: rgba(255, 255, 255, .92); }
.idcard__brand img { width: 22px; height: 22px; border-radius: 6px; }
.idcard__edit {
  display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px; cursor: pointer;
  border-radius: var(--r-full); border: 1px solid rgba(255, 255, 255, .34); background: rgba(255, 255, 255, .12);
  color: #fff; font: inherit; font-size: var(--fs-sm); font-weight: 600;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
@media (hover: hover) { .idcard__edit:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5); } }
.idcard :is(.idcard__edit, .idcard__photo, .idcard__addname):focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.idcard__who { display: flex; align-items: center; gap: var(--s-5); min-width: 0; }
.idcard__photo {
  position: relative; flex: none; width: 108px; height: 108px; padding: 0; overflow: hidden; cursor: pointer;
  display: grid; place-items: center; border-radius: 28px; border: 3px solid rgba(255, 255, 255, .92);
  background: rgba(255, 255, 255, .16); color: #fff; box-shadow: 0 10px 22px -12px rgba(0, 0, 0, .5);
}
.idcard__photo img { width: 100%; height: 100%; object-fit: cover; }
.idcard__initial { font-family: var(--font-display); font-size: calc(44px * var(--fs-scale, 1)); font-weight: 700; line-height: 1; }
.idcard__cam {
  position: absolute; right: 6px; bottom: 6px; width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: #fff; color: #1E45AC; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  transition: transform var(--dur-fast);
}
.idcard__photo:hover .idcard__cam { transform: scale(1.08); }
.idcard__id { display: grid; gap: 6px; min-width: 0; }
.idcard__name {
  margin: 0; font-family: var(--font-display); font-size: clamp(1.7rem, 3.4vw, 2.3rem); line-height: 1.08;
  letter-spacing: -.025em; color: #fff; overflow-wrap: anywhere;
}
/* "Lägg till ditt namn": a button that looks like one (it was a big dashed-underlined headline that read as a link). */
.idcard__addname {
  justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; cursor: pointer; text-align: left;
  border: 1.5px dashed rgba(255, 255, 255, .6); border-radius: var(--r-full); background: rgba(255, 255, 255, .12);
  font-family: var(--font-display); font-size: var(--fs-md, 1rem); font-weight: 600; color: #fff;
}
@media (hover: hover) { .idcard__addname:hover { background: rgba(255, 255, 255, .22); border-color: #fff; } }
.idcard__mail { margin: 0; font-size: var(--fs-sm); color: rgba(255, 255, 255, .8); overflow-wrap: anywhere; }
.idcard__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.idcard__tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: var(--r-full);
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600;
}
.idcard__tag svg { flex: none; opacity: .85; }
.idcard__since { margin: 2px 0 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: rgba(255, 255, 255, .7); }
/* The record along the foot: a darker band, four figures. */
.idcard__stats {
  margin: 0 calc(-1 * var(--s-6)); padding: var(--s-4) var(--s-6);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3);
  background: rgba(6, 20, 64, .3); border-top: 1px solid rgba(255, 255, 255, .12);
}
.idcard__stat { display: grid; gap: 2px; min-width: 0; }
.idcard__stat + .idcard__stat { padding-left: var(--s-3); border-left: 1px solid rgba(255, 255, 255, .14); }
.idcard__stat strong { font-family: var(--font-display); font-size: calc(24px * var(--fs-scale, 1)); line-height: 1.15; font-variant-numeric: tabular-nums; }
.idcard__stat span { font-size: calc(12.5px * var(--fs-scale, 1)); line-height: 1.3; color: rgba(255, 255, 255, .76); }

/* The profile card's look as a page's head (Bibliotek, Framsteg, Inför provet; set-ui.js pageBand): the same blue,
   rings and row of figures, so those pages open the way the profile does. The figures share .idcard__stats. */
.pageband {
  position: relative; isolation: isolate; overflow: hidden; display: grid; gap: var(--s-4);
  margin-bottom: var(--s-5); padding: var(--s-5) var(--s-6); border-radius: 22px; color: #fff;
  background: var(--brandcard-bg); box-shadow: var(--brandcard-shadow);
}
.pageband:has(> .idcard__stats) { padding-bottom: 0; }
.pageband > * { margin: 0; }
.pageband h1 { margin: 0; color: #fff; }
.pageband :is(.settings__head p, .exam-lede, .libhead__trail) { color: rgba(255, 255, 255, .82); }
.pageband .btn, .pageband .iconbtn {
  color: #fff; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .34); box-shadow: none;
}
@media (hover: hover) { .pageband .btn:hover:not(:disabled), .pageband .iconbtn:hover:not(:disabled) { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5); } }
.pageband :is(.btn, .iconbtn):focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
/* As many columns as figures (four at the top of the library, two for one subject). */
.pageband .idcard__stats { margin: 0 calc(-1 * var(--s-6)); grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
@media (max-width: 560px) {
  .pageband { padding: var(--s-4); border-radius: 18px; }
  .pageband .idcard__stats {
    margin: 0 calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4);
    grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pageband .idcard__stat:nth-child(odd) { padding-left: 0; border-left: 0; }
}
@media (max-width: 620px) {
  .idcard { padding: var(--s-4) var(--s-4) 0; gap: var(--s-4); border-radius: 18px; }
  .idcard__who { align-items: flex-start; gap: var(--s-4); }
  .idcard__photo { width: 84px; height: 84px; border-radius: 22px; }
  .idcard__initial { font-size: calc(34px * var(--fs-scale, 1)); }
  .idcard__cam { width: 24px; height: 24px; right: 4px; bottom: 4px; }
  .idcard__stats { margin-inline: calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4); grid-template-columns: 1fr 1fr; row-gap: var(--s-3); }
  .idcard__stat:nth-child(odd) { padding-left: 0; border-left: 0; }
}

/* Subjects: a dot, the name, a bar and the level letter in a column that lines up. */
.profile-subjs { list-style: none; margin: 0; padding: var(--s-2) 0 0; display: grid; }
.profile-subj {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(64px, 36%) 30px; align-items: center;
  gap: var(--s-3); padding: 11px 0; border-top: 1px solid var(--line);
}
.profile-subj:first-child { border-top: 0; }
.profile-subj__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--subject); }
.profile-subj__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-subj__bar { height: 8px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
.profile-subj__bar i { display: block; height: 100%; border-radius: inherit; background: var(--subject); transition: width var(--dur-slow) var(--ease-out); }
.profile-subj .gradepill { justify-self: end; }
.profile-hp {
  display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-3); padding: 12px 14px;
  border-radius: var(--r-md); background: var(--surface-sunk); color: inherit; text-decoration: none;
  transition: background var(--dur-fast);
}
@media (hover: hover) { .profile-hp:hover { background: var(--brand-tint); } }
.profile-hp:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.profile-hp__ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--c-tangerine-tint); color: var(--c-tangerine-ink); }
.profile-hp__text { flex: 1; display: grid; min-width: 0; }
.profile-hp__text small { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.profile-hp__score { font-family: var(--font-display); font-size: calc(22px * var(--fs-scale, 1)); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.profile-more { margin: 0; padding: var(--s-3) 0 var(--s-2); }
.profile-more .linkbtn { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

/* Trophies: the medal in its tier's metal, the name, the tier and the day it was won. */
.profile-trophies { list-style: none; margin: 0; padding: var(--s-2) 0 0; display: grid; }
.profile-trophy {
  --m: var(--brand); --m-ink: var(--brand-ink);
  display: flex; align-items: center; gap: var(--s-3); padding: 10px 0; border-top: 1px solid var(--line);
}
.profile-trophy:first-child { border-top: 0; }
.profile-trophy--bronze { --m: var(--ach-bronze); --m-ink: var(--ach-bronze-ink); }
.profile-trophy--silver { --m: var(--ach-silver); --m-ink: var(--ach-silver-ink); }
.profile-trophy--gold { --m: var(--ach-gold); --m-ink: var(--ach-gold-ink); }
.profile-trophy--platinum { --m: var(--ach-platinum); --m-ink: var(--ach-platinum-ink); }
.profile-trophy__medal {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-on-color);
  background: linear-gradient(145deg, color-mix(in oklab, var(--m) 60%, #fff), var(--m) 55%, color-mix(in oklab, var(--m) 72%, #000));
}
.profile-trophy--platinum .profile-trophy__medal { background: var(--ach-platinum-sheen); color: #34506A; }
.profile-trophy--milestone .profile-trophy__medal { color: #fff; }   /* brand blue: white reads best there */
.profile-trophy__medal svg { width: 21px; height: 21px; }
.profile-trophy__text { display: grid; gap: 1px; min-width: 0; }
.profile-trophy__text strong { font-weight: 600; }
.profile-trophy__text small { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.profile-trophy__tier { color: var(--m-ink); font-weight: 700; }
.profile-signout { color: var(--retry-ink); }

/* The edit dialog. */
.modal__card.profile-edit { max-width: 540px; display: grid; gap: var(--s-4); }
.profile-edit:focus { outline: none; }
.profile-edit h2 { margin: 0; font-size: var(--fs-lg); }
.profile-edit .field { margin: 0; }
.profile-edit .field input[type=date] {
  width: 100%; font: inherit; padding: var(--s-3); border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.profile-edit__photo { display: flex; align-items: center; gap: var(--s-4); }
.profile-edit__face {
  flex: none; width: 72px; height: 72px; border-radius: 20px; overflow: hidden; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand-ink); font-family: var(--font-display); font-size: calc(28px * var(--fs-scale, 1)); font-weight: 700;
}
.profile-edit__face img { width: 100%; height: 100%; object-fit: cover; }
.profile-edit__label { margin: 0 0 var(--s-2); font-weight: 700; font-size: var(--fs-sm); }
.profile-edit__photoacts { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.profile-edit__student { display: grid; gap: var(--s-4); }
.profile-edit__student:empty { display: none; }
.profile-edit__group { border: 0; margin: 0; padding: 0; min-width: 0; }
.profile-edit__group legend { padding: 0; margin-bottom: var(--s-2); font-weight: 700; font-size: var(--fs-sm); }
.profile-edit__group .chips { margin: 0; }
.profile-edit__actions { display: flex; justify-content: flex-end; gap: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--line); }
@media (max-width: 480px) { .profile-edit__actions .btn { flex: 1; justify-content: center; } }

/* Shown by js/boot.js when the app can't start (a module didn't load, or the browser is too old). */
.boot-failed { max-width: 34rem; margin: 18vh auto 0; padding: 0 var(--s-4); display: grid; gap: var(--s-3); justify-items: start; color: var(--ink); }
.boot-failed h1 { margin: 0; font-size: var(--fs-xl, 1.5rem); text-wrap: balance; }
.boot-failed p { margin: 0; color: var(--ink-soft); line-height: 1.5; }

/* Högskoleprovet's score card: the calibration as a labelled bar with a hint, not a bare empty track. */
.hp-calibbox { margin: var(--s-3) 0 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-sunk); display: grid; gap: 6px; }
.hp-calibbox__row { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); color: var(--ink-soft); }
.hp-calibbox__row b { color: var(--ink); font-weight: 700; }
.hp-calibbox__bar.hp-calib__bar { display: block; width: 100%; background: var(--line-strong); }
.hp-calibbox__hint { margin: 0; font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); line-height: 1.45; }

/* ---------- study session on phones: full screen, one bar on top, the main button pinned ----------
   Below the sidebar breakpoint a session drops the app's top bar, "← Home", the title row and the dot row
   for one slim bar: ✕ (leave), progress "n/N", the clock on a timed run, and ⋯ (the header's tools). The
   step's main button ("Check", "Start", "Next") sits in a bar fixed at the bottom, where a thumb is, and
   the answer options stack in one column. session.js builds the pieces (.sessionview--bar, .mtop, .mprimary, .q-primary);
   commute mode has its own screen and keeps none of this. Desktop is untouched. */
.mtop, .mtop__title, .mprimary { display: none; }
button.toolfly__item { border: 0; background: transparent; font: inherit; font-size: var(--fs-sm); width: 100%; text-align: left; cursor: pointer; }
@media (max-width: 899.98px) {
  body:has(.sessionview--bar) :is(.topbar, .examtimer--float) { display: none !important; }
  body:has(.sessionview--bar) .content { padding-top: 0; padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .sessionview--bar > :is(.homebtn, .session__head, .progressbar, .progress-dots, .progress-label) { display: none !important; }

  .mtop {
    position: sticky; top: 0; z-index: 25;
    display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto 44px; align-items: center; gap: 10px;
    margin-inline: -6px; padding: calc(env(safe-area-inset-top) + 8px) 0 8px;
    background: color-mix(in srgb, var(--canvas) 92%, transparent); backdrop-filter: blur(12px);
  }
  .mtop__btn {
    width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
    border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer;
  }
  .mtop__btn:active { background: var(--surface-sunk); }
  .mtop__btn:focus-visible { outline: none; box-shadow: var(--ring); }
  .mtop__track { position: relative; height: 8px; border-radius: var(--r-full); overflow: hidden; background: var(--surface); background: color-mix(in srgb, var(--ink) 10%, var(--surface)); }
  .mtop__fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--c-sky), var(--brand)); transition: width var(--dur-slow) var(--ease-out); }
  .mtop__n { min-width: 2.6em; text-align: right; font-size: calc(14px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
  .mtop__time { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: var(--r-full); background: var(--surface-sunk); font-size: calc(14px * var(--fs-scale, 1)); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
  .mtop__time.is-warn { background: var(--retry-tint); color: var(--retry-ink); }
  .mtop__time[hidden] { display: none; }
  .mtop__title {
    display: block; margin: 0 0 var(--s-4); font-size: calc(13px * var(--fs-scale, 1)); font-weight: 600; color: var(--ink-faint);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* The bottom bar: Skip (and an exam's Previous / flag) beside the main button. Leave is the ✕ above;
     answers so far and an exam's question map are in the ⋯ menu. */
  .sessionview--bar .session .nav-row {
    position: fixed; left: 0; right: 0; bottom: var(--kb-lift, 0px); z-index: 30; margin: 0;
    flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 10px;
    padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
    background: color-mix(in srgb, var(--canvas) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  /* The bar above is fixed over the page: a scrolled-to explanation stops above it, not behind it. */
  .sessionview--bar .feedback { scroll-margin-bottom: calc(var(--kb-lift, 0px) + env(safe-area-inset-bottom) + 84px); }
  .sessionview--bar .nav-row > div:first-child > :not(.flagbtn) { display: none !important; }
  .sessionview--bar .nav-row > div:first-child:not(:has(> .flagbtn:not([hidden]))) { display: none; }
  .sessionview--bar .nav-row > div:first-child { flex: none; width: auto; }
  .sessionview--bar .nav-row .flagbtn { min-width: 50px; min-height: 50px; padding: 0; justify-content: center; border-radius: 14px; }
  .sessionview--bar .nav-row .flagbtn > span { display: none; }
  .sessionview--bar .nav-row > div:last-child { flex: 1; width: auto; flex-wrap: nowrap; }
  .sessionview--bar .nav-row > div:last-child > .btn { min-height: 52px; border-radius: 14px; font-size: 1rem; justify-content: center; }
  .sessionview--bar .nav-row > div:last-child > .btn--ghost { flex: 0 0 auto; padding-inline: 18px; }
  .sessionview--bar .nav-row .nextbtn { display: none !important; }
  .sessionview--bar .nav-row .mprimary { display: inline-flex !important; flex: 1 1 auto; gap: 8px; }
  .sessionview--bar .nav-row .mprimary[hidden] { display: none !important; }
  .sessionview--bar .q-primary { display: none !important; }
  /* "Continue where you left off" brings its own two buttons. */
  .sessionview--bar:has(.resume) .nav-row { display: none !important; }

  /* Answer options: one full-width row each, easy to hit with a thumb. */
  .sessionview--bar .choices--grid { grid-template-columns: minmax(0, 1fr); }
  .sessionview--bar .choice { min-height: 56px; }

  button.toolfly__item { min-height: 44px; }
}
@media (max-width: 899.98px) {
  /* Nothing to flag before an HP run has started. */
  .sessionview--bar:has(.hp-intro) .nav-row .flagbtn { display: none !important; }
  /* An exam's fixed "exam conditions" banner is read on the intro; once the run is going it would sit
     over every question on a small screen. (A test's banner with its on/off switch stays.) */
  .sessionview--bar:not(:has(.hp-intro)) > .testbar:not(:has(button)) { display: none; }
}

@media (pointer: coarse) { .plan-cal__chip { min-height: 24px; } }

/* ===== Practice screen on a wide desktop window (audit A-41) =====
   It used only the top 40% of a 1440 x 900 window: a narrow question column and a short tutor card, empty below.
   From 1200px: a wider column with the question centred in the free height and larger, the Back / Skip / Next bar
   pinned to the bottom of it, and the tutor panel as tall as the window. Phones keep the full-screen study mode. */
@media (min-width: 1200px) {
  /* width: 100% — .content is a flex column, where auto side margins alone shrink the view to its content:
     a short question ("stringent") gave a 755px, phone-like screen on a 1920px window. */
  .sessionview { width: 100%; max-width: 1180px; margin-inline: auto; }
  .sessionview .session { grid-template-columns: minmax(0, 1fr) 420px; align-items: stretch; min-height: calc(100dvh - 300px); }
  .sessionview .session > div:first-child { display: flex; flex-direction: column; min-width: 0; }
  .sessionview .session__stage { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; padding-block: var(--s-4); }
  .sessionview .question__prompt { font-size: var(--fs-xl); line-height: 1.3; }
  .sessionview .session .nav-row { margin-top: auto; position: sticky; bottom: 0; z-index: 3; padding-block: var(--s-3); background: var(--canvas); border-top: 1px solid var(--line); }
  .sessionview .tutor { top: var(--s-4); height: calc(100dvh - 300px); max-height: none; }
}

/* ---------- home and Studera on phones ----------
   The home page leads with one thing to do (.home-continue, built in menu.js: a run left part-way, the
   questions due for review, or the set studied last). The five shortcuts stay as they are. "Dina set"
   is a preview of the first four on the page itself rather than a card inside a card, and every set
   card is a compact row: the mastery ring first, then subject, title and count.
   Search and filters stay on Studera. Tablets and desktop are untouched. */
.home-panel__all { display: none; }
@media (max-width: 620px) {
  .home__head { margin-bottom: var(--s-4); }

  /* "Dina set": a section on the page, not a card around cards. */
  .home-panel--sets { background: transparent; border: 0; box-shadow: none; padding: 0; }
  .home-panel--sets .home-panel__label { margin-bottom: var(--s-2); }
  .home-panel--sets .home-panel__all { display: inline; }
  .home-panel--sets :is(.librarybar .search, .filtertoggle, .filterdrawer, .acard--new, .acard--extra) { display: none !important; }
  .home-panel--sets .librarybar { margin-bottom: var(--s-3); }

  /* Set cards as rows: ring (or a start chip) | subject, title, count | ⋮ */
  .grid { gap: 10px; }
  .grid > .acard:not(.acard--new) {
    display: grid; grid-template-columns: 46px minmax(0, 1fr) 36px;
    grid-template-areas: "lead top menu" "lead title menu" "lead meta menu";
    column-gap: 14px; row-gap: 1px; align-items: center;
    min-height: 0; padding: 12px 6px 12px 14px; border-radius: 16px;
  }
  .grid > .acard::before { display: none; }
  .grid > .acard .acard__top { grid-area: top; padding-right: 0; min-height: 0; }
  .grid > .acard .acard__title { grid-area: title; font-size: 1rem; line-height: 1.3; }
  .grid > .acard :is(.acard__foot, .acard__meta) { display: contents; }
  .grid > .acard .acard__meta > span:first-child { grid-area: meta; font-size: 13px; color: var(--ink-faint); }
  .grid > .acard .acard__meta > :last-child { grid-area: lead; justify-self: center; }
  .grid > .acard .ring { width: 46px; height: 46px; }
  .grid > .acard .acard__meta > :last-child:not(.ring) {
    width: 46px; height: 46px; display: grid; place-items: center; border-radius: var(--r-full);
    background: var(--surface); background: color-mix(in oklab, var(--subject, var(--brand)) 14%, var(--surface));
  }
  .grid > .acard :is(.acard__status, .acard__progress) { grid-column: 2 / 4; margin-top: 4px; }
  .grid > .acard .acard__menu { grid-area: menu; position: static; width: 36px; height: 36px; opacity: 1; align-self: center; }

  /* Studera: the title and a compact "+ New" on one line. */
  .study-page .planner-page__head .btn { min-height: 40px; padding: 0 14px; border-radius: var(--r-full); }
  .study-page__sub { margin: 2px 0 14px; }
}

/* ---------- library header: where you are ---------- */
.libhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.libhead__text { min-width: 0; }
.libhead__trail { margin: 0 0 2px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-faint); }
.libhead h1 { margin: 0; }

.results__bar { display: none; }

@media (max-width: 899.98px) {
  /* ---------- results on phones: a finish screen, the next step pinned at the bottom ---------- */
  body:has(.results__bar) :is(.topbar, .tabbar) { display: none !important; }
  body:has(.results__bar) .content { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .results__dup { display: none !important; }
  .results__bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 10px;
    padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
    background: color-mix(in srgb, var(--canvas) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .results__bar .btn { min-height: 52px; border-radius: 14px; font-size: 1rem; justify-content: center; gap: 8px; }
  .results__bar .btn:not(.btn--ghost) { flex: 1; }
  .results__bar .btn--ghost { flex: 0 0 auto; padding-inline: 18px; }
}

@media (max-width: 620px) {
  /* The answers worth a look: lighter cards, the explanation in a size meant for reading on a phone. */
  .results .delta-list--review .delta--review { padding: 12px 14px; gap: 4px; }
  .results .delta__explain { font-size: 14px; line-height: 1.5; }

  /* ---------- the library on phones ---------- */
  /* The subject list and the set list sit on the page, not in a card around cards. */
  .libview .panel { background: transparent; border: 0; box-shadow: none; padding: 0; }
  .libview .levelcard { padding: var(--s-4); }
  .libview .libgrid { gap: 10px; margin-top: var(--s-3); }
  .libview .libcard { padding: 14px; gap: 10px; border-radius: 16px; }
  .libview .libcard .note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  /* Questions per session: one tidy row, label on the left, the choice on the right. */
  .libview .libseg { justify-content: space-between; flex-wrap: nowrap; }
  .libview .libseg__group button { min-height: 40px; min-width: 48px; }
  /* The main action as a full-width button; the extras (weak spots, exam mode, worksheet) in a row under it. */
  .libview .libcard__foot { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .libview .libcard__foot > div { display: flex; flex-wrap: wrap; gap: 8px !important; }
  .libview .libcard__foot > div > .libseg { flex: 1 1 100%; }
  .libview .libcard__foot > div > .btn:not(.btn--ghost) { flex: 1 1 100%; justify-content: center; min-height: 46px; border-radius: 12px; }
  .libview .libcard__foot > div > .btn--ghost { flex: 1 1 0; justify-content: center; min-width: 0; white-space: nowrap; }
  .libview .libcard__foot > div > .iconbtn { flex: none; width: 44px; height: 44px; }
}

/* "Om det här": a set's summary, from its card menu or inside a session. */
.summarydlg__card { max-width: 560px; display: grid; gap: var(--s-3); max-height: calc(100dvh - 32px); overflow-y: auto; }
.summarydlg__card h3 { margin: 0; text-wrap: balance; }
.summarydlg__eyebrow { margin: 0; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: var(--fs-sm); font-weight: 600; }
.summarydlg__body { line-height: 1.6; }
.summarydlg__body > :first-child { margin-top: 0; }
.summarydlg__body > :last-child { margin-bottom: 0; }
.summarydlg__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: var(--s-2); }
.set-summary h3 { margin: 0 0 var(--s-2); }
@media (max-width: 620px) {
  .summarydlg__actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .summarydlg__actions .btn { justify-content: center; min-height: 48px; }
  .summarydlg__actions .btn:not(.btn--ghost) { order: -1; }
}

/* ---- The home page's background (components/home-backdrop.js) ----
   An aura at the top of the page, nothing below it: two soft lights side by side behind the greeting, in
   a pair of hues that follows the time of day (data-daypart, like the greeting), greyed down so they tint
   rather than colour. Over them a faint dot grid and a fine paper grain: the grain makes the page feel
   printed rather than painted, and it dithers the gradients so they never show bands. Everything fades
   out before the content below the shortcuts. The lights drift a little, very slowly, in opposite
   directions; nothing moves for anyone who has asked for less motion. */
.homebg {
  display: none;
  --hb-a: #3D6FE6; --hb-b: #0FA3C2;
  --hb-strength: 0.27; --hb-grain: 0.05;
  --hb-dot: color-mix(in srgb, var(--ink) 12%, transparent);
}
.homebg[data-daypart="morning"] { --hb-a: #F08A3C; --hb-b: #E8679A; }
.homebg[data-daypart="day"]     { --hb-a: #3D6FE6; --hb-b: #12A5B8; }
.homebg[data-daypart="evening"] { --hb-a: #7650FF; --hb-b: #C25BC9; }
.homebg[data-daypart="night"]   { --hb-a: #3F51C4; --hb-b: #5B3FB0; --hb-strength: 0.15; }
body.route-home { background: transparent; }
body.route-home .homebg {
  display: block; position: absolute; inset: 0 0 auto 0; height: 620px; z-index: -1; overflow: hidden; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
  mask-image: linear-gradient(to bottom, #000 45%, transparent);
}
.homebg__light {
  position: absolute; top: -260px; width: 760px; height: 560px; border-radius: 50%;
  opacity: var(--hb-strength);
  will-change: transform;
}
.homebg__light--a {
  left: calc(50% - 640px);
  background: radial-gradient(closest-side, color-mix(in oklab, var(--hb-a) 60%, #8B93A7), transparent);
  animation: homebg-drift-a 38s ease-in-out infinite alternate;
}
.homebg__light--b {
  left: calc(50% - 60px);
  background: radial-gradient(closest-side, color-mix(in oklab, var(--hb-b) 60%, #8B93A7), transparent);
  animation: homebg-drift-b 46s ease-in-out infinite alternate;
}
@keyframes homebg-drift-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(60px, 24px, 0); } }
@keyframes homebg-drift-b { from { transform: translate3d(0, 10px, 0); } to { transform: translate3d(-70px, -8px, 0); } }
/* A dot every 22px, like a bullet-journal page, under the greeting only. */
.homebg__grid {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, var(--hb-dot) 1px, transparent 1.4px);
  background-size: 22px 22px; background-position: 11px 11px;
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 40% 0%, #000 0%, transparent 70%);
  mask-image: radial-gradient(ellipse 70% 80% at 40% 0%, #000 0%, transparent 70%);
}
.homebg__grain {
  position: absolute; inset: 0; opacity: var(--hb-grain); mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .homebg { --hb-strength: 0.24; --hb-grain: 0.06; --hb-dot: color-mix(in srgb, var(--ink) 9%, transparent); }
:root[data-theme="dark"] .homebg[data-daypart="night"] { --hb-strength: 0.18; }
:root[data-theme="dark"] .homebg__grain { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .homebg { --hb-strength: 0.24; --hb-grain: 0.06; --hb-dot: color-mix(in srgb, var(--ink) 9%, transparent); }
  :root[data-theme="system"] .homebg[data-daypart="night"] { --hb-strength: 0.18; }
  :root[data-theme="system"] .homebg__grain { mix-blend-mode: screen; }
}
:root[data-theme="paper"] .homebg { --hb-strength: 0.1; --hb-grain: 0.07; }
/* The top bar lets the aura through instead of laying a band over it. */
body.route-home .topbar { background: color-mix(in srgb, var(--canvas) 70%, transparent); border-bottom-color: transparent; }
@media (max-width: 899.98px) {
  /* On phones the bar spans the page and cards scroll under it: blur them so their text doesn't show
     through the buttons (design.css turns the usual blur off for the phone shell). */
  body.route-home .topbar { -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); }
  .homebg__light { width: 520px; height: 420px; top: -220px; }
  .homebg__light--a { left: calc(50% - 420px); }
  .homebg__light--b { left: calc(50% - 60px); }
}
@media (prefers-reduced-motion: reduce) { .homebg__light { animation: none; } }

/* The greeting's small sun or moon, in the hour's own hue: the same clock the aura follows. */
.home__date { display: flex; align-items: center; gap: 6px; }
.home__daymark { display: inline-grid; color: var(--hb-mark, var(--ink-faint)); }
.home__daymark[data-daypart="morning"] { --hb-mark: #C8641E; }
.home__daymark[data-daypart="day"]     { --hb-mark: #2C5CD6; }
.home__daymark[data-daypart="evening"] { --hb-mark: #6A45E8; }
.home__daymark[data-daypart="night"]   { --hb-mark: #5B6BD8; }
:root[data-theme="dark"] .home__daymark { filter: brightness(1.45); }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .home__daymark { filter: brightness(1.45); } }
.home__title h1 { letter-spacing: -0.015em; }

/* ---- "Välj": picking sets to delete (menu.js select mode) ----
   Picking is a calm, everyday act, so it is drawn in the brand blue: a picked card gets a blue edge, a
   light blue wash and a filled check. Red is kept for the one destructive button. The actions live in a
   floating bar at the bottom of the screen (dark in light mode, light in dark mode), within reach however
   far down the list you are; it slides up when select mode opens. */
.selecttoggle[aria-pressed="true"] { background: var(--brand-tint); border-color: transparent; color: var(--brand-ink); }

.acard__check {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: #fff;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
  pointer-events: none;   /* only a mark: a tap on it goes through to the card's button underneath */
}
.acard__check svg { width: 14px; height: 14px; stroke-width: 3; }
/* Picking is instant and still: no lift on hover (it jumped under the pointer and stuck after a tap on a
   phone), no grey tap flash, no double-tap-zoom wait. */
.grid.is-selecting .acard {
  user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: box-shadow var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.grid.is-selecting .acard:active { transform: none; }
@media (hover: hover) { .grid.is-selecting .acard:hover { transform: none; } }
.grid.is-selecting .acard:hover .acard__go { transform: none; }
.grid.is-selecting .acard:hover .acard__check { border-color: var(--brand); }
.acard.is-picked {
  background: color-mix(in oklab, var(--brand) 7%, var(--surface));
  border-color: color-mix(in oklab, var(--brand) 55%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--brand) 55%, transparent), var(--shadow-1);
}
.acard.is-picked .acard__check { background: var(--brand); border-color: var(--brand); }
/* Room under the last card, so the floating bar never sits on it. */
.grid.is-selecting { padding-bottom: 84px; }

.selectbar {
  --sb-bg: color-mix(in srgb, var(--ink) 94%, var(--brand));
  --sb-fg: var(--canvas);
  --sb-soft: color-mix(in srgb, var(--canvas) 68%, transparent);
  position: fixed; z-index: 40; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 6px 6px 6px 18px; border-radius: var(--r-full);
  background: var(--sb-bg); color: var(--sb-fg);
  box-shadow: 0 12px 32px -8px rgba(10, 14, 30, .45), 0 2px 6px rgba(10, 14, 30, .2);
  animation: selectbar-in .22s cubic-bezier(.2, .8, .2, 1);
}
.selectbar[hidden] { display: none; }
@keyframes selectbar-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.selectbar__info { display: inline-flex; align-items: center; gap: 8px; margin-right: 10px; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.selectbar__info .selectbar__n { color: var(--sb-soft); font-weight: 500; }
.selectbar.has-picks .selectbar__info .selectbar__n { color: var(--sb-fg); font-weight: 600; }
.selectbar__num {
  min-width: 26px; height: 26px; padding: 0 7px; border-radius: var(--r-full); display: inline-grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.selectbar__num[hidden] { display: none; }
.selectbar__all, .selectbar__del {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 0; border-radius: var(--r-full);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast), opacity var(--dur-fast);
}
.selectbar__all { background: transparent; color: var(--sb-fg); }
@media (hover: hover) { .selectbar__all:hover { background: color-mix(in srgb, var(--sb-fg) 12%, transparent); } }
.selectbar__del { background: var(--c-berry-ink); color: #fff; padding: 0 16px 0 14px; }
@media (hover: hover) { .selectbar__del:hover:not(:disabled) { background: color-mix(in srgb, var(--c-berry-ink) 86%, #000); } }
.selectbar__del:disabled { opacity: .4; cursor: default; }
.selectbar :is(button):focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 2px; }
/* Desktop: centred under the content column, not under the whole window (the sidebar takes the left). */
@media (min-width: 900px) { .selectbar { left: calc(50% + 126px); } }
/* Phone: a full-width pill just above the tab bar. */
@media (max-width: 899.98px) {
  .selectbar { width: calc(100vw - 24px); bottom: calc(72px + env(safe-area-inset-bottom, 0px)); padding-left: 16px; }
  .selectbar__info { margin-right: auto; }
}
@media (max-width: 620px) {
  .grid > .acard .acard__check { grid-area: menu; position: static; justify-self: center; align-self: center; }
}
@media (prefers-reduced-motion: reduce) { .selectbar { animation: none; } }
/* The floating chat bubble would sit on the bar's corner: it steps aside while sets are being picked. */
body:has(.selectbar:not([hidden])) .sitechat__fab { display: none; }

/* ---- Keyboard focus is never hidden under the bars (WCAG 2.4.11) ----
   When Tab moves to a control the browser scrolls it into view; without this it could stop with the
   control under the sticky top bar or, on a phone, under the tab bar at the bottom. A screen with a
   taller bar of its own (the edit bar) keeps its larger value: html:has(.editbar) above. */
html { scroll-padding-top: 80px; }
@media (max-width: 899.98px) { html { scroll-padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); } }

/* ---- Dark mode: readable placeholders and the "+" number on results ----
   Placeholder text left to the browser default was 3.9:1 on the dark fields; the theme's own faint ink
   is 7:1. The results page's improvement number used the light theme's dark green (3.4:1); the dark
   theme has a light green for text. */
:root[data-theme="dark"] :where(input, textarea)::placeholder { color: var(--ink-faint); opacity: 1; }
:root[data-theme="dark"] .delta__n.up { color: var(--ok-ink); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] :where(input, textarea)::placeholder { color: var(--ink-faint); opacity: 1; }
  :root[data-theme="system"] .delta__n.up { color: var(--ok-ink); }
}
/* The eye button on password fields in dialogs and the welcome card (components/password-field.js). */
.welcome__acct-fields .pwfield { min-width: 0; }
.welcome__acct-fields .pwfield input { width: 100%; box-sizing: border-box; }

/* ---- "Before you use the AI features" (components/ai-consent.js) ---- */
.aiconsent .confirmdlg__card { max-width: 440px; }
.aiconsent .confirmdlg__body { font-family: inherit; font-weight: 400; font-size: var(--fs-md); line-height: 1.5; color: var(--ink-soft); }
.aiconsent__list { margin: var(--s-3) 0 0; padding-left: 1.2em; display: grid; gap: 6px; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink); }
.aiconsent__note { margin: var(--s-3) 0 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-soft); }

/* ---- "Rapportera" under an AI answer, and its dialog (components/ai-report.js) ---- */
.aireport {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border: 0; border-radius: var(--r-full);
  background: transparent; color: var(--ink-faint); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
@media (hover: hover) { .aireport:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); } }
.aireport:disabled { cursor: default; color: var(--ok-ink); }
.msg__acts { display: flex; justify-content: flex-start; margin: -2px 0 4px; }
.tutor .msg__acts { align-self: flex-start; }
.aireportdlg .confirmdlg__card { max-width: 440px; display: grid; gap: var(--s-3); }
.aireportdlg__title { margin: 0; font-size: var(--fs-lg); line-height: 1.3; text-wrap: balance; }
.aireportdlg__reasons { margin: 0; padding: 0; border: 0; display: grid; gap: 8px; }
.aireportdlg__reasons legend { margin-bottom: 6px; padding: 0; font-weight: 600; color: var(--ink); }
.aireportdlg__choice { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.aireportdlg__choice:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.aireportdlg__choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.aireportdlg__note textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }
.aireportdlg__privacy { margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); line-height: 1.45; }
.aireportdlg .confirmdlg__actions { margin-top: var(--s-2); }
@media (max-width: 620px) {
  .aireportdlg .confirmdlg__actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .aireportdlg .confirmdlg__actions .btn { justify-content: center; min-height: 48px; }
  .aireportdlg .confirmdlg__actions .btn:not(.btn--ghost) { order: -1; }
}
/* #/admin/ai-reports */
.admin-aireport { display: grid; gap: 10px; }
.admin-aireport__meta { margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.admin-aireport__tag--harmful { background: var(--retry-tint); color: var(--retry-ink); }
.admin-aireport__label { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.admin-aireport__text { margin: 0; padding: 10px 14px; border-left: 3px solid var(--line-strong); background: var(--surface-sunk); white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); line-height: 1.5; }

/* ---- "Sign in with Apple" (components/apple-signin.js): Apple's look - black in light mode, white in dark,
   the logo and Apple's wording - the same height and pill shape as Google's button above it. ---- */
.auth__apple { display: flex; justify-content: center; margin-top: 10px; }
.auth__apple[hidden] { display: none; }
.applebtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 360px; height: 40px; padding: 0 16px; border: 1px solid #000; border-radius: 999px;
  background: #000; color: #fff; font: 500 15px/1 -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  letter-spacing: .01em; cursor: pointer;
}
@media (hover: hover) { .applebtn:hover:not(:disabled) { background: #1d1d1f; } }
.applebtn:disabled { opacity: .6; cursor: default; }
.applebtn:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.applebtn__logo { display: inline-grid; margin-top: -2px; }
:root[data-theme="dark"] .applebtn { background: #fff; color: #000; border-color: #fff; }
@media (hover: hover) { :root[data-theme="dark"] .applebtn:hover:not(:disabled) { background: #f2f2f7; } }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .applebtn { background: #fff; color: #000; border-color: #fff; }
  @media (hover: hover) { :root[data-theme="system"] .applebtn:hover:not(:disabled) { background: #f2f2f7; } }
}

/* ---------- feedback: Tyck till (#/feedback, the help panel's second tab, the card after a session, #/admin/feedback) ---------- */
.fbbtn { text-decoration: none; color: var(--ink-soft); }
.fbbtn.is-active { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-ink); }
.fbbtn__label { display: none; }
@media (max-width: 639px) { .fbbtn { display: none; } }   /* a phone's top bar is full: it is in the Meny tab instead */
@media (min-width: 1100px) {
  .fbbtn { width: auto; gap: 6px; padding: 0 12px; color: var(--ink); }
  .fbbtn__label { display: inline; font-size: calc(13px * var(--fs-scale, 1)); font-weight: 700; }
}

.fbpage { max-width: 680px; }
.fb-lead { margin: 0 0 var(--s-4); color: var(--ink-soft); }
.fb-hint { margin: 0 0 var(--s-3); color: var(--ink-soft); font-size: var(--fs-sm); }
.fb-block { margin-bottom: var(--s-4); }
.fb-label { margin: 0 0 var(--s-2); font-weight: 700; font-size: var(--fs-sm); }
.fb-form { display: grid; gap: 0; }
.fb-faces { display: flex; gap: var(--s-2); flex-wrap: wrap; }
/* Each face in its mood's colour, red to green (the same neon hues as the library's subjects), in the
   site's subtle neon: a tinted edge and face at rest, the full colour with a soft glow when picked. */
.fb-face {
  --mood: var(--brand);
  display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border-radius: var(--r-full);
  border: 1px solid var(--line-strong); border-color: color-mix(in srgb, var(--mood) 45%, var(--line-strong));
  background: var(--surface); color: var(--ink-soft); color: color-mix(in srgb, var(--mood) 70%, var(--ink));
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}
.fb-face--1 { --mood: #F0484E; }
.fb-face--2 { --mood: #FF7426; }
.fb-face--3 { --mood: #F5B82E; }
.fb-face--4 { --mood: #74B816; }
.fb-face--5 { --mood: #22A35A; }
@media (hover: hover) { .fb-face:hover { border-color: var(--mood); transform: translateY(-1px); } }
.fb-face[aria-pressed="true"] {
  background: color-mix(in oklab, var(--mood) 14%, var(--surface)); border: 1.5px solid var(--mood);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mood) 25%, transparent), 0 0 14px -4px color-mix(in srgb, var(--mood) 60%, transparent);
}
.fb-face:focus-visible, .fb-kind:focus-visible, .fb-tab:focus-visible, .fb-filter:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fb-kinds { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.fb-kind {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; font: inherit; font-weight: 600;
  font-size: var(--fs-sm); color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); cursor: pointer;
}
@media (hover: hover) { .fb-kind:hover { border-color: var(--brand); } }
.fb-kind[aria-pressed="true"] { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-ink); }
.fb-text {
  width: 100%; min-height: 84px; font: inherit; font-size: var(--fs-sm); padding: 10px 12px; resize: vertical;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-sunk); color: var(--ink);
}
.fb-text:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.fb-meta { display: flex; justify-content: space-between; gap: var(--s-2); margin: 6px 0 var(--s-3); font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
/* Screenshots (components/feedback-form.js): "Lägg till bild" with a line beside it, then the pictures as
   thumbnails, each with a round remove button. Also the thumbnails under "Dina förslag" and in the inbox. */
.fb-shots { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.fb-shots__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-3); }
.fb-shots__hint, .fb-shots__busy { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-faint); }
.fb-shots__busy:empty { display: none; }
.fb-shots__list { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.fb-shots__list[hidden] { display: none; }
.fb-shot {
  position: relative; margin: 0; width: 92px; height: 72px; display: grid; place-items: center; overflow: hidden;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-sunk);
}
.fb-shot img { width: 100%; height: 100%; object-fit: cover; display: block; font-size: 12px; color: var(--ink-faint); }   /* small alt text if one can't load */
a.fb-shot { text-decoration: none; }
@media (hover: hover) { a.fb-shot:hover { border-color: var(--brand); } }
a.fb-shot:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fb-shot .note { font-size: 12px; text-align: center; padding: 4px; }
.fb-shot__x {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: var(--r-full); background: rgba(10, 12, 17, .72); color: #fff; cursor: pointer;
}
@media (hover: hover) { .fb-shot__x:hover { background: rgba(10, 12, 17, .9); } }
.fb-shot__x:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
/* A picture dragged over the form: the whole form says it will take it. */
.fb-form.is-dropping { outline: 2px dashed var(--brand); outline-offset: 6px; border-radius: var(--r-sm); }
.fb-check { display: flex; align-items: flex-start; gap: var(--s-3); margin: 0 0 var(--s-4); font-size: var(--fs-sm); }
.fb-check input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; }
.fb-check small { display: block; color: var(--ink-faint); font-size: calc(12.5px * var(--fs-scale, 1)); }
.fb-done { text-align: center; padding: var(--s-5) var(--s-3); display: grid; justify-items: center; gap: var(--s-2); }
.fb-done > svg { color: var(--ok); }
.fb-done h3 { margin: 0; }
.fb-done p { margin: 0 0 var(--s-2); color: var(--ink-soft); font-size: var(--fs-sm); }
.fb-done[hidden], .fb-form[hidden] { display: none; }
.fb-signedout { display: grid; gap: var(--s-3); }
.fb-signedout p { margin: 0; }
.fb-signedout__row { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.fb-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--s-4); }
.fb-tab {
  font: inherit; font-weight: 700; font-size: var(--fs-sm); padding: 10px 14px; margin-bottom: -1px; cursor: pointer;
  border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-soft);
}
@media (hover: hover) { .fb-tab:hover { color: var(--ink); } }
.fb-tab[aria-selected="true"] { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* the help panel's two tabs */
.sitechat__panel > .fb-tabs { margin-bottom: 0; padding: 0 var(--s-3); flex: none; }
.sitechat__panel.is-fb > .sitechat__log, .sitechat__panel.is-fb > .sitechat__form, .sitechat__panel.is-fb > .sitechat__fine { display: none; }
.sitechat__fb { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-4); }
.sitechat__fb[hidden] { display: none; }
.sitechat__fb .fb-kind { padding: 8px 2px; }
.sitechat__fb .fb-text { min-height: 64px; }

/* the student's own list */
.fb-list { display: grid; gap: var(--s-3); margin-top: var(--s-3); }
.fb-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); display: grid; gap: var(--s-2); }
.fb-item__head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.fb-item__head .note { margin-left: auto; }
.fb-item__msg { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-badge { display: inline-block; font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; padding: 2px 10px; border-radius: var(--r-full); background: var(--surface-sunk); color: var(--ink-soft); }
.fb-badge--seen { background: var(--info-tint); color: var(--info); }
.fb-badge--planned { background: var(--retry-tint); color: var(--retry-ink); }
.fb-badge--done { background: var(--ok-tint); color: var(--ok-ink); }
.fb-badge--declined { color: var(--ink-faint); }
.fb-reply { background: var(--brand-tint); border-radius: var(--r-sm); padding: 9px 12px; font-size: var(--fs-sm); }
.fb-reply strong { display: block; color: var(--brand-ink); font-size: calc(12px * var(--fs-scale, 1)); }
.fb-reply p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-moodtag, .fb-kindtag { display: inline-flex; align-items: center; gap: 4px; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-soft); }
.fb-kindtag { font-weight: 700; color: var(--ink); }
/* The signed-out page's preview (views/feedback.js feedbackPreview): smaller faces that only show, and the sent idea. */
.fbprev__faces { display: flex; gap: 6px; pointer-events: none; }
.fbprev__faces .fb-face { width: 36px; height: 36px; }
.fbprev__kind svg { color: var(--c-tangerine, var(--retry)); }
.fbprev__msg { margin: 0; font-weight: 500; color: var(--ink); }

/* the card under the score after a session */
.fb-after { max-width: 460px; margin: var(--s-4) auto; text-align: center; padding: var(--s-4) var(--s-5); }
.fb-after h3 { margin: 0; }
.fb-after__sub { margin: 4px 0 var(--s-3); color: var(--ink-faint); font-size: calc(13px * var(--fs-scale, 1)); }
.fb-after .fb-faces { justify-content: center; }
.fb-after .fb-face { width: 48px; height: 48px; }
.fb-after__skip { margin-top: var(--s-2); border: 0; background: none; font: inherit; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-faint); cursor: pointer; }
@media (hover: hover) { .fb-after__skip:hover { color: var(--ink); } }
.fb-after .fb-text { text-align: left; }
.fb-after__row { display: flex; gap: var(--s-2); justify-content: center; margin-top: var(--s-2); }
.fb-after__thanks { display: grid; justify-items: center; gap: 4px; color: var(--ok); }
.fb-after [hidden] { display: none; }

/* the inbox */
.fbadmin { max-width: 860px; }
.fb-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); }
.fb-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); }
.fb-stat b { display: block; font-size: calc(26px * var(--fs-scale, 1)); line-height: 1.1; }
.fb-stat span { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); }
.fb-bars { display: flex; align-items: flex-end; gap: 6px; height: 40px; margin-top: var(--s-2); }
.fb-bars i { flex: 1; background: var(--brand); border-radius: 3px; }
.fb-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fb-filter { font: inherit; font-weight: 700; font-size: calc(13px * var(--fs-scale, 1)); padding: 5px 12px; border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.fb-filter[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.fb-filters__sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.fb-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fb-actions .linkbtn { margin-left: auto; }
.fb-replybox { display: grid; gap: 4px; }
.fb-replybox[hidden] { display: none; }
@media (max-width: 640px) {
  .fb-kinds { grid-template-columns: repeat(2, 1fr); }
  .fb-stats { grid-template-columns: repeat(2, 1fr); }
}

/* A phone turned on its side: under 500px of height the top bar, the AI page's tab bar and a session's
   options took half the screen (177px were left for the conversation on a 375px-high phone). The AI page
   drops the tab bar there (the top bar still leads home) and its greeting moves up, the top bar slims, and a session's options
   sit two by two so all four show above its button bar. */
@media (max-height: 500px) and (max-width: 1100px) {
  body.route-chat .tabbar { display: none; }
  body.route-chat .solve-dock, body.route-chat .solve-gate { bottom: calc(var(--s-2) + env(safe-area-inset-bottom, 0px)); }
  body.route-chat .shell:not(.shell--immersive) .content { padding-bottom: calc(var(--s-2) + env(safe-area-inset-bottom, 0px)); }
  .topbar__inner { padding-block: 6px; }
  /* The greeting starts right under the head, without the back link, the tile or the space around it. */
  .solve > .homebtn, .solve-hero__mark { display: none; }
  .solve-chat { min-height: 0; }
  .solve-hero { margin-block: 0; padding-top: var(--s-3); }
  .session .choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
}

/* The HP page's own set list (#/hp): the only place the högskoleprov sets are listed. */
.hp-sets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
@media (max-width: 640px) { .hp-sets { grid-template-columns: minmax(0, 1fr); } }
.hp-set {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: var(--s-3) var(--s-4); text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
@media (hover: hover) { .hp-set:hover { border-color: var(--c); } }
.hp-set:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.hp-set__title { font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.hp-set__meta { font-size: calc(12.5px * var(--fs-scale, 1)); color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Troféer: the compact track rows, two across on a wide screen. */
.achgrid { display: grid; gap: var(--s-3); }
@media (min-width: 900px) { .achgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Framsteg: the detail folds under each card; trophies are one line that leads to their page. */
.pg-fold { margin-top: var(--s-2); }
.pg-fold > summary { padding: var(--s-3) 0; }
.pg-fold[open] > summary { margin-bottom: var(--s-2); }
.pg-subhead { margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-base, 15px); }
.pg-linkrow {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  color: var(--ink); text-decoration: none;
}
.pg-linkrow__text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pg-linkrow__text small { font-size: var(--fs-sm); color: var(--ink-faint); }
.pg-linkrow > svg { color: var(--ink-faint); flex: none; }
@media (hover: hover) { .pg-linkrow:hover { border-color: var(--line-strong, var(--line)); } }

/* Högskoleprovet before the first result: the one thing to do, the date and the other modes one tap away. */
.hp-hero__score--first { display: grid; gap: var(--s-2); justify-items: start; }
.hp-hero__score--first .hp-hero__hint { margin: 0; }
.hp-hero__date--none .linkbtn { display: inline-flex; align-items: center; gap: 6px; }
.hp-hero__more { margin-top: var(--s-2); }
.hp-hero__more > .hp-hero__next { padding-bottom: var(--s-3); }
.hp-tile__status.is-none { display: none; }

/* ---------- Dagens repetition: today's review as a round per subject (views/review-rounds.js) ---------- */
.rv { max-width: 640px; margin: 0 auto; padding: var(--s-6, 32px) 0; display: grid; gap: 14px; }
.rv__kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.rv__title { margin: 0; font-size: 28px; letter-spacing: -.015em; }
.rv__focus { margin: 0; justify-self: start; padding: 8px 12px; border-radius: 12px; font-size: 14px; background: var(--c-leaf-tint); color: var(--ink); }
.rv__rounds { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.rv-round { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.rv-round:hover { border-color: var(--c); }
.rv-round:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.rv-round__dot { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }
.rv-round__main b { display: block; font-size: 16px; }
.rv-round__main small { display: block; font-size: 13px; color: var(--ink-faint); }
.rv-round__go { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; color: var(--brand-ink, var(--brand)); }
.rv__actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 6px; }
.rv__done { font-size: 14px; color: var(--ink-soft); }

/* ---------- Contrast on coloured fills in the darker or warmer themes ----------
   The dark theme's fills are lighter (pastel) than the light theme's, so white on them drops to 2-2.5:1: an
   unlocked medal, a category icon, a streak at risk and the weak-spots tile take the dark ink there. The paper
   theme's green on cream read at 3.9:1 for "+75"; its darker green ink passes. */
:root[data-theme="dark"] :is(.streakbadge--risk, .tile--weak .tile__icon, .achmedal--unlocked .achmedal__icon, .ach-hero__icon) { color: var(--ink-on-color); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] :is(.streakbadge--risk, .tile--weak .tile__icon, .achmedal--unlocked .achmedal__icon, .ach-hero__icon) { color: var(--ink-on-color); }
}
:root[data-theme="paper"] .delta__n.up { color: var(--ok-ink); }

/* ---------- Home: the focus card (components/focus-card.js) ----------
   A slim bar between the shortcuts and the sets: one suggestion at a time, best first, with arrows to the
   next. The icon chip and the top edge take the suggestion's colour (a subject's, or a token), like the set
   cards under it; the icon itself is white on the stronger fill. */
.focuscard {
  display: flex; align-items: center; gap: 16px; padding: 16px 16px 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: var(--r-md);
  box-shadow: var(--shadow-card, none);
}
.focuscard__icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--c); color: #fff; }
.focuscard__text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.focuscard__kicker { font-size: calc(12px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); line-height: 1.2; }
.focuscard__line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.focuscard h2 {
  flex: 0 1 auto; min-width: 0; margin: 0; font-size: calc(16px * var(--fs-scale, 1)); line-height: 1.3; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.focuscard__why { flex: 0 100 auto; min-width: 0; color: var(--ink-soft); font-size: calc(14px * var(--fs-scale, 1)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focuscard__go { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.focuscard__nav { flex: none; display: flex; align-items: center; gap: 8px; }
.focuscard__step {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
}
.focuscard__step:disabled { opacity: .35; cursor: default; }
.focuscard__step:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (hover: hover) { .focuscard__step:not(:disabled):hover { border-color: var(--ink-faint); } }
.focuscard__pips { display: flex; gap: 5px; }
.focuscard__pips i { width: 6px; height: 6px; border-radius: 3px; background: var(--line-strong); transition: width var(--dur-fast, .15s); }
.focuscard__pips i.is-on { width: 16px; background: var(--c); }
/* Phones: the title may take two lines and the reason goes under it; the button and arrows share a row below. */
@media (max-width: 600px) {
  .focuscard { flex-wrap: wrap; row-gap: 10px; padding: 12px; }
  .focuscard__text { flex-basis: calc(100% - 60px); }
  .focuscard__line { display: grid; gap: 1px; }
  .focuscard h2 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .focuscard__nav { margin-left: auto; }
}

/* Live-quiz: the teacher's panel on a class page, the join card on Klasser, and the screen a student plays on. */
.liveform { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-3); align-items: end; }
.liveform__field { display: grid; gap: 4px; font-size: calc(13px * var(--fs-scale, 1)); color: var(--ink-soft); }
.liveform__field select { width: 100%; }
.livebox { display: grid; gap: var(--s-3); margin-top: var(--s-3); }
.livebox h4 { margin: var(--s-2) 0 0; }
.livebox__code { display: flex; align-items: baseline; gap: var(--s-3); }
.livebox__digits { font-size: calc(44px * var(--fs-scale, 1)); font-weight: 700; letter-spacing: .18em; font-variant-numeric: tabular-nums; line-height: 1; }
.liveboard { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.liveboard li { display: flex; justify-content: space-between; gap: var(--s-3); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md, 10px); background: var(--surface); }
.liveboard li.is-you { border-color: var(--brand); background: var(--brand-tint); }
.liveboard__nick { font-weight: 600; overflow-wrap: anywhere; }
.liveboard__score { color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.liveboard__me { margin: 8px 0 0; font-size: calc(14px * var(--fs-scale, 1)); color: var(--ink-soft); }
.liveboardcard { margin-top: var(--s-4); padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.liveboardcard h4 { margin: 0 0 8px; }
.livenicks ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.livenicks li { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.livequestions { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s-3); }
.livequestions__q { font-weight: 600; overflow-wrap: anywhere; }
.livejoin { display: grid; gap: var(--s-3); }
.livelist { display: grid; gap: var(--s-2); }
.livelist__item { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md, 10px); }
.livejoin__form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-2); align-items: center; }
.livegame { display: grid; gap: var(--s-3); }
.livegame__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.livegame__stats { display: flex; gap: var(--s-3); align-items: center; font-variant-numeric: tabular-nums; font-size: calc(14px * var(--fs-scale, 1)); color: var(--ink-soft); }
