/* Member app layout (after welly-design/ui_kits/app). Phones: top bar, content, fixed tab bar.
   From 768px: a sidebar replaces the tab bar and the content gets a grid. Tokens only. */

html, body { min-height: 100%; }
body { background: var(--surface-page); color: var(--text-primary); }

/* One logo per theme. Both <img>s are in the markup; exactly one may be displayed. Never set
   `display` on these images elsewhere (a more specific rule would show both and double the
   gold mark) - the !important makes sure. */
img.ap-logo-dark { display: none !important; }
[data-theme="dark"] img.ap-logo-light { display: none !important; }
[data-theme="dark"] img.ap-logo-dark { display: block !important; }
/* a reseller's sidebar colour (data-side-bg on .ap-side and .ap-top, layouts/shell.html.twig) decides their logo in both themes */
.ap-side[data-side-bg="dark"] img.ap-logo-light, .ap-side[data-side-bg="light"] img.ap-logo-dark,
.ap-top[data-side-bg="dark"] img.ap-logo-light, .ap-top[data-side-bg="light"] img.ap-logo-dark { display: none !important; }
.ap-side[data-side-bg="dark"] img.ap-logo-dark, .ap-side[data-side-bg="light"] img.ap-logo-light,
.ap-top[data-side-bg="dark"] img.ap-logo-dark, .ap-top[data-side-bg="light"] img.ap-logo-light { display: block !important; }

.ap-eyebrow { margin: 0; font: var(--type-eyebrow); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
.ap-eyebrow-gold { color: var(--gold-300); }

/* ---------- login ---------- */
.ap-login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-8); padding: calc(var(--space-10) + env(safe-area-inset-top)) var(--gutter-mobile) calc(var(--space-8) + env(safe-area-inset-bottom)); }
.ap-login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--space-8); }
.ap-login-hero { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; }
.ap-login-hero img { width: var(--space-12); height: auto; }
/* a reseller's logo is any shape: fit it to the height instead (sizes only - see the logo rule above) */
.ap-login-brand img { width: auto; max-width: 100%; height: var(--space-10); object-fit: contain; }
.ap-login-hero p { margin: 0; font: var(--type-body); color: var(--text-secondary); }
.ap-login-hero h1 { margin: 0; font: var(--type-h1); letter-spacing: var(--tracking-tight); color: var(--text-primary); }
.ap-wordmark { font: var(--type-wordmark); font-size: var(--text-2xl); letter-spacing: var(--tracking-wordmark); color: var(--text-primary); }
.ap-login-form { display: flex; flex-direction: column; gap: var(--space-4); }
.ap-login-foot { margin: var(--space-2) 0 0; text-align: center; font: var(--type-caption); color: var(--text-secondary); line-height: var(--leading-normal); }
/* links in running text are underlined: colour alone does not set them apart (WCAG 1.4.1) */
.ap-login-foot a { text-decoration: underline; text-underline-offset: 3px; }
.ap-login-theme { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.ap-login-card > .wl-alert[data-tone="info"] { background: var(--info-soft); color: var(--info-fg); }

/* "Continue with Vipps": Vipps MobilePay's brand button, the one exception to "tokens only".
   Orange and white in both themes, as the Vipps brand guidelines require. */
/* the Vipps colours: the brand exception to tokens only, wherever a Vipps button is (login, profile) */
.ap-login-card, .ap-vipps-inline, .ap-pay-vipps { --vipps-orange: #ff5b24; --vipps-orange-dark: #db460f; --vipps-on-orange: #fff; }
.ap-vipps-btn { display: flex; align-items: center; justify-content: center; gap: var(--space-2); width: 100%;
  height: var(--control-h-lg); padding: 0 var(--space-6); border-radius: var(--radius-pill);
  background: var(--vipps-orange); color: var(--vipps-on-orange);
  /* white on Vipps orange is 3.1:1, enough only for large text (WCAG 1.4.3: 3:1 at 18.66px bold),
     so the label is bold and just over that size, at every text step */
  font: var(--weight-bold) calc(1.1875rem * var(--text-scale))/1 var(--font-body);
  text-decoration: none; transition: var(--transition-color), transform var(--dur-fast) var(--ease-standard); }
.ap-vipps-btn:hover, .ap-vipps-btn:active { background: var(--vipps-orange-dark); color: var(--vipps-on-orange); text-decoration: none; }
.ap-vipps-btn:active { transform: scale(var(--press-scale)); }
.ap-vipps-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ap-vipps-logo { width: auto; height: 1.15em; margin-top: .2em; }

/* "or" between the Vipps button and the password form */
.ap-login-or { display: flex; align-items: center; gap: var(--space-4); font: var(--type-caption); color: var(--text-secondary); }
.ap-login-or::before, .ap-login-or::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }
@media (min-width: 768px) {
  .ap-login { background: var(--surface-sunken); }
  .ap-login-card { max-width: 440px; padding: var(--space-10); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--surface-card); }
}

/* ---------- shell ---------- */
/* the top bar's height: installed on a phone the page runs under the status bar, and the top bar grows by
   the safe area. Heights worked out from the screen's must take this, not --nav-h alone, or the page is
   that much too tall and scrolls under the tab bar */
:root { --top-h: calc(var(--nav-h) + env(safe-area-inset-top)); }
.ap-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
/* Installed on a phone (data-installed and --app-h, the screen's height, from base.html.twig) iOS lays out a
   page that cannot scroll as if the screen ended env(safe-area-inset-top) higher, about 60 pt, and corrects
   it after the first paint: the tab bar's bottom: 0 and 100dvh came out short and the bar slid down. The
   tab bar and the full-height pages take the screen's height instead, the bar placed from the top. */
:root { --app-h: 100vh; }
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }
:root[data-installed] .ap-shell { min-height: var(--app-h); }
.ap-side { display: none; }

/* a reseller's sidebar colour, on the sidebar and the phone's top bar: the same in both themes; text,
   hover and borders mixed from it (the colours are set in layouts/base.html.twig) */
.ap-side[data-side-bg], .ap-top[data-side-bg] { color: var(--text-primary);
  --text-primary: var(--side-fg); --text-secondary: color-mix(in oklch, var(--side-fg) 72%, var(--side-bg)); --text-muted: color-mix(in oklch, var(--side-fg) 50%, var(--side-bg));
  --surface-card: color-mix(in oklch, var(--side-fg) 10%, var(--side-bg)); --surface-sunken: color-mix(in oklch, var(--side-fg) 6%, var(--side-bg));
  --border-subtle: color-mix(in oklch, var(--side-fg) 14%, var(--side-bg)); --border-strong: color-mix(in oklch, var(--side-fg) 24%, var(--side-bg));
  --surface-inverse: var(--side-fg); --text-inverse: var(--side-bg); }
/* the accent marks the current page: a lighter step on a dark sidebar, a darker one on a light sidebar */
.ap-side[data-side-bg="dark"], .ap-top[data-side-bg="dark"] { --accent: var(--gold-300); }
.ap-side[data-side-bg="light"], .ap-top[data-side-bg="light"] { --accent: var(--gold-700); }

/* installed on a phone the page runs under the status bar: the top bar grows by the safe area.
   It has the sidebar's background, Welly's or the reseller's. */
.ap-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  height: var(--top-h); padding: env(safe-area-inset-top) var(--space-2) 0 var(--gutter-mobile);
  background: var(--surface-sunken); border-bottom: 1px solid var(--border-subtle); }
.ap-top[data-side-bg] { background: var(--side-bg); }
.ap-top-logo img { height: var(--space-5); width: auto; }
.ap-top-right { display: flex; align-items: center; gap: 0; }
.ap-top-right form { margin: 0; }
/* the help button while the manual is open */
.ap-top-right .wl-ibtn[aria-current="page"], .ap-side-actions .wl-ibtn[aria-current="page"] { color: var(--accent); }
.ap-top-right [data-display-toggle][aria-expanded="true"] { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--border-subtle); }

/* the display panel under the top bar: theme and text size, a labelled row each (app.js opens it) */
.ap-display { position: absolute; top: calc(100% + var(--space-2)); right: var(--space-2); z-index: 20; display: flex; flex-direction: column;
  gap: var(--space-3); min-width: calc(var(--space-16) * 4 - var(--space-4)); max-width: calc(100vw - var(--space-4)); padding: var(--space-4);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--surface-raised); box-shadow: var(--shadow-lg);
  color: var(--text-primary); }
.ap-display-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); font: var(--type-label); }

.ap-main { flex: 1; padding-bottom: calc(var(--tabbar-h) + var(--space-6) + env(safe-area-inset-bottom)); }
.ap-page { max-width: 640px; margin: 0 auto; padding: var(--space-5) var(--gutter-mobile); display: flex; flex-direction: column; gap: var(--space-5); }

/* tab bar (phones) */
.ap-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in oklch, var(--surface-page) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle); }
:root[data-installed] .ap-tabbar { top: var(--app-h); bottom: auto; transform: translateY(-100%); }
.ap-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); padding: var(--space-1) 2px;
  color: var(--text-muted); font: var(--type-caption); font-weight: var(--weight-medium); text-align: center; line-height: 1.2;
  text-decoration: none; transition: var(--transition-color); }
/* with larger text the labels stop at about 117 % and may wrap; the bar grows, and so does the room kept for it */
.ap-tab > span:not(.wl-visually-hidden) { font-size: min(var(--text-xs), .875rem); overflow-wrap: break-word; }
:root[data-text-size] .ap-main { padding-bottom: calc(var(--tabbar-h) + var(--space-12) + env(safe-area-inset-bottom)); }
.ap-tab:hover { color: var(--text-primary); text-decoration: none; }
.ap-tab[aria-current="page"] { color: var(--text-primary); }
.ap-tab[aria-current="page"] .wl-icon { color: var(--accent); }
.ap-tab[aria-disabled="true"] { opacity: .45; }
.ap-tab:focus-visible { outline: 3px solid var(--focus-color); outline-offset: -3px; box-shadow: none; }

/* ---------- home ---------- */
.ap-greet { display: flex; flex-direction: column; gap: var(--space-1); }
.ap-greet h1 { margin: 0; font: var(--type-h1); font-size: var(--text-2xl); letter-spacing: var(--tracking-tight); }
.ap-grid { display: flex; flex-direction: column; gap: var(--space-5); }
.ap-course { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-6); }
.ap-course h2 { margin: 0; font: var(--type-h2); letter-spacing: var(--tracking-tight); }
.ap-course p:last-child { margin: 0; font: var(--type-body); color: var(--grey-400); }
[data-theme="dark"] .ap-course p:last-child { color: var(--grey-600); }
[data-theme="dark"] .ap-course .ap-eyebrow-gold { color: var(--gold-700); } /* the card is white in dark mode */
.ap-section-title { margin: 0 0 var(--space-3); font: var(--type-h3); }
.ap-steps { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.ap-step { display: flex; gap: var(--space-4); padding: var(--space-4); }
.ap-step-icon { flex: none; display: grid; place-items: center; width: var(--touch-min); height: var(--touch-min); border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-soft-fg); }
.ap-step h3 { margin: 0 0 var(--space-1); font: var(--type-label); font-size: var(--text-md); }
.ap-step p { margin: 0; font: var(--type-body-sm); color: var(--text-secondary); }
.ap-legal { margin: var(--space-4) 0 0; font: var(--type-caption); color: var(--text-muted); text-align: center; line-height: var(--leading-normal); }

/* once the programme has started: unread messages and the next seven days */
.ap-home-side { display: flex; flex-direction: column; gap: var(--space-5); }
.ap-home-box { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.ap-home-box-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1) var(--space-3); }
.ap-home-box-head h2 { margin: 0; display: inline-flex; align-items: center; gap: var(--space-2); font: var(--type-h3); }
.ap-home-box-head h2 .wl-icon { color: var(--accent); }
.ap-home-box-head a { font: var(--type-label); }
.ap-home-empty { margin: 0; font: var(--type-body-sm); color: var(--text-secondary); }
.ap-home-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.ap-home-list li + li { border-top: 1px solid var(--border-subtle); }
.ap-home-list a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch-min); padding: var(--space-2) 0; color: var(--text-primary); text-decoration: none; }
.ap-home-list a:hover strong { text-decoration: underline; }
.ap-home-what { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ap-home-what strong { font: var(--type-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-home-what span { font: var(--type-caption); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-home-list .wl-badge { flex: none; font-variant-numeric: tabular-nums; }
/* a latest message: who, where and when on one line, two lines of the text under it */
.ap-home-msg > span:first-child { font: var(--type-caption); color: var(--text-secondary); }
.ap-home-msg strong { font: var(--type-label); color: var(--text-primary); }
.ap-home-msg strong[data-staff] { color: var(--accent-soft-fg); }
.ap-home-msg .ap-home-text { font: var(--type-body-sm); color: var(--text-primary); white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.ap-home-icon { flex: none; display: grid; place-items: center; width: var(--space-8); height: var(--space-8); border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--text-secondary); }
.ap-home-icon[data-kind="live"] { background: var(--accent-soft); color: var(--accent-soft-fg); }

/* ---------- tablet and desktop: sidebar instead of the tab bar ---------- */
@media (min-width: 768px) {
  .ap-shell { flex-direction: row; }
  .ap-top, .ap-tabbar { display: none; }
  .ap-side { position: sticky; top: 0; display: flex; flex-direction: column; flex: none; width: calc(var(--space-16) * 4); height: 100vh; height: 100dvh;
    border-right: 1px solid var(--border-subtle); background: var(--surface-sunken); }
  .ap-side[data-side-bg] { background: var(--side-bg); border-right-color: var(--border-subtle); }
  /* the head: the logo, and the button that makes the sidebar minimal, shown on hover or focus (always on touch) */
  .ap-side-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    padding: calc(var(--space-6) + env(safe-area-inset-top)) var(--space-3) var(--space-4) var(--space-5); }
  .ap-side-logo { display: block; flex: 1; min-width: 0; }
  .ap-side-lockup { display: block; }
  .ap-side-lockup img { height: var(--space-6); width: auto; }
  /* a reseller's logo is any shape: fill the width, up to twice Welly's height (sizes only - see the logo rule above) */
  .ap-side-lockup img.ap-logo-brand { width: 100%; height: auto; max-height: var(--space-12); object-fit: contain; object-position: left center; }
  /* the mark in the minimal sidebar: Welly's gold W, or the reseller's favicon (not one of the theme's logo images) */
  .ap-side-mark { display: none; width: var(--space-8); height: var(--space-8); object-fit: contain; }
  .ap-side-toggle { flex: none; width: var(--control-h-sm); height: var(--control-h-sm); color: var(--text-secondary); opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-standard), var(--transition-color); }
  .ap-side-head:hover .ap-side-toggle, .ap-side-toggle:focus-visible { opacity: 1; }
  .ap-side-toggle:hover { background: var(--surface-card); color: var(--text-primary); border-color: var(--border-subtle); }
  /* one icon at a time: close in the full sidebar, open in the minimal one */
  .ap-side-toggle-hide, :root[data-side="rail"] .ap-side-toggle-pin { display: contents; }
  .ap-side-toggle-pin, :root[data-side="rail"] .ap-side-toggle-hide { display: none; }
  @media (hover: none) { .ap-side-toggle { opacity: 1; } }
  .ap-side-nav { flex: 1; display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3); }
  .ap-side-nav a, .ap-side-nav > span { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); min-height: var(--touch-min);
    padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); font: var(--type-label); color: var(--text-secondary); text-decoration: none; transition: var(--transition-color); }
  .ap-side-nav a:hover { background: var(--surface-card); color: var(--text-primary); text-decoration: none; }
  .ap-side-nav a:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .ap-side-nav a[aria-current="page"] { background: var(--surface-card); color: var(--text-primary); }
  .ap-side-nav a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: var(--space-2); bottom: var(--space-2); width: 3px; border-radius: var(--radius-xs); background: var(--accent); }
  .ap-side-nav a[aria-current="page"] .wl-icon { color: var(--accent); }
  .ap-side-nav > span[aria-disabled="true"] { color: var(--text-muted); }
  .ap-side-nav > span .wl-badge { margin-left: auto; }
  .ap-side-foot { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); border-top: 1px solid var(--border-subtle); }
  .ap-user { display: flex; align-items: center; gap: var(--space-3); min-width: 0; color: var(--text-primary); }
  a.ap-user:hover { color: var(--text-primary); text-decoration: none; }
  a.ap-user:hover .ap-user-txt strong { text-decoration: underline; }
  a.ap-user[aria-current="page"] .ap-avatar { box-shadow: 0 0 0 2px var(--accent); }
  .ap-user-txt { display: flex; flex-direction: column; min-width: 0; }
  .ap-user-txt strong { font: var(--type-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ap-user-txt span { font: var(--type-caption); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* theme, text size, then Help and Log out close together, all on one line with the space shared between
     the groups; the segments and the two buttons are narrower to leave room for them */
  .ap-side-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-1); }
  .ap-side-actions .wl-theme button { padding: 0 var(--space-2); }
  .ap-side-exit { display: flex; align-items: center; }
  .ap-side-exit .wl-ibtn { width: var(--control-h-sm); }
  /* the question mark drawn 3 px towards Log out, for even space on both sides of it; the button
     itself stays where it is, so the two never overlap */
  .ap-side-exit a .wl-icon { transform: translateX(calc(var(--space-1) * .75)); }
  .ap-side-actions form { margin: 0; }
  /* Visning only in the minimal sidebar; the full one has the two groups */
  .ap-side-display { display: none; position: relative; }
  .ap-side-display .ap-display { top: auto; right: auto; bottom: 0; left: calc(100% + var(--space-3)); }
  .ap-side-display [data-display-toggle][aria-expanded="true"] { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--border-subtle); }

  /* ---------- the minimal sidebar (docs/plans/sidebar/): a strip of icons, the page starting after it ---------- */
  :root[data-side="rail"] { --rail-w: calc(var(--space-16) + var(--space-3)); }
  :root[data-side="rail"] .ap-shell { padding-left: var(--rail-w); }
  :root[data-side="rail"] .ap-side { position: fixed; left: 0; top: 0; z-index: 30; width: var(--rail-w); }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-head { justify-content: center; padding-inline: 0; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-logo { flex: none; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-lockup,
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-toggle { display: none; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-mark { display: block; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-nav { align-items: center; padding-inline: var(--space-2); }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-nav > * { justify-content: center; width: var(--touch-min); padding-inline: 0; }
  /* the names stay for screen readers, and show when the menu opens */
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-nav > * > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-nav a[aria-current="page"]::before { left: calc(var(--space-2) * -1); }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-foot { align-items: center; padding-inline: 0; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-user-txt,
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-actions > .wl-theme { display: none; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-actions { flex-direction: column; gap: var(--space-1); }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-display { display: block; }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-exit { flex-direction: column; gap: var(--space-1); }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-exit .wl-ibtn { width: var(--control-h-md); }
  :root[data-side="rail"] .ap-side:not([data-open]) .ap-side-exit a .wl-icon { transform: none; }
  /* opened by the mouse, focus or a tap: the whole menu over the page, which stays where it is. It is uncovered
     from the strip outwards with clip-path, which needs no new layout while it runs */
  :root[data-side="rail"] .ap-side[data-open] { width: calc(var(--space-16) * 4); box-shadow: var(--shadow-lg);
    animation: ap-side-open var(--dur-base) var(--ease-standard); }
  @keyframes ap-side-open {
    from { clip-path: inset(0 calc(100% - var(--rail-w)) 0 0); }
    to { clip-path: inset(0 calc(var(--space-6) * -1) 0 0); }
  }

  .ap-main { flex: 1; min-width: 0; padding-bottom: 0; }
  .ap-page { max-width: var(--content-max); padding: var(--space-10) var(--gutter-desktop) var(--space-16); gap: var(--space-8); }
  .ap-greet h1 { font-size: var(--text-3xl); }
  .ap-course { padding: var(--space-8); }
  .ap-steps { gap: var(--space-4); }
  .ap-step { padding: var(--space-5); }
  .ap-legal { text-align: left; }
}

/* wide screens: the course card and what to expect side by side */
@media (min-width: 1100px) {
  .ap-grid { display: grid; grid-template-columns: 5fr 7fr; gap: var(--space-8); align-items: start; }
}

/* the session warning's buttons: the gold one first, side by side, full width on a phone */
.ap-dlg-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-2); }
.ap-dlg-actions form { margin: 0; }
@media (max-width: 699px) {
  .ap-dlg-actions { flex-direction: column; }
  .ap-dlg-actions .wl-btn, .ap-dlg-actions form { width: 100%; }
}

/* the avatar: initials in a circle; data-size="lg" is the profile's, gold (ui_kits/app Profile) */
.ap-avatar { flex: none; display: grid; place-items: center; width: var(--control-h-sm); height: var(--control-h-sm); border-radius: 50%;
  background: var(--surface-inverse); color: var(--text-inverse); font: var(--type-label); }
.ap-avatar[data-size="lg"] { width: calc(var(--space-12) + var(--space-2)); height: calc(var(--space-12) + var(--space-2)); background: var(--accent); color: var(--text-on-accent); font: var(--type-h3); }

/* the profile (/profile/): a head, then sections as cards with fields, key/value rows and rows with an action */
.ap-profile { gap: var(--space-6); }
.ap-profile-head { display: flex; align-items: center; gap: var(--space-4); }
.ap-profile-head h1 { margin: 0; font: var(--type-h2); letter-spacing: var(--tracking-tight); overflow-wrap: anywhere; }
.ap-profile-meta { margin: var(--space-1) 0 0; font: var(--type-body-sm); color: var(--text-secondary); }
.ap-profile-section { scroll-margin-top: calc(var(--top-h) + var(--space-4)); }
.ap-profile-card { display: flex; flex-direction: column; gap: var(--space-5); }
.ap-profile-grid { display: grid; gap: var(--space-4); }
.ap-profile-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.ap-phone { display: grid; grid-template-columns: calc(var(--space-24) + var(--space-2)) minmax(0, 1fr); gap: var(--space-2); }
.ap-from-vipps { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.ap-from-vipps-head { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font: var(--type-caption); color: var(--text-secondary); }
.ap-kv { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.ap-kv > div { display: flex; justify-content: space-between; gap: var(--space-4); font: var(--type-body-sm); }
.ap-kv dt { color: var(--text-secondary); }
.ap-kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.ap-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--touch-min); }
.ap-profile-card > .ap-row + .ap-row, .ap-profile-card > .ap-row + .ap-password-wrap { padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.ap-row-txt { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; font: var(--type-body-sm); }
.ap-row-txt strong { font: var(--type-label); }
.ap-row-txt span { color: var(--text-secondary); }
.ap-row > .wl-btn, .ap-row > .wl-badge, .ap-row > .wl-theme, .ap-row > .ap-vipps-btn { flex: none; }
.ap-row .wl-badge .wl-icon { width: 14px; height: 14px; margin-right: var(--space-1); }
.ap-password-wrap > summary { list-style: none; cursor: pointer; }
.ap-password-wrap > summary::-webkit-details-marker { display: none; }
.ap-password-wrap > summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control); }
.ap-password-wrap[open] > summary .wl-btn { background: var(--surface-sunken); }
.ap-password { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.wl-btn[data-danger] { color: var(--danger-fg); }
.wl-btn[data-variant="danger"] { background: var(--danger); color: var(--white); border-color: var(--danger); }
.wl-btn[data-variant="danger"]:hover:not([disabled]) { background: var(--danger-fg); color: var(--white); }
/* the Vipps button in a row: the login button's look, sized like a small button */
/* compact, but the label stays bold large text: white on Vipps orange is 3.1:1, enough only there (see .ap-vipps-btn) */
.ap-vipps-inline { width: auto; min-height: var(--control-h-sm); padding: 0 var(--space-4); }
.ap-back { display: inline-flex; align-items: center; gap: var(--space-2); font: var(--type-body-sm); color: var(--text-secondary); }
.ap-back:hover { color: var(--text-primary); }
.ap-profile-title { margin: 0; font: var(--type-h2); letter-spacing: var(--tracking-tight); }
.ap-card-title { margin: 0; font: var(--type-label); }
.ap-list { margin: calc(-1 * var(--space-2)) 0 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); font: var(--type-body-sm); }
.ap-note { margin: 0; font: var(--type-body-sm); color: var(--text-secondary); }
.ap-erase-actions { justify-content: space-between; align-items: center; }
@media (min-width: 768px) {
  .ap-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ap-profile { max-width: 760px; }
}

/* ---------- a video (docs/plans/video/02-player.md) ---------- */
.ap-video-page { max-width: var(--content-max); }
/* the player keeps 16:9 and never grows taller than the screen leaves room for */
.ap-video-frame { position: relative; width: 100%; max-width: calc((100dvh - var(--space-24) * 2) * 16 / 9); margin: 0 auto;
  aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-media); background: var(--black); color: var(--white); }
.ap-video-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ap-video-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-video-poster + .ap-video-wait { background: color-mix(in srgb, var(--black) 35%, transparent); }
.ap-video-wait { position: absolute; inset: 0; display: grid; place-items: center; }
.ap-video-spinner { width: var(--space-10); height: var(--space-10); border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--white) 20%, transparent); border-top-color: var(--gold-400);
  animation: ap-video-spin 900ms linear infinite; }
@keyframes ap-video-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ap-video-spinner { animation: none; } }
.ap-video-message { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: var(--space-6);
  font: var(--type-body); text-align: center; }
.ap-video-head { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
.ap-video-title { margin: 0; font: var(--type-h2); letter-spacing: var(--tracking-tight); }
.ap-video-description { margin: 0; white-space: pre-line; font: var(--type-body); color: var(--text-secondary); }
/* the member's own notes on the video */
.wl-field > .ap-video-notes-title { font: var(--type-h3); }
.ap-video-notes-input { min-height: calc(var(--space-24) * 1.5); padding: var(--space-3); resize: vertical; }
.ap-video-notes-status:empty { display: none; }
.ap-video-notes-status[data-state="failed"] { color: var(--danger-fg); }
/* phones: the player runs from edge to edge */
@media (max-width: 767px) {
  .ap-video-page { padding-top: 0; padding-inline: 0; }
  .ap-video-frame { border-radius: 0; max-width: none; }
  .ap-video-head, .ap-video-description { padding-inline: var(--gutter-mobile); }
  .ap-video-notes { margin-inline: var(--gutter-mobile); }
  /* the way back keeps the page's gutter, and a full touch height, close above the player */
  .ap-video-page > .ap-back { min-height: var(--touch-min); padding-inline: var(--gutter-mobile); margin-bottom: calc(-1 * var(--space-3)); }
}

/* ---------- Programs (docs/plans/program/04-app.md) ---------- */
.ap-program { gap: var(--space-6); }
.ap-prog-head { display: flex; flex-direction: column; gap: var(--space-2); }
.ap-prog-head h1 { margin: 0; font: var(--type-h1); font-size: var(--text-2xl); letter-spacing: var(--tracking-tight); }
.ap-prog-meta { margin: 0; font: var(--type-body-sm); color: var(--text-secondary); }
/* a bar of how much is watched; the width comes from data-share in steps of 5 (no inline styles under the CSP) */
.ap-bar { position: relative; display: block; height: var(--space-1); overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-sunken); }
.ap-bar > span, .ap-vcard-bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.ap-bar-inverse { background: color-mix(in srgb, var(--white) 20%, transparent); }
[data-share="0"] { width: 0%; }
[data-share="5"] { width: 5%; }
[data-share="10"] { width: 10%; }
[data-share="15"] { width: 15%; }
[data-share="20"] { width: 20%; }
[data-share="25"] { width: 25%; }
[data-share="30"] { width: 30%; }
[data-share="35"] { width: 35%; }
[data-share="40"] { width: 40%; }
[data-share="45"] { width: 45%; }
[data-share="50"] { width: 50%; }
[data-share="55"] { width: 55%; }
[data-share="60"] { width: 60%; }
[data-share="65"] { width: 65%; }
[data-share="70"] { width: 70%; }
[data-share="75"] { width: 75%; }
[data-share="80"] { width: 80%; }
[data-share="85"] { width: 85%; }
[data-share="90"] { width: 90%; }
[data-share="95"] { width: 95%; }
[data-share="100"] { width: 100%; }

.ap-section { display: flex; flex-direction: column; gap: var(--space-3); scroll-margin-top: calc(var(--top-h) + var(--space-4)); }
.ap-section-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle); }
.ap-section-head h2 { margin: 0; font: var(--type-h3); }
.ap-section-status { flex-basis: 100%; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2);
  font: var(--type-body-sm); color: var(--text-secondary); }
.ap-section-status .wl-icon { flex: none; }
.ap-section[data-locked] .ap-section-head h2 { color: var(--text-secondary); }
.ap-track strong { color: var(--text-primary); }
.ap-linkbtn { padding: 0; border: 0; background: none; color: var(--text-link); font: inherit; text-decoration: underline; cursor: pointer; }
.ap-linkbtn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-xs); }

.ap-vlist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-3); }
.ap-vcard { display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch-min); padding: var(--space-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card); background: var(--surface-card); color: var(--text-primary); text-decoration: none; }
a.ap-vcard:hover { border-color: var(--border-strong); text-decoration: none; }
a.ap-vcard:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ap-vcard[data-locked] { background: var(--surface-sunken); color: var(--text-secondary); }
.ap-vcard[data-locked] .ap-vcard-pic img { opacity: .4; filter: grayscale(1); }
.ap-vcard-pic { position: relative; flex: none; display: grid; place-items: center; width: calc(var(--space-24) + var(--space-8)); aspect-ratio: 16 / 9;
  overflow: hidden; border-radius: var(--radius-media); background: var(--surface-sunken); color: var(--text-muted); }
.ap-vcard-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-vcard-done, .ap-vcard-lock { position: absolute; right: var(--space-1); bottom: var(--space-1); display: grid; place-items: center;
  width: var(--space-6); height: var(--space-6); border-radius: 50%; }
.ap-vcard-done { background: var(--success); color: var(--white); }
.ap-vcard-lock { background: var(--surface-card); color: var(--text-secondary); }
.ap-vcard-bar { position: absolute; left: 0; right: 0; bottom: 0; height: var(--space-1); background: color-mix(in srgb, var(--black) 40%, transparent); }
.ap-vcard-txt { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.ap-vcard-txt strong { font: var(--type-label); font-size: var(--text-md); overflow-wrap: anywhere; }
.ap-vcard-txt > span { font: var(--type-caption); color: var(--text-secondary); }
.ap-vrow { display: flex; flex-direction: column; gap: var(--space-2); padding-left: var(--space-3); border-left: 3px solid var(--border-subtle); }
.ap-vrow > p { margin: 0; font: var(--type-caption); color: var(--text-secondary); }

.ap-choice { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5); }
.ap-choice h2 { margin: 0; font: var(--type-h3); }
.ap-choice p { margin: 0; }
.ap-choice-form { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
.ap-choice-options { margin: var(--space-2) 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.ap-choice-options li { display: flex; flex-direction: column; padding: var(--space-3) var(--space-4); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-control); color: var(--text-secondary); }
.ap-choice-options span { font: var(--type-caption); }
.ap-choice-radios { display: flex; flex-direction: column; gap: var(--space-2); }
.ap-choice-radios .wl-radio > span:last-child { display: flex; flex-direction: column; }
.ap-choice-radios small { font: var(--type-caption); color: var(--text-secondary); }
.ap-choice-dlg .ap-eyebrow { color: var(--text-muted); }

.ap-back { display: inline-flex; align-items: center; gap: var(--space-2); align-self: flex-start; font: var(--type-label); }
.ap-video-next { margin: 0; }
.ap-prog-card { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); color: var(--text-primary); text-decoration: none; }
.ap-prog-card:hover { text-decoration: none; border-color: var(--border-strong); }
.ap-prog-card span { font: var(--type-body-sm); color: var(--text-secondary); }
.ap-course-btn { align-self: flex-start; }
.ap-course-link { color: var(--gold-300); font: var(--type-label); }

@media (min-width: 768px) {
  .ap-program { max-width: 880px; }
  .ap-vrow .ap-vlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--space-24) * 2), 1fr)); }
  .ap-vrow .ap-vcard { flex-direction: column; align-items: stretch; }
  .ap-vrow .ap-vcard-pic { width: 100%; }
}
.ap-course > p:not(.ap-eyebrow) { margin: 0; font: var(--type-body); color: var(--grey-400); }
[data-theme="dark"] .ap-course > p:not(.ap-eyebrow) { color: var(--grey-600); }
[data-theme="dark"] .ap-course-link { color: var(--gold-700); }

/* ---------- Fellesskap, the chat (docs/plans/community/02-app.md) ---------- */
/* the rooms beside the open room from 768 px; on a phone the list is one screen and a room another,
   and in a room the tab bar gives way to the composer */
.cm-page { display: grid; grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--top-h) - var(--tabbar-h)); height: calc(var(--app-h) - var(--top-h) - var(--tabbar-h) - env(safe-area-inset-bottom)); background: var(--surface-page); }
.ap-main:has(.cm-page) { min-width: 0; padding-bottom: 0; }
/* the rooms */
.cm-rooms { display: flex; flex-direction: column; min-height: 0; background: var(--surface-page); }
.cm-rooms-head { flex: none; display: flex; align-items: center; gap: var(--space-2); min-height: calc(var(--control-h-md) + var(--space-6));
  padding: 0 var(--space-2) 0 var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.cm-rooms-head h1 { flex: 1; margin: 0; font: var(--type-h3); letter-spacing: var(--tracking-tight); }
.cm-rooms-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-2); }
.cm-rooms-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin: var(--space-4) var(--space-2) var(--space-1); font: var(--type-eyebrow); color: var(--text-secondary); }
.cm-rooms-title:first-child { margin-top: var(--space-2); }
.cm-rooms-title .wl-ibtn { width: var(--control-h-sm); height: var(--control-h-sm); margin: calc(-1 * var(--space-2)) 0; }
.cm-room-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.cm-room { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--touch-min); padding: 0 var(--space-2);
  border: 0; border-radius: var(--radius-control); background: none; color: var(--text-secondary); font: var(--type-body-sm); text-align: left;
  text-decoration: none; cursor: pointer; transition: var(--transition-color); }
.cm-room > .wl-icon { flex: none; color: var(--text-muted); }
.cm-room:hover { background: var(--surface-sunken); color: var(--text-primary); text-decoration: none; }
.cm-room:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cm-room[aria-current="page"] { background: var(--surface-sunken); color: var(--text-primary); }
.cm-room[data-unread] { color: var(--text-primary); font-weight: var(--weight-semibold); }
.cm-room-name { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.cm-room-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-md); font-weight: var(--weight-semibold); }
.cm-room[data-unread] .cm-room-name > span:first-child { font-weight: var(--weight-bold); }
.cm-room-name small { font: var(--type-caption); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-count { flex: none; display: inline-grid; place-items: center; min-width: var(--space-5); height: var(--space-5); padding: 0 var(--space-1);
  border-radius: var(--radius-pill); background: var(--surface-inverse); color: var(--text-inverse); font: var(--type-caption); font-weight: var(--weight-bold); }
.cm-count[data-mention] { background: var(--accent); color: var(--text-on-accent); }
.cm-avatar { flex: none; display: grid; place-items: center; width: var(--space-6); height: var(--space-6); border-radius: 50%;
  background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border-subtle); color: var(--nick, var(--text-primary));
  font: var(--type-caption); font-weight: var(--weight-bold); }
.cm-avatar[data-staff] { background: var(--accent); box-shadow: none; color: var(--text-on-accent); }
.cm-room-note { margin: var(--space-2); font: var(--type-caption); color: var(--text-muted); list-style: none; }

/* the open room */
.cm-chat { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface-page); }
.cm-chat-head { flex: none; display: flex; align-items: center; gap: var(--space-2); min-height: calc(var(--control-h-md) + var(--space-6));
  padding: 0 var(--space-2) 0 var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.cm-chat-head [data-chat-icon] { flex: none; display: inline-flex; color: var(--text-muted); }
.cm-chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cm-chat-title h2 { margin: 0; font: var(--type-label); font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-chat-title span { font: var(--type-caption); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-chat-actions { flex: none; display: flex; align-items: center; gap: var(--space-2); }
.cm-chat-actions:empty { display: none; }
.cm-page:not([data-open]) .cm-chat-head { visibility: hidden; }

.cm-log-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cm-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 1px;
  padding: var(--space-3) var(--space-4) var(--space-4); font: var(--type-body-sm); line-height: var(--leading-normal);
  /* the chat reads one text-size step up (× 1.125, as the text-size buttons do), times and day lines too */
  --cm-step: 1.125; font-size: calc(var(--text-sm) * var(--cm-step)); }
.cm-empty { margin: auto; padding: var(--space-6); text-align: center; font: var(--type-body-sm); color: var(--text-muted); }
.cm-older { align-self: center; margin: 0 0 var(--space-2); font: var(--type-caption); color: var(--text-muted); }
.cm-day { margin: var(--space-4) 0 var(--space-1); font-family: var(--font-mono); font-size: calc(var(--text-xs) * var(--cm-step, 1)); color: var(--text-muted); }
.cm-msg { display: flex; flex-direction: column; }
.cm-line { position: relative; margin: 0 calc(-1 * var(--space-2)); padding: 1px var(--space-2); border-radius: var(--radius-xs); overflow-wrap: anywhere; }
.cm-line:hover, .cm-line:focus-within, .cm-line[data-active] { background: var(--surface-sunken); }
.cm-time { font-family: var(--font-mono); font-size: calc(var(--text-xs) * var(--cm-step, 1)); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cm-nick { font-weight: var(--weight-semibold); color: var(--nick, var(--text-primary)); }
/* a nickname's colour (community.js sets data-colour; a style attribute would be dropped by the CSP) */
[data-colour="blue"] { --nick: var(--info-fg); }
[data-colour="green"] { --nick: var(--success-fg); }
[data-colour="amber"] { --nick: var(--warning-fg); }
[data-colour="red"] { --nick: var(--danger-fg); }
.cm-nick[data-staff] { color: var(--accent-soft-fg); }
.cm-edited { font: var(--type-caption); color: var(--text-muted); }
.cm-mention { padding: 0 2px; border-radius: var(--radius-xs); background: var(--accent-soft); color: var(--accent-soft-fg); font-weight: var(--weight-medium); }
.cm-line[data-mentioned] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.cm-line[data-mentioned] .cm-mention { background: none; }
.cm-line[data-pending] { opacity: .55; }
.cm-line[data-failed] { box-shadow: inset 2px 0 0 var(--danger); }
.cm-line[data-editing] { background: var(--info-soft); box-shadow: inset 2px 0 0 var(--info); }
.cm-line[data-deleted] .cm-text { font-style: italic; color: var(--text-muted); }
.cm-text a { color: var(--text-link); }
.cm-retry { padding: 0; border: 0; background: none; color: var(--danger-fg); font: var(--type-caption); font-weight: var(--weight-semibold); text-decoration: underline; cursor: pointer; }
.cm-actions { position: absolute; top: calc(-1 * var(--space-4)); right: var(--space-2); z-index: 2; display: none; gap: 2px; padding: 2px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-control); background: var(--surface-raised); box-shadow: var(--shadow-sm); }
.cm-line:hover .cm-actions, .cm-line:focus-within .cm-actions, .cm-line[data-active] .cm-actions { display: flex; }
.cm-actions .wl-ibtn { width: var(--control-h-sm); height: var(--control-h-sm); }
.cm-msg:first-of-type .cm-actions { top: 0; }
.cm-sys { grid-column: 1 / -1; margin: var(--space-2) 0; font: var(--type-caption); color: var(--text-muted); font-style: italic; }

/* "Nye meldinger": the line where this person stopped reading */
.cm-new { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2) 0; color: var(--danger-fg);
  font: var(--type-caption); font-weight: var(--weight-semibold); }
.cm-new::before { content: ""; flex: 1; height: 1px; background: var(--danger); }

/* a video link, opened up under its message */
.cm-embed { display: flex; gap: var(--space-3); max-width: calc(var(--space-24) * 4); margin: var(--space-1) 0 var(--space-2);
  padding: var(--space-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--surface-card); }
.cm-embed-thumb { flex: none; display: grid; place-items: center; width: calc(var(--space-24) * 1.3); aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius-media); background: var(--surface-inverse); color: var(--text-inverse); }
.cm-embed-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cm-embed-txt { min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.cm-embed-txt strong { font: var(--type-label); }
.cm-embed-txt span { font: var(--type-caption); color: var(--text-secondary); }
.cm-embed-txt a { display: inline-flex; align-items: center; gap: var(--space-1); margin-top: auto; font: var(--type-caption); font-weight: var(--weight-medium); }

/* scrolled up while something arrives */
.cm-jump { position: absolute; bottom: var(--space-3); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4); border-radius: var(--radius-pill); background: var(--surface-inverse);
  color: var(--text-inverse); box-shadow: var(--shadow-md); font: var(--type-body-sm); white-space: nowrap; }
.cm-jump[hidden] { display: none; }
.cm-jump button { display: inline-flex; align-items: center; gap: var(--space-1); height: var(--control-h-sm); padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-pill); background: color-mix(in oklch, var(--text-inverse) 14%, transparent); color: inherit; font: var(--type-label); cursor: pointer; }
.cm-status { flex: none; margin: 0; padding: var(--space-2) var(--space-4) 0; font: var(--type-caption); color: var(--text-secondary); }

/* the composer */
.cm-composer { flex: none; position: relative; margin: 0; padding: var(--space-2) var(--space-4) var(--space-3); }
.cm-input-row { display: flex; align-items: flex-end; gap: var(--space-2); }
.cm-input { flex: 1; height: auto; min-height: var(--control-h-md); max-height: calc(var(--space-24) * 2); padding: var(--space-3); resize: none; font: var(--type-body-sm);
  font-size: calc(var(--text-sm) * 1.125); }
/* the gold border alone marks the field you write in; the ring around it as well was too much */
.cm-input:focus { box-shadow: none; }
.cm-input-row .wl-btn { flex: none; height: var(--control-h-md); }
.cm-hint { margin: var(--space-1) 0 0; font: var(--type-caption); color: var(--text-muted); }
.cm-edit-bar { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  border-radius: var(--radius-control); background: var(--info-soft); color: var(--info-fg); font: var(--type-caption); }
.cm-edit-bar[hidden] { display: none; }
.cm-edit-bar strong { font-weight: var(--weight-semibold); }
.cm-edit-bar span { flex: 1; }
.cm-edit-bar .wl-ibtn { width: var(--control-h-sm); height: var(--control-h-sm); color: inherit; }
.cm-popover { position: absolute; left: var(--space-4); right: var(--space-4); bottom: calc(100% - var(--space-1)); z-index: 5; margin: 0; padding: var(--space-1);
  list-style: none; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--surface-raised); box-shadow: var(--shadow-lg); }
.cm-popover-title { padding: var(--space-2) var(--space-3) var(--space-1); font: var(--type-eyebrow); color: var(--text-secondary); }
.cm-option { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); font: var(--type-body-sm); cursor: pointer; }
.cm-option[aria-selected="true"] { background: var(--surface-sunken); }
.cm-option small { margin-left: auto; font: var(--type-caption); color: var(--text-muted); }

/* the dialogs: settings, a new conversation */
.cm-settings { display: flex; flex-direction: column; gap: var(--space-5); }
/* the settings' fields after the picture, which is a form of its own */
.cm-settings-form { display: flex; flex-direction: column; gap: var(--space-5); }
.cm-settings-picture { display: flex; flex-direction: column; gap: var(--space-2); }
.cm-settings-picture > strong { font: var(--type-label); }
.cm-swatches { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.cm-swatches[hidden] { display: none; }
.cm-swatch { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-h-sm); padding: 0 var(--space-3) 0 var(--space-2);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); font: var(--type-body-sm); color: var(--text-primary); cursor: pointer; }
.cm-swatch::before { content: ""; width: var(--space-4); height: var(--space-4); border-radius: 50%; background: var(--nick, var(--text-primary)); }
.cm-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.cm-swatch:has(input:checked) { border-color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--text-primary); }
.cm-swatch:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.cm-swatch[data-reserved] { opacity: .5; border-style: dashed; cursor: default; }
.cm-preview { padding: var(--space-3); border-radius: var(--radius-control); background: var(--surface-sunken); font: var(--type-body-sm); }
.cm-settings-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4);
  padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.cm-settings-row > div { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; flex: 1; font: var(--type-body-sm); }
.cm-settings-row strong { font: var(--type-label); }
.cm-settings-row span { color: var(--text-secondary); }
.cm-blocked { width: 100%; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-1); }
.cm-blocked:empty { display: none; }
.cm-blocked li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font: var(--type-body-sm); }
.cm-dlg-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
.cm-find-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; min-height: var(--space-10); }

@media (max-width: 767px) {
  .cm-page[data-view="room"] .cm-rooms, .cm-page[data-view="list"] .cm-chat { display: none; }
  .ap-shell:has(.cm-page[data-view="room"]) .ap-tabbar { display: none; }
  .cm-page[data-view="room"] { height: calc(100vh - var(--top-h)); height: calc(var(--app-h) - var(--top-h)); }
  .cm-composer { padding-bottom: max(var(--space-3), env(safe-area-inset-bottom)); }
  .cm-hint { display: none; }
}
@media (min-width: 768px) {
  .cm-back { display: none; }
  .cm-page { grid-template-columns: calc(var(--space-16) * 4.5) minmax(0, 1fr); height: 100vh; height: 100dvh; }
  .ap-main:has(.cm-page) { flex: 1; }
  .cm-rooms { border-right: 1px solid var(--border-subtle); }
  .cm-room { min-height: var(--control-h-sm); }
}

/* ---------- chat styles (the chat's settings; docs/plans/chatstyles/) ----------
   community.js gives every message both looks: a face and a name line (.cm-face, .cm-head) beside the
   line, and [time] <nick> inside it. Oldschool shows the second; the others show the first and keep the
   second for screen readers. A message that goes on from the one before has data-follows. */
[data-chat-style="oldschool"] :is(.cm-face, .cm-head) { display: none; }
[data-chat-style="oldschool"] .cm-day span::before { content: "-- "; }
[data-chat-style="oldschool"] .cm-day span::after { content: " --"; }

[data-chat-style]:not([data-chat-style="oldschool"]) { gap: 0; }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-line > :is(.cm-time, .cm-nick) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-day { display: flex; justify-content: center; margin: var(--space-5) 0 var(--space-2); font: var(--type-caption); }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-day span { padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill);
  background: var(--surface-sunken); color: var(--text-secondary); font-weight: var(--weight-medium); }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-face { flex: none; display: grid; place-items: center; width: var(--space-8); height: var(--space-8);
  border-radius: 50%; background: color-mix(in oklch, var(--nick, var(--text-muted)) 16%, var(--surface-card)); color: var(--nick, var(--text-secondary));
  font: var(--type-label); font-weight: var(--weight-semibold); }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-face[data-staff] { background: var(--accent); color: var(--text-on-accent); }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-body { min-width: 0; }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-head { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: var(--type-label); font-size: calc(var(--text-sm) * var(--cm-step, 1)); color: var(--nick, var(--text-primary)); }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-name[data-staff] { color: var(--accent-soft-fg); }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-head time { flex: none; font: var(--type-caption); color: var(--text-muted); font-variant-numeric: tabular-nums; }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-badge { flex: none; padding: 0 var(--space-1); border-radius: var(--radius-badge);
  background: var(--accent-soft); color: var(--accent-soft-fg); font: var(--type-caption); font-weight: var(--weight-semibold); }
/* Nora, the AI helper: her badge outlined, so AI never reads as a person from Welly */
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-badge[data-agent] { background: transparent; box-shadow: inset 0 0 0 1px currentColor; color: var(--accent-soft-fg); }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-msg[data-follows] .cm-head { display: none; }
[data-chat-style]:not([data-chat-style="oldschool"]) .cm-msg[data-follows] .cm-face { visibility: hidden; height: 0; }
/* in a live session's room the face makes the person large (community.js, live.js) */
button.cm-face { border: 0; padding: 0; cursor: pointer; transition: var(--transition-color); }
button.cm-face:hover { box-shadow: 0 0 0 2px var(--accent); }
button.cm-face:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Strøm: everything to the left, a face, the name and time over each group */
[data-chat-style="stream"] .cm-msg { display: grid; grid-template-columns: var(--space-10) minmax(0, 1fr); column-gap: var(--space-3); margin-top: var(--space-3); }
[data-chat-style="stream"] .cm-msg[data-follows] { margin-top: 0; }
[data-chat-style="stream"] .cm-face { width: var(--space-10); height: var(--space-10); font: var(--type-body); font-weight: var(--weight-semibold); }
[data-chat-style="stream"] .cm-name { font-weight: var(--weight-semibold); }

/* Bobler: others to the left, your own to the right, Welly in gold */
[data-chat-style="bubbles"] .cm-msg { display: flex; flex-direction: row; align-items: flex-start; gap: var(--space-2); max-width: min(80%, calc(var(--space-24) * 6)); margin-top: var(--space-3); }
[data-chat-style="bubbles"] .cm-msg[data-follows] { margin-top: 2px; }
[data-chat-style="bubbles"] .cm-msg[data-mine] { align-self: flex-end; }
[data-chat-style="bubbles"] .cm-msg[data-mine] :is(.cm-face, .cm-name, .cm-badge) { display: none; }
[data-chat-style="bubbles"] .cm-body { display: flex; flex-direction: column; align-items: flex-start; }
[data-chat-style="bubbles"] .cm-msg[data-mine] .cm-body { align-items: flex-end; }
[data-chat-style="bubbles"] .cm-head { padding: 0 var(--space-3) var(--space-1); }
[data-chat-style="bubbles"] .cm-name { font: var(--type-caption); font-weight: var(--weight-semibold); }
[data-chat-style="bubbles"] .cm-line { margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); background: var(--surface-sunken); line-height: var(--leading-normal); }
[data-chat-style="bubbles"] .cm-line:is(:hover, :focus-within, [data-active]) { background: var(--surface-sunken); }
[data-chat-style="bubbles"] .cm-msg:not([data-mine])[data-follows] .cm-line { border-top-left-radius: var(--radius-sm); }
[data-chat-style="bubbles"] .cm-msg:not([data-mine]):has(+ .cm-msg[data-follows]) .cm-line { border-bottom-left-radius: var(--radius-sm); }
[data-chat-style="bubbles"] .cm-msg[data-mine][data-follows] .cm-line { border-top-right-radius: var(--radius-sm); }
[data-chat-style="bubbles"] .cm-msg[data-mine]:has(+ .cm-msg[data-follows]) .cm-line { border-bottom-right-radius: var(--radius-sm); }
[data-chat-style="bubbles"] .cm-msg[data-mine] .cm-line, [data-chat-style="bubbles"] .cm-msg[data-mine] .cm-line:is(:hover, :focus-within, [data-active]) {
  background: var(--surface-inverse); color: var(--text-inverse); }
[data-chat-style="bubbles"] .cm-msg[data-mine] .cm-line :is(a, .cm-edited) { color: inherit; }
[data-chat-style="bubbles"] .cm-msg[data-staff] .cm-line, [data-chat-style="bubbles"] .cm-msg[data-staff] .cm-line:is(:hover, :focus-within, [data-active]) {
  background: var(--accent-soft); color: var(--accent-soft-fg); }
[data-chat-style="bubbles"] .cm-line[data-mentioned] { box-shadow: inset 0 0 0 2px var(--accent); }
[data-chat-style="bubbles"] .cm-line[data-editing] { box-shadow: inset 0 0 0 2px var(--info); }
[data-chat-style="bubbles"] .cm-line[data-failed] { box-shadow: inset 0 0 0 2px var(--danger); }
[data-chat-style="bubbles"] .cm-msg .cm-line[data-deleted] { background: none; box-shadow: inset 0 0 0 1px var(--border-subtle); color: var(--text-muted); }
[data-chat-style="bubbles"] .cm-embed { background: var(--surface-card); }

/* Kort: each group a flat card in a narrower column; Welly with a gold edge, your own on light gold */
[data-chat-style="cards"] { align-items: center; background: var(--surface-sunken); }
[data-chat-style="cards"] > * { width: 100%; max-width: var(--content-narrow); }
[data-chat-style="cards"] > .cm-older { text-align: center; }
[data-chat-style="cards"] .cm-day span { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--border-subtle); }
[data-chat-style="cards"] .cm-msg { display: grid; grid-template-columns: var(--space-8) minmax(0, 1fr); column-gap: var(--space-3);
  margin-top: var(--space-3); padding: var(--space-4) var(--space-4) var(--space-1); border: 1px solid var(--border-subtle); border-bottom: 0;
  border-radius: var(--radius-card) var(--radius-card) 0 0; background: var(--surface-card); }
[data-chat-style="cards"] .cm-msg[data-follows] { margin-top: 0; padding-top: var(--space-1); border-top: 0; border-radius: 0; }
[data-chat-style="cards"] .cm-msg:not(:has(+ .cm-msg[data-follows])) { padding-bottom: var(--space-4); border-bottom: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--radius-card); border-bottom-right-radius: var(--radius-card); }
[data-chat-style="cards"] .cm-msg[data-staff] { box-shadow: inset 3px 0 0 var(--accent); }
[data-chat-style="cards"] .cm-msg[data-mine] { background: color-mix(in oklch, var(--accent-soft) 55%, var(--surface-card)); }
[data-chat-style="cards"] .cm-head { margin-bottom: var(--space-1); }
[data-chat-style="cards"] .cm-new { max-width: var(--content-narrow); }

/* the preview in the settings: one of your own messages in the chosen style */
.cm-preview[data-chat-style] { display: flex; flex-direction: column; line-height: var(--leading-normal); }
.cm-preview[data-chat-style] .cm-msg { margin-top: 0; }
.cm-preview[data-chat-style="cards"] { padding: var(--space-3); }
@media (max-width: 767px) {
  [data-chat-style="bubbles"] .cm-msg { max-width: 88%; }
}

/* the choice of style in the settings */
.cm-styles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.cm-style-option { position: relative; display: flex; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control); cursor: pointer; transition: var(--transition-color); }
.cm-style-option:hover { border-color: var(--border-strong); }
.cm-style-option input { position: absolute; opacity: 0; pointer-events: none; }
.cm-style-option > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cm-style-option strong { font: var(--type-label); }
.cm-style-option small { font: var(--type-caption); color: var(--text-secondary); }
.cm-style-option:has(input:checked) { border-color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--text-primary); }
.cm-style-option:has(input:focus-visible) { box-shadow: var(--focus-ring); }

/* pictures: a person's, a reseller's, a group's or a program's, in the same circle as the letters */
:is(.cm-avatar, .cm-face)[data-picture] { overflow: hidden; background: var(--surface-sunken); box-shadow: none; }
:is(.cm-avatar, .cm-face) img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* a shared room without a picture: its first letter on one of eight deep tints, chosen by the room's id */
.cm-avatar[data-tint] { box-shadow: none; color: var(--white); }
.cm-avatar[data-tint="0"] { background: var(--blue-800); }
.cm-avatar[data-tint="1"] { background: var(--green-800); }
.cm-avatar[data-tint="2"] { background: var(--red-800); }
.cm-avatar[data-tint="3"] { background: var(--amber-800); }
.cm-avatar[data-tint="4"] { background: color-mix(in oklch, var(--blue-800), var(--green-800)); }
.cm-avatar[data-tint="5"] { background: color-mix(in oklch, var(--blue-800), var(--red-800)); }
.cm-avatar[data-tint="6"] { background: var(--grey-700); }
.cm-avatar[data-tint="7"] { background: var(--gold-800); }
[data-chat-icon] .cm-avatar { width: var(--space-8); height: var(--space-8); }

/* a profile picture (partials/picture.html.twig): a circle with a camera, Remove beside it */
.wl-picture { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.wl-picture-face { position: relative; flex: none; display: grid; place-items: center; width: var(--space-16); height: var(--space-16);
  border-radius: 50%; background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border-subtle); color: var(--text-secondary);
  font: var(--type-h3); cursor: pointer; }
.wl-picture-face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.wl-picture-face:focus-within { box-shadow: var(--focus-ring); }
.wl-picture-face[data-over] { box-shadow: inset 0 0 0 2px var(--accent); }
.wl-picture-fallback { display: grid; place-items: center; }
.wl-picture-fallback[hidden], .wl-picture [data-picture-remove][hidden] { display: none; }
.wl-picture-cam { position: absolute; right: calc(-1 * var(--space-1)); bottom: calc(-1 * var(--space-1)); display: grid; place-items: center;
  width: var(--space-6); height: var(--space-6); border-radius: 50%; background: var(--surface-raised); box-shadow: 0 0 0 1px var(--border-subtle), var(--shadow-sm);
  color: var(--text-primary); }
.wl-picture-face:hover .wl-picture-cam { background: var(--surface-sunken); }
.wl-picture[data-busy] .wl-picture-face { opacity: .55; cursor: progress; }
.wl-picture-actions:empty { display: none; }
.wl-picture-hint { flex-basis: 100%; margin: 0; font: var(--type-caption); color: var(--text-secondary); }
.wl-picture + * { margin-top: var(--space-4); }

.ap-avatar[data-picture] { overflow: hidden; background: var(--surface-sunken); }
.ap-avatar[data-picture] img { width: 100%; height: 100%; object-fit: cover; }
.ap-profile-head .wl-picture { flex-direction: column; }

/* a conversation's ✕: hides it from one's own list. Shown on hover or focus, always on a touch screen */
.cm-room-list > li:has(.cm-room-hide) { position: relative; }
.cm-room-list > li:has(.cm-room-hide) > .cm-room { padding-right: calc(var(--control-h-sm) + var(--space-2)); }
.cm-room-hide { position: absolute; top: 50%; right: var(--space-1); transform: translateY(-50%); width: var(--control-h-sm); height: var(--control-h-sm);
  opacity: 0; color: var(--text-muted); }
.cm-room-list > li:hover .cm-room-hide, .cm-room-hide:focus-visible { opacity: 1; }
.cm-room-hide:hover { color: var(--text-primary); }
@media (hover: none) { .cm-room-hide { opacity: 1; } }

/* the picture dialog (picture.js): a file or the camera, the avatars in a grid of four, and the cropper */
.wl-picker { max-width: calc(var(--space-24) * 5.5); }
.wl-picker[data-busy] { opacity: .6; pointer-events: none; }
.wl-picker-step { display: flex; flex-direction: column; gap: var(--space-3); }
.wl-picker-step[hidden] { display: none; }
.wl-picker-sources { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.wl-picker-sources .wl-btn:focus-within { box-shadow: var(--focus-ring); }
.wl-picker-camera { display: none; }
@media (hover: none) and (pointer: coarse) { .wl-picker-camera { display: inline-flex; } }
.wl-picker-label { margin: var(--space-2) 0 0; font: var(--type-label); color: var(--text-secondary); }
.wl-picker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3);
  max-height: min(50vh, calc(var(--space-24) * 3.6)); overflow-y: auto; overscroll-behavior: contain; padding: var(--space-1);
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.wl-picker-avatar { aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard); }
.wl-picker-avatar img { display: block; width: 100%; height: auto; border-radius: 50%; }
.wl-picker-avatar:hover { box-shadow: 0 0 0 2px var(--border-strong); transform: scale(1.03); }
.wl-picker-avatar:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wl-picker-foot { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.wl-picker-gap { flex: 1; }

.wl-crop { position: relative; width: fit-content; margin: 0 auto; overflow: hidden; border-radius: var(--radius-md);
  touch-action: none; user-select: none; -webkit-user-select: none; }
.wl-crop img { display: block; max-width: none; }
/* everything outside the square is dimmed; the ring inside shows the circle the picture is shown in */
.wl-crop-box { position: absolute; box-shadow: 0 0 0 100vmax var(--surface-overlay); outline: 2px solid var(--white); cursor: move; touch-action: none; }
.wl-crop-box::before { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--white); opacity: .7; pointer-events: none; }
.wl-crop-box:focus-visible { outline-color: var(--focus-color); outline-width: 3px; }
.wl-crop-handle { position: absolute; right: var(--space-1); bottom: var(--space-1); width: var(--space-4); height: var(--space-4);
  border-radius: 50%; background: var(--white); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-strong); cursor: nwse-resize; }
.wl-crop-handle::after { content: ""; position: absolute; inset: calc(-1 * var(--space-3)); }

/* ---------- Live sessions (docs/plans/live/02-app-page.md) ---------- */
/* the list (/live/): a card per session, its time first */
.ap-live-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-5); }
.ap-live-card p { margin: 0; }
.ap-live-card h2 { margin: 0; font: var(--type-h3); }
.ap-live-when { display: flex; align-items: center; gap: var(--space-2); font: var(--type-label); color: var(--text-secondary); }
.ap-live-now { background: var(--danger-soft); color: var(--danger-fg); }

/* the room: presenters on the stage, the others in a grid of small tiles under it */
.ap-room { display: flex; flex-direction: column; gap: var(--space-4); }
.ap-room-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.ap-room-head h1 { margin: 0; font: var(--type-h3); }
.ap-room-rec { display: inline-flex; align-items: center; gap: var(--space-1); margin: 0; padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill); background: var(--danger-soft); color: var(--danger-fg); font: var(--type-label); }
.ap-room-lobby, .ap-room-over, .ap-room-host { padding: var(--space-5); }
.ap-room-lobby, .ap-room-over { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }
.ap-room-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ap-room-lobby p, .ap-room-over p { margin: 0; }
.ap-room-error { color: var(--danger-fg); }
.ap-room-live { display: flex; flex-direction: column; gap: var(--space-3); }
.ap-room-stage { display: grid; gap: var(--space-2); grid-template-columns: 1fr; }
/* a phone's page of four is one row, so the chat below gets the room */
.ap-room-grid { display: grid; gap: var(--space-2); grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 767px) {
  .ap-room-grid .ap-tile-tools .wl-ibtn { width: var(--space-8); height: var(--space-8); }
}
@media (min-width: 768px) {
  .ap-room-stage { grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-24) * 3), 1fr)); }
  .ap-room-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.ap-tile { position: relative; margin: 0; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-media);
  background: var(--surface-inverse); color: var(--text-inverse); }
.ap-tile[data-big="true"], .ap-tile[data-screen] { aspect-ratio: 16 / 9; }
.ap-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-tile[data-big="true"] video, .ap-tile[data-screen] video { object-fit: contain; }
.ap-tile-face { position: absolute; inset: 0; display: grid; place-items: center; font: var(--type-h3); }
.ap-tile-face img { width: 40%; aspect-ratio: 1; border-radius: var(--radius-pill); object-fit: cover; }
.ap-tile[data-video="true"] .ap-tile-face { visibility: hidden; }
.ap-tile figcaption { position: absolute; left: var(--space-1); right: var(--space-1); bottom: var(--space-1); display: flex;
  align-items: center; gap: var(--space-1); }
.ap-tile-name { overflow: hidden; padding: 0 var(--space-1); border-radius: var(--radius-sm); background: var(--surface-overlay);
  color: var(--white); font: var(--type-caption); white-space: nowrap; text-overflow: ellipsis; }
.ap-tile-icons { display: inline-flex; gap: var(--space-1); color: var(--white); }
.ap-tile.is-speaking { box-shadow: inset 0 0 0 2px var(--accent); }
.ap-tile-tools { position: absolute; top: var(--space-1); right: var(--space-1); display: flex; gap: var(--space-1); }
.ap-tile-tools .wl-ibtn { background: var(--surface-overlay); color: var(--white); }
.ap-room-hosts { display: flex; flex-direction: column; gap: var(--space-2); }
.ap-room-hosts h2 { margin: 0; font: var(--type-label); color: var(--text-secondary); }
.ap-room-host-row { display: grid; gap: var(--space-2); grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 768px) {
  .ap-room-host-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.ap-room-pages { display: flex; align-items: center; justify-content: center; gap: var(--space-2); font: var(--type-label); }
.ap-flip svg { transform: scaleX(-1); }
.ap-room-note { min-height: 1.5em; margin: 0; font: var(--type-body-sm); color: var(--text-secondary); }
.ap-room-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-2); }
.ap-room-bar .wl-ibtn { border: 1px solid var(--border-strong); }
.ap-room-bar .wl-ibtn[aria-pressed="false"] { color: var(--danger-fg); }
.ap-room-host { display: flex; flex-direction: column; gap: var(--space-3); }
.ap-room-host h2, .ap-room-host h3 { margin: 0; font: var(--type-label); }
.ap-room-switches { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ap-room-switches .wl-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-soft-fg); background: var(--accent-soft); }
.ap-room-hands ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.ap-room-hands li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }

/* screen sharing and large for me (docs/plans/screenshare/) */
/* the share button is a choice, not a muted device: not red while off */
.ap-room-bar .ap-room-share[aria-pressed="false"] { color: var(--text-primary); }
.ap-room-bar .ap-room-share[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-soft-fg); background: var(--accent-soft); }
/* the sharer's camera, small in the corner of their share */
.ap-tile-pip { position: absolute; right: var(--space-3); bottom: var(--space-3); width: 22%; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius-control); background: var(--grey-900); box-shadow: var(--shadow-md); outline: 1px solid var(--grey-700); }
.ap-tile .ap-tile-pip video { object-fit: cover; }
.ap-room-strip .ap-tile-pip { right: var(--space-1); bottom: var(--space-1); width: 34%; border-radius: var(--radius-xs); }
/* what the host who shares sees in place of their own screen */
.ap-tile[data-own] { background: var(--surface-sunken); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--border-subtle); }
.ap-tile-sharing { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3);
  padding: var(--space-3); text-align: center; }
.ap-tile-sharing > .wl-icon { color: var(--accent); }
.ap-tile-sharing p { margin: 0; font: var(--type-h3); }
.ap-room-strip .ap-tile-sharing { gap: 0; }
.ap-room-strip .ap-tile-sharing :is(p, .wl-btn) { display: none; }
/* every tile makes itself large on a click; its button (shown under the mouse, and to the keyboard) says so */
.ap-tile[data-key] { cursor: pointer; }
.ap-tile-focus { position: absolute; top: var(--space-1); left: var(--space-1); display: inline-flex; gap: var(--space-1); width: auto; height: var(--space-8);
  padding: 0 var(--space-2); border-radius: var(--radius-pill); background: var(--surface-overlay); color: var(--white); font: var(--type-caption);
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.ap-tile-focus:hover { background: var(--surface-overlay); color: var(--white); }
.ap-tile:hover .ap-tile-focus, .ap-tile-focus:focus-visible { opacity: 1; }
.ap-tile-focus-icon { display: contents; }
:is(.ap-room-strip, .ap-room-grid, .ap-room-host-row) .ap-tile-focus { width: var(--space-8); padding: 0; justify-content: center; }
:is(.ap-room-strip, .ap-room-grid, .ap-room-host-row) .ap-tile-focus-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (hover: none) { .ap-tile-focus:not(:focus-visible) { opacity: 0; } }
/* large for me: everyone else as small pictures under the stage, a row that scrolls sideways on a phone */
.ap-room-strip { display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; }
.ap-room-strip .ap-tile { flex: none; width: calc(var(--space-16) * 1.4); }
.ap-room-strip .ap-tile-name { font-size: var(--text-xs); }
@media (max-width: 767px) {
  .ap-room-strip .ap-tile-tools .wl-ibtn { width: var(--space-8); height: var(--space-8); }
}
@media (min-width: 768px) {
  .ap-room-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--space-20) * 1.1), 1fr)); align-items: start; overflow: visible; }
  .ap-room-strip .ap-tile { width: auto; }
}

/* the session's chat (docs/plans/chat-vid/): under the controls to the bottom of the screen on a phone,
   with no tab bar in the room (as in an open room in Fellesskap); a column on the right from 768 px */
.ap-room { height: calc(100vh - var(--top-h)); height: calc(var(--app-h) - var(--top-h)); padding-bottom: 0; overflow-y: auto; }
.ap-room-main { flex: none; display: flex; flex-direction: column; gap: var(--space-4); }
.ap-room-chat { flex: 1 1 0; display: flex; flex-direction: column; min-height: calc(var(--space-24) * 3.5);
  margin: 0 calc(var(--gutter-mobile) * -1); border-top: 1px solid var(--border-subtle); }
.ap-room-chat .cm-chat { flex: 1; }
.ap-room-chat .cm-chat-head { min-height: auto; padding-block: var(--space-2); }
.ap-room-chat .cm-composer { padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom)); }
dialog[data-devices] { width: min(calc(100vw - var(--space-8)), calc(var(--space-24) * 5)); }
.ap-room-devices-form { gap: var(--space-4); }
.ap-room-devices-actions { justify-content: flex-end; }
.ap-room-host-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.ap-room-host-toggle { position: relative; }
.ap-room-count { position: absolute; top: calc(var(--space-1) * -1); right: calc(var(--space-1) * -1); min-width: var(--space-5); height: var(--space-5);
  padding: 0 var(--space-1); border-radius: var(--radius-pill); background: var(--accent); color: var(--text-on-accent); font: var(--type-caption);
  font-weight: var(--weight-semibold); display: grid; place-items: center; }
.ap-room-count[hidden] { display: none; }
.ap-room-bar .ap-room-host-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent-soft-fg); background: var(--accent-soft); }
.ap-room-bar .ap-room-chat-toggle[aria-pressed] { color: var(--text-primary); }
.ap-room-bar .ap-room-chat-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-soft-fg); background: var(--accent-soft); }
@media (max-width: 767px) {
  /* several hosts with nobody on the floor stand side by side, so the chat keeps its room */
  .ap-room-stage:has(> .ap-tile + .ap-tile) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ap-shell:has(.ap-room) .ap-tabbar { display: none; }
  .ap-main:has(.ap-room) { padding-bottom: 0; }
  .ap-room-chat-toggle { display: none; }
  /* the host's controls: a sheet over the chat, opened with Vert */
  .ap-room-host { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 80dvh; overflow-y: auto;
    border-radius: var(--radius-card) var(--radius-card) 0 0; padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); }
  .ap-room-host:not([data-open]) { display: none; }
  .ap-room-host .ap-room-switches .wl-btn { flex: 1 1 calc(50% - var(--space-2)); justify-content: center; }
}
@media (min-width: 768px) {
  .ap-main:has(.ap-room) { padding-bottom: 0; min-width: 0; }
  .ap-page.ap-room { display: grid; grid-template-columns: minmax(0, 1fr) calc(var(--space-24) * 3.6); gap: 0; max-width: none;
    height: 100vh; height: 100dvh; padding: 0; overflow: hidden; }
  .ap-room[data-chat-hidden] { grid-template-columns: minmax(0, 1fr); }
  .ap-room[data-chat-hidden] .ap-room-chat { display: none; }
  .ap-room-main { min-height: 0; overflow-y: auto; padding: var(--space-8) var(--gutter-desktop); }
  .ap-room-main > * { width: 100%; max-width: var(--content-max); margin-inline: auto; box-sizing: border-box; }
  .ap-room-chat { min-height: 0; margin: 0; border-top: 0; border-left: 1px solid var(--border-subtle); }
  .ap-room-host-toggle, .ap-room-host-close { display: none; }
  /* the stage keeps under half the height, so the others and the controls show without scrolling */
  .ap-room-stage .ap-tile[data-big="true"] { width: min(100%, calc(48dvh * 16 / 9)); justify-self: center; }
}

/* pinned messages (Welly\Community\Pins): the pin on a line, the line the pinned list led to, and the list */
.cm-pinned { display: inline-flex; vertical-align: -2px; margin-left: var(--space-1); color: var(--accent-soft-fg); }
.cm-actions .wl-ibtn[data-pin][aria-pressed="true"] { color: var(--accent-soft-fg); }
.cm-msg[data-focus] .cm-line { background: var(--accent-soft); border-radius: var(--radius-sm); transition: background 1s ease-out; }
.cm-pins { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.cm-pin { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); }
.cm-pin-link { display: flex; flex-direction: column; gap: var(--space-2); color: inherit; text-decoration: none; }
.cm-pin-link:hover .cm-pin-text { text-decoration: underline; text-decoration-color: var(--border-strong); }
.cm-pin-where { display: inline-flex; align-items: center; gap: var(--space-1); font: var(--type-label); color: var(--text-secondary); }
.cm-pin-msg { display: grid; grid-template-columns: var(--space-8) minmax(0, 1fr); column-gap: var(--space-3); align-items: start; }
.cm-pin-msg .cm-avatar { width: var(--space-8); height: var(--space-8); }
.cm-pin-body { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.cm-pin-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.cm-pin-head strong { font: var(--type-label); color: var(--nick, var(--text-primary)); }
.cm-pin-head strong[data-staff] { color: var(--accent-soft-fg); }
.cm-pin-head time { font: var(--type-caption); color: var(--text-muted); }
.cm-pin-text { overflow-wrap: anywhere; }
.cm-pin-remove { margin: 0; align-self: flex-end; }

/* ---------- the calendar (docs/plans/calendar/) ---------- */
.cal-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3) var(--space-4); }
.cal-head h1 { margin: 0; font: var(--type-h1); font-size: var(--text-2xl); letter-spacing: var(--tracking-tight); }
.cal-nav { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-1); }
.cal-nav h2 { margin: 0 var(--space-1); font: var(--type-h3); white-space: nowrap; }
.cal-nav .wl-btn { margin-left: var(--space-2); }
/* Month | List: links in the theme toggle's look */
.cal-switch { grid-column: 2; grid-row: 1; display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); background: var(--surface-sunken); }
.cal-switch a { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 30px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  color: var(--text-secondary); font: var(--type-label); text-decoration: none; }
.cal-switch a:hover { color: var(--text-primary); text-decoration: none; }
.cal-switch a[aria-current="page"] { background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* the month: a phone shows the times and flags, a tap on a day shows it under the grid */
.cal-month { overflow: hidden; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--surface-card); }
.cal-wd, .cal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd { border-bottom: 1px solid var(--border-subtle); background: var(--surface-sunken); }
.cal-wd span { padding: var(--space-2) 0; font: var(--type-caption); font-weight: var(--weight-semibold); text-align: center; text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted); }
.cal-days { grid-auto-rows: minmax(calc(var(--space-12) + var(--space-4)), auto); }
.cal-day { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); padding: var(--space-1) 2px;
  border-right: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:nth-last-child(-n + 7) { border-bottom: 0; }
.cal-day[data-out] { background: var(--surface-sunken); }
.cal-daylink { color: inherit; text-decoration: none; }
.cal-daylink::after { content: ""; position: absolute; inset: 0; }
.cal-daylink:hover { text-decoration: none; }
.cal-daylink:focus-visible { outline: none; box-shadow: none; }
.cal-daylink:focus-visible::after { box-shadow: inset 0 0 0 3px var(--focus-color); }
.cal-num { display: grid; place-items: center; width: var(--space-6); height: var(--space-6); border-radius: 50%; font: var(--type-label);
  font-variant-numeric: tabular-nums; color: var(--text-primary); }
.cal-day[data-out] .cal-num, .cal-day[data-past] .cal-num { color: var(--text-muted); }
.cal-day[data-today] .cal-num { background: var(--accent); color: var(--text-on-accent); }
.cal-day[data-selected] { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-daylink:hover .cal-num { text-decoration: underline; }

.cal-events { width: 100%; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cal-chip { display: flex; align-items: center; gap: var(--space-1); max-width: 100%; padding: 0 var(--space-1); border-radius: var(--radius-xs);
  font: var(--type-caption); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; text-decoration: none; white-space: nowrap;
  pointer-events: none; }
.cal-chip:hover { text-decoration: none; }
.cal-chip[data-kind="live"] { background: var(--accent-soft); color: var(--accent-soft-fg); }
.cal-chip[data-kind="live"][data-past] { background: var(--surface-sunken); color: var(--text-secondary); }
.cal-chip[data-kind="program"] { padding: 0; color: var(--text-secondary); }
.cal-chip-title { display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: var(--weight-medium); }
.cal-more { font: var(--type-caption); color: var(--text-secondary); }

.cal-legend { margin: calc(var(--space-2) * -1) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font: var(--type-caption); color: var(--text-muted); }
.cal-legend > span { display: inline-flex; align-items: center; gap: var(--space-2); }
.cal-key { display: inline-block; width: var(--space-4); height: var(--space-3); border-radius: var(--radius-xs); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

/* a day under the grid, and the rows of the list */
.cal-dayview { scroll-margin-top: calc(var(--top-h) + var(--space-4)); }
.cal-dayview > section { display: flex; flex-direction: column; gap: var(--space-3); }
.cal-dayview h2 { margin: 0; display: flex; align-items: center; gap: var(--space-2); font: var(--type-h3); }
.cal-empty { margin: 0; font: var(--type-body-sm); color: var(--text-muted); }
.cal-item { position: relative; display: flex; align-items: flex-start; gap: var(--space-4); padding: var(--space-4); }
.cal-item-time { flex: none; display: flex; flex-direction: column; width: var(--space-12); font: var(--type-label); font-variant-numeric: tabular-nums; }
.cal-item-time span { font: var(--type-caption); color: var(--text-muted); }
.cal-item[data-kind="live"] .cal-item-time time { color: var(--accent-soft-fg); }
.cal-item[data-kind="program"] .cal-item-time { color: var(--text-secondary); }
.cal-item[data-past] .cal-item-time time { color: var(--text-secondary); }
.cal-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.cal-item-body h3 { margin: 0; font: var(--type-label); font-size: var(--text-md); }
.cal-item-body p { margin: 0; display: flex; align-items: center; gap: var(--space-1); font: var(--type-body-sm); color: var(--text-secondary); }
.cal-item-body p .wl-icon { flex: none; }
.cal-item-body .cal-item-note { font: var(--type-caption); color: var(--text-muted); }
.cal-item-act { margin-top: var(--space-2); }
.cal-item-link { color: inherit; text-decoration: none; }
.cal-item-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.cal-item-link:focus-visible { outline: none; box-shadow: none; }
.cal-item-link:focus-visible::after { box-shadow: var(--focus-ring); }
.cal-item:has(.cal-item-link:hover) h3 { text-decoration: underline; }
.cal-item-go { align-self: center; color: var(--text-muted); }

.cal-section { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); scroll-margin-top: calc(var(--top-h) + var(--space-4)); }
.cal-section > h2 { margin: 0; font: var(--type-eyebrow); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
.cal-groups { width: 100%; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-4); }
.cal-group { display: grid; grid-template-columns: var(--space-10) minmax(0, 1fr); gap: var(--space-3); }
.cal-date { display: flex; flex-direction: column; align-items: center; padding-top: var(--space-3); font: var(--type-caption); color: var(--text-muted); text-transform: uppercase; }
.cal-date strong { font: var(--type-h3); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.cal-group[data-today] .cal-date strong { color: var(--accent); }

/* from 768px the titles fit in the month, and a chip goes straight to the session or the programme */
@media (min-width: 768px) {
  .cal-head { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-6); }
  .cal-head h1 { margin-right: auto; }
  .cal-wd span { padding-left: var(--space-3); text-align: left; }
  .cal-days { grid-auto-rows: minmax(var(--space-24), auto); }
  .cal-day { align-items: stretch; padding: var(--space-1) var(--space-1) var(--space-2); }
  .cal-num { margin-left: var(--space-1); }
  .cal-events { align-items: stretch; }
  .cal-chip { position: relative; z-index: 1; padding: 2px var(--space-2); pointer-events: auto; }
  .cal-chip[data-kind="program"] { padding: 2px var(--space-2); background: var(--surface-sunken); }
  a.cal-chip:hover .cal-chip-title { text-decoration: underline; }
  .cal-chip-title { display: block; }
  .cal-more { padding: 0 var(--space-2); }
  .cal-group { grid-template-columns: var(--space-12) minmax(0, 1fr); gap: var(--space-5); }
}

/* ---------- checkout (docs/plans/checkout/): the home page's table, /checkout/<SKU> ---------- */
.ap-offers-wrap { padding: 0; overflow: hidden; }
.ap-offers { width: 100%; border-collapse: collapse; font: var(--type-body-sm); }
.ap-offers thead { display: none; }
.ap-offers tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3) var(--space-4); align-items: center;
  padding: var(--space-4); }
.ap-offers tr + tr { border-top: 1px solid var(--border-subtle); }
.ap-offers th, .ap-offers td { padding: 0; text-align: left; font-weight: normal; }
.ap-offers th[scope="row"] { grid-column: 1 / -1; }
.ap-offer { display: flex; align-items: center; gap: var(--space-3); }
.ap-offer-pic { flex: none; display: grid; place-items: center; width: var(--space-12); height: var(--space-12); overflow: hidden;
  border-radius: var(--radius-control); background: var(--surface-sunken); color: var(--text-secondary); }
.ap-offer-pic img { width: 100%; height: 100%; object-fit: cover; }
.ap-offer-txt { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.ap-offer-txt strong { font: var(--type-label); }
.ap-offer-txt span { color: var(--text-secondary); }
.ap-offer-price { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.ap-offer-price strong { font: var(--type-label); }
.ap-offer-price span { font: var(--type-caption); color: var(--text-muted); }
.ap-offer-act { justify-self: end; }
.ap-offer-act .wl-btn { gap: var(--space-2); }

.ap-checkout-title { margin: 0; font: var(--type-h2); letter-spacing: var(--tracking-tight); }
.ap-checkout-grid { display: flex; flex-direction: column; gap: var(--space-5); }
.ap-checkout-side { display: flex; flex-direction: column; gap: var(--space-5); }
.ap-checkout-product { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.ap-checkout-pic { position: relative; display: block; aspect-ratio: 16 / 7; overflow: hidden; background: var(--surface-sunken); }
.ap-checkout-pic > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-checkout-about { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.ap-checkout-about h2 { margin: 0; font: var(--type-h3); }
.ap-checkout-about p { margin: 0; font: var(--type-body-sm); color: var(--text-secondary); white-space: pre-line; }
.ap-checkout-about .ap-checkout-gives { display: flex; align-items: center; gap: var(--space-2); color: var(--text-primary); white-space: normal; }
.ap-checkout-gives .wl-icon { flex: none; color: var(--accent); }
.ap-checkout-sum, .ap-checkout-pay { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.ap-checkout-sum > p { margin: 0; }
.ap-kv dt .wl-icon { margin-right: var(--space-2); vertical-align: -3px; }
.ap-kv dd { font-variant-numeric: tabular-nums; }
.ap-sum-discount dd { color: var(--success-fg); }
.ap-sum-total { padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.ap-kv .ap-sum-total dt, .ap-kv .ap-sum-total dd { font: var(--type-h3); color: var(--text-primary); }
.ap-kv .ap-sum-vat { font: var(--type-caption); }
.ap-code { padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.ap-code-row { display: flex; gap: var(--space-2); }
.ap-code-row .wl-input { flex: 1; min-width: 0; text-transform: uppercase; font-family: var(--font-mono); }
.ap-code-applied { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.ap-code-applied .wl-badge { font-family: var(--font-mono); }
.ap-code-applied .wl-badge .wl-icon { width: 14px; height: 14px; margin-right: var(--space-1); }
.ap-field-error .wl-input { border-color: var(--danger); }
.ap-error { color: var(--danger-fg); }
.ap-checkout-pay .wl-fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.ap-checkout-pay .wl-radios { display: flex; flex-direction: column; gap: var(--space-2); }
.ap-pay { gap: var(--space-3); }
.ap-pay-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; font: var(--type-body-sm); }
.ap-pay-txt strong { font: var(--type-label); }
.ap-pay-txt span { color: var(--text-secondary); }
.ap-pay-icon { display: grid; color: var(--text-secondary); }
/* the Vipps wordmark in Vipps orange on the Vipps card (the brand exception, see .ap-vipps-btn) */
.ap-pay-vipps { color: var(--vipps-orange); }
.ap-pay[data-soon] { opacity: 0.55; cursor: not-allowed; background: var(--surface-sunken); }
.ap-pay-soon { flex: none; }
.ap-checkout-go { display: flex; flex-direction: column; gap: var(--space-3); }
.ap-checkout-go .wl-btn { gap: var(--space-2); }
.ap-checkout-go .ap-note { font: var(--type-caption); text-align: center; }
@media (min-width: 768px) {
  .ap-offers thead { display: table-header-group; }
  .ap-offers tr { display: table-row; }
  .ap-offers th, .ap-offers td { padding: var(--space-3) var(--space-5); vertical-align: middle; border-top: 1px solid var(--border-subtle); }
  .ap-offers thead th { border-top: 0; font: var(--type-eyebrow); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
  .ap-offers th[scope="row"] { width: 100%; }
  .ap-offer-price { white-space: nowrap; }
  .ap-checkout { max-width: 1040px; }
  .ap-checkout-grid { display: grid; grid-template-columns: 7fr 5fr; gap: var(--space-8); align-items: start; }
  .ap-checkout-go .ap-note { text-align: left; }
}
