/* Global HomeQuest styles shared by the web and Android clients. */

/* =====================================================================================================
   DESIGN TOKENS — the single source for colours, type, spacing, radii and shadows.
   Storybook RPG palette: night sky, parchment, gold rims, magic purple, candy colours. Component rules below use
   these variables only; MudBlazor's palette (Theme/HomeQuestTheme.cs) uses the same values.
   Contrast rule: light candy fills (gold, orange, green) carry ink text; deep fills (magic, red, blue, amber)
   carry white/parchment text. Every text pair listed here passes WCAG 2.2 AA (4.5:1, or 3:1 for large text).
   ===================================================================================================== */
:root {
  /* ---- Colour primitives ---- */
  --hq-night: #2e2a68;            /* the sky: page background */
  --hq-night-deep: #17133a;       /* toy shadows, overlays */
  --hq-night-soft: #241f55;       /* pills and tracks on the sky */
  --hq-night-track: #57507f;      /* empty progress segment */
  --hq-parchment: #fff3d6;        /* cards */
  --hq-parchment-soft: #fff8ea;   /* raised parchment: popovers, outlined buttons, chips */
  --hq-parchment-dim: #f6efdd;    /* past / done / locked rows */
  --hq-paper: #ffffff;            /* inset rows inside a card, inputs */
  --hq-medal: #ffe2a3;            /* medallion fill */
  --hq-medal-deep: #f2c46b;       /* medallion inner shadow */
  --hq-coin: #ffe8a3;             /* coin pills */
  --hq-gold: #e9a93b;             /* card rims */
  --hq-gold-bright: #ffc93c;      /* selected / active fills, focus ring on the sky */
  --hq-gold-deep: #b97a1b;        /* pressed gold, gold shadows */
  --hq-line: #e2c98f;             /* dividers, soft borders */
  --hq-line-soft: #f0e0bc;        /* borders of inset rows, tracks */
  --hq-line-strong: #8b7a5a;      /* input outlines, checkbox rings (3:1 on white) */
  --hq-ink: #3b2a5c;              /* text */
  --hq-ink-soft: #6e5a8c;         /* secondary text (5.4:1 on parchment) */
  --hq-earth: #6b5a3a;            /* notes and hints on parchment (6:1) */
  --hq-amber: #8a4510;            /* warm small headings (aisles, reward label) */
  --hq-coin-ink: #7a4e0f;         /* text on coin / gold pills */
  --hq-star: #ffe9a8;             /* text and stars on the sky */
  --hq-lilac: #d9d3f5;            /* secondary text on the sky */
  --hq-magic: #5b4bb7;            /* primary actions */
  --hq-magic-deep: #3b2e8a;
  --hq-magic-light: #a99bea;
  --hq-magic-line: #9a8bd6;
  --hq-magic-soft: #e4ddf7;
  --hq-magic-ink: #4a3b8c;        /* text on magic-soft */
  --hq-success: #4cb963;
  --hq-success-bright: #5ed16a;
  --hq-success-strong: #3c9a4f;
  --hq-success-deep: #22652f;     /* success text */
  --hq-success-soft: #eaf6e2;
  --hq-success-line: #8ccb7a;
  --hq-danger: #c0392b;           /* errors, destructive actions, counters (5.4:1 with white) */
  --hq-danger-bright: #e2463f;    /* decorative red (pinned note) */
  --hq-danger-deep: #7d1f27;
  --hq-danger-soft: #ffd9d4;
  --hq-boss: #b8323a;
  --hq-warning: #a65a0e;          /* warning text */
  --hq-warning-line: #f0a24b;
  --hq-warning-soft: #ffe3c2;
  --hq-warning-softer: #fff4e6;
  --hq-pending: #c99a3c;          /* "waiting for a parent" dashed rims */
  --hq-pink: #e79cb4;
  --hq-pink-deep: #b0587a;
  --hq-pink-ink: #b0306b;
  --hq-pink-soft: #ffe6ee;
  --hq-sky-soft: #e3f1ff;
  --hq-sky-line: #8fbaf0;
  --hq-note: #fff8d9;
  --hq-note-line: #e5c75f;

  /* ---- Semantic colours ---- */
  --hq-text: var(--hq-ink);
  --hq-text-muted: var(--hq-ink-soft);
  --hq-text-subtle: var(--hq-earth);
  --hq-text-on-night: var(--hq-parchment);
  --hq-text-on-night-muted: var(--hq-lilac);
  --hq-surface: var(--hq-parchment);
  --hq-surface-raised: var(--hq-parchment-soft);
  --hq-surface-inset: var(--hq-paper);
  --hq-border: var(--hq-gold);
  --hq-border-soft: var(--hq-line);
  --hq-border-inset: var(--hq-line-soft);
  --hq-action: var(--hq-magic);
  --hq-selected: var(--hq-gold-bright);
  --hq-focus: var(--hq-gold-bright);          /* on the sky; parchment surfaces switch it to magic */

  /* ---- Typography ---- */
  --hq-title: "Fredoka", "Nunito", system-ui, sans-serif;   /* titles, buttons, numbers */
  --hq-body: "Nunito", system-ui, "Segoe UI", Roboto, sans-serif;
  --hq-fs-2xs: 0.75rem;     /* 12px: counters, tiny chips only */
  --hq-fs-xs: 0.8125rem;    /* 13px: captions, meta */
  --hq-fs-sm: 0.875rem;     /* 14px: secondary text */
  --hq-fs-md: 1rem;         /* 16px: body */
  --hq-fs-lg: 1.125rem;     /* 18px: item names */
  --hq-fs-xl: 1.25rem;      /* 20px: card titles, ribbons */
  --hq-fs-2xl: 1.375rem;    /* 22px: big card titles */
  --hq-fs-3xl: 1.5rem;      /* 24px: hero numbers */
  --hq-fs-4xl: 2rem;        /* 32px: page titles, big counters */
  --hq-fs-5xl: 2.25rem;     /* 36px: timers */
  --hq-lh-tight: 1.15;
  --hq-lh-snug: 1.3;
  --hq-lh-body: 1.5;
  --hq-fw-body: 600;
  --hq-fw-bold: 700;
  --hq-fw-heavy: 800;
  --hq-fw-black: 900;       /* Nunito only: Fredoka stops at 700 */

  /* ---- Spacing (4px grid) ---- */
  --hq-space-1: 4px;
  --hq-space-2: 8px;
  --hq-space-3: 12px;
  --hq-space-4: 16px;
  --hq-space-5: 24px;
  --hq-space-6: 32px;
  --hq-card-pad: 14px;

  /* ---- Radii ---- */
  --hq-radius-sm: 12px;     /* inputs, inset rows */
  --hq-radius-md: 14px;     /* buttons, small cards */
  --hq-radius-lg: 18px;     /* cards */
  --hq-radius-xl: 24px;     /* celebration */
  --hq-radius-pill: 999px;

  /* ---- Shadows ---- */
  --hq-toy-shadow: 0 5px 0 var(--hq-night-deep);           /* cards on the sky */
  --hq-toy-shadow-sm: 0 3px 0 var(--hq-night-deep);        /* pills, small buttons */
  --hq-gold-shadow: 0 4px 0 var(--hq-gold-deep);           /* highlighted (today, active tab) */
  --hq-press-shadow: 0 1px 0 var(--hq-night-deep);

  /* ---- Layout ---- */
  --hq-bottom-nav-height: 64px;
  --hq-target-min: 44px;    /* minimum touch target (WCAG 2.5.8 asks 24px; children need more) */
}

html, body {
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}

/* Room for the bottom navigation on phones. */
@media (max-width: 959.98px) {
  .hq-main {
    padding-bottom: calc(var(--hq-bottom-nav-height) + env(safe-area-inset-bottom));
  }
}

.hq-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  display: flex;
  box-sizing: border-box;
  height: calc(var(--hq-bottom-nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--mud-palette-surface);
  border-top: 1px solid var(--mud-palette-lines-default);
}

.hq-bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--hq-fs-2xs);
  color: var(--mud-palette-text-secondary);
  text-decoration: none;
}

.hq-bottom-nav-item.active {
  color: var(--mud-palette-primary);
  font-weight: 600;
}

.hq-feature-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  height: 100%;
}

#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 2000;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  background: lightyellow;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

/* FocusOnNavigate moves focus to the page title for screen readers; no visible outline needed. */
h1:focus {
  outline: none;
}

/* ---------- Sprint 1: avatars, profile picker, PIN pad ---------- */

.hq-activity {
  min-height: 100vh;
}

.hq-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  line-height: 1;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.hq-avatar-button {
  display: inline-flex;
  border: 0;
  padding: 0;
  margin-left: 4px;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
}

.hq-bare {
  min-height: 100vh;
  background: var(--mud-palette-background);
}

.hq-bare-top {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
}

.hq-welcome-actions {
  width: 100%;
  max-width: 360px;
}

/* Avatar picker */
.hq-avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.hq-emoji-grid {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  gap: 6px;
}

.hq-emoji {
  width: 48px;
  height: 48px;
  font-size: 26px;
  border: 2px solid transparent;
  border-radius: var(--hq-radius-sm);
  background: var(--mud-palette-background-gray);
  cursor: pointer;
}

.hq-emoji.selected {
  border-color: var(--mud-palette-primary);
  background: var(--mud-palette-surface);
}

.hq-color-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.hq-color {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}

.hq-color.selected {
  border-color: var(--mud-palette-text-primary);
}

/* Profile picker */
.hq-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
  width: 100%;
}

.hq-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border: 0;
  border-radius: var(--hq-radius-lg);
  background: var(--mud-palette-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  font: inherit;
  color: var(--mud-palette-text-primary);
}

.hq-profile:active {
  transform: scale(0.97);
}

.hq-profile-name {
  font-size: var(--hq-fs-lg);
  font-weight: 600;
}

/* PIN pad */
.hq-pinpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  outline: none;
}

.hq-pin-dots {
  display: flex;
  gap: 16px;
}

.hq-pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--mud-palette-primary);
}

.hq-pin-dot.filled {
  background: var(--mud-palette-primary);
}

.hq-pin-message {
  min-height: 1.5em;
  color: var(--mud-palette-error);
  text-align: center;
}

.hq-pin-keys {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 12px;
}

.hq-key {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 0;
  background: var(--mud-palette-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  font-size: var(--hq-fs-4xl);
  font-weight: 600;
  color: var(--mud-palette-text-primary);
  cursor: pointer;
}

.hq-key:active:not(:disabled) {
  background: var(--mud-palette-primary);
  color: var(--mud-palette-primary-text);
}

.hq-key:disabled {
  opacity: 0.5;
}

.hq-key-muted {
  background: transparent;
  box-shadow: none;
}

.hq-shake {
  animation: hq-shake 0.4s;
}

@keyframes hq-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

/* Family page */
.hq-member-list {
  display: flex;
  flex-direction: column;
}

.hq-member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--mud-palette-lines-default);
}

.hq-member-row:last-child {
  border-bottom: 0;
}

.hq-member-row.inactive {
  opacity: 0.55;
}

.hq-member-info {
  flex: 1;
  min-width: 0;
}

/* ---------- Sprint 2: quests ---------- */
.hq-feature-link { text-decoration: none; color: inherit; display: block; height: 100%; }
.hq-feature-tile.ready { border: 2px solid var(--mud-palette-primary); }

.hq-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 10px;
  background: var(--mud-palette-error);
  color: var(--hq-paper);
  font-size: var(--hq-fs-2xs);
  font-weight: 700;
  line-height: 1;
}

.hq-bottom-nav-icon { position: relative; display: inline-flex; }
.hq-bottom-nav-icon .hq-nav-count { position: absolute; top: -6px; right: -14px; margin: 0; }

.hq-quest-section { display: flex; flex-direction: column; gap: 8px; }
.hq-group-title { font-weight: 700; margin-top: 4px; }
.hq-quest-list { display: flex; flex-direction: column; gap: 10px; }

.hq-quest {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--hq-radius-lg);
  background: var(--mud-palette-surface);
  border: 2px solid var(--mud-palette-lines-default);
}
.hq-quest.assigned { border-color: var(--mud-palette-primary); }
.hq-quest.pendingreview { border-style: dashed; border-color: var(--mud-palette-warning); }
.hq-quest.approved { border-color: var(--mud-palette-success); }
.hq-quest.expired { opacity: 0.5; }

/* Big emoji first: the youngest child reads the picture, not the words. */
.hq-quest-icon {
  flex: none;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-size: 40px;
  line-height: 1;
  border-radius: var(--hq-radius-md);
  background: var(--mud-palette-background-gray);
}
.hq-quest.compact .hq-quest-icon, .hq-quest-icon.small { width: 44px; height: 44px; font-size: 26px; }

.hq-quest-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.hq-quest-title { font-size: var(--hq-fs-lg); font-weight: 700; overflow-wrap: anywhere; }
.hq-quest.compact .hq-quest-title { font-size: var(--hq-fs-md); }
.hq-quest-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: var(--hq-fs-sm); color: var(--mud-palette-text-secondary); }
.hq-coins { font-weight: 700; color: var(--mud-palette-text-primary); }
.hq-quest-assignee { display: inline-flex; align-items: center; gap: 4px; }
.hq-quest-rejected { font-size: var(--hq-fs-sm); color: var(--mud-palette-warning-darken); font-weight: 600; }
.hq-quest-actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }

@media (max-width: 599.98px) {
  .hq-quest { flex-wrap: wrap; }
  /* Only real buttons get their own full-width row; a lone icon button stays beside the text. */
  .hq-quest-actions:has(> .mud-button-root) { width: 100%; }
  .hq-quest-actions > .mud-button-root { flex: 1; min-height: 48px; }
}

.hq-empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; background: transparent; }
.hq-empty-icon { font-size: 56px; line-height: 1; }

.hq-menu-member { display: inline-flex; align-items: center; gap: 8px; }

.hq-template-list { display: flex; flex-direction: column; }
.hq-template-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--mud-palette-lines-default); }
.hq-template-row:last-child { border-bottom: 0; }
.hq-template-row.inactive { opacity: 0.55; }

.hq-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.hq-icon-choice, .hq-day-chip {
  font: inherit;
  cursor: pointer;
  border: 2px solid var(--mud-palette-lines-default);
  background: var(--mud-palette-surface);
  color: var(--mud-palette-text-primary);
}
.hq-icon-choice { height: 48px; border-radius: var(--hq-radius-sm); font-size: 26px; line-height: 1; }
.hq-icon-choice.selected, .hq-day-chip.selected { border-color: var(--mud-palette-primary); background: var(--mud-palette-primary-hover); }
.hq-icon-choice:focus-visible, .hq-day-chip:focus-visible { outline: 2px solid var(--mud-palette-primary); outline-offset: 2px; }
.hq-day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hq-day-chip { min-width: 52px; height: 40px; border-radius: var(--hq-radius-lg); padding: 0 10px; text-transform: capitalize; }
.hq-day-chip.selected { font-weight: 700; }
.hq-type-toggle { flex-wrap: wrap; }
.hq-next-date { display: block; color: var(--mud-palette-primary); font-weight: 600; }
.hq-member-chip { display: inline-flex; align-items: center; gap: 6px; text-transform: none; }

/* =====================================================================================================
   Storybook RPG skin: night sky, parchment cards with a gold rim, candy buttons, ribbons, medallions.
   Everything is CSS + inline SVG (StoryIcon): no image files. Fonts: Fredoka and Nunito (SIL OFL), Latin subsets.
   ===================================================================================================== */

@font-face {
  font-family: "Fredoka";
  src: url("fonts/Fredoka-Latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  src: url("fonts/Nunito-Latin.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}


/* ---------- Night sky with a few stars ---------- */
/* One fixed layer behind everything: painting it on several nested elements doubled every star, and
   background-attachment: fixed is ignored (or janky) on phones. Stars are round with a soft edge. */
html { background-color: var(--hq-night); }
body, .hq-bare, .mud-layout { background: transparent !important; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--hq-night);
  background-image:
    radial-gradient(circle at 24px 40px, var(--hq-star) 0 1.1px, transparent 2.1px),
    radial-gradient(circle at 150px 110px, rgba(255, 233, 168, 0.75) 0 0.8px, transparent 1.8px),
    radial-gradient(circle at 260px 30px, var(--hq-star) 0 1.3px, transparent 2.4px),
    radial-gradient(circle at 330px 150px, rgba(255, 233, 168, 0.55) 0 0.7px, transparent 1.6px),
    radial-gradient(circle at 90px 190px, rgba(255, 233, 168, 0.85) 0 0.9px, transparent 1.9px),
    radial-gradient(circle at 205px 235px, rgba(255, 233, 168, 0.6) 0 0.7px, transparent 1.6px);
  background-size: 360px 270px;
}

body { color: var(--hq-ink); }

/* ---------- Parchment cards ---------- */
.hq-book-page,
.mud-main-content .mud-paper:not(.hq-empty),
.mud-dialog,
.hq-quest,
.hq-profile,
.hq-day-progress,
.mud-expansion-panels {
  background: var(--hq-parchment) !important;
  border: 3px solid var(--hq-gold) !important;
  border-radius: var(--hq-radius-lg) !important;
  box-shadow: var(--hq-toy-shadow) !important;
}

.hq-book-page { padding: 16px 12px; margin-top: 8px; }
.mud-dialog .mud-dialog-title { font-family: var(--hq-title); font-weight: 600; }

.mud-popover {
  background: var(--hq-parchment-soft) !important;
  border: 3px solid var(--hq-gold);
  border-radius: var(--hq-radius-md) !important;
  box-shadow: 0 4px 0 var(--hq-night-deep) !important;
}

/* ---------- App bar, drawer, bottom navigation ---------- */
/* Solid: with a see-through bar, page content scrolled right through the logo and the buttons. */
.mud-appbar { background: var(--hq-night) !important; box-shadow: 0 3px 0 rgba(23, 19, 58, 0.55) !important; }
.hq-brand { font-family: var(--hq-title) !important; font-weight: 700 !important; color: var(--hq-star) !important; }

.mud-drawer {
  background: var(--hq-parchment) !important;
  border-right: 4px solid var(--hq-gold) !important;
  box-shadow: 4px 0 0 var(--hq-night-deep) !important;
}
.mud-drawer .mud-nav-link {
  font-family: var(--hq-title);
  font-weight: 600;
  font-size: var(--hq-fs-md);
  margin: 4px 10px;
  border-radius: var(--hq-radius-md);
  width: calc(100% - 20px);
}
.mud-drawer .mud-nav-link .mud-nav-link-text { display: flex; align-items: center; gap: 12px; }
.mud-drawer .mud-nav-link.active {
  background: var(--hq-gold-bright) !important;
  color: var(--hq-ink) !important;
  box-shadow: inset 0 -4px 0 var(--hq-gold-deep);
}

.hq-bottom-nav {
  background: var(--hq-parchment);
  border-top: 4px solid var(--hq-gold);
  box-shadow: 0 -4px 0 var(--hq-night-deep);
  overflow: visible;
}
.hq-bottom-nav-item {
  font-weight: 800;
  font-size: var(--hq-fs-2xs);
  color: var(--hq-ink-soft);
  justify-content: flex-end;
  padding-bottom: 6px;
}
.hq-bottom-nav-item.active { color: var(--hq-ink); }
.hq-bottom-nav-item.active .hq-bottom-nav-icon {
  width: 54px;
  height: 54px;
  margin-top: -24px;
  border-radius: 50%;
  background: var(--hq-gold-bright);
  border: 3px solid var(--hq-ink);
  box-shadow: var(--hq-gold-shadow);
  display: grid;
  place-items: center;
  box-sizing: border-box;
}

.hq-nav-count {
  background: var(--hq-danger);
  border: 2px solid var(--hq-parchment);
  font-family: var(--hq-title);
}
.hq-bottom-nav-item.active .hq-nav-count { top: -4px; right: -8px; }

/* ---------- Text on the night sky ---------- */
.mud-main-content h1 { color: var(--hq-parchment) !important; }
.mud-main-content .mud-paper h1, .mud-main-content .mud-dialog h1 { color: var(--hq-ink) !important; }
.hq-on-night { color: var(--hq-lilac) !important; }

/* ---------- Ribbons (section titles) ---------- */
.hq-ribbon { --r: #d9524b; --r-dark: #a8322e; --r-light: #f28a82; --r-shadow: #7e2421; display: flex; align-items: center; align-self: center; margin: 6px 0 2px; }
.hq-ribbon-blue { --r: #3e8acb; --r-dark: #2c6e9e; --r-light: #7db8e8; --r-shadow: #1f4e75; }
.hq-ribbon-purple { --r: #7a6ad8; --r-dark: #5546b0; --r-light: var(--hq-magic-light); --r-shadow: #382c80; }
.hq-ribbon-text {
  margin: 0;
  padding: 4px 20px;
  background: var(--r);
  border-top: 2px solid var(--r-light);
  box-shadow: 0 3px 0 var(--r-shadow);
  font-family: var(--hq-title);
  font-weight: 600;
  font-size: var(--hq-fs-xl);
  color: var(--hq-parchment);
  white-space: nowrap;
}
.hq-ribbon-end { width: 18px; height: 32px; background: var(--r-dark); flex: none; }
.hq-ribbon-end.left { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 45% 50%); }
.hq-ribbon-end.right { clip-path: polygon(0 0, 100% 0, 55% 50%, 100% 100%, 0 100%); }

.hq-group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--hq-title);
  font-weight: 600;
  font-size: var(--hq-fs-lg);
  color: var(--hq-star);
  margin-top: 4px;
}

/* ---------- "Your day" progress ---------- */
.hq-day-progress { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.hq-day-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hq-day-progress-title { font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-2xl); }
.hq-day-progress-count { font-weight: 800; font-size: var(--hq-fs-sm); color: var(--hq-earth); }
.hq-day-progress-bar { display: flex; gap: 3px; height: 18px; padding: 3px; box-sizing: border-box; background: var(--hq-ink); border-radius: var(--hq-radius-pill); }
.hq-segment { flex: 1; background: var(--hq-night-track); border-radius: 4px; }
.hq-segment:first-child { border-radius: 999px 4px 4px 999px; }
.hq-segment:last-child { border-radius: 4px 999px 999px 4px; }
.hq-segment:only-child { border-radius: var(--hq-radius-pill); }
.hq-segment.done { background: var(--hq-success-bright); }

/* ---------- Buttons: candy with a toy shadow ---------- */
.mud-button-root { border-radius: var(--hq-radius-md) !important; font-family: var(--hq-title); }
.mud-button-filled {
  min-height: 44px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.22), 0 4px 0 var(--hq-night-deep) !important;
  margin-bottom: 4px;
  transition: transform 80ms, box-shadow 80ms;
}
.mud-button-filled.mud-button-filled-size-large { min-height: 52px; font-size: var(--hq-fs-lg); }
.mud-button-filled:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22), 0 1px 0 var(--hq-night-deep) !important;
}
.mud-button-outlined {
  border-width: 3px !important;
  background: var(--hq-parchment-soft) !important;
  box-shadow: 0 4px 0 var(--hq-night-deep);
  margin-bottom: 4px;
}
.mud-main-content .mud-icon-button { border-radius: var(--hq-radius-sm); }

/* ---------- Inputs, alerts, snackbars, chips ---------- */
.mud-input.mud-input-outlined { background: var(--hq-paper); border-radius: var(--hq-radius-sm) !important; }
.mud-input-outlined-border { border-radius: var(--hq-radius-sm) !important; border-width: 2px !important; }
.mud-alert { border-radius: var(--hq-radius-md) !important; border: 3px solid currentColor; box-shadow: var(--hq-toy-shadow); }
.mud-snackbar { border-radius: var(--hq-radius-md) !important; font-family: var(--hq-title); font-weight: 600; box-shadow: 0 4px 0 var(--hq-night-deep) !important; }
.mud-chip { font-weight: 800; }
.mud-toggle-group { border-radius: var(--hq-radius-md) !important; }

/* ---------- Avatars: medallions with a gold ring ---------- */
/* --hq-ring / --hq-drop come from AvatarBadge: small avatars get a thinner ring so it stays off the text. */
.hq-avatar {
  box-shadow: 0 0 0 var(--hq-ring, 3px) var(--hq-gold-bright),
              0 var(--hq-drop, 4px) 0 var(--hq-ring, 3px) var(--hq-night-deep) !important;
}
.hq-medallion { display: inline-flex; padding: 4px; }

/* ---------- Icons ---------- */
.hq-story-icon { display: inline-block; vertical-align: middle; flex: none; overflow: visible; }
.hq-inline-icon { vertical-align: -3px; }
.hq-emoji-icon { line-height: 1; display: inline-block; }

/* ---------- Home tiles ---------- */
.hq-feature-tile { gap: 10px; }
.hq-feature-tile .mud-typography-h6 { font-family: var(--hq-title) !important; }
.hq-feature-tile.ready { border-color: var(--hq-gold-bright) !important; }
.hq-feature-link:active .hq-feature-tile { transform: translateY(3px); box-shadow: 0 2px 0 var(--hq-night-deep) !important; }

/* ---------- Quest cards ---------- */
.hq-quest { padding: 12px; gap: 12px; }
.hq-quest.pendingreview { border-style: dashed !important; border-color: var(--hq-pending) !important; }
.hq-quest.approved { background: var(--hq-success-soft) !important; border-color: var(--hq-success-line) !important; }
.hq-quest.expired { opacity: 0.6; filter: grayscale(0.6); }

.hq-quest-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--hq-medal);
  border: 3px solid var(--hq-gold);
  box-shadow: inset 0 -4px 0 var(--hq-medal-deep);
  box-sizing: border-box;
}
.hq-quest.compact .hq-quest-icon, .hq-quest-icon.small { width: 50px; height: 50px; }
.hq-quest-title { font-family: var(--hq-title); font-weight: 600; font-size: var(--hq-fs-xl); }
.hq-quest-meta { color: var(--hq-ink-soft); font-weight: 700; }
.hq-coins, .hq-deadline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 9px 1px 4px;
  border-radius: var(--hq-radius-pill);
  font-weight: 800;
  font-size: var(--hq-fs-sm);
}
.hq-coins { background: var(--hq-coin); border: 2px solid var(--hq-gold); color: var(--hq-coin-ink); }
.hq-deadline { background: var(--hq-magic-soft); border: 2px solid var(--hq-magic-line); color: var(--hq-magic-ink); padding-left: 9px; }
/* Part of the day, colored like the sky: dawn, noon, night. */
.hq-deadline-morning { background: var(--hq-warning-soft); border-color: var(--hq-warning-line); color: var(--hq-amber); padding-left: 4px; }
.hq-deadline-afternoon { background: #fff2b3; border-color: #e5c033; color: #6e5a00; padding-left: 4px; }
.hq-deadline-evening { background: #3b3470; border-color: #241f4d; color: #f5efff; padding-left: 4px; }
.hq-deadline-part { font-weight: 900; }
.hq-quest-rejected { color: var(--hq-warning); font-weight: 800; }
.hq-quest-actions > .mud-button-root { min-height: 48px; }

/* Template list and pickers. */
.hq-template-row { border-bottom: 2px dashed var(--hq-line); }
.hq-icon-choice {
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--hq-gold);
  background: var(--hq-medal);
  display: grid;
  place-items: center;
}
.hq-icon-choice.selected { background: var(--hq-gold-bright); border-color: var(--hq-ink); box-shadow: 0 3px 0 var(--hq-night-deep); }
.hq-day-chip { border-radius: var(--hq-radius-pill); border: 3px solid var(--hq-gold); background: var(--hq-parchment-soft); color: var(--hq-ink); font-weight: 800; }
.hq-day-chip.selected { background: var(--hq-gold-bright); border-color: var(--hq-ink); }

/* ---------- Empty states on the sky ---------- */
.hq-empty .mud-typography { color: var(--hq-parchment) !important; font-family: var(--hq-title) !important; }

/* ---------- Profile picker, PIN pad, avatar picker ---------- */
.hq-profile { padding: 14px 8px; }
.hq-profile-name { font-family: var(--hq-title); font-weight: 600; }
.hq-key {
  background: var(--hq-magic);
  color: var(--hq-paper);
  font-family: var(--hq-title);
  box-shadow: inset 0 -6px 0 var(--hq-magic-deep), 0 4px 0 var(--hq-night-deep);
}
.hq-key:active:not(:disabled) { background: var(--hq-magic); transform: translateY(3px); box-shadow: inset 0 -3px 0 var(--hq-magic-deep), 0 1px 0 var(--hq-night-deep); }
.hq-key-muted { background: transparent; color: var(--hq-ink); box-shadow: none; }
.hq-pin-dot { border: 3px solid var(--hq-gold); }
.hq-pin-dot.filled { background: var(--hq-gold-bright); border-color: var(--hq-ink); }
.hq-emoji { border: 3px solid var(--hq-gold); background: var(--hq-medal); }
.hq-emoji.selected { background: var(--hq-gold-bright); border-color: var(--hq-ink); }
.hq-member-row { border-bottom: 2px dashed var(--hq-line); }
.hq-bare-top { color: var(--hq-star); }

/* =====================================================================================================
   Polish pass: fixes for small visual defects (nested cards, toggle groups, tight rows, alignment).
   ===================================================================================================== */

/* Crisper text on the dark sky. */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }

/* ---------- Before sign-in: no card inside the parchment page ---------- */
.hq-book-page .mud-paper {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.hq-book-page .mud-paper.pa-4 { padding: 0 !important; }
.hq-color.selected { border-color: var(--hq-parchment); box-shadow: 0 0 0 3px var(--hq-ink); }
.hq-book-page .mud-card,
.hq-book-page .mud-expansion-panels {
  background: var(--hq-parchment-soft) !important;
  border: 2px solid var(--hq-line) !important;
  border-radius: var(--hq-radius-md) !important;
  box-shadow: none !important;
}
.hq-welcome .mud-card { width: 100%; max-width: 360px; }
.mud-typography-subtitle1 { line-height: 1.4; }

/* ---------- Toggle groups: one segmented control, not three candy buttons glued together ---------- */
.mud-toggle-group {
  border: 3px solid var(--hq-gold) !important;
  border-radius: var(--hq-radius-md) !important;
  background: var(--hq-parchment-soft);
  overflow: hidden;
}
.mud-toggle-group .mud-toggle-item {
  margin: 0 !important;
  border-radius: 0 !important;
  border-width: 0 !important;
  box-shadow: none !important;
  transform: none !important;
  background: transparent !important;
  min-height: 44px;
  padding: 6px 8px;
  font-size: var(--hq-fs-md);
  line-height: 1.2;
  color: var(--hq-ink) !important;
}
.mud-toggle-group .mud-toggle-item + .mud-toggle-item { border-left: 2px solid var(--hq-gold) !important; }
.mud-toggle-group .mud-toggle-item.mud-toggle-item-selected {
  background: var(--hq-gold-bright) !important;
  box-shadow: inset 0 -4px 0 var(--hq-gold-deep) !important;
}

/* ---------- Dialogs ---------- */
.mud-dialog .mud-dialog-actions { padding: 8px 16px 12px; gap: 4px; }
.mud-dialog .mud-dialog-content { overscroll-behavior: contain; }
.mud-dialog .mud-typography-caption { display: block; margin-top: 4px; line-height: 1.35; }
.mud-input-helper-text { line-height: 1.35 !important; }

/* ---------- Icon buttons sitting directly on the sky (back arrow next to a page title) ---------- */
.mud-icon-button.hq-sky-button { color: var(--hq-star) !important; }

/* ---------- Quest cards ---------- */
.hq-quest-meta { gap: 6px 10px; }
.hq-quest-assignee { gap: 8px; padding-left: 3px; line-height: 1; }
.hq-quest-status { display: inline-flex; align-items: center; }
.hq-menu-member { gap: 12px; padding-left: 3px; }
.hq-member-chip { gap: 9px; padding-left: 9px; }
.hq-quest-title { line-height: 1.25; }
.hq-quest .mud-button-filled, .hq-quest .mud-button-outlined { white-space: nowrap; }

/* ---------- Lists inside cards (templates, members) ---------- */
.hq-template-row { gap: 10px; padding: 10px 0; }
.hq-template-row .mud-typography-subtitle1,
.hq-member-row .mud-typography-subtitle1 { line-height: 1.25; overflow-wrap: anywhere; }
.hq-template-row .mud-typography-caption,
.hq-member-row .mud-typography-caption { display: block; line-height: 1.4; margin-top: 2px; overflow-wrap: anywhere; }
.hq-template-row .mud-input-control { flex: none; width: auto; margin: 0; }
.hq-template-row > .mud-icon-button { flex: none; margin-right: -6px; }
/* Phones: switch above the edit button, so the title and schedule keep enough width to read. */
@media (max-width: 599.98px) {
  .hq-template-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 10px; row-gap: 0; }
  .hq-template-row > .hq-quest-icon, .hq-template-row > .hq-member-info { grid-row: 1 / span 2; }
  .hq-template-row > .mud-input-control { grid-column: 3; grid-row: 1; align-self: end; justify-self: center; }
  .hq-template-row > .mud-icon-button { grid-column: 3; grid-row: 2; align-self: start; justify-self: center; margin-right: 0; }
}
.hq-member-row { padding: 10px 0; }
.hq-member-row .hq-avatar { margin: 0 3px 4px; }

/* ---------- Bottom navigation ---------- */
.hq-bottom-nav-item { min-width: 0; -webkit-tap-highlight-color: transparent; }
.hq-bottom-nav-item > span:last-child {
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Focus rings for keyboard users, press feedback ---------- */
.hq-key:focus-visible, .hq-profile:focus-visible, .hq-emoji:focus-visible, .hq-color:focus-visible,
.hq-avatar-button:focus-visible, .hq-bottom-nav-item:focus-visible, .hq-feature-link:focus-visible {
  outline: 3px solid var(--hq-gold-bright);
  outline-offset: 3px;
}
.hq-feature-link { border-radius: var(--hq-radius-lg); }
.hq-feature-tile { transition: transform 80ms, box-shadow 80ms; }
.hq-key, .hq-profile { transition: transform 80ms, box-shadow 80ms; -webkit-tap-highlight-color: transparent; }
.hq-key-muted { display: grid; place-items: center; }
.hq-key-muted:active:not(:disabled) { background: transparent; box-shadow: none; transform: scale(0.92); }

@media (prefers-reduced-motion: reduce) {
  .hq-shake { animation: none; }
  .mud-button-filled, .hq-key, .hq-profile, .hq-feature-tile { transition: none; }
}

/* =====================================================================================================
   Sprint 3: coins, XP, dashboards, history, celebrations.
   ===================================================================================================== */

/* Coin counter in the app bar. */
.hq-coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  padding: 4px 12px 4px 5px;
  border: 2px solid var(--hq-gold-bright);
  border-radius: var(--hq-radius-pill);
  background: var(--hq-night-soft);
  color: var(--hq-star);
  font-family: var(--hq-title);
  font-weight: 600;
  font-size: var(--hq-fs-md);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.hq-coin-pill:focus-visible { outline: 3px solid var(--hq-gold-bright); outline-offset: 2px; }

/* Level chip + XP bar. */
.hq-level { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.hq-level-chip {
  display: inline-block;
  padding: 1px 10px;
  border: 2px solid var(--hq-ink);
  border-radius: var(--hq-radius-pill);
  background: var(--hq-magic-light);
  color: var(--hq-ink);
  font-family: var(--hq-title);
  font-weight: 600;
  font-size: var(--hq-fs-sm);
  white-space: nowrap;
}
.hq-xp-bar {
  flex: 1 1 110px;
  max-width: 180px;
  height: 14px;
  border: 2px solid var(--hq-magic-light);
  border-radius: var(--hq-radius-pill);
  background: var(--hq-night-soft);
  overflow: hidden;
}
.hq-xp-fill { height: 100%; background: var(--hq-magic-light); border-radius: var(--hq-radius-pill); transition: width 400ms ease-out; }
.hq-xp-text { font-weight: 800; font-size: var(--hq-fs-xs); color: var(--hq-lilac); font-variant-numeric: tabular-nums; }
.hq-level.compact { margin-top: 2px; }
.hq-level.compact .hq-xp-bar { border-color: var(--hq-magic-line); background: var(--hq-magic-soft); max-width: 120px; }
.hq-level.compact .hq-xp-fill { background: #7a6ad8; }
.hq-hello { min-width: 0; }
.hq-profile .hq-level-chip { font-size: var(--hq-fs-xs); }

/* Child dashboard: day ring + coins card. */
.hq-dashboard { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 599.98px) { .hq-dashboard { grid-template-columns: minmax(0, 1fr); } }

.hq-day-card, .hq-coins-card, .hq-child-card {
  background: var(--hq-parchment);
  border: 3px solid var(--hq-gold);
  border-radius: var(--hq-radius-lg);
  box-shadow: var(--hq-toy-shadow);
}
.hq-day-card { display: flex; align-items: center; gap: 14px; padding: 14px; }
.hq-day-card-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hq-ring {
  --p: 0;
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: conic-gradient(var(--hq-success) calc(var(--p) * 1%), var(--hq-line-soft) 0);
  display: grid;
  place-items: center;
}
.hq-ring span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--hq-parchment);
  display: grid;
  place-items: center;
  font-family: var(--hq-title);
  font-weight: 700;
  font-size: var(--hq-fs-xl);
  font-variant-numeric: tabular-nums;
}

.hq-coins-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  padding: 14px;
  color: var(--hq-ink);
  text-decoration: none;
}
.hq-coins-card .hq-story-icon { grid-row: 1 / span 2; }
.hq-coins-card-amount { font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-4xl); line-height: 1; font-variant-numeric: tabular-nums; }
.hq-coins-card-label { font-weight: 800; color: var(--hq-earth); }
.hq-coins-card-link { grid-column: 1 / span 2; margin-top: 8px; font-weight: 800; font-size: var(--hq-fs-sm); color: var(--hq-magic); text-decoration: underline; }
.hq-coins-card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--hq-night-deep); }

/* Parents' family overview. */
.hq-child-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
@media (max-width: 599.98px) { .hq-child-list { grid-template-columns: minmax(0, 1fr); } }
.hq-child-card { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.hq-child-head { display: flex; align-items: center; gap: 12px; }
.hq-child-info { flex: 1; min-width: 0; }
.hq-child-info h2 { margin: 0; line-height: 1.2; }
.hq-coins-big { font-size: var(--hq-fs-md); padding: 3px 12px 3px 5px; }
.hq-child-today { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: var(--hq-fs-sm); color: var(--hq-ink-soft); }
.hq-child-today .hq-day-progress-bar { flex: 1; }
.hq-child-today-count { font-variant-numeric: tabular-nums; color: var(--hq-ink); }
.hq-day-progress-bar.small { height: 14px; padding: 2px; }
.hq-child-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Coins dialog presets. */
.hq-amount-row { display: flex; flex-wrap: wrap; gap: 6px; }
.hq-amount-row .hq-day-chip { min-width: 48px; height: 38px; padding: 0 12px; }

/* History. */
.hq-history { list-style: none; margin: 0; padding: 0; }
.hq-history-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 2px dashed var(--hq-line); }
.hq-history-row:last-child { border-bottom: 0; }
.hq-history-icon {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--hq-medal);
  border: 3px solid var(--hq-gold);
  display: grid;
  place-items: center;
  box-sizing: border-box;
}
.hq-history-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hq-history-title { font-weight: 800; overflow-wrap: anywhere; }
.hq-history-meta { font-size: var(--hq-fs-xs); color: var(--hq-ink-soft); font-weight: 700; }
.hq-history-amount { font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-xl); font-variant-numeric: tabular-nums; }
.hq-history-amount.plus { color: var(--hq-success-deep); }
.hq-history-amount.minus { color: var(--hq-danger); }

/* Celebration overlay. */
.hq-celebration {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 19, 58, 0.72);
  animation: hq-fade-in 200ms ease-out;
}
.hq-celebration-card {
  width: min(360px, 100%);
  padding: 20px 20px 16px;
  text-align: center;
  background: var(--hq-parchment);
  border: 4px solid var(--hq-gold-bright);
  border-radius: var(--hq-radius-xl);
  box-shadow: 0 8px 0 var(--hq-night-deep);
  animation: hq-pop 380ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.hq-celebration-card h2 { margin: 8px 0 4px; font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-4xl); color: var(--hq-ink); }
.hq-celebration-card p { margin: 0 0 14px; font-weight: 700; color: var(--hq-ink-soft); }
.hq-celebration-burst { position: relative; display: grid; place-items: center; height: 130px; }
.hq-celebration-burst > .hq-story-icon { animation: hq-bob 1.6s ease-in-out infinite; }
.hq-celebration-star {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -14px 0 0 -14px;
  transform: rotate(calc(var(--i) * 45deg)) translateY(-58px);
  animation: hq-twinkle 1.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 120ms);
}
@keyframes hq-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes hq-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes hq-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hq-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .hq-celebration, .hq-celebration-card, .hq-celebration-burst > .hq-story-icon, .hq-celebration-star { animation: none; }
  .hq-xp-fill { transition: none; }
}
.hq-amount-row .hq-day-chip { text-transform: none; }

/* "My history" on the child's coins card: styled like the parents' history button (the card is the link). */
.hq-coins-card-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  border: 3px solid var(--hq-magic);
  border-radius: var(--hq-radius-md);
  background: var(--hq-parchment-soft);
  box-shadow: 0 3px 0 var(--hq-night-deep);
  color: var(--hq-magic);
  font-family: var(--hq-title);
  font-weight: 600;
  font-size: var(--hq-fs-md);
  text-decoration: none;
}
.hq-coins-card:active .hq-coins-card-link { transform: translateY(2px); box-shadow: 0 1px 0 var(--hq-night-deep); }

/* ---------- Sprint 4: shop, vouchers, screen time ---------- */
.hq-reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
@media (max-width: 599.98px) { .hq-reward-grid { grid-template-columns: 1fr; } }
.hq-reward.locked .hq-quest-icon { filter: grayscale(0.7); opacity: 0.7; }
.hq-reward-description { font-size: var(--hq-fs-sm); color: var(--hq-ink-soft); overflow-wrap: anywhere; }
.hq-reward-why {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--hq-radius-pill);
  border: 2px dashed var(--hq-pending);
  color: var(--hq-coin-ink);
  font-weight: 800;
  font-size: var(--hq-fs-sm);
  white-space: nowrap;
}
.hq-voucher.honored { background: var(--hq-success-soft) !important; border-color: var(--hq-success-line) !important; }
.hq-voucher.cancelled { opacity: 0.6; }
.hq-voucher.pending { border-style: dashed !important; border-color: var(--hq-pending) !important; }

.hq-timer.running { border-color: var(--hq-success-bright) !important; }
.hq-timer.paused { border-style: dashed !important; border-color: var(--hq-magic-line) !important; }
.hq-timer.finished { opacity: 0.7; }
.hq-timer-clock {
  font-family: var(--hq-title);
  font-weight: 700;
  font-size: var(--hq-fs-5xl);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--hq-ink);
}
.hq-timer-clock.warning { color: var(--hq-danger); }

/* The banner of running timers, above every page. */
.hq-timer-banner { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }
.hq-timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--hq-radius-pill);
  border: 3px solid var(--hq-success-bright);
  background: var(--hq-parchment);
  box-shadow: 0 3px 0 var(--hq-night-deep);
  color: var(--hq-ink);
  font-family: var(--hq-title);
  font-weight: 700;
  text-decoration: none;
}
.hq-timer-pill-clock { font-size: var(--hq-fs-lg); font-variant-numeric: tabular-nums; }
.hq-timer-pill.warning { border-color: var(--hq-warning-line); background: var(--hq-warning-soft); animation: hq-twinkle 1.6s ease-in-out infinite; }
.hq-timer-pill.paused { border-color: var(--hq-magic-line); border-style: dashed; }
.hq-timer-pill.finished { border-color: var(--hq-danger); background: var(--hq-danger-soft); }
@media (prefers-reduced-motion: reduce) { .hq-timer-pill.warning { animation: none; } }

@media (max-width: 599.98px) {
  /* "Come back later" / "55 more coins" goes under the reward, like the Buy button, so the title keeps its width. */
  .hq-quest-actions:has(> .hq-reward-why) { width: 100%; }
  .hq-reward-why { flex: 1; justify-content: center; }
  /* Timer: the main action (start / pause / resume) on its own row, the small ones below. */
  .hq-timer .hq-quest-actions > .mud-button-root:first-child { flex-basis: 100%; }
  .hq-timer .hq-quest-actions > .mud-button-root { padding-left: 8px; padding-right: 8px; }
}

/* ---------- Sprint 6: 3D heroes ---------- */
.hq-avatar-portrait { overflow: hidden; }
.hq-avatar-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
a.hq-medallion { border-radius: 50%; }
a.hq-medallion:focus-visible { outline: 3px solid var(--hq-gold-bright); outline-offset: 2px; }

.hq-hero-stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--hq-radius-lg);
  background: radial-gradient(120% 90% at 50% 15%, #4a3aa8 0%, #2a1f63 45%, #140e2b 100%);
}
.hq-hero-stage .hq-hero-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hq-hero-stage-loading, .hq-hero-stage-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  text-align: center; color: var(--hq-lilac); font-weight: 700;
}
.hq-hero-hint {
  position: absolute; top: 10px; right: 12px; font-size: var(--hq-fs-2xs); color: var(--hq-lilac); opacity: .8; pointer-events: none;
}

/* Hero screen: stage on the left, wardrobe on the right; stacked on phones. */
.hq-hero-workshop { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 899.98px) { .hq-hero-workshop { grid-template-columns: minmax(0, 1fr); } }
.hq-hero-stage-column { display: grid; gap: 12px; position: sticky; top: 76px; }
@media (max-width: 899.98px) { .hq-hero-stage-column { position: static; } }
.hq-hero-stage-big { aspect-ratio: 4 / 5; max-height: 70vh; width: 100%; border: 3px solid var(--hq-gold); }
@media (max-width: 899.98px) { .hq-hero-stage-big { aspect-ratio: 1 / 1; max-height: 52vh; } }

.hq-wardrobe {
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); border-radius: var(--hq-radius-lg);
  box-shadow: var(--hq-toy-shadow); padding: 14px; display: grid; gap: 14px; min-width: 0;
}
.hq-wardrobe-level { font-weight: 700; color: var(--hq-ink-soft); }
.hq-wardrobe-slot { display: grid; gap: 6px; }
.hq-wardrobe-slot h2 {
  margin: 0; font-family: var(--hq-title); font-size: var(--hq-fs-sm); font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--hq-ink-soft);
}
.hq-on-panel-muted { color: var(--hq-ink-soft); }
.hq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hq-chip {
  font: inherit; font-weight: 700; font-size: var(--hq-fs-sm); color: var(--hq-ink); cursor: pointer;
  background: var(--hq-parchment-soft); border: 2px solid var(--hq-medal); border-radius: var(--hq-radius-sm);
  padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
}
.hq-chip:hover:not(:disabled) { border-color: var(--hq-gold); }
.hq-chip:focus-visible { outline: 3px solid var(--hq-night); outline-offset: 1px; }
.hq-chip[aria-pressed="true"] { background: var(--hq-gold-bright); border-color: var(--hq-gold); }
.hq-chip:disabled { cursor: not-allowed; opacity: .6; }
.hq-chip-class { background: var(--hq-lilac); }
.hq-chip-lock { display: inline-flex; align-items: center; gap: 2px; font-size: var(--hq-fs-2xs); color: var(--hq-ink-soft); }
.hq-swatch {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 3px solid var(--hq-parchment-soft); box-shadow: 0 0 0 2px var(--hq-medal);
}
.hq-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--hq-night); }
.hq-swatch:focus-visible { outline: 3px solid var(--hq-gold-bright); outline-offset: 2px; }

/* Child dashboard: the hero card spans the first column. */
.hq-hero-card {
  grid-row: span 2; display: grid; gap: 8px; padding: 10px; cursor: pointer;
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); border-radius: var(--hq-radius-lg); box-shadow: var(--hq-toy-shadow);
}
@media (max-width: 599.98px) { .hq-hero-card { grid-row: auto; } }
.hq-hero-stage-card { height: 280px; }
.hq-hero-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.hq-hero-card-hint { font-weight: 700; color: var(--hq-ink-soft); }
.hq-hero-card-empty {
  place-items: center; text-align: center; text-decoration: none; color: var(--hq-ink); padding: 24px 16px;
}
.hq-hero-card-title { font-family: var(--hq-title); font-size: var(--hq-fs-2xl); font-weight: 700; }

/* Celebration: the hero cheers in place of the big icon. */
.hq-celebration-burst-hero .hq-hero-stage-celebration { width: 200px; height: 220px; background: transparent; }
.hq-swatch-native { background: var(--hq-parchment-soft); border-style: dashed; border-color: var(--hq-ink-soft); color: var(--hq-ink); font-weight: 700; font-size: var(--hq-fs-lg); line-height: 1; }

/* App bar on phones: the name gives way so the coin counter, status, language and the avatar always fit. */
.mud-appbar .hq-coin-pill, .mud-appbar .hq-avatar-button { flex-shrink: 0; }
@media (max-width: 599.98px) { .mud-appbar .hq-brand { display: none; } }

/* Storybook emoji (tools/icons): SVG pictures, the same on every device. */
.hq-emoji-svg { display: inline-block; vertical-align: middle; flex-shrink: 0; user-select: none; }
.hq-inline-emoji { margin-top: -0.2em; }
.hq-avatar .hq-emoji-svg { display: block; }
.hq-nowrap { white-space: nowrap; }

/* ---------- Sprint 7: leaderboard, streaks, badges ---------- */
.hq-period-switch { display: inline-flex; gap: 6px; background: var(--hq-night-soft); padding: 4px; border-radius: var(--hq-radius-md); width: fit-content; }
.hq-period { font: inherit; font-weight: 800; border: 0; border-radius: 10px; padding: 8px 16px; cursor: pointer; color: var(--hq-lilac); background: transparent; }
.hq-period.active { background: var(--hq-gold-bright); color: var(--hq-ink); }
.hq-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 10px; max-width: 640px; }
.hq-podium-spot { display: grid; justify-items: center; gap: 6px; min-width: 0; }
.hq-podium-first { order: 2; } .hq-podium-second { order: 1; } .hq-podium-third { order: 3; }
.hq-podium-spot:only-child { grid-column: 2; }
.hq-hero-stage-podium { width: 100%; height: 170px; background: transparent; }
.hq-podium-first .hq-hero-stage-podium { height: 200px; }
.hq-podium-step {
  width: 100%; display: grid; justify-items: center; gap: 2px; padding: 10px 6px; text-align: center;
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); border-radius: 14px 14px 6px 6px; box-shadow: var(--hq-toy-shadow);
}
.hq-podium-first .hq-podium-step { min-height: 120px; background: var(--hq-coin); }
.hq-podium-second .hq-podium-step { min-height: 96px; }
.hq-podium-third .hq-podium-step { min-height: 80px; }
.hq-podium-name { font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-md); overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.hq-podium-score { font-weight: 800; color: var(--hq-ink-soft); font-size: var(--hq-fs-sm); }
.hq-rank-list { display: grid; gap: 8px; max-width: 640px; }
.hq-rank-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--hq-parchment); border: 3px solid var(--hq-gold); border-radius: var(--hq-radius-md); }
.hq-rank-number { font-family: var(--hq-title); font-weight: 700; width: 24px; text-align: center; }
.hq-rank-name { flex: 1; font-weight: 800; }
.hq-rank-score { font-weight: 800; color: var(--hq-ink-soft); }

.hq-streak-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap;
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); border-radius: var(--hq-radius-lg); box-shadow: var(--hq-toy-shadow);
}
.hq-streak-body { display: grid; flex: 1; min-width: 160px; }
.hq-streak-days { font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-2xl); }
.hq-streak-meta { font-weight: 700; color: var(--hq-ink-soft); font-size: var(--hq-fs-sm); }
.hq-streak-badges {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--hq-radius-pill); text-decoration: none;
  font-weight: 800; color: var(--hq-ink); background: var(--hq-lilac); border: 2px solid var(--hq-magic-line);
}
.hq-child-streak { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; margin-right: 8px; }

.hq-badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.hq-badge {
  display: grid; justify-items: center; gap: 4px; padding: 12px 10px; text-align: center;
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); border-radius: var(--hq-radius-lg); box-shadow: var(--hq-toy-shadow);
}
.hq-badge.locked { background: var(--hq-parchment-dim); border-color: var(--hq-line); }
.hq-badge.locked .hq-badge-medal { filter: grayscale(1); opacity: .45; }
.hq-badge-medal {
  display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--hq-parchment-soft) 0, var(--hq-medal) 70%); border: 3px solid var(--hq-gold); box-shadow: 0 0 0 2px var(--hq-ink);
}
.hq-badge-name { font-family: var(--hq-title); font-weight: 700; }
.hq-badge-text { font-size: var(--hq-fs-sm); color: var(--hq-ink-soft); }
.hq-badge-date { font-size: var(--hq-fs-xs); font-weight: 700; color: var(--hq-ink-soft); }
.hq-badge-progress { width: 100%; height: 8px; background: var(--hq-line-soft); border-radius: var(--hq-radius-pill); overflow: hidden; }
.hq-badge-progress span { display: block; height: 100%; background: var(--hq-gold); }
.hq-badge-unlock { display: inline-flex; align-items: center; gap: 4px; font-size: var(--hq-fs-xs); font-weight: 800; color: var(--hq-magic-ink); background: var(--hq-magic-soft); border-radius: var(--hq-radius-pill); padding: 2px 8px; }
.hq-celebration-badge { display: grid; place-items: center; margin: 4px auto 0; }

.hq-milestones { display: grid; gap: 8px; }
.hq-milestone-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }

/* ----- Sprint 8: the family boss and the piggy banks ----- */
.hq-goal-section { display: flex; flex-direction: column; gap: 12px; }
.hq-goal-form { background: var(--hq-parchment); border: 3px solid var(--hq-gold); border-radius: var(--hq-radius-lg); }
.hq-goal-hint { font-size: var(--hq-fs-sm); font-weight: 700; color: var(--hq-earth); }
.hq-goal-give { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hq-goal-give-label { font-weight: 900; color: var(--hq-text); width: 100%; }

.hq-boss-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 18px 16px; border-radius: var(--hq-radius-lg); border: 3px solid var(--hq-boss);
  background: radial-gradient(circle at 50% 18%, #ffe9d2 0, var(--hq-parchment) 55%);
  box-shadow: 0 6px 0 var(--hq-danger-deep);
}
.hq-boss-card.defeated { border-color: var(--hq-success-strong); box-shadow: 0 6px 0 var(--hq-success-deep); }
.hq-boss-card.fled, .hq-boss-card.cancelled { border-color: var(--hq-magic-line); box-shadow: 0 6px 0 var(--hq-magic-ink); }
.hq-boss-reward { display: flex; flex-direction: column; }
.hq-boss-reward-label { font-size: var(--hq-fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--hq-amber); }
.hq-boss-title { font-family: var(--hq-title); font-size: var(--hq-fs-3xl); font-weight: 700; color: var(--hq-text); }
.hq-boss-help { margin: 0; font-size: var(--hq-fs-sm); color: var(--hq-text); }
.hq-boss-result { margin: 0; font-weight: 900; color: var(--hq-text); }

.hq-boss-health {
  position: relative; width: 100%; height: 28px; border-radius: var(--hq-radius-pill); overflow: hidden;
  background: var(--hq-ink); border: 3px solid var(--hq-night-deep);
}
.hq-boss-health.small { height: 12px; border-width: 2px; }
.hq-boss-health-fill {
  position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ff6b6b, #d6303a);
  transition: width .6s cubic-bezier(.3, 1.4, .5, 1);
}
.hq-boss-health-text {
  position: relative; display: block; line-height: 22px; font-weight: 900; color: var(--hq-paper);
  text-shadow: 0 1px 0 var(--hq-night-deep), 0 0 4px var(--hq-night-deep);
}

.hq-boss-monster { display: grid; place-items: center; width: var(--size); height: var(--size); animation: hq-boss-bob 2.4s ease-in-out infinite; }
.hq-boss-monster.hit { animation: hq-boss-hit .5s ease-out; }
.hq-boss-monster.defeated { animation: none; transform: rotate(-12deg); filter: grayscale(.5) opacity(.75); }
@keyframes hq-boss-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hq-boss-hit {
  0% { transform: translateX(0); filter: none; }
  20% { transform: translateX(-8px) rotate(-6deg); filter: brightness(2) saturate(.2); }
  45% { transform: translateX(8px) rotate(6deg); }
  70% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

.hq-boss-heroes { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.hq-boss-hero { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; }
.hq-boss-hero-name { font-weight: 900; font-size: var(--hq-fs-sm); color: var(--hq-text); }
.hq-boss-hero-hits { display: inline-flex; gap: 6px; font-size: var(--hq-fs-xs); font-weight: 800; color: var(--hq-danger-deep); align-items: center; }

.hq-boss-mini {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--hq-radius-lg); text-decoration: none;
  background: var(--hq-parchment); border: 3px solid var(--hq-boss); box-shadow: 0 4px 0 var(--hq-danger-deep); color: inherit;
}
.hq-boss-mini-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.hq-boss-mini-title { font-weight: 900; color: var(--hq-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hq-boss-mini-left { font-size: var(--hq-fs-xs); font-weight: 800; color: var(--hq-danger-deep); }

.hq-piggy {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--hq-radius-lg);
  background: var(--hq-parchment); border: 3px solid var(--hq-pink); box-shadow: 0 5px 0 var(--hq-pink-deep);
}
.hq-piggy.reached, .hq-piggy.given { border-color: var(--hq-success-strong); box-shadow: 0 5px 0 var(--hq-success-deep); }
.hq-piggy.withdrawn, .hq-piggy.cancelled { opacity: .75; }
.hq-piggy-head { display: flex; align-items: center; gap: 10px; }
.hq-piggy-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--hq-medal); border: 3px solid var(--hq-gold); }
.hq-piggy-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.hq-piggy-name { font-weight: 900; font-size: var(--hq-fs-xl); color: var(--hq-text); }
.hq-piggy-owner { font-size: var(--hq-fs-sm); font-weight: 800; color: var(--hq-earth); }
.hq-piggy-bar { height: 16px; border-radius: var(--hq-radius-pill); overflow: hidden; background: var(--hq-pink-soft); border: 2px solid var(--hq-pink-deep); }
.hq-piggy-bar span { display: block; height: 100%; background: linear-gradient(#ffb3c9, #e0608a); transition: width .6s ease; }
.hq-piggy-numbers { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 900; color: var(--hq-text); }
.hq-piggy-numbers > span:first-child { display: inline-flex; align-items: center; gap: 4px; }
.hq-piggy-bonus { font-size: var(--hq-fs-xs); color: var(--hq-success-deep); background: var(--hq-success-soft); border-radius: var(--hq-radius-pill); padding: 1px 8px; }
.hq-piggy-status { margin: 0; font-weight: 800; color: var(--hq-text); }
.hq-piggy-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.hq-piggy-choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; border-radius: var(--hq-radius-lg); cursor: pointer;
  background: var(--hq-paper); border: 2px solid var(--hq-line); font: inherit; font-weight: 800; color: var(--hq-text);
}
.hq-piggy-choice:hover, .hq-piggy-choice:focus-visible { border-color: var(--hq-gold); outline: none; }
.hq-piggy-choice-name { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .hq-boss-monster, .hq-boss-monster.hit { animation: none; }
}

.hq-boss-stage {
  position: relative; overflow: hidden; border-radius: var(--hq-radius-lg); cursor: pointer;
  background: radial-gradient(120% 90% at 50% 15%, #a8475a 0%, #5a1f3a 45%, #22102b 100%);
  display: grid; place-items: center;
}
.hq-boss-stage .hq-hero-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: manipulation; }
.hq-boss-stage-big { width: 100%; aspect-ratio: 4 / 3; max-height: 46vh; border: 3px solid var(--hq-danger-deep); }

/* ----- Sprint 5: shopping lists ----- */
.hq-list-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.hq-list-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--hq-radius-pill); cursor: pointer;
  font: inherit; font-weight: 900; color: var(--hq-text); background: var(--hq-parchment); border: 2px solid var(--hq-line);
}
.hq-list-tab.active { background: var(--hq-gold-bright); border-color: var(--hq-gold-deep); box-shadow: 0 3px 0 var(--hq-gold-deep); }
.hq-list-tab.add { padding: 6px 10px; }
.hq-list-tab:focus-visible { outline: 3px solid var(--hq-gold); outline-offset: 2px; }
.hq-list-count { min-width: 22px; padding: 0 6px; border-radius: var(--hq-radius-pill); background: var(--hq-night); color: var(--hq-paper); font-size: var(--hq-fs-xs); text-align: center; }
.hq-sync { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--hq-radius-md); font-weight: 800; }
.hq-sync.offline { background: var(--hq-warning-soft); color: var(--hq-amber); border: 2px solid var(--hq-warning-line); }

.hq-shopping {
  display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: var(--hq-radius-lg);
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); box-shadow: var(--hq-toy-shadow); color: var(--hq-text);
}
.hq-shopping-head { display: flex; align-items: center; gap: 8px; }
.hq-shopping-title { font-family: var(--hq-title); font-size: var(--hq-fs-2xl); font-weight: 700; flex: 1; min-width: 0; }
.hq-shopping-add { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem auto; gap: 8px; align-items: center; }
@media (max-width: 599.98px) { .hq-shopping-add { grid-template-columns: minmax(0, 1fr) 5.5rem; } .hq-shopping-add > .mud-button-root { grid-column: 1 / -1; } }
.hq-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.hq-suggestion {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--hq-radius-pill); cursor: pointer;
  font: inherit; font-size: var(--hq-fs-sm); font-weight: 800; color: var(--hq-text); background: var(--hq-paper); border: 2px dashed var(--hq-line);
}
.hq-suggestion:hover, .hq-suggestion:focus-visible { border-style: solid; border-color: var(--hq-gold); outline: none; }

.hq-aisle { display: flex; flex-direction: column; gap: 4px; }
.hq-aisle-title { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: var(--hq-fs-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--hq-amber); padding-top: 4px; }
.hq-item { display: flex; align-items: center; gap: 4px; border-radius: var(--hq-radius-md); background: var(--hq-paper); border: 2px solid var(--hq-line-soft); }
.hq-item-check {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 10px; min-height: 52px;
  background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.hq-item-check:focus-visible { outline: 3px solid var(--hq-gold); border-radius: var(--hq-radius-sm); }
.hq-item-box {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--hq-line-strong); background: var(--hq-paper); color: var(--hq-paper);
}
.hq-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hq-item-name { font-weight: 800; font-size: var(--hq-fs-md); overflow-wrap: anywhere; }
.hq-item-note { font-size: var(--hq-fs-xs); color: var(--hq-earth); }
.hq-item-qty { flex: none; font-weight: 900; font-size: var(--hq-fs-sm); padding: 1px 9px; border-radius: var(--hq-radius-pill); background: var(--hq-magic-soft); color: var(--hq-magic-ink); }
.hq-item.checked { opacity: .65; background: var(--hq-parchment-dim); }
.hq-item.checked .hq-item-box { background: var(--hq-success-strong); border-color: var(--hq-success-deep); }
.hq-item.checked .hq-item-name { text-decoration: line-through; }
.hq-cart { border-top: 2px dashed var(--hq-line); padding-top: 6px; }
.hq-shopping-add.todo { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 599.98px) { .hq-shopping-add.todo { grid-template-columns: minmax(0, 1fr); } }

/* ----- Sprint 9: family calendar ----- */
.hq-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hq-cal-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.hq-cal-nav .hq-cal-arrow { color: var(--hq-parchment); }
.hq-cal-range { font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-lg); color: var(--hq-parchment); min-width: 11rem; text-align: center; }
.hq-cal-today-button { margin-left: 4px; }
.hq-cal-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.hq-cal-alert {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--hq-radius-md); font-weight: 800;
  background: var(--hq-warning-soft); color: var(--hq-amber); border: 2px solid var(--hq-warning-line);
}
.hq-cal-week { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 1280px) { .hq-cal-week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; } }
.hq-cal-day {
  display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--hq-radius-lg); min-height: 4rem;
  background: var(--hq-parchment); border: 3px solid var(--hq-line); color: var(--hq-text);
}
.hq-cal-day.today { border-color: var(--hq-gold); box-shadow: var(--hq-gold-shadow); background: var(--hq-parchment-soft); }
.hq-cal-day.past { opacity: .72; }
.hq-cal-day-head { display: flex; align-items: center; gap: 6px; }
.hq-cal-day-name { font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-md); text-transform: capitalize; }
.hq-cal-day-number { font-weight: 800; color: var(--hq-ink-soft); font-size: var(--hq-fs-sm); flex: 1; }
.hq-cal-today-chip { font-size: var(--hq-fs-2xs); font-weight: 900; padding: 1px 8px; border-radius: var(--hq-radius-pill); background: var(--hq-gold-bright); }
.hq-cal-day-add {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 2px dashed var(--hq-line-strong); background: transparent; color: var(--hq-ink);
}
.hq-cal-day-add:hover, .hq-cal-day-add:focus-visible { border-style: solid; background: var(--hq-paper); outline: none; }
.hq-cal-free { font-size: var(--hq-fs-sm); color: var(--hq-earth); font-style: italic; }
.hq-cal-event {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: stretch; justify-content: start; gap: 10px;
  width: 100%; padding: 8px 10px 8px 8px; border-radius: var(--hq-radius-md); cursor: pointer; text-align: left;
  font: inherit; color: inherit; background: var(--hq-paper); border: 2px solid var(--hq-line-soft);
}
.hq-cal-event:hover, .hq-cal-event:focus-visible { border-color: var(--hq-gold); outline: none; }
.hq-cal-event.no-driver { border-color: var(--hq-warning-line); background: var(--hq-warning-softer); }
.hq-cal-event-time {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1px;
  min-width: 3.6rem; padding: 0 12px 0 4px; text-align: center; white-space: nowrap;
  border-right: 3px solid var(--hq-gold); font-weight: 900; font-size: var(--hq-fs-md); color: var(--hq-magic-ink); line-height: 1.15;
}
.hq-cal-event-end { font-size: var(--hq-fs-2xs); font-weight: 800; color: var(--hq-ink-soft); }
.hq-cal-event-allday { font-size: var(--hq-fs-2xs); line-height: 1.15; white-space: normal; max-width: 4.2rem; }
.hq-cal-event-text { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.hq-cal-event-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 800; font-size: var(--hq-fs-md); }
.hq-cal-event-icon { flex: none; }
.hq-cal-event-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hq-cal-repeat { flex: none; color: var(--hq-ink-soft); }
.hq-cal-event-people { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.hq-cal-avatars { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.hq-cal-ride {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--hq-fs-xs); font-weight: 800; margin-left: auto; white-space: nowrap;
  padding: 1px 8px; border-radius: var(--hq-radius-pill); background: var(--hq-magic-soft); color: var(--hq-magic-ink);
}
.hq-cal-ride.missing { background: var(--hq-warning-soft); color: var(--hq-amber); border: 1px solid var(--hq-warning-line); }
.hq-cal-times, .hq-cal-repeat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hq-cal-people { display: flex; flex-wrap: wrap; gap: 6px; }
.hq-cal-person { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.hq-cal-person-choice {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: var(--hq-radius-pill); cursor: pointer;
  font: inherit; font-weight: 800; color: var(--hq-text); background: var(--hq-parchment-soft); border: 2px solid var(--hq-line);
}
.hq-cal-person-choice.selected { background: var(--hq-gold-bright); border-color: var(--hq-ink); }
.hq-cal-person-choice:focus-visible { outline: 3px solid var(--hq-gold); outline-offset: 2px; }
.hq-cal-details-title { display: flex; align-items: center; gap: 10px; font-family: var(--hq-title); font-size: var(--hq-fs-2xl); font-weight: 700; }
.hq-cal-notes { white-space: pre-line; }

/* ----- Sprint 9: message board ----- */
.hq-board-form {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--hq-radius-lg);
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); box-shadow: var(--hq-toy-shadow); color: var(--hq-text);
}
.hq-board-kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.hq-board-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hq-board-for, .hq-board-when { flex: 1 1 12rem; }
.hq-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 14px; align-items: start; }
.hq-note {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 10px; border-radius: 6px 18px 18px 18px;
  background: var(--hq-note); border: 2px solid var(--hq-note-line); color: var(--hq-text); box-shadow: 0 4px 0 rgba(23, 19, 58, .45);
}
.hq-note:nth-child(3n + 1) { transform: rotate(-0.6deg); }
.hq-note:nth-child(3n + 2) { transform: rotate(0.5deg); }
.hq-note.kind-word { background: var(--hq-pink-soft); border-color: var(--hq-pink); }
.hq-note.reminder { background: var(--hq-sky-soft); border-color: var(--hq-sky-line); }
.hq-note.pinned { border-width: 3px; border-color: var(--hq-danger-bright); }
.hq-note.for-me { box-shadow: 0 0 0 3px var(--hq-gold-bright), 0 4px 0 rgba(23, 19, 58, .45); }
.hq-note-pin { position: absolute; top: -14px; right: 12px; }
.hq-note-head { display: flex; align-items: center; gap: 8px; }
.hq-note-who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.15; }
.hq-note-author { font-weight: 900; }
.hq-note-to { font-size: var(--hq-fs-xs); font-weight: 800; color: var(--hq-pink-ink); }
.hq-note-date { align-self: flex-start; font-size: var(--hq-fs-xs); font-weight: 900; padding: 1px 8px; border-radius: var(--hq-radius-pill); background: var(--hq-paper); border: 1px solid var(--hq-sky-line); text-transform: capitalize; }
.hq-note-date.today { background: var(--hq-gold-bright); border-color: var(--hq-gold-deep); }
.hq-note-date.past { opacity: .6; text-decoration: line-through; }
.hq-note-text { margin: 0; font-size: var(--hq-fs-md); font-weight: 700; white-space: pre-line; overflow-wrap: anywhere; }
.hq-note-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.hq-note-time { font-size: var(--hq-fs-2xs); color: var(--hq-earth); }
.hq-note-actions { display: inline-flex; }
.hq-reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.hq-reaction {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; min-height: 30px; border-radius: var(--hq-radius-pill); cursor: pointer;
  font: inherit; font-size: var(--hq-fs-sm); font-weight: 900; color: var(--hq-text); background: rgba(255, 255, 255, .7); border: 2px solid transparent;
}
.hq-reaction.empty { opacity: .45; }
.hq-reaction.empty:hover, .hq-reaction:focus-visible { opacity: 1; outline: none; border-color: var(--hq-gold); }
.hq-reaction.mine { background: var(--hq-paper); border-color: var(--hq-ink); }

/* Unread messages badge (S9-2). */
.hq-avatar-button { position: relative; }
.hq-avatar-count { position: absolute; top: -4px; right: -6px; margin: 0; }
.hq-feature-tile { position: relative; }
.hq-tile-count { position: absolute; top: 8px; right: 8px; margin: 0; min-width: 26px; height: 26px; font-size: var(--hq-fs-sm); border-radius: 13px; }
.hq-note.new { outline: 3px solid var(--hq-gold-bright); outline-offset: 2px; }
.hq-note-new {
  position: absolute; top: -12px; left: 12px; padding: 1px 10px; border-radius: var(--hq-radius-pill); font-size: var(--hq-fs-2xs); font-weight: 900;
  background: var(--hq-gold-bright); color: var(--hq-ink); border: 2px solid var(--hq-ink);
}

/* ----- Sprint 10: kiosk (a tablet on the fridge) ----- */
.hq-kiosk-root { min-height: 100vh; background: radial-gradient(120% 80% at 50% 0%, var(--hq-night) 0%, var(--hq-night-deep) 100%); }
.hq-kiosk { display: flex; flex-direction: column; gap: 14px; padding: 16px; min-height: 100vh; box-sizing: border-box; color: var(--hq-parchment); }
.hq-kiosk-head { display: flex; align-items: center; gap: 16px; }
.hq-kiosk-date { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.hq-kiosk-day { font-family: var(--hq-title); font-weight: 700; font-size: clamp(1.4rem, 3vw, 2.2rem); text-transform: capitalize; }
.hq-kiosk-family { color: var(--hq-lilac); font-weight: 800; }
.hq-kiosk-clock { font-family: var(--hq-title); font-weight: 700; font-size: clamp(2rem, 6vw, 3.6rem); color: var(--hq-gold-bright); }
.hq-kiosk-exit { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: var(--hq-lilac); border: 2px solid rgba(217, 211, 245, .35); }
.hq-kiosk-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; flex: 1; }
@media (min-width: 900px) { .hq-kiosk-body { grid-template-columns: minmax(0, 2.2fr) minmax(16rem, 1fr); align-items: start; } }
.hq-kiosk-children { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 12px; align-items: start; }
.hq-kiosk-child {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--hq-radius-lg);
  background: var(--hq-parchment); border: 3px solid var(--hq-gold); box-shadow: var(--hq-toy-shadow); color: var(--hq-text);
}
.hq-kiosk-child.all-done { border-color: var(--hq-success-strong); box-shadow: 0 5px 0 var(--hq-success-deep); }
.hq-kiosk-child-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px; border-radius: var(--hq-radius-lg); cursor: pointer;
  background: transparent; border: 0; font: inherit; color: inherit; text-align: left;
}
.hq-kiosk-child-head:focus-visible, .hq-kiosk-child-head:hover { background: var(--hq-medal); outline: none; }
.hq-kiosk-child-name { flex: 1; min-width: 0; font-family: var(--hq-title); font-weight: 700; font-size: var(--hq-fs-3xl); }
.hq-kiosk-child-count { font-weight: 900; font-size: var(--hq-fs-xl); color: var(--hq-magic-ink); }
.hq-kiosk-bravo { font-weight: 900; color: var(--hq-success-deep); }
.hq-kiosk-quests { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hq-kiosk-quest { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--hq-radius-sm); background: var(--hq-paper); border: 2px solid var(--hq-line-soft); }
.hq-kiosk-quest-title { flex: 1; min-width: 0; font-weight: 800; font-size: var(--hq-fs-md); overflow-wrap: anywhere; }
.hq-kiosk-quest-state { font-size: var(--hq-fs-2xl); }
.hq-kiosk-quest.done { opacity: .6; }
.hq-kiosk-quest.done .hq-kiosk-quest-title { text-decoration: line-through; }
.hq-kiosk-quest.waiting { background: var(--hq-warning-softer); border-color: var(--hq-warning-line); }
.hq-kiosk-empty { color: var(--hq-earth); font-style: italic; margin: 0; }
.hq-kiosk-side { display: flex; flex-direction: column; gap: 12px; }
.hq-kiosk-card { padding: 12px; border-radius: var(--hq-radius-lg); background: var(--hq-parchment-soft); border: 3px solid var(--hq-line); color: var(--hq-text); }
.hq-kiosk-card h2 { margin: 0 0 8px; font-family: var(--hq-title); font-size: var(--hq-fs-xl); }
.hq-kiosk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hq-kiosk-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 800; }
.hq-kiosk-list li.no-driver { color: var(--hq-amber); }
.hq-kiosk-list li.running .hq-kiosk-timer { color: var(--hq-pink-ink); }
.hq-kiosk-time { min-width: 3.2rem; font-weight: 900; color: var(--hq-magic-ink); }
.hq-kiosk-timer { margin-left: auto; font-weight: 900; font-variant-numeric: tabular-nums; }
.hq-kiosk-coins { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; }
.hq-kiosk-people { display: inline-flex; gap: 2px; }
.hq-kiosk-note { display: flex; align-items: flex-start; gap: 8px; padding: 8px; border-radius: var(--hq-radius-sm); background: var(--hq-note); border: 2px solid var(--hq-note-line); margin-bottom: 6px; font-weight: 700; white-space: pre-line; }

/* ----- Sprint 10: parent statistics ----- */
.hq-stats-child {
  display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: var(--hq-radius-lg);
  background: var(--hq-parchment-soft); border: 3px solid var(--hq-gold); box-shadow: var(--hq-toy-shadow); color: var(--hq-text);
}
.hq-stats-head { display: flex; align-items: center; gap: 10px; }
.hq-stats-head h2 { font-family: var(--hq-title) !important; }
.hq-stats-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.25rem), 1fr)); gap: 8px; }
.hq-stat-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--hq-radius-md); background: var(--hq-paper); border: 2px solid var(--hq-line-soft); }
.hq-stat-label { font-size: var(--hq-fs-xs); font-weight: 800; color: var(--hq-ink-soft); }
.hq-stat-value { display: inline-flex; align-items: center; gap: 4px; font-size: var(--hq-fs-3xl); font-weight: 900; color: var(--hq-ink); font-variant-numeric: tabular-nums; }
.hq-stat-sub { font-size: var(--hq-fs-xs); font-weight: 700; color: var(--hq-ink-soft); }
.hq-stat-delta { display: inline-flex; align-items: center; gap: 2px; font-size: var(--hq-fs-xs); font-weight: 800; }
.hq-stat-delta.up { color: var(--hq-success-deep); }
.hq-stat-delta.down { color: var(--hq-danger); }
.hq-trend { margin: 0; }
.hq-trend-title { font-size: var(--hq-fs-sm); font-weight: 800; color: var(--hq-ink); margin-bottom: 4px; }
.hq-trend-svg { display: block; width: 100%; max-width: 40rem; height: auto; overflow: visible; }
.hq-trend-grid { stroke: var(--hq-line-soft); stroke-width: 1; }
.hq-trend-base { stroke: var(--hq-line); stroke-width: 1; }
.hq-trend-axis { font-size: 11px; fill: var(--hq-ink-soft); font-weight: 700; }
.hq-trend-value { font-size: var(--hq-fs-2xs); fill: var(--hq-ink); font-weight: 900; }
.hq-trend-bar { fill: var(--hq-magic); }
.hq-trend-none { stroke: var(--hq-line); stroke-width: 2; stroke-linecap: round; }
.hq-trend-hit { fill: transparent; }
.hq-trend-col:hover .hq-trend-hit { fill: rgba(106, 82, 199, .08); }
.hq-trend-table summary { cursor: pointer; font-size: var(--hq-fs-sm); font-weight: 800; color: var(--hq-ink-soft); margin-top: 4px; }
.hq-trend-table table { border-collapse: collapse; margin-top: 6px; font-size: var(--hq-fs-sm); font-variant-numeric: tabular-nums; }
.hq-trend-table th, .hq-trend-table td { padding: 3px 10px; text-align: right; border-bottom: 1px solid var(--hq-line-soft); }
.hq-trend-table th:first-child, .hq-trend-table td:first-child { text-align: left; }
.hq-stats-missed ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hq-stats-missed li { display: flex; align-items: center; gap: 8px; font-weight: 800; }

/* =====================================================================================================
   Design-system harmonisation (UI/UX audit, 2026-11): shared rules that apply across every page.
   Kept last so they win over the per-sprint rules above at equal specificity.
   ===================================================================================================== */

/* ---------- Type: one body voice, readable on parchment ---------- */
body { font-family: var(--hq-body); font-weight: var(--hq-fw-body); line-height: var(--hq-lh-body); }
/* Ribbons: bold Fredoka at 20px is "large text", so the ribbon colours keep a 3:1+ contrast with parchment. */
.hq-ribbon-text { font-weight: var(--hq-fw-bold); font-size: var(--hq-fs-xl); line-height: var(--hq-lh-snug); }
/* Names people scan in lists: one size everywhere. */
.hq-item-name, .hq-note-text, .hq-kiosk-quest-title { font-size: var(--hq-fs-lg); }
.hq-cal-event-title, .hq-cal-day-name, .hq-podium-name { font-size: var(--hq-fs-md); }
/* Card titles drawn by hand used Nunito Black; same Fredoka voice as the MudBlazor h6 card titles. */
.hq-piggy-name, .hq-boss-mini-title { font-family: var(--hq-title); font-weight: var(--hq-fw-bold); }
.hq-piggy-name { font-size: var(--hq-fs-xl); }

/* ---------- Focus: one visible ring everywhere (WCAG 2.4.7 / 2.4.11) ---------- */
/* Gold on the night sky, magic purple on parchment (gold on parchment is only 1.4:1). */
.mud-paper, .mud-dialog, .mud-popover, .mud-drawer, .hq-bottom-nav, .hq-book-page, .hq-quest, .hq-profile,
.hq-day-card, .hq-coins-card, .hq-child-card, .hq-hero-card, .hq-wardrobe, .hq-streak-card, .hq-badge, .hq-rank-row,
.hq-podium-step, .hq-boss-card, .hq-boss-mini, .hq-piggy, .hq-goal-form, .hq-shopping, .hq-cal-day, .hq-board-form,
.hq-note, .hq-kiosk-child, .hq-kiosk-card, .hq-stats-child, .hq-celebration-card, .hq-day-progress {
  --hq-focus: var(--hq-magic);
}
:where(button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"]), .mud-button-root, .mud-nav-link,
       .mud-icon-button, .mud-toggle-item):focus-visible {
  outline: 3px solid var(--hq-focus) !important;
  outline-offset: 2px;
}
/* MudBlazor text fields draw their own focused outline. */
.mud-input-slot:focus-visible, .mud-input input:focus-visible, .mud-input textarea:focus-visible { outline: none !important; }
.hq-pinpad:focus-visible { outline: 3px dashed var(--hq-focus) !important; outline-offset: 6px; border-radius: var(--hq-radius-lg); }

/* ---------- Buttons ---------- */
/* Same family and weight for every MudBlazor button; text buttons get a comfortable target too. */
.mud-button-root { font-family: var(--hq-title); font-weight: 600; letter-spacing: 0; }
.mud-button-text:not(.mud-button-text-size-small), .mud-button-outlined { min-height: 40px; }
.mud-button-filled.mud-button-filled-size-small { min-height: 36px; }
.mud-button-filled, .mud-button-outlined { transition: transform 80ms, box-shadow 80ms, filter 120ms; }
@media (hover: hover) {
  .mud-button-filled:hover:not(:disabled), .mud-button-outlined:hover:not(:disabled) { filter: brightness(1.06); }
}
.mud-button-outlined:active:not(:disabled) { transform: translateY(3px); box-shadow: var(--hq-press-shadow); }
/* Disabled: flat, no toy shadow, so it never looks pressable. */
.mud-button-root:disabled, .mud-button-root.mud-button-disabled {
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
  cursor: not-allowed;
}
.mud-button-filled:disabled { background: var(--hq-line-soft) !important; color: var(--hq-earth) !important; }
.mud-button-outlined:disabled { border-color: var(--hq-line) !important; color: var(--hq-earth) !important; }
/* Busy state: MudBlazor's progress circle inside a button follows the text colour. */
.mud-button-root .mud-progress-circular { color: currentColor; }

/* ---------- Dimmed states: lighter pictures, readable text (opacity made text fail 4.5:1) ---------- */
.hq-member-row.inactive, .hq-template-row.inactive, .hq-quest.expired, .hq-voucher.cancelled, .hq-timer.finished,
.hq-piggy.withdrawn, .hq-piggy.cancelled, .hq-item.checked, .hq-cal-day.past, .hq-kiosk-quest.done, .hq-note-date.past {
  opacity: 1;
}
.hq-member-row.inactive :is(.hq-avatar, .hq-quest-icon), .hq-template-row.inactive :is(.hq-avatar, .hq-quest-icon),
.hq-quest.expired .hq-quest-icon, .hq-voucher.cancelled .hq-quest-icon, .hq-timer.finished .hq-quest-icon,
.hq-piggy.withdrawn .hq-piggy-icon, .hq-piggy.cancelled .hq-piggy-icon, .hq-kiosk-quest.done .hq-emoji-svg {
  opacity: .55;
  filter: grayscale(.6);
}
.hq-member-row.inactive, .hq-template-row.inactive { color: var(--hq-text-muted); }
.hq-quest.expired, .hq-voucher.cancelled, .hq-timer.finished, .hq-piggy.withdrawn, .hq-piggy.cancelled {
  filter: none;
  background: var(--hq-parchment-dim) !important;
  border-color: var(--hq-line) !important;
}
.hq-item.checked .hq-item-name, .hq-kiosk-quest.done .hq-kiosk-quest-title { color: var(--hq-text-muted); }
.hq-item.checked .hq-item-qty { background: var(--hq-line-soft); color: var(--hq-text-muted); }
.hq-cal-day.past { background: var(--hq-parchment-dim); border-color: var(--hq-line-soft); }
.hq-cal-day.past .hq-cal-day-name { color: var(--hq-text-muted); }
.hq-note-date.past { background: var(--hq-parchment-dim); color: var(--hq-text-muted); }

/* ---------- Muted text on parchment: one token ---------- */
.hq-cal-free, .hq-kiosk-empty, .hq-goal-hint, .hq-item-note, .hq-note-time, .hq-piggy-owner { color: var(--hq-text-subtle); }
/* Small text on parchment: never below 13px. */
.hq-cal-today-chip, .hq-cal-event-allday, .hq-hero-hint { font-size: var(--hq-fs-xs); }

/* ---------- Cards: one padding, one radius ---------- */
.hq-child-card, .hq-kiosk-child, .hq-kiosk-card, .hq-piggy, .hq-streak-card, .hq-shopping, .hq-board-form,
.hq-stats-child, .hq-day-card, .hq-coins-card, .hq-wardrobe { padding: var(--hq-card-pad); }

/* ---------- Lists toolbar: tabs (role=tablist) + the "new list" button beside them ---------- */
.hq-list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hq-space-2); }

/* ---------- Counters: white on danger red (5.4:1) ---------- */
.hq-nav-count { background: var(--hq-danger); color: var(--hq-paper); }

@media (prefers-reduced-motion: reduce) {
  .mud-button-filled, .mud-button-outlined { transition: none; }
}

/* Light candy fills keep their colour on hover/tap: MudBlazor darkens them, which drops ink text under 4.5:1
   (and the hover state sticks after a tap on phones). The brightness filter above is the hover cue. */
.mud-button-filled.mud-button-filled-success:hover, .mud-button-filled.mud-button-filled-success:focus-visible {
  background-color: var(--mud-palette-success);
}
.mud-button-filled.mud-button-filled-secondary:hover, .mud-button-filled.mud-button-filled-secondary:focus-visible {
  background-color: var(--mud-palette-secondary);
}

/* ---------- Dialog actions: never overlap (phones, large system font) ---------- */
/* Buttons keep their label width and wrap to a new row instead of squeezing into each other. */
.mud-dialog .mud-dialog-actions { flex-wrap: wrap; gap: var(--hq-space-2); row-gap: var(--hq-space-2); }
.mud-dialog .mud-dialog-actions > .mud-button-root { margin: 0 !important; flex-shrink: 0; max-width: 100%; }
@media (max-width: 599.98px) {
  /* Cancel | Save share the first row; Delete gets its own row below, away from the main action. */
  .mud-dialog .mud-dialog-actions > .mud-button-root { flex: 1 1 auto; }
  .mud-dialog .mud-dialog-actions:has(> .flex-grow-1) > .flex-grow-1 { display: none; }
  .mud-dialog .mud-dialog-actions:has(> .flex-grow-1) > .mud-button-root:first-child { order: 2; flex-basis: 100%; }
}

/* ---------- Toggle groups: stack the choices when they don't fit (phones, large system font) ---------- */
/* The parent is the size container; em-based thresholds follow the user's font size. */
:has(> .mud-toggle-group) { container-type: inline-size; }
@container (max-width: 26em) {
  .mud-toggle-group-horizontal:has(> .mud-toggle-item:nth-child(3)) { grid-template-columns: minmax(0, 1fr) !important; grid-auto-flow: row !important; }
  .mud-toggle-group-horizontal:has(> .mud-toggle-item:nth-child(3)) > .mud-toggle-item + .mud-toggle-item {
    border-left: 0 !important;
    border-top: 2px solid var(--hq-gold) !important;
    margin-left: 0 !important;
  }
}
@container (max-width: 15em) {
  .mud-toggle-group-horizontal { grid-template-columns: minmax(0, 1fr) !important; grid-auto-flow: row !important; }
  .mud-toggle-group-horizontal > .mud-toggle-item + .mud-toggle-item { border-left: 0 !important; border-top: 2px solid var(--hq-gold) !important; margin-left: 0 !important; }
}
.mud-toggle-group .mud-toggle-item { min-width: 0; white-space: normal; overflow-wrap: anywhere; hyphens: auto; }

/* ---------- PIN screen: the whole pad fits the phone, nothing to scroll ---------- */
/* Key size comes from the screen height (what is left after the name, avatar and dots) and its width. */
.hq-pinpad {
  --hq-key: clamp(44px, min(21vw, calc((100dvh - 480px) / 4.5)), 84px);
  gap: 8px;
}
.hq-pin-keys { grid-template-columns: repeat(3, var(--hq-key)); gap: calc(var(--hq-key) * 0.18); }
.hq-key { width: var(--hq-key); height: var(--hq-key); font-size: calc(var(--hq-key) * 0.4); touch-action: manipulation; }
.hq-key-muted .mud-icon-root { font-size: calc(var(--hq-key) * 0.45); }
.hq-pin-message { min-height: 1.3em; }
.hq-book-page:has(.hq-pinpad) { margin-top: 0; padding-block: 10px; }
.hq-book-page:has(.hq-pinpad) > .mud-stack { gap: 6px !important; margin-top: 0 !important; }
.hq-bare:has(.hq-pinpad) .hq-bare-top { padding: 4px 8px; }
@media (orientation: portrait) {
  html:has(.hq-pinpad), body:has(.hq-pinpad) { overflow: hidden; height: 100%; overscroll-behavior: none; }
}
@media (max-height: 700px) {
  /* Short phones: the household name gives its line to the keys. */
  .hq-book-page:has(.hq-pinpad) > .mud-stack > .mud-typography-subtitle1 { display: none; }
  .hq-pinpad { --hq-key: clamp(44px, min(21vw, calc((100dvh - 440px) / 4.5)), 84px); }
}

/* ----- Sprint 11: allowance ----- */
.hq-allowance-rate { margin: 0; font-weight: var(--hq-fw-heavy); display: flex; flex-wrap: wrap; align-items: center; gap: var(--hq-space-1); }
.hq-allowance-ask {
  display: flex; flex-direction: column; gap: var(--hq-space-3); padding: var(--hq-card-pad); border-radius: var(--hq-radius-lg);
  background: var(--hq-surface); border: 3px solid var(--hq-border); box-shadow: var(--hq-toy-shadow); color: var(--hq-text);
  --hq-focus: var(--hq-magic);
}
.hq-allowance-ask h2 { margin: 0; }
.hq-allowance-wallet { display: flex; flex-direction: column; gap: 2px; }
.hq-allowance-big { font-family: var(--hq-title); font-weight: var(--hq-fw-bold); font-size: var(--hq-fs-4xl); line-height: var(--hq-lh-tight); color: var(--hq-success-deep); font-variant-numeric: tabular-nums; }
.hq-allowance-sub { font-weight: var(--hq-fw-bold); color: var(--hq-text-muted); }
.hq-allowance-why { margin: 0; font-weight: var(--hq-fw-heavy); color: var(--hq-text-subtle); }
.hq-allowance-note { margin: 0; text-align: center; }
.hq-allowance-ask .hq-day-chip { min-width: 64px; height: var(--hq-target-min); font-size: var(--hq-fs-lg); font-family: var(--hq-title); }

/* ----- Sprint 11: admin console ----- */
.hq-admin-row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: var(--hq-space-3); }
.hq-admin-fresh {
  display: flex; flex-direction: column; gap: var(--hq-space-2); padding: var(--hq-space-3); border-radius: var(--hq-radius-md);
  background: var(--hq-success-soft); border: 2px dashed var(--hq-success-line);
}
.hq-admin-code { font-family: ui-monospace, Consolas, monospace; font-weight: var(--hq-fw-heavy); font-size: var(--hq-fs-3xl); letter-spacing: .08em; color: var(--hq-text); }
.hq-admin-code.small { font-size: var(--hq-fs-md); }
.hq-admin-link { font-size: var(--hq-fs-sm); color: var(--hq-text-muted); overflow-wrap: anywhere; user-select: all; }
.hq-admin-actions { display: flex; flex-wrap: wrap; gap: var(--hq-space-2); align-items: center; }
.hq-admin-list { list-style: none; margin: 0; padding: 0; }
.hq-admin-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--hq-space-2) var(--hq-space-3); padding: var(--hq-space-3) 0;
  border-bottom: 2px dashed var(--hq-line);
}
.hq-admin-item:last-child { border-bottom: 0; }
.hq-admin-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 14rem; min-width: 0; }
.hq-admin-title { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--hq-space-2); font-weight: var(--hq-fw-heavy); overflow-wrap: anywhere; }
.hq-admin-meta { font-size: var(--hq-fs-sm); color: var(--hq-text-muted); overflow-wrap: anywhere; }
.hq-admin-state { display: inline-block; padding: 1px 9px; border-radius: var(--hq-radius-pill); font-size: var(--hq-fs-xs); font-weight: var(--hq-fw-heavy); white-space: nowrap; }
.hq-admin-state.open { background: var(--hq-success-soft); color: var(--hq-success-deep); }
.hq-admin-state.usedup { background: var(--hq-magic-soft); color: var(--hq-magic-ink); }
.hq-admin-state.expired, .hq-admin-state.revoked { background: var(--hq-warning-soft); color: var(--hq-amber); }
.hq-admin-item.disabled .hq-admin-title { color: var(--hq-text-muted); }
