/* The backoffice's components (backoffice/templates/base.html.twig and every page under it),
   over the tokens of assets/tokens.css, which is loaded first.
   The installer's family (public/installer/installer.css): warm paper, slate ink, felt green,
   sky accent, system serif headings. Three shells share the tokens and the components:
     .console  the staff area: a navigation rail, a top bar, the page
     .player   a signed-in player's pages: the brand's band, the page
     .auth     sign-in, registration, the second factor: the brand's band, one card
   The player and auth shells take the brand's colours (assets/brand.js sets --brand-* on <html>
   from the brand settings); the staff area never does. No web fonts, nothing from another host,
   and the templates carry no inline style, so the pages hold under default-src 'self'. */

/* ---------- 1. The brand's colours (the tokens themselves are in tokens.css) ---------- */

/* The player and auth shells carry .is-brand: where assets/brand.js has set --brand-* on <html>
   (from the brand's own colours, each already brought to the contrast its use needs), the roles
   take them; where it has not, the roles are the defaults of tokens.css. */
.is-brand {
  --primary: var(--brand-primary, var(--p-felt));
  --primary-hover: var(--brand-primary-hover, var(--p-felt-hover));
  --primary-ink: var(--brand-primary-ink, var(--p-cream));
  --band: var(--brand-band, var(--p-felt));
  --band-2: var(--brand-band-2, var(--p-felt-deep));
  --band-ink: var(--brand-band-ink, #F6F2E8);
  --accent: var(--brand-accent, var(--p-sky));
  --accent-ink: var(--brand-link, var(--p-sky-ink));
  --gold: var(--brand-accent, var(--p-gold));
}
@media (prefers-color-scheme: dark) {
  .is-brand {
    --primary: var(--brand-primary-dark, var(--p-felt-bright));
    --primary-hover: var(--brand-primary-hover-dark, var(--p-felt-bright-hover));
    --primary-ink: var(--brand-primary-ink-dark, var(--p-white));
    --band-2: var(--brand-band-2, #0A2F1F);
    --accent: var(--brand-accent-dark, var(--p-sky));
    --accent-ink: var(--brand-link-dark, var(--p-sky-light));
  }
}

/* ---------- 2. Base ---------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 76px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-md)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { margin: 0; color: var(--ink); text-wrap: balance; }
h1 { font: 700 clamp(1.6rem, 3.4vw, var(--fs-2xl))/1.15 var(--serif); letter-spacing: -.02em; }
h2 { font: 700 var(--fs-xl)/1.3 var(--sans); letter-spacing: -.012em; }
h3 { font: 700 var(--fs-md)/1.35 var(--sans); }
h4 { font: 700 var(--fs-sm)/1.35 var(--sans); letter-spacing: .02em; }
p { margin: 0; text-wrap: pretty; }
ul, ol, dl, dd, figure { margin: 0; padding: 0; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-6) 0; }

a { color: var(--accent-ink); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2.5px; }

code, pre, kbd, .mono { font-family: var(--mono); font-size: .9em; }
code { padding: .1em .38em; border-radius: 6px; background: var(--surface-2); overflow-wrap: anywhere; }
pre {
  margin: 0;
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: .84rem;
  line-height: 1.55;
  overflow: auto;
  max-height: 34rem;
  tab-size: 2;
}
pre code { padding: 0; background: none; font-size: 1em; }

/* The focus outline is the link colour: 3:1 or more on every surface of both themes, which
   the accent itself is not on the light ones. */
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.skip {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--p-cream);
  color: var(--p-night);
  font-weight: 700;
  box-shadow: var(--shadow-3);
}
.skip:focus { top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- 3. The staff console: rail, top bar, page ---------- */

.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }

.rail {
  background: linear-gradient(180deg, var(--rail-bg) 0%, var(--rail-bg-2) 100%);
  color: var(--rail-ink);
  position: relative;
  z-index: 30;
}
.rail::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(227, 180, 92, .55), transparent);
  pointer-events: none;
}
.rail-inner { display: flex; flex-direction: column; }
.rail-head { display: flex; align-items: center; gap: var(--sp-3); padding: 12px 16px; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; margin-right: auto; color: inherit; text-decoration: none; border-radius: 10px; }
.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--p-felt-bright) 0%, var(--p-felt-deep) 100%);
  box-shadow: inset 0 0 0 1px rgba(251, 248, 241, .18), 0 6px 16px -8px rgba(0, 0, 0, .7);
  color: #FBF8F1;
  font: 700 1.2rem/1 var(--serif);
  text-transform: uppercase;
}
.brand-text { display: grid; gap: 4px; min-width: 0; }
.brand-name { font: 700 1.14rem/1.1 var(--serif); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-tag { font: 700 .62rem/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--rail-mark); }

.rail-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .06);
  color: var(--rail-ink);
  font: 650 var(--fs-sm)/1 var(--sans);
  text-decoration: none;
}
.rail-toggle:hover { background: rgba(255, 255, 255, .12); }
.rail-toggle .icon { width: 18px; height: 18px; }

.rail-nav { display: none; padding: 4px 12px 18px; }
.rail-nav:target, .rail-nav.is-open { display: block; }
.rail-close { display: inline-block; margin: 0 4px 6px; color: var(--rail-mark); font-size: var(--fs-sm); font-weight: 600; }
.js .rail-close { display: none; }

.nav-group + .nav-group { margin-top: 14px; }
.nav-title { padding: 0 12px 6px; font: 700 .66rem/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--rail-ink-2); }
.nav-list { list-style: none; display: grid; gap: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--rail-ink);
  font-size: .94rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
}
.nav-link .icon { color: var(--rail-ink-2); }
.nav-link:hover { background: var(--rail-hover); }
.nav-link[aria-current] { background: var(--rail-active); font-weight: 650; color: #FFFFFF; }
.nav-link[aria-current] .icon { color: var(--gold); }
.nav-link[aria-current]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
}
.rail :focus-visible { outline-color: var(--rail-mark); }

.rail-foot { display: none; }

.frame { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.crumbs { margin-right: auto; min-width: 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: var(--fs-sm); color: var(--ink-2); }
.crumbs li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs li + li::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--line-strong); border-top: 1.5px solid var(--line-strong); transform: rotate(45deg); flex: none; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }

.topbar-end { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 12px 4px 4px; border-radius: var(--r-pill); color: var(--ink); text-decoration: none; }
.who:hover { background: var(--surface-2); }
.who-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink);
  font: 700 .9rem/1 var(--sans);
  text-transform: uppercase;
}
.who-text { display: none; min-width: 0; line-height: 1.2; }
.who-name { display: block; font-size: var(--fs-sm); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.who-role { display: block; font-size: var(--fs-xs); color: var(--ink-2); }
.logout { margin: 0; }

.content { flex: 1; width: 100%; max-width: 1280px; padding: 22px 16px 48px; }
.frame-foot { padding: 14px 16px 22px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: var(--fs-xs); }

@media (min-width: 720px) {
  .who-text { display: block; }
  .topbar { padding: 10px 28px; }
  .content { padding: 28px 28px 56px; }
  .frame-foot { padding: 14px 28px 24px; }
}

@media (min-width: 1040px) {
  .app { grid-template-columns: 264px minmax(0, 1fr); grid-template-rows: auto; }
  .rail::after { inset: 0 0 0 auto; width: 1px; height: auto; background: linear-gradient(180deg, transparent, rgba(227, 180, 92, .45), transparent); }
  .rail-inner { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; }
  .rail-head { padding: 20px 20px 14px; }
  .rail-toggle, .rail-close { display: none; }
  .rail-nav, .rail-nav:target, .rail-nav.is-open { display: block; padding: 6px 12px 20px; flex: 1; }
  .rail-foot { display: block; padding: 14px 24px 20px; border-top: 1px solid var(--rail-line); color: var(--rail-ink-2); font-size: var(--fs-xs); line-height: 1.5; }
  .topbar { position: sticky; top: 0; z-index: 20; min-height: 62px; padding: 10px 36px; -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); }
  .content { padding: 32px 36px 64px; }
  .frame-foot { padding: 14px 36px 24px; }
}

/* ---------- 4. The player's pages and the sign-in pages ---------- */

.site-head {
  --ink: var(--band-ink);
  background:
    url("pattern.svg"),
    linear-gradient(135deg, var(--band) 0%, var(--band-2) 100%);
  background-color: var(--band);
  color: var(--band-ink);
  position: relative;
}
.site-head::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .75;
}
.site-head-inner { max-width: 1040px; margin-inline: auto; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.site-head .brand-mark { background: color-mix(in srgb, var(--band-ink) 14%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--band-ink) 30%, transparent); color: var(--band-ink); }
.site-head .brand-name { font-size: 1.25rem; color: var(--band-ink); }
.site-head :focus-visible { outline-color: var(--band-ink); }
.site-head .badge-play, .auth-head .badge-play { background: color-mix(in srgb, var(--band-ink) 16%, transparent); color: var(--band-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--band-ink) 34%, transparent); }

/* A phone: the brand and the sign-out, then the badge and the pages. */
.site-account { order: 1; }
.site-head .badge-play { order: 2; }
.site-nav { order: 3; flex: 1 1 0; min-width: 0; }
.site-nav ul { list-style: none; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -6px; padding: 2px 6px; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  color: var(--band-ink);
  font-size: .93rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a .icon { width: 18px; height: 18px; opacity: .85; }
.logout-button .icon { display: none; width: 18px; height: 18px; }
/* A phone: the sign-out is its icon (the words stay for assistive technologies), so the
   brand, the badge and the sign-out share the first line and the pages have the second. */
@media (max-width: 479px) {
  .site-nav { order: 3; flex: 1 1 100%; }
  .site-head .badge-play { order: 0; }
  .site-nav a { padding: 6px 11px; font-size: .88rem; }
  .site-nav a .icon { display: none; }
  .site-head .brand-name { font-size: 1.12rem; }
  .site-head .logout-button { width: 38px; padding: 0; }
  .logout-button .icon { display: block; }
  .logout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.site-nav a:hover { background: color-mix(in srgb, var(--band-ink) 12%, transparent); }
.site-nav a[aria-current] { background: color-mix(in srgb, var(--band-ink) 18%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--band-ink) 28%, transparent); }

.site-account { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; }
.site-account-name { display: none; font-size: var(--fs-sm); opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.site-head button.ghost, .auth-foot button.ghost { border-color: color-mix(in srgb, currentColor 40%, transparent); background: transparent; color: inherit; box-shadow: none; }
.site-head button.ghost:hover { background: color-mix(in srgb, var(--band-ink) 14%, transparent); border-color: var(--band-ink); }

.player { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.player .content { flex: 1 0 auto; max-width: 1040px; margin-inline: auto; padding: 26px 16px 56px; }
.site-foot { width: 100%; max-width: 1040px; margin-inline: auto; padding: 18px 16px 30px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: 6px 18px; }

@media (min-width: 860px) {
  .site-head-inner { padding: 14px 28px; flex-wrap: nowrap; }
  .site-account, .site-head .badge-play { order: 0; }
  .site-nav { order: 0; flex: 1 1 auto; }
  .site-nav ul { justify-content: center; }
  .site-account-name { display: block; }
  .player .content { padding: 40px 28px 72px; }
  .site-foot { padding: 20px 28px 36px; }
}

.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); position: relative; isolation: isolate; }
.auth::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 300px;
  z-index: -1;
  background:
    url("pattern.svg"),
    radial-gradient(120% 120% at 15% 0%, color-mix(in srgb, var(--band) 86%, #FFFFFF) 0%, var(--band) 42%, var(--band-2) 100%);
  background-color: var(--band);
  border-bottom: 2px solid color-mix(in srgb, var(--gold) 70%, transparent);
}
.auth-head { padding: 34px 16px 22px; display: grid; justify-items: center; gap: 12px; color: var(--band-ink); text-align: center; }
.auth-head .brand { margin: 0; flex-direction: column; gap: 12px; }
.auth-head .brand-mark { width: 56px; height: 56px; border-radius: 16px; font-size: 1.8rem; background: color-mix(in srgb, var(--band-ink) 14%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--band-ink) 32%, transparent), 0 14px 30px -14px rgba(0, 0, 0, .6); color: var(--band-ink); }
.auth-head .brand-name { font-size: 1.6rem; white-space: normal; color: var(--band-ink); }
.auth-head :focus-visible { outline-color: var(--band-ink); }

.auth .content {
  flex: none;
  width: min(30rem, 100% - 32px);
  max-width: none;
  margin-inline: auto;
  padding: 26px 22px 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-3);
}
.auth .content.wide { width: min(40rem, 100% - 32px); }
.auth-foot { width: min(30rem, 100% - 32px); margin: 18px auto 0; padding-bottom: 40px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; color: var(--ink-2); font-size: var(--fs-sm); text-align: center; }
.auth-foot form { margin: 0; }
@media (min-width: 560px) {
  .auth-head { padding-top: 52px; }
  .auth .content { padding: 34px 36px 36px; }
}

/* ---------- 5. The page: flow, heads, cards ---------- */

.content > * + *, .card > * + *, .stack > * + *, section > * + *, .panel > * + * { margin-top: var(--sp-4); }
.content > h2, .content > section > h2:not(:first-child) { margin-top: var(--sp-8); }
.content > h3, .card > h3 { margin-top: var(--sp-6); }
.content > section + section, .content > .card + .card, .content > section + .card, .content > .card + section { margin-top: var(--sp-6); }
.content ul:not([class]), .content ol:not([class]) { padding-left: 1.35em; display: grid; gap: 6px; }
.content ul.plain { list-style: none; padding: 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.page-head > div:first-child { min-width: 0; display: grid; gap: 8px; }
.page-head + * { margin-top: var(--sp-6); }
.page-actions, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.eyebrow { font: 700 .72rem/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--accent-ink); }
.lead { font-size: 1.04rem; line-height: 1.6; color: var(--ink-2); max-width: 46em; }
.muted, .help, .fine { color: var(--ink-2); }
.help, .fine { font-size: .92rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 20px 18px;
}
.card > h2:first-child, .panel > h2:first-child { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.card-warn { border-color: var(--wait-line); box-shadow: inset 4px 0 0 var(--wait-line), var(--shadow-2); }
.card-danger { border-color: var(--bad-line); }
.card .card, .card .panel { box-shadow: none; background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
@media (min-width: 720px) { .card, .panel { padding: 24px 26px; } }

.grid { display: grid; gap: var(--sp-4); }
@media (min-width: 720px) { .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.grid > * { margin-top: 0; min-width: 0; }

/* Task cards: the dashboard and the account home. */
.tiles { list-style: none; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 14px;
  align-content: start;
  height: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.tile-icon { grid-row: 1 / span 2; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); }
@media (prefers-color-scheme: dark) { .tile-icon { background: color-mix(in srgb, var(--primary) 30%, var(--surface)); color: color-mix(in srgb, var(--primary) 30%, #FFFFFF); } }
.tile-title { font-weight: 700; align-self: end; }
.tile-text { grid-column: 2; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-2); }
.tiles-title { font: 700 .72rem/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.tiles-title + .tiles { margin-top: var(--sp-3); }

/* Facts: a short labelled summary (an account's head, a table's state). */
.facts { display: grid; gap: 12px 28px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.facts > div { min-width: 0; display: grid; gap: 2px; align-content: start; }
.facts dt { font: 700 .7rem/1.3 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.facts dd { font-weight: 600; overflow-wrap: anywhere; }
.meta { color: var(--ink-2); font-size: .95rem; line-height: 1.7; }
.meta strong, .meta code { color: var(--ink); }

/* Sub-navigation: the settings tabs, the account tabs. */
.subnav, .tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); width: fit-content; max-width: 100%; box-shadow: var(--shadow-1); list-style: none; }
.subnav a, .tabs a { flex: none; padding: 7px 14px; border-radius: var(--r-pill); color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; white-space: nowrap; }
.subnav a:hover, .tabs a:hover { background: var(--surface-2); color: var(--ink); }
.subnav a[aria-current], .tabs a[aria-current] { background: var(--ink); color: var(--surface); }
.subnav + h1, .tabs + h1, .tabs + .page-head, .subnav + .page-head { margin-top: var(--sp-5); }

/* ---------- 6. Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); -webkit-overflow-scrolling: touch; }
.card .table-wrap, .panel .table-wrap { box-shadow: none; }
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; font-variant-numeric: tabular-nums; }
caption { caption-side: top; padding: 12px 14px; text-align: left; font-weight: 700; color: var(--ink); }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  font: 700 .72rem/1.35 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: bottom;
}
tbody th { font-weight: 650; }
tbody tr:last-child > td, tbody tr:last-child > th, tfoot tr:last-child > td, tfoot tr:last-child > th { border-bottom: 0; }
tbody tr:hover > td, tbody tr:hover > th { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tfoot td, tfoot th { background: var(--surface-2); font-weight: 650; }
td > a:first-child:last-child { font-weight: 600; }
td[colspan].muted, td[colspan].help, td.empty { padding: 30px 16px; text-align: center; color: var(--ink-2); font-size: .95rem; }
tbody tr:hover > td[colspan] { background: none; }
td form, th form { margin: 0; }
/* A table that is not in a wrap (a few are read by tests as the heading's sibling): on a
   small screen it scrolls in itself. */
@media (max-width: 719px) { :not(.table-wrap) > table { display: block; overflow-x: auto; } }
:not(.table-wrap) > table { border: 1px solid var(--line); border-radius: var(--r-md); border-collapse: separate; border-spacing: 0; background: var(--surface); overflow: hidden; }

.empty-state { padding: 34px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); text-align: center; color: var(--ink-2); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.empty-state > * + * { margin-top: 8px; }
.empty-state strong { display: block; color: var(--ink); font-size: 1.05rem; }

/* ---------- 7. Badges and messages ---------- */

.badge {
  display: inline-block;
  max-width: 100%;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--soon-bg);
  color: var(--soon);
  font: 600 .76rem/1.5 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
  overflow-wrap: anywhere;
}
.badge-applied, .badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-pending, .badge-restart, .badge-wait { background: var(--wait-bg); color: var(--wait); }
.badge-error, .badge-out-of-sync, .badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-secret { background: var(--secret-bg); color: var(--secret); }
.badge-play, .badge.bot { background: var(--play-bg); color: var(--play); }
.badge-play { font-weight: 700; }
h1 .badge { font-size: .8rem; }

.flash, .banner {
  padding: 12px 16px 12px 46px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  position: relative;
  box-shadow: var(--shadow-1);
}
.flash::before, .banner::before {
  content: "i";
  position: absolute;
  left: 15px;
  top: 14px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: currentColor;
  font: 800 .78rem/20px var(--sans);
  text-align: center;
}
.flash::after, .banner::after {
  content: "i";
  position: absolute;
  left: 15px;
  top: 14px;
  width: 20px;
  color: var(--surface);
  font: 800 .78rem/20px var(--sans);
  text-align: center;
}
.flash-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.flash-success::after { content: ""; left: 21px; top: 20px; width: 9px; height: 5px; border-left: 2.5px solid var(--ok-bg); border-bottom: 2.5px solid var(--ok-bg); transform: rotate(-45deg); }
.flash-success::before { content: ""; }
.flash-error { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.flash-error::before, .flash-warning::before, .banner::before { content: ""; }
.flash-error::after { content: "!"; color: var(--bad-bg); }
.flash-warning, .banner { background: var(--wait-bg); border-color: var(--wait-line); color: var(--wait); }
.flash-warning::after, .banner::after { content: "!"; color: var(--wait-bg); }
.flash a, .banner a { color: inherit; font-weight: 700; }
.flash > p + p, .banner > p + p { margin-top: 6px; }
.flash form, .banner form { margin-top: 10px; }
.flash.is-dismissible { padding-right: 46px; }
.flash-close {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 34px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font: 400 1.35rem/1 var(--sans);
}
.flash-close:hover { background: color-mix(in srgb, currentColor 14%, transparent); transform: none; border: 0; }
.field-warning { font-size: .9rem; }

/* ---------- 8. Forms ---------- */

form { margin: 0; }
label { font-weight: 650; font-size: .95rem; }
.content form:not(.inline-form) label { display: block; margin-top: 14px; }
.content form:not(.inline-form) label:first-child { margin-top: 0; }
.content form:not(.inline-form) label + input, .content form:not(.inline-form) label + select, .content form:not(.inline-form) label + textarea { margin-top: 6px; display: block; }
.content form:not(.inline-form) label > input:not([type=checkbox]):not([type=radio]), .content form:not(.inline-form) label > select, .content form:not(.inline-form) label > textarea { display: block; margin-top: 6px; font-weight: 400; }
.content form:not(.inline-form) > button, .content form:not(.inline-form) > p > button { margin-top: 18px; }
.content form:not(.inline-form) > input[type=hidden]:first-child + button { margin-top: 0; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=date], input[type=datetime-local], input[type=time], input[type=tel], input:not([type]), select, textarea {
  width: 100%;
  max-width: 34rem;
  min-height: var(--control-h);
  padding: 9px 13px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 9rem; max-width: 100%; font-family: var(--mono); font-size: .88rem; line-height: 1.5; resize: vertical; }
select { appearance: auto; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: .9; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 10px; }
input[disabled], select[disabled], textarea[disabled], input[readonly] { background: var(--surface-2); color: var(--ink-2); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0 8px 0 0; vertical-align: -3px; accent-color: var(--primary); }
.auth input[type=text], .auth input[type=email], .auth input[type=password], .auth input[type=number], .auth select { max-width: none; }
.code-input, .auth input.code-input, input[autocomplete="one-time-code"] { max-width: 14rem; font-family: var(--mono); font-size: 1.3rem; letter-spacing: .24em; text-align: center; }

/* A field: its label (and what is said of it, as badges) on one line, then the control, its
   messages and its help, each on a line of its own. */
.field { min-width: 0; }
.field + .field { margin-top: 16px; }
.content form:not(.inline-form) .field > label { display: inline-block; margin: 0 8px 0 0; }
.field > .badge { margin: 0 4px 0 0; }
.field > input:not([type=checkbox]):not([type=radio]), .field > select, .field > textarea, .field > div, .field > p, .field > ul, .field > button { display: block; margin-top: 6px; }
.content form:not(.inline-form) .field > label + input, .content form:not(.inline-form) .field > label + select, .content form:not(.inline-form) .field > label + textarea { margin-top: 6px; }
.field-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.help-text, .field .help, form .help-text { font-size: .86rem; line-height: 1.5; color: var(--ink-2); font-weight: 400; }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea, [aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.field-errors, ul.errors, form ul:not([class]):has(> li:only-child):not(:has(a, input, label, code, strong)) { color: var(--bad); font-size: .9rem; font-weight: 600; }
.field-errors ul, .content .field-errors ul:not([class]) { list-style: none; padding: 0; display: grid; gap: 4px; }
.field-errors li { padding-left: 24px; position: relative; }
.field-errors li::before {
  content: "!";
  position: absolute;
  left: 0;
  top: .15em;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bad);
  color: var(--surface);
  font: 800 .72rem/16px var(--sans);
  text-align: center;
}
.field-check { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 2px; row-gap: 4px; align-items: start; }
.content form:not(.inline-form) .field-check > label { margin: 0; }
.field.field-check > div, .field.field-check > p { margin-top: 0; }
.field-check > input { grid-column: 1; grid-row: 1; margin-top: 3px; }
.field-check > label { grid-column: 2; grid-row: 1; }
.field-check > .field-errors, .field-check > .help-text { grid-column: 2; }
.field-group > .field-group-body { display: grid; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.field-group .field + .field { margin-top: 0; }
fieldset { margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
legend { padding: 0 6px; font-weight: 650; font-size: .95rem; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 9px 20px;
  border: 1.5px solid var(--primary);
  border-radius: var(--r-pill);
  background: var(--primary);
  color: var(--primary-ink);
  font: 650 .97rem/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 18px -14px color-mix(in srgb, var(--primary) 90%, transparent);
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
button:hover, .button:hover { background: var(--primary-hover); border-color: var(--primary-hover); transform: translateY(-1px); }
button:active, .button:active { transform: translateY(0); }
button.secondary, .button.secondary, button.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); box-shadow: none; }
button.secondary:hover, .button.secondary:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); border-color: var(--ink); }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); box-shadow: none; }
button.danger:hover, .button.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
button.danger.secondary { background: transparent; color: var(--bad); border-color: var(--bad-line); }
button.danger.secondary:hover { background: var(--bad-bg); border-color: var(--bad); }
button[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
button.small, .button.small, td button, td .button, .inline-form button, .topbar button, .site-head button {
  min-height: 36px;
  padding: 6px 15px;
  font-size: .88rem;
}
.link-button { min-height: 0; padding: 0; border: 0; border-radius: 4px; background: none; box-shadow: none; color: var(--accent-ink); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { background: none; transform: none; text-decoration-thickness: 2.5px; }

/* A form that sits in a line: a row's action, a toolbar's control with its reason. */
.inline-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; vertical-align: middle; }
.inline-form input[type=text], .inline-form input[type=number], .inline-form select, .inline-form input:not([type]) { width: auto; min-width: 0; max-width: 13rem; min-height: 36px; padding: 5px 11px; font-size: .9rem; flex: 1 1 8rem; }
.inline-form label { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.toolbar > * { margin-top: 0; }
.toolbar .inline-form { flex-wrap: nowrap; }
.inline-form button, td button { white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); }
.content form.filters label { margin-top: 0; flex: 1 1 11rem; min-width: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.content form.filters label > input, .content form.filters label > select { max-width: none; color: var(--ink); }
.content form.filters > button { margin-top: 0; }
.filters input[type=text], .filters select, .filters input[type=date], .filters input[type=number] { min-height: 40px; padding: 7px 11px; }

@media (max-width: 479px) { .actions > button, .actions > .button, .auth .content form > button { flex: 1 1 100%; width: 100%; } }
.auth .content form > button { width: 100%; }

details { border: 1px solid var(--line); border-radius: var(--r-md); background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
details > summary { cursor: pointer; padding: 11px 16px; font-weight: 650; border-radius: var(--r-md); }
details[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--r-md) var(--r-md) 0 0; }
details > :not(summary) { margin: 14px 16px; }

/* ---------- 9. Small parts ---------- */

.recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.recovery-codes code { display: block; padding: 10px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 1rem; font-weight: 600; letter-spacing: .06em; text-align: center; }

.key-line { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 1.05rem; font-weight: 600; letter-spacing: .06em; }
code.wrap { display: block; padding: 10px 12px; font-size: .8rem; overflow-wrap: anywhere; word-break: break-all; }
.steps-list { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 18px; }
.content ol.steps-list { padding-left: 0; }
.steps-list > li { counter-increment: s; position: relative; padding-left: 44px; min-width: 0; }
.steps-list > li > * + * { margin-top: 8px; }
.steps-list > li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1.5px solid var(--line); font: 700 .88rem/27px var(--sans); text-align: center; }

.item-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.content ul.item-list { padding-left: 0; }
.item-list > li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.item-list > li > form { margin-left: auto; }

.split { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: var(--fs-sm); }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .95rem; }
.auth .links, .auth .auth-actions { justify-content: center; }
.auth .content > h1 + .lead { text-align: center; margin-inline: auto; }
.auth .content > .error-code + h1 { margin-top: 4px; }
.plain-mark { border-radius: 16px; box-shadow: 0 14px 30px -14px rgba(0, 0, 0, .6); }
.auth .content > h1 { text-align: center; }
.auth .content > h1 + p:not(.flash):not(.banner) { text-align: center; color: var(--ink-2); }

.error-code { font: 700 clamp(3.4rem, 12vw, 5rem)/1 var(--serif); letter-spacing: -.03em; color: color-mix(in srgb, var(--ink) 22%, transparent); text-align: center; }

.text-bad { color: var(--bad); font-weight: 650; }
.text-ok { color: var(--ok); font-weight: 650; }

/* ---------- 10. The player's pages ---------- */

#balance { font-size: 1.08rem; font-weight: 600; color: var(--ink); }
#balance.muted { font-weight: 400; color: var(--ink-2); }
.balance-line { font-size: 1.05rem; }
.claims { display: grid; gap: 14px; }
.claims > * { margin-top: 0; }
.claim { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); }
.claim > * + * { margin-top: 8px; }
.claim[data-available="yes"] { border-color: var(--ok-line); background: color-mix(in srgb, var(--ok-bg) 45%, var(--surface)); }
@media (min-width: 720px) { .claims { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#totp-secret { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 1.05rem; font-weight: 600; letter-spacing: .06em; word-spacing: .2em; }
.passkey-form { display: grid; gap: 14px; }
.passkey-form > * { margin-top: 0; }
.passkey-form:has(> button[hidden]) { display: none; }
.content form.passkey-form > button { margin-top: 0; width: 100%; }
label.check { display: flex !important; align-items: flex-start; gap: 2px; font-weight: 500; }
label.check > input { margin-top: 3px; }

/* A row of forms: a table's controls, each with its reason. */
.content > .inline-form, .card > .inline-form, section > .inline-form { margin: 10px 14px 0 0; }
.content > h2 + .inline-form, .card > h2 + .inline-form { margin-top: var(--sp-4); }

/* Choices as a row of ticks (roles), inside a field. */
.field-group > div[id]:has(> input[type=checkbox], > input[type=radio]) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 4px; }
.content form:not(.inline-form) .field-group > div[id] > label { display: inline; margin: 0 16px 0 0; font-weight: 500; }

/* ---------- 11. The staff console's plain pages ---------- */

/* A form that stands on a console page by itself is a card, whatever its page wrote. */
.console .content > form:not(.inline-form):not(.filters):not(.card) {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 20px 18px;
}
@media (min-width: 720px) { .console .content > form:not(.inline-form):not(.filters):not(.card) { padding: 24px 26px; } }
/* A form that is only its hidden fields and one button (a single action) stays a button. */
.console .content > form:not(.inline-form):not(.filters):not(.card):not(:has(label, input:not([type=hidden]), select, textarea)) { background: none; border: 0; box-shadow: none; padding: 0; }

/* The session warning of assets/session.js: a calm note at the foot of the window. */
.session-warning {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  max-width: 560px;
  margin: 0 auto;
  box-shadow: var(--shadow-2);
}
.session-warning button { margin-top: 10px; }

/* ---------- 12. Motion and print ---------- */

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

@media print {
  .rail, .topbar, .site-head, .frame-foot, .site-foot, .skip { display: none !important; }
  .app { display: block; }
  body { background: #FFFFFF; }
  .card, .table-wrap { box-shadow: none; }
}
