/* The account pages' stylesheet. It uses design tokens (tokens.css) and
   nothing else: no raw colours, sizes of the brand, or durations. Phone first
   (designed at 390px), the same single column on desktop.

   Components (docs/design.md s15.4). Class names are the contract with the
   templates:

   Shell        .app-header .brand .logo .header-actions .tabs .tab
                (a tab marks the current section with aria-current="page")
                .skip-link .page .auth (single column, max 28rem)
   Surfaces     .card (+ .hero-card, .card-quiet) .card-head .stack .prose
   Hero         .hero .hero-mark .hero-icon .lede .badge-icon
   Auth extras  .chip .promise .footer-links .row-link
   Options      .options (group of secondary actions under the primary one)
   Buttons      .btn (primary) .btn-secondary .btn-quiet .btn-danger
                sizes .btn-lg .btn-sm, .btn-block (full width), a bare
                <button> is primary; icons go inside as {{icon "name"}}
   Fields       .field (label, input, .field-hint, .field-error) .input-code
                .check (checkbox or radio row) .avatar-grid .avatar-choice
   Status       .banner .banner-info|success|warning|danger (icon + text)
                .status for a [data-status] line (add .is-error or
                data-state="error" to turn it red) .meta .muted .error-text
   Signed in    .greeting .profile .avatar-initial .app-grid .app-tile .banners
                .section .section-head .back .kv .btn-danger-quiet .sheet-title
                a.list-row (a whole row that opens a page) .list-action
   Lists        .list > .list-row (.list-icon .list-main .list-trail), .row,
                .empty (empty state)
   Confirm      <details class="confirm"> with a <summary class="btn
                btn-danger"> and a .confirm-body: no JavaScript needed
   QR and codes .qr-panel .qr, .code-grid, .actions (.actions-row)
   Kids         .avatar .kid-grid .kid-tile .pad .pair-code .kid-mode
                (kid mode raises --touch-min to 64px)

   Rules: every control is at least var(--touch-min) tall; focus is always a
   visible ring; nothing moves on load (images and QR codes have fixed sizes);
   reduced motion zeroes the durations in tokens.css. */

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

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

/* The hidden attribute must win over the display rules below (the hybrid action is hidden until the browser supports it). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--color-bg) var(--glow-page-narrow) no-repeat;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* A smaller, fainter lamplight on phones; the wide one from 40rem. */
@media (min-width: 40rem) {
  body {
    background-image: var(--glow-page);
  }
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
}

strong {
  font-weight: var(--weight-semibold);
}

a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--color-accent-hover);
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: block;
  flex: none;
  width: var(--icon-size);
  height: var(--icon-size);
}

/* ---- Shell ---- */

.skip-link {
  position: absolute;
  top: calc(-1 * var(--space-12) - var(--space-8));
  left: var(--space-4);
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.skip-link:focus {
  top: var(--space-2);
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: var(--space-3);
  max-width: var(--content-max);
  margin: 0 auto;
  padding: calc(var(--space-2) + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-min);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.brand:hover {
  color: var(--color-text);
}

.logo {
  display: block;
  flex: none;
  width: 2rem;
  height: 2rem;
}

.logo-l {
  fill: var(--color-mark-l);
}

.logo-door {
  fill: var(--color-mark-door);
}

/* The wordmark: Literata SemiBold. Under 24px tall the mark stands alone. */
.brand-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.header-actions form {
  margin: 0;
}

.tabs {
  display: flex;
  grid-column: 1 / -1;
  gap: var(--space-1);
  margin-top: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  margin-bottom: -1px;
  padding: 0 var(--space-4);
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

.tab:hover {
  color: var(--color-text);
}

.tab[aria-current="page"] {
  border-bottom-color: var(--color-accent);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.tab[aria-current="page"] .icon {
  color: var(--color-accent);
}

.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4) max(var(--gutter), env(safe-area-inset-right)) calc(var(--space-12) + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

.page > * + * {
  margin-top: var(--space-4);
}

.bare .app-header {
  display: none;
}

/* Kid-device screens: the lockup (a plain, non-link span there) floats at the
   top centre without taking height. Grown-up pages that reuse .kid-stage keep
   their normal header. */
body:has(.kid-mode) .kid-stage {
  padding-top: calc(var(--space-3) + var(--touch-min) + var(--space-2));
}

body:has(.kid-mode) .app-header {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  justify-content: center;
  padding-top: calc(var(--space-3) + env(safe-area-inset-top));
  pointer-events: none;
}

/* A signed-in page built on the narrow auth column (codes, links) lines the
   header up with it. */
body:has(.auth) .app-header {
  max-width: var(--auth-max);
}

/* From 30rem the card is drawn: the logo shares the card's content edge. */
@media (min-width: 30rem) {
  body:has(.auth) .app-header {
    padding-inline: calc(var(--space-5) + 1px);
  }
}

@media (min-width: 40rem) {
  body:has(.auth) .app-header {
    padding-inline: calc(var(--space-8) + 1px);
  }
}

/* Narrow phones: the logo alone is the brand; the name stays for assistive
   technology. Leaves room for "Back to kids" and "Sign out" together. */
@media (max-width: 22rem) {
  .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

.bare .page {
  padding-top: calc(var(--space-8) + env(safe-area-inset-top));
}

.auth {
  display: grid;
  gap: var(--space-4);
  max-width: var(--auth-max);
  margin: 0 auto;
}

@media (min-width: 40rem) {
  .page {
    padding-top: var(--space-8);
  }

  .bare .page {
    padding-top: var(--space-12);
  }
}

/* ---- Surfaces ---- */

/* On phones an auth page gives the content the full width: no card chrome,
   the page background shows through. The card returns from 30rem up. */
@media (max-width: 29.99rem) {
  .auth .hero-card {
    padding-inline: 0;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  .auth .qr-panel {
    background: var(--color-qr-bg);
  }
}

.card {
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
}

.card-quiet {
  border-color: transparent;
  background: var(--color-surface-2);
  box-shadow: none;
}

.hero-card {
  padding: var(--space-8) var(--space-5) var(--space-6);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.card-head > div > * + * {
  margin-top: var(--space-1);
}

.card-head h2 {
  font-size: var(--text-lg);
}

.stack {
  --stack-gap: var(--space-4);
}

.hero-card {
  --stack-gap: var(--space-5);
}

.stack > * + * {
  margin-top: var(--stack-gap);
}

@media (min-width: 40rem) {
  .card {
    padding: var(--space-6);
  }

  .hero-card {
    padding: var(--space-10) var(--space-8) var(--space-8);
  }
}

.hero {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.625rem, 7vw, var(--text-3xl));
  text-wrap: balance;
}

.hero .hero-brand {
  font-size: clamp(1.5rem, 6.5vw, var(--text-2xl));
}

.hero .lede {
  max-width: 24rem;
}

.lede {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  text-wrap: pretty;
}

.hero-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.hero-mark .logo {
  width: 2.5rem;
  height: 2.5rem;
}

.hero-wordmark {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
}

.hero-icon,
.badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: var(--radius-full);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.hero-icon {
  width: 4rem;
  height: 4rem;
}

.hero-icon .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.hero-icon-muted {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.badge-icon {
  width: 2.75rem;
  height: 2.75rem;
}

.prose {
  max-width: 38rem;
  margin: 0 auto;
}

.prose h1 {
  margin-top: var(--space-2);
  font-size: var(--text-3xl);
}

.prose h2 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-2);
}

.prose p {
  margin-bottom: var(--space-4);
  line-height: 1.65;
}

.prose .lede {
  margin-top: var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
}

.prose .back {
  margin: 0;
}

.center {
  text-align: center;
}

.footnote {
  text-align: center;
}

.footnote a,
.back a,
.center > a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: 0 var(--space-2);
}

.muted {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.meta .icon {
  width: 1rem;
  height: 1rem;
}

.meta.center {
  justify-content: center;
}

p.meta {
  margin-bottom: var(--space-4);
}

.hero-card .meta {
  margin-bottom: 0;
}

.error-text {
  color: var(--color-danger);
}

/* ---- Buttons ---- */

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  min-width: var(--touch-min);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font: inherit;
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:hover,
button:hover {
  background: var(--color-primary-hover);
  color: var(--color-on-primary);
}

/* The main button carries the lamplight shadow (dark theme only). */
.btn:not(.btn-secondary, .btn-quiet, .btn-danger, .btn-danger-quiet, .btn-muted) {
  box-shadow: var(--shadow-primary);
}

.btn:active,
button:active {
  transform: scale(0.98);
}

.btn:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-lg {
  min-height: 3.5rem;
  border-radius: var(--radius-lg);
  font-size: var(--text-lg);
}

.btn-lg .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.btn-sm {
  min-height: var(--touch-min);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-secondary {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
}

.btn-secondary:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-quiet {
  background: transparent;
  color: var(--color-accent);
}

.btn-quiet:hover {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.btn-muted {
  color: var(--color-text-muted);
}

.btn-muted:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-danger);
  color: var(--color-on-danger);
}

.btn-danger:hover {
  background: var(--color-danger);
  color: var(--color-on-danger);
  box-shadow: inset 0 0 0 999px var(--color-scrim);
}

.actions {
  display: grid;
  gap: var(--space-3);
}

.actions-3 {
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.actions-3 .btn {
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.actions-3 .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.actions-row {
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}

/* Secondary options under a primary action ("Other ways to sign in"): a
   group of quiet buttons or links. It disappears when every item is hidden. */
.options {
  display: grid;
  gap: var(--space-1);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.options:not(:has(> :not([hidden]))) {
  display: none;
}

/* An app-context chip ("School is asking who you are"), a one-line promise
   and the footer links of an auth page. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-accent-soft);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.chip .icon {
  width: 1rem;
  height: 1rem;
  color: var(--color-accent);
}

.promise {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.promise .icon {
  margin-top: 0.1rem;
  color: var(--color-success);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1) var(--space-4);
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  font-size: var(--text-sm);
}

/* One tappable row with a chevron (a button or a link). */
.row-link {
  display: flex;
  border: 1px solid var(--color-border);
  justify-content: flex-start;
  gap: var(--space-3);
  width: 100%;
  min-height: 4rem;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: var(--weight-regular);
  text-align: left;
}

.row-link:hover {
  background: var(--color-accent-soft);
  color: var(--color-text);
}

.row-link-text {
  display: grid;
  flex: 1;
  gap: var(--space-1);
}

.row-link > .icon {
  color: var(--color-text-muted);
}

/* ---- Fields ---- */

label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

input:not([type="checkbox"], [type="radio"], [type="hidden"]),
select,
textarea {
  display: block;
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  transition: border-color var(--duration-fast) var(--ease-out);
}

input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

input:not([type="checkbox"], [type="radio"], [type="hidden"]):focus,
select:focus,
textarea:focus {
  border-color: var(--color-focus);
  outline: 3px solid var(--color-focus);
  outline-offset: 0;
}

input[readonly] {
  background: var(--color-surface-2);
  text-overflow: ellipsis;
}

select {
  width: auto;
  max-width: 100%;
  padding-right: var(--space-3);
}

.field select {
  width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--color-accent);
}

.field label {
  margin-bottom: var(--space-2);
}

.field-hint {
  margin-top: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.field-error {
  margin-top: var(--space-2);
  color: var(--color-danger);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.input-code {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

.input-code::placeholder {
  text-transform: none;
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-min);
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
}

fieldset.avatars {
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.avatars legend {
  padding: 0;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* ---- Status ---- */

.banner,
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.banner .icon {
  margin-top: 0.1rem;
  color: var(--color-accent);
}

.banner-success {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.banner-success .icon {
  color: var(--color-success);
}

.banner-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.banner-warning .icon {
  color: var(--color-warning);
}

.banner-danger,
.notice.error-text {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.banner-danger .icon {
  color: var(--color-danger);
}

/* The live region stays rendered, even when empty: a region that is not in the
   accessibility tree when its text changes is announced unreliably. One line
   of height is reserved so the layout does not jump when a message arrives. */
.status {
  min-height: calc(var(--text-sm) * var(--leading-snug));
  line-height: var(--leading-snug);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

/* Reserved line, kept close to the action it reports on. */
.stack > .status {
  margin-top: var(--space-2);
}

.stack > .status + * {
  margin-top: var(--space-2);
}

.status.is-error,
[data-status][data-state="error"] {
  color: var(--color-danger);
  font-weight: var(--weight-medium);
}

/* ---- Lists, rows, empty states, confirm ---- */

.list {
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3.5rem;
  padding: var(--space-3) var(--space-4);
}

.list-row + .list-row {
  border-top: 1px solid var(--color-border);
}

.list-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.list-main {
  flex: 1;
  min-width: 0;
}

.list-main > :first-child {
  font-weight: var(--weight-medium);
}

.list-trail {
  flex: none;
  color: var(--color-text-muted);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border);
}

.row:first-of-type {
  border-top: 0;
}

.row form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.empty {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
  text-align: center;
}

details > summary {
  list-style: none;
  cursor: pointer;
}

details > summary::-webkit-details-marker {
  display: none;
}

details[open] > summary {
  margin-bottom: var(--space-3);
}

.confirm-body {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

/* ---- QR and codes ---- */

.qr-panel {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-qr-bg);
}

.qr {
  display: block;
  image-rendering: pixelated;
  width: 18rem;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  aspect-ratio: 1;
  background: var(--color-qr-bg);
}

.code-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin-bottom: 0;
  padding: 0;
  list-style: none;
}

.code-grid li {
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
  user-select: all;
}

@media (max-width: 21rem) {
  .actions-3 {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 18.5rem) {
  .code-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Kids: avatars, picker, picture pad, pairing. Colours of each avatar
   are tokens (--avatar-<id>), the ones published in /static/avatars.json. ---- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-full);
  background: var(--color-border);
  font-size: 1.75rem;
  line-height: 1;
}

.avatar-sm {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.25rem;
}

.avatar-xl {
  width: 7rem;
  height: 7rem;
  font-size: 3.5rem;
}

.av-fox {
  background: var(--avatar-fox);
}

.av-owl {
  background: var(--avatar-owl);
}

.av-whale {
  background: var(--avatar-whale);
}

.av-cat {
  background: var(--avatar-cat);
}

.av-dog {
  background: var(--avatar-dog);
}

.av-panda {
  background: var(--avatar-panda);
}

.av-frog {
  background: var(--avatar-frog);
}

.av-lion {
  background: var(--avatar-lion);
}

.av-tiger {
  background: var(--avatar-tiger);
}

.av-bear {
  background: var(--avatar-bear);
}

.av-bunny {
  background: var(--avatar-bunny);
}

.av-penguin {
  background: var(--avatar-penguin);
}

.av-koala {
  background: var(--avatar-koala);
}

.av-monkey {
  background: var(--avatar-monkey);
}

.av-unicorn {
  background: var(--avatar-unicorn);
}

.av-dragon {
  background: var(--avatar-dragon);
}

.av-dino {
  background: var(--avatar-dino);
}

.av-octopus {
  background: var(--avatar-octopus);
}

.av-turtle {
  background: var(--avatar-turtle);
}

.av-butterfly {
  background: var(--avatar-butterfly);
}

.av-bee {
  background: var(--avatar-bee);
}

.av-robot {
  background: var(--avatar-robot);
}

.av-rocket {
  background: var(--avatar-rocket);
}

.av-star {
  background: var(--avatar-star);
}

.av-pig {
  background: var(--avatar-pig);
}

.av-hedgehog {
  background: var(--avatar-hedgehog);
}

.av-otter {
  background: var(--avatar-otter);
}

.av-sloth {
  background: var(--avatar-sloth);
}

.av-flamingo {
  background: var(--avatar-flamingo);
}

.av-shark {
  background: var(--avatar-shark);
}

.av-dolphin {
  background: var(--avatar-dolphin);
}

.av-ladybug {
  background: var(--avatar-ladybug);
}

.av-cactus {
  background: var(--avatar-cactus);
}

.av-sunflower {
  background: var(--avatar-sunflower);
}

.av-mushroom {
  background: var(--avatar-mushroom);
}

.av-tree {
  background: var(--avatar-tree);
}

.av-taco {
  background: var(--avatar-taco);
}

.av-pizza {
  background: var(--avatar-pizza);
}

.av-cupcake {
  background: var(--avatar-cupcake);
}

.av-avocado {
  background: var(--avatar-avocado);
}

.av-strawberry {
  background: var(--avatar-strawberry);
}

.av-moon {
  background: var(--avatar-moon);
}

.av-sun {
  background: var(--avatar-sun);
}

.av-planet {
  background: var(--avatar-planet);
}

.av-balloon {
  background: var(--avatar-balloon);
}

.av-guitar {
  background: var(--avatar-guitar);
}

.av-smile {
  background: var(--avatar-smile);
}

.av-cool {
  background: var(--avatar-cool);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr));
  gap: var(--space-1);
}

.avatar-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: var(--space-1);
  border: 3px solid transparent;
  border-radius: var(--radius-lg);
  font-weight: var(--weight-regular);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.avatar-choice .avatar {
  width: 3.25rem;
  height: 3.25rem;
  font-size: 1.75rem;
}

.avatar-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.avatar-choice:hover {
  background: var(--color-surface-2);
}

.avatar-choice:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.avatar-choice:has(input:focus-visible) {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.avatar-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.avatar-lg {
  width: 4.5rem;
  height: 4.5rem;
  font-size: 2.25rem;
}

/* Kid mode: 64px targets, big avatars, one sentence per screen. */

.kid-mode {
  --touch-min: 64px;
  --control-height: 4rem;
}

.kid-stage {
  display: grid;
  justify-items: center;
  gap: var(--space-5);
  max-width: 36rem;
  margin: 0 auto;
  text-align: center;
}

.kid-tall {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 48rem;
  min-height: calc(100dvh - var(--space-12) - var(--space-8) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* Free height splits above the content and above the grown-up button, so the
   tiles sit in the middle of a tall tablet and the quiet button stays at the
   bottom corner. */
.kid-tall > :first-child {
  margin-top: auto;
}

.kid-tall > :last-child:not(.kid-foot) {
  margin-bottom: auto;
}

.kid-tall > .kid-foot {
  margin-top: auto;
  padding-top: var(--space-5);
}

.kid-stage > * {
  max-width: 100%;
  margin: 0;
}

.kid-stage .banner {
  text-align: left;
}

.kid-title,
.kid-hello h1 {
  font-size: var(--text-3xl);
}

.kid-card {
  width: 100%;
  max-width: var(--auth-max);
  justify-items: center;
  padding: var(--space-8) var(--space-5);
}

.kid-card > *,
.kid-card [data-live] > *,
.kid-card [data-gone] > * {
  margin-inline: auto;
}

.kid-card .btn,
.kid-card button {
  min-height: var(--touch-min);
}

/* Cards that swap their content (pairing denied/expired) and the result
   cards keep full-width buttons: grid items would shrink to their content. */
.kid-card [data-live],
.kid-card [data-gone],
.kid-card > p {
  width: 100%;
}

.kid-card h1[tabindex="-1"]:focus {
  outline: none;
}

.kid-card form {
  width: 100%;
}

.kid-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: var(--radius-full);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.kid-badge .icon {
  width: 2.25rem;
  height: 2.25rem;
}

.kid-badge-ok {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.kid-badge-warn {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.kid-badge-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.kid-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
}

.kid-grid form {
  display: block;
  flex: 0 1 calc(50% - var(--space-2));
  min-width: 0;
}

@media (min-width: 34rem) {
  .kid-grid {
    gap: var(--space-4);
  }

  .kid-grid form {
    flex-basis: calc(33.333% - var(--space-3));
  }
}

.kid-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 11.5rem;
  padding: var(--space-5) var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-2);
  transition:
    transform var(--duration-base) var(--ease-spring),
    border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

/* At 320px two tiles leave less than the 7rem avatar: let it shrink, not spill. */
.kid-tile .avatar {
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.kid-tile:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-2);
  color: var(--color-text);
}

.kid-tile:active {
  transform: scale(0.96);
}

.kid-tile:disabled {
  border-style: dashed;
  background: var(--color-surface);
  opacity: 1;
}

.kid-tile:disabled .avatar {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.kid-tile:disabled .kid-name {
  color: var(--color-text-muted);
}

.kid-face {
  position: relative;
  display: inline-flex;
}

.kid-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  overflow-wrap: anywhere;
}

.kid-note {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.kid-lock {
  position: absolute;
  right: -0.25rem;
  bottom: -0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--color-surface);
  border-radius: var(--radius-full);
  background: var(--color-warning);
  color: var(--color-bg);
}

.kid-lock .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.kid-hello {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.kid-ask {
  font-size: var(--text-xl);
  color: var(--color-text);
}

.kid-foot {
  margin-top: var(--space-4);
}

.kid-stage .kid-foot .btn {
  min-height: var(--touch-min);
  color: var(--color-text-muted);
}

.kid-stage .kid-foot .btn:hover {
  color: var(--color-text);
}

/* A picture cue that carries the meaning without words. */

.big-cue {
  display: inline-flex;
  flex: none;
}

.big-cue .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.kid-error {
  align-items: center;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

/* The picture pad: 3x3 big keys, four dots, a clear way to start over. */

.pad {
  display: grid;
  gap: var(--space-5);
  justify-items: center;
}

.pad-keys {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 6.5rem));
  gap: var(--space-3);
  width: 100%;
  justify-content: center;
}

.pad-key {
  aspect-ratio: 1;
  width: 100%;
  min-height: 4.5rem;
  padding: 0;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-2);
  color: var(--color-text);
  font-size: clamp(2.25rem, 11vw, 3rem);
  transition:
    transform var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.pad-key:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-text);
}

.pad-key:active {
  transform: scale(0.92);
  background: var(--color-accent-soft);
}

.pad-dots {
  display: flex;
  gap: var(--space-4);
}

.dot {
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  transition:
    background-color var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
}

.dot.on {
  border-color: var(--color-accent);
  background: var(--color-accent);
  animation: pop var(--duration-slow) var(--ease-spring);
}

/* Compact kid layout: keep the avatar, the pad and "Not me" on one screen.
   Two cases, and a landscape tablet is neither:
   - a portrait phone: narrow (up to 40rem, where the tablet key size starts)
     and shorter than 56rem (900px; an iPhone is 844 or less);
   - any short window: under 40rem (640px) high, which is a phone on its side
     (844x390, 740x360) and a small tablet on its side (1024x600, 960x600),
     whose full-size pad would not fit, however wide they are.
   A tablet on its side with room (1024x768, 1180x820, 1366x1024) is wider
   than 40rem and at least 40rem high, so it keeps the full-size avatar and
   keys. */
@media (max-height: 56rem) and (max-width: 40rem), (max-height: 40rem) {
  .kid-hello {
    gap: var(--space-2);
  }

  .kid-hello .avatar {
    width: 4.5rem;
    height: 4.5rem;
    font-size: 2.25rem;
  }

  .kid-hello h1 {
    font-size: var(--text-2xl);
  }

  .kid-tall.kid-stage {
    gap: var(--space-3);
  }

  .kid-tall .pad {
    gap: var(--space-3);
  }

  .kid-tall .pad-keys {
    gap: var(--space-2);
  }
}

/* A phone or small tablet on its side is short: the lockup, a title and the
   pad must share 360 to 600px. The tall layout would centre the content in free height
   and add the page and lockup padding on top of that, leaving a big gap above
   it, so start the content just below the lockup instead. */
@media (max-height: 40rem) {
  .bare .page {
    padding-top: calc(var(--space-2) + env(safe-area-inset-top));
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }

  body:has(.kid-mode) .kid-stage {
    padding-top: calc(var(--space-2) + 2rem + var(--space-2));
  }

  .kid-tall {
    min-height: 0;
  }

  .kid-tall > :first-child {
    margin-top: 0;
  }

  .kid-tall > :last-child:not(.kid-foot) {
    margin-bottom: 0;
  }

  .kid-tall > .kid-foot {
    margin-top: var(--space-2);
    padding-top: 0;
  }

  /* The picture pad is three rows of keys: beside the greeting, not under it,
     so the whole pad fits in 360px of height. Keys stay 4rem (64px). */
  .kid-stage.kid-tall:has(.pad) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--space-8);
    align-content: start;
    align-items: center;
    max-width: 44rem;
  }

  .kid-tall:has(.pad) > .kid-hello {
    grid-column: 1;
    grid-row: 1;
  }

  .kid-tall:has(.pad) > .kid-ask {
    grid-column: 1;
    grid-row: 2;
  }

  .kid-tall:has(.pad) > .kid-error {
    grid-column: 1;
    grid-row: 3;
  }

  .kid-tall:has(.pad) > form {
    grid-column: 2;
    grid-row: 1 / span 4;
  }

  .kid-tall:has(.pad) > .kid-foot {
    grid-column: 1;
    grid-row: 4;
  }

  .kid-tall:has(.pad) .kid-hello .avatar {
    width: 4rem;
    height: 4rem;
    font-size: 2rem;
  }

  .kid-tall .pad {
    gap: var(--space-2);
  }

  .kid-tall .pad-keys {
    grid-template-columns: repeat(3, 4rem);
    gap: var(--space-2);
  }

  .kid-tall .pad-key {
    min-height: 4rem;
    font-size: 2rem;
  }
}

/* Tablets get bigger keys. */
@media (min-width: 40rem) {
  .pad-keys {
    grid-template-columns: repeat(3, minmax(0, 8rem));
    gap: var(--space-4);
  }

  .pad-key {
    font-size: 3.5rem;
  }
}

.pad-clear {
  color: var(--color-text-muted);
}

@keyframes pop {
  0% {
    transform: scale(0.6);
  }

  100% {
    transform: scale(1);
  }
}

.shake {
  animation: shake var(--duration-slow) var(--ease-out);
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-10px);
  }

  40%,
  80% {
    transform: translateX(10px);
  }
}

/* Pairing, on the device */

/* Height stays auto: .qr is aspect-ratio 1, so the code stays square when the
   card is narrower than 18rem. */
.qr-lg {
  width: 18rem;
  height: auto;
}

@media (max-width: 22rem) {
  .qr-lg {
    width: 14rem;
  }
}

.pair-code {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  text-align: center;
}

.pair-wait,
.pair-left {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--color-text);
  font-size: var(--text-lg);
}

.pair-left {
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.pair-left strong {
  display: inline-block;
  min-width: 3ch;
  color: var(--color-text);
  text-align: left;
}

.pulse {
  position: relative;
  flex: none;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: var(--radius-full);
  background: var(--color-accent);
}

.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  animation: pulse var(--duration-pulse) var(--ease-out) infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.6;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(2.8);
  }
}

/* Approve page, on the parent's phone */

.ask {
  display: grid;
  gap: var(--space-2);
}

.stack > fieldset.avatars {
  margin-top: var(--space-5);
}

.ask > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

.ask dt {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.ask dt .icon {
  align-self: center;
  width: 1.125rem;
  height: 1.125rem;
}

.ask dd {
  margin: 0;
  font-weight: var(--weight-semibold);
  text-align: right;
  overflow-wrap: anywhere;
}

.ask dd .muted {
  display: block;
  font-weight: var(--weight-regular);
}

.ask-code {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
}

.banner a.btn,
.banner button {
  margin-top: var(--space-2);
}

.kid-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: var(--space-3);
}

.kid-check {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  margin: 0;
  padding: var(--space-3) var(--space-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.kid-check input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.kid-check:hover {
  background: var(--color-surface-2);
}

.kid-check:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.kid-check:has(input:checked)::after {
  content: "\2713";
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-sm);
  line-height: 1;
}

.kid-check:has(input:focus-visible) {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.kid-check-name {
  overflow-wrap: anywhere;
}

.btn-quiet-danger {
  color: var(--color-danger);
}

.btn-quiet-danger:hover {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

/* Grown-up PIN entry */

.input-pin {
  min-height: 4rem;
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  letter-spacing: 0.4em;
  text-align: center;
}

.input-pin::placeholder {
  letter-spacing: 0.1em;
}

@media (prefers-reduced-motion: reduce) {
  .shake,
  .dot.on,
  .pulse::after {
    animation: none;
  }

  .pulse::after {
    opacity: 0.35;
    transform: scale(1.8);
  }

  .btn:active,
  button:active,
  .kid-tile:active,
  .pad-key:active {
    transform: none;
  }
}

/* ---- Signed in: home, account and household pages (docs/design.md s15.7) ---- */

.greeting {
  display: grid;
  gap: var(--space-1);
  padding-top: var(--space-2);
}

.greeting .muted {
  font-size: var(--text-base);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.section-head h2 {
  font-size: var(--text-lg);
}

.section {
  display: grid;
  gap: var(--space-3);
}

.back {
  margin-bottom: calc(var(--space-2) * -1);
}

.back a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: 0 var(--space-2) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.back a:hover {
  color: var(--color-text);
}

.profile {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.profile > div {
  min-width: 0;
}

.profile h1 {
  overflow-wrap: anywhere;
}

.avatar-initial {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.avatar-lg {
  width: 4.5rem;
  height: 4.5rem;
  font-size: var(--text-2xl);
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: var(--space-3);
  padding: 0;
  list-style: none;
}

.app-tile {
  display: grid;
  align-content: start;
  gap: var(--space-1);
  min-height: 7.5rem;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
  color: var(--color-text);
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.app-tile:hover {
  background: var(--color-accent-soft);
  color: var(--color-text);
}

.app-tile .list-icon {
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.app-tile:hover .list-icon {
  background: var(--color-surface);
}

.app-tile strong,
.app-tile .muted {
  overflow-wrap: anywhere;
}

.banners {
  display: grid;
  gap: var(--space-3);
}

.banner a {
  font-weight: var(--weight-semibold);
}

a.list-row {
  color: var(--color-text);
  text-decoration: none;
}

a.list-row:hover {
  background: var(--color-accent-soft);
  color: var(--color-text);
}

.list-row .avatar {
  width: 2.5rem;
  height: 2.5rem;
  font-size: var(--text-base);
}

.list-row .avatar:not(.avatar-initial) {
  font-size: 1.25rem;
}

.list-main > * {
  display: block;
  overflow-wrap: anywhere;
}

.list-main > .muted {
  font-weight: var(--weight-regular);
}

.list-action {
  color: var(--color-accent);
}

.list-action .list-icon {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.steps {
  display: grid;
  gap: var(--space-2);
  padding-left: var(--space-5);
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  font-size: var(--text-sm);
}

.kv dt {
  color: var(--color-text-muted);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.btn-danger-quiet {
  border-color: var(--color-danger);
  background: var(--color-surface);
  color: var(--color-danger);
}

.btn-danger-quiet:hover {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.confirm > summary {
  display: flex;
}

.confirm-body {
  display: grid;
  gap: var(--space-4);
  border: 1px solid var(--color-border);
}

.confirm-body .actions {
  grid-template-columns: 1fr 1fr;
}

.confirm-body .actions form {
  display: contents;
}

.sheet-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

.form-status {
  margin-top: var(--space-2);
}

/* A step-up that failed: an error beside the form, not a footnote. */
.form-status.is-error {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  text-align: left;
}

/* A grown-up on a kid device has two header actions: on a narrow phone the
   brand's name gives way so nothing wraps. */
@media (max-width: 26rem) {
  .app-header:has(.header-actions form + form) .brand-name {
    display: none;
  }
}

.field-error {
  display: flex;
  gap: var(--space-2);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.check-list {
  display: grid;
  gap: var(--space-1);
}

.check-list .check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-min);
  margin: 0;
}


/* In-card form buttons fill the card on a phone (s15.4); small buttons stay small. */
@media (max-width: 40rem) {
  .card form > .btn:not(.btn-sm),
  .card form > button:not(.btn-sm, .btn-quiet) {
    display: flex;
    width: 100%;
  }
}

#email .btn,
#email button {
  display: flex;
  width: 100%;
}

/* ---- Print: recovery codes on paper ---- */

@media print {
  :root {
    color-scheme: light;
  }

  body {
    background: Canvas;
    color: CanvasText;
  }

  .app-header,
  .skip-link,
  .actions,
  .btn,
  .banner {
    display: none !important;
  }

  .card {
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  /* Dark mode keeps light-grey text tokens: print everything in the paper's
     own ink. */
  .card * {
    color: CanvasText;
  }

  .code-grid li {
    border: 1px solid GrayText;
    background: none;
    color: CanvasText;
  }
}

/* Welcome page: the owner's checklist and the Sol card. */
.steps-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps-list li + li {
  border-top: 1px solid var(--color-border);
}

.step-off {
  opacity: 0.65;
}

.step-done {
  display: inline-flex;
  flex: none;
  color: var(--color-accent);
}

.card-sol {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.card-sol .list-icon {
  background: var(--color-surface);
  color: var(--color-accent);
}

/* Feedback: a person's own list and the operators' inbox (docs/feedback.md). */
.fb-item {
  display: grid;
  gap: var(--space-3);
}

.fb-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.fb-title {
  font-size: var(--text-base);
  line-height: var(--leading-snug);
}

.fb-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.fb-snippet,
.fb-filter .field {
  overflow-wrap: anywhere;
}

.fb-status {
  flex: none;
  background: var(--color-surface-2);
}

.fb-status.fb-done {
  background: var(--color-success-soft);
}

.fb-status.fb-done .icon {
  color: var(--color-success);
}

.fb-status.fb-answered {
  background: var(--color-accent-soft);
}

.fb-reply {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}

.fb-reply-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.fb-reply-head .icon {
  width: 1rem;
  height: 1rem;
  color: var(--color-accent);
}

.fb-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  font-size: var(--text-sm);
}

.fb-meta dt {
  color: var(--color-text-muted);
  text-transform: capitalize;
}

.fb-meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.fb-filter {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.fb-filter select {
  width: 100%;
}

.fb-textarea {
  min-height: 8rem;
  padding: var(--space-3) var(--space-4);
  resize: vertical;
}

/* ---- Pictures (ADR 0074): a photo fills the circle; the cropper is a circle
   mask over a canvas the person drags and zooms (picture.js). ---- */

.avatar {
  overflow: hidden;
}

.avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cropper {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
}

.crop-canvas {
  width: min(16rem, 100%);
  aspect-ratio: 1;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  touch-action: none;
  cursor: grab;
}

.crop-canvas:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.crop-zoom {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: min(16rem, 100%);
  font-size: var(--text-sm);
}

.crop-zoom input {
  flex: 1;
  min-width: 0;
}

/* The Sandbox ribbon: a small fixed amber tag in the top corner of every screen
   of a sandbox household (ADR 0087 s4). It sits above the header's corner and
   never covers a control: the header keeps its own padding clear of it. */
.sandbox-ribbon {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  padding: 2px var(--space-3, 12px);
  border-radius: 0 0 var(--radius-md, 8px) 0;
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
  border-top: 0;
  border-left: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.notice-list {
  margin: 0;
  padding-left: 1.25em;
}

.notice-list li + li {
  margin-top: var(--space-2, 8px);
}

.provider-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.provider-table th,
.provider-table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2, 8px) var(--space-2, 8px) var(--space-2, 8px) 0;
  border-bottom: 1px solid var(--color-border, currentColor);
}
