/* Hreyfing — base styles (L0): tokens, reset, layout and every shared component.
 * Leaf stylesheets build on these tokens; please do not hard-code colours elsewhere.
 * Contrast of every text/background pair defined here was computed (WCAG 2.2 AA): see the
 * comment block after the dark tokens.
 */

/* ------------------------------------------------------------------------------------------ */
/* Font                                                                                        */
/* ------------------------------------------------------------------------------------------ */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-var.woff2') format('woff2');
}

/* ------------------------------------------------------------------------------------------ */
/* Tokens — light (default)                                                                    */
/* ------------------------------------------------------------------------------------------ */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d2321;
  --muted: #55605b;
  --primary: #1f6f5c;
  --primary-hover: #185a4b;
  --primary-ink: #ffffff;
  --primary-soft: #e3f0eb;
  --primary-soft-ink: #17594a;
  --accent: #d9653b;
  --accent-soft: #fbe9e1;
  --accent-ink: #94401f;
  --success: #2e7d4f;
  --success-soft: #e4f2e9;
  --success-ink: #22603c;
  --warning: #a35b00;
  --warning-soft: #fbf0dc;
  --warning-ink: #7a4400;
  --danger: #b3261e;
  --danger-hover: #951f19;
  --danger-soft: #fbe7e5;
  --danger-ink: #8c1d17;
  --on-danger: #ffffff;
  --info: #2f5f8a;
  --info-soft: #e5eef6;
  --info-ink: #264d71;
  --on-info: #ffffff;
  --border: #dcd6ca;
  --control-border: #7c8580;
  --focus: #1f6f5c;
  --overlay: rgba(18, 22, 20, 0.5);
  --shadow: 0 1px 2px rgba(29, 35, 33, 0.06), 0 4px 14px rgba(29, 35, 33, 0.06);
  --shadow-lg: 0 8px 28px rgba(29, 35, 33, 0.16), 0 2px 6px rgba(29, 35, 33, 0.08);

  /* Chart palette (HF.charts uses these) */
  --chart-1: #1f6f5c;
  --chart-2: #d9653b;
  --chart-3: #2f5f8a;
  --chart-4: #7a4400;
  --chart-grid: #dcd6ca;
  --chart-axis: #55605b;

  /* Shape, spacing, type, motion */
  --radius-card: 14px;
  --radius-ctl: 10px;
  --radius-pill: 999px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --gutter: 16px;
  --maxw: 1120px;
  --readw: 68ch;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 200ms;
  --header-h: 64px;
  --tabbar-h: 62px;

  color-scheme: light;
}

/* Dark tokens: explicit choice, or "system" when the device prefers dark. */
:root[data-theme="dark"] {
  --bg: #121614;
  --surface: #1a201d;
  --surface-2: #232a26;
  --text: #e9ede9;
  --muted: #a9b3ad;
  --primary: #5cc4a6;
  --primary-hover: #7dd3ba;
  --primary-ink: #0d1512;
  --primary-soft: #193229;
  --primary-soft-ink: #8fdcc4;
  --accent: #f08a5d;
  --accent-soft: #3a2419;
  --accent-ink: #f6b190;
  --success: #6fcf97;
  --success-soft: #16301f;
  --success-ink: #8edcae;
  --warning: #f0b45e;
  --warning-soft: #36270f;
  --warning-ink: #f5c886;
  --danger: #ff8a80;
  --danger-hover: #ffaba3;
  --danger-soft: #3b1b19;
  --danger-ink: #ffaba3;
  --on-danger: #1a0f0e;
  --info: #8ab8e6;
  --info-soft: #182839;
  --info-ink: #a9cbee;
  --on-info: #0d1512;
  --border: #2f3833;
  --control-border: #737e78;
  --focus: #5cc4a6;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  --chart-1: #5cc4a6;
  --chart-2: #f08a5d;
  --chart-3: #8ab8e6;
  --chart-4: #f5c886;
  --chart-grid: #2f3833;
  --chart-axis: #a9b3ad;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"],
  :root:not([data-theme]) {
    --bg: #121614;
    --surface: #1a201d;
    --surface-2: #232a26;
    --text: #e9ede9;
    --muted: #a9b3ad;
    --primary: #5cc4a6;
    --primary-hover: #7dd3ba;
    --primary-ink: #0d1512;
    --primary-soft: #193229;
    --primary-soft-ink: #8fdcc4;
    --accent: #f08a5d;
    --accent-soft: #3a2419;
    --accent-ink: #f6b190;
    --success: #6fcf97;
    --success-soft: #16301f;
    --success-ink: #8edcae;
    --warning: #f0b45e;
    --warning-soft: #36270f;
    --warning-ink: #f5c886;
    --danger: #ff8a80;
    --danger-hover: #ffaba3;
    --danger-soft: #3b1b19;
    --danger-ink: #ffaba3;
    --on-danger: #1a0f0e;
    --info: #8ab8e6;
    --info-soft: #182839;
    --info-ink: #a9cbee;
    --on-info: #0d1512;
    --border: #2f3833;
    --control-border: #737e78;
    --focus: #5cc4a6;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    --chart-1: #5cc4a6;
    --chart-2: #f08a5d;
    --chart-3: #8ab8e6;
    --chart-4: #f5c886;
    --chart-grid: #2f3833;
    --chart-axis: #a9b3ad;
    color-scheme: dark;
  }
}

/* Contrast (computed with the WCAG relative-luminance formula; text pairs need 4.5:1, UI boundaries 3:1).
 * Light: text/bg 14.66, text/surface 15.97, text/surface-2 13.53, muted/bg 6.00, muted/surface 6.54,
 *   muted/surface-2 5.54, primary/bg 5.53, primary/surface 6.02, primary/surface-2 5.10,
 *   primary-ink/primary 6.02, primary-ink/primary-hover 8.07, primary-soft-ink/primary-soft 6.99,
 *   muted/primary-soft 5.58, accent-ink/accent-soft 5.92, success-ink/success-soft 6.48,
 *   warning-ink/warning-soft 7.01, danger-ink/danger-soft 7.67, info-ink/info-soft 7.51,
 *   danger/surface 6.54, danger/bg 6.00, on-danger/danger 6.54, on-info/info 6.72, warning/surface 5.18,
 *   success/surface 5.05, info/surface 6.72; UI: control-border/surface 3.80, control-border/bg 3.49,
 *   control-border/surface-2 3.22, focus/bg 5.53, accent/surface 3.57 (accent is never body text).
 * Dark: text/bg 15.43, text/surface 14.00, text/surface-2 12.41, muted/bg 8.46, muted/surface 7.68,
 *   muted/surface-2 6.81, primary/bg 8.61, primary/surface 7.81, primary/surface-2 6.92,
 *   primary-ink/primary 8.74, primary-soft-ink/primary-soft 8.63, muted/primary-soft 6.37,
 *   accent-ink/accent-soft 8.03, success-ink/success-soft 8.80, warning-ink/warning-soft 9.28,
 *   danger-ink/danger-soft 8.55, info-ink/info-soft 8.89, danger/surface 7.25, on-danger/danger 8.22,
 *   on-info/info 8.90; UI: control-border/surface 3.93, control-border/surface-2 3.48, focus/bg 8.61.
 */

/* ------------------------------------------------------------------------------------------ */
/* Reset and base                                                                              */
/* ------------------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 8px);
}

html.has-dialog { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

@media (min-width: 768px) {
  body { font-size: 1.0625rem; }
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: 1.2;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.005em;
}
h1 {
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p, ul, ol, dl, figure, blockquote { margin: 0; }
ul, ol { padding-left: 1.25em; }
li + li { margin-top: 0.25em; }
img, svg, video { max-width: 100%; }
img { height: auto; display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s4) 0; }
strong, b { font-weight: 650; }
small { font-size: 0.875rem; }

a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 650; }

.tabular, time, .stat-value, .num { font-variant-numeric: tabular-nums; }

/* Focus: always visible for keyboard users */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
/* Headings and <main> receive programmatic focus on route change; no ring needed there */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible { outline: none; }

::selection { background: var(--primary-soft); color: var(--text); }

/* ------------------------------------------------------------------------------------------ */
/* Utilities                                                                                   */
/* ------------------------------------------------------------------------------------------ */
.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.text-sm { font-size: 0.9375rem; }
.text-xs { font-size: 0.8125rem; }
.text-lg { font-size: 1.125rem; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.prose { max-width: var(--readw); }
.prose > * + * { margin-top: var(--s3); }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain > li + li { margin-top: var(--s2); }
.divider { border: 0; border-top: 1px solid var(--border); margin: var(--s4) 0; width: 100%; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  display: inline-block;
  vertical-align: -0.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------------------------------ */
/* Layout                                                                                      */
/* ------------------------------------------------------------------------------------------ */
.container {
  width: 100%;
  max-width: calc(var(--maxw) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
@media (min-width: 768px) { :root { --gutter: 24px; } }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--s4)); }
.stack-xs { --stack-gap: var(--s1); }
.stack-sm { --stack-gap: var(--s2); }
.stack-md { --stack-gap: var(--s3); }
.stack-lg { --stack-gap: var(--s5); }
.stack-xl { --stack-gap: var(--s6); }

.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--s2)); }
.cluster-lg { --cluster-gap: var(--s4); }
.cluster-between { justify-content: space-between; }
.cluster-end { justify-content: flex-end; }

.grid {
  display: grid;
  gap: var(--grid-gap, var(--s4));
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min, 280px)), 1fr));
}
.grid > * { min-width: 0; }
.grid-2, .grid-3 { display: grid; gap: var(--grid-gap, var(--s4)); grid-template-columns: minmax(0, 1fr); }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.split { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}
.span-all { grid-column: 1 / -1; }

/* ------------------------------------------------------------------------------------------ */
/* Shell: skip link, header, main, footer                                                      */
/* ------------------------------------------------------------------------------------------ */
.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -200px;
  z-index: 200;
  background: var(--primary);
  color: var(--primary-ink);
  padding: 10px 16px;
  border-radius: var(--radius-ctl);
  font-weight: 650;
  text-decoration: none;
}
.skip-link:focus,
.skip-link:focus-visible { top: 10px; outline: 3px solid var(--focus); outline-offset: 2px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2) var(--s3);
  min-height: var(--header-h);
  padding-block: var(--s2);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-right: auto;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  font-size: 1.25rem;
  letter-spacing: -0.015em;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-mark-bg { fill: var(--primary); }
.brand-mark-fg { fill: none; stroke: var(--primary-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.header-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--s2);
  min-width: 0;
}

.site-main {
  flex: 1 0 auto;
  padding-top: var(--s5);
  padding-bottom: var(--s7);
}
@media (min-width: 768px) { .site-main { padding-top: var(--s6); } }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9375rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3) var(--s5);
  padding-block: var(--s5);
}
.footer-line { color: var(--text); }
.footer-sub { margin-top: 2px; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 var(--s4); }
.footer-links li + li { margin-top: 0; }
.footer-links a,
.footer-links .link-btn { display: inline-flex; align-items: center; min-height: 44px; }

body.has-tabbar .site-footer { padding-bottom: 0; }
@media (max-width: 767.98px) {
  body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  /* Keep keyboard focus from hiding behind the fixed tab bar (WCAG 2.4.11). */
  html.has-tabbar { scroll-padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); }
}

/* Button that looks like a link (footer "Reset demo", inline actions) */
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  font: inherit;
  cursor: pointer;
  min-height: 44px;
}
.link-btn:hover { text-decoration-thickness: 2px; }

/* ------------------------------------------------------------------------------------------ */
/* Navigation: desktop top nav, mobile bottom tab bar (approved users), account menu           */
/* ------------------------------------------------------------------------------------------ */
.nav-main { min-width: 0; }
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}
.nav-list > li { margin: 0; }
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-ctl);
  border: 0;
  background: none;
  color: var(--text);
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link .icon { color: var(--muted); }
.nav-link[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
  font-weight: 700;
}
.nav-link[aria-current="page"] .icon { color: var(--primary-soft-ink); }
/* Non-colour signal for the current page: an underline bar */
.nav-link[aria-current="page"]::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.nav-link--cta {
  background: var(--primary);
  color: var(--primary-ink);
}
.nav-link--cta .icon { color: var(--primary-ink); }
.nav-link--cta:hover { background: var(--primary-hover); }
.nav-link--cta[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.nav-link--cta[aria-current="page"] .icon { color: var(--primary-ink); }
.nav-link--button { font: inherit; font-weight: 550; cursor: pointer; }

.nav-label-short { display: none; }

/* Small screens, roles without the tab bar (signed out, admin): logo row, then one nav row that
 * never wraps into a tall stack. The header scrolls away instead of staying pinned. */
@media (max-width: 767.98px) {
  body:not(.has-tabbar) .site-header { position: static; }
  body[data-role="guest"] .header-nav,
  body[data-role="admin"] .header-nav {
    order: 3;
    flex: 1 0 100%;
    justify-content: flex-start;
    margin-inline: -6px;
  }
  body[data-role="guest"] .nav-list,
  body[data-role="admin"] .nav-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 4px;
    padding: 2px;
  }
  .nav-label-full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .nav-label-short { display: inline; }
}
@media (max-width: 480px) {
  .nav-link { padding: 0 10px; gap: 6px; }
}
/* Tablet: keep the signed-in header on one row by dropping the nav icons */
@media (min-width: 768px) and (max-width: 1023.98px) {
  body[data-role="user"] .nav-main .nav-link { padding: 0 10px; }
  body[data-role="user"] .nav-main .nav-link > .icon { display: none; }
}
@media (max-width: 419.98px) {
  body[data-role="guest"] .nav-main .nav-link > .icon,
  body[data-role="admin"] .nav-main .nav-link > .icon { display: none; }
}

/* Mobile: fixed bottom tab bar with the five primary items */
@media (max-width: 767.98px) {
  .nav-main--tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .nav-main--tabs .nav-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
  }
  .nav-main--tabs .nav-link {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    width: 100%;
    min-height: var(--tabbar-h);
    padding: 6px 2px;
    border-radius: 0;
    font-size: 0.75rem;
    font-weight: 600;
    background: none;
  }
  .nav-main--tabs .nav-link .icon { width: 24px; height: 24px; }
  .nav-main--tabs .nav-link[aria-current="page"] { background: var(--primary-soft); }
  .nav-main--tabs .nav-link[aria-current="page"]::after {
    top: 0;
    bottom: auto;
    left: 20%;
    right: 20%;
    height: 3px;
    border-radius: 0 0 3px 3px;
  }
}

.account-menu { position: relative; }
.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--control-border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.account-btn:hover { background: var(--surface-2); }
.account-btn[aria-expanded="true"] { border-color: var(--primary); }
.account-btn[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }
.account-chevron { transition: transform var(--dur) var(--ease); }
.account-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  width: min(300px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  padding: var(--s2);
  animation: hf-fade-in var(--dur) var(--ease);
}
.account-who {
  display: flex;
  flex-direction: column;
  padding: var(--s2) var(--s3) var(--s3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s1);
}
.account-name { font-weight: 650; }
.account-email { color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list li + li { margin-top: 0; }
.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s3);
  border-radius: var(--radius-ctl);
  border: 0;
  background: none;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  text-align: left;
}
.menu-link:hover { background: var(--surface-2); text-decoration: none; }
.menu-link .icon { color: var(--muted); }
.menu-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary-soft-ink); font-weight: 650; }
.menu-sep { height: 1px; background: var(--border); margin: var(--s1) 0; }

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--info);
  color: var(--on-info);
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
}

/* ------------------------------------------------------------------------------------------ */
/* Buttons                                                                                     */
/* ------------------------------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 9px 18px;
  border-radius: var(--radius-ctl);
  border: 2px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 1.15em; height: 1.15em; }

.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover { background: var(--primary-soft); color: var(--primary-soft-ink); }

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

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

.btn-danger-outline { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); color: var(--danger-ink); }

.btn-icon { padding: 0; width: 44px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: 1.0625rem; }
.btn-sm { padding: 6px 12px; font-size: 0.9375rem; } /* still 44px tall: touch target */

.btn[disabled],
.btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

/* ------------------------------------------------------------------------------------------ */
/* Forms                                                                                       */
/* ------------------------------------------------------------------------------------------ */
.form { display: flex; flex-direction: column; gap: var(--s4); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; padding-top: var(--s2); }
.form-row { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; }
.field-req, .field-opt { font-weight: 400; color: var(--muted); font-size: 0.875rem; }
.field-hint { color: var(--muted); font-size: 0.9375rem; line-height: 1.45; }

.input,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
select.input,
textarea.input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-ctl);
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea.input, .field textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: 1; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--text); }
.input:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  border-color: var(--primary);
}
.field select,
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355605b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9b3ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .field select,
  :root[data-theme="system"] select.input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9b3ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* Error state */
[aria-invalid="true"].input,
.field [aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}
.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.4;
}
.field-error .icon { margin-top: 1px; width: 1.1em; height: 1.1em; }
fieldset.has-error > legend { color: var(--danger); }

/* Checkbox / radio standalone */
.field--checkbox {
  flex-direction: row;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0 12px;
  min-height: 44px;
  padding-block: 4px;
}
.field--checkbox .field-check-text { flex: 1 1 0; min-width: 0; }
.field--checkbox .field-label { font-weight: 500; cursor: pointer; display: inline-block; padding-top: 1px; }
.field--checkbox .field-error { flex-basis: 100%; padding-left: 36px; }
input[type="checkbox"].checkbox,
.field--checkbox input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}
input[type="radio"], input[type="checkbox"] { accent-color: var(--primary); }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; }

/* ------------------------------------------------------------------------------------------ */
/* Chips (checkbox / radio pills)                                                              */
/* ------------------------------------------------------------------------------------------ */
.chips-legend, .scale-legend { margin-bottom: var(--s2); }
.chips > .field-hint, .scale > .field-hint { margin: calc(-1 * var(--s1)) 0 var(--s2); }
.chips > .field-error, .scale > .field-error { margin-top: var(--s2); }
.chip-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { position: relative; display: inline-flex; margin: 0; }
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.chip-face {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--control-border);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  line-height: 1.25;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  user-select: none;
}
.chip-check { display: none; }
.chip-check .icon { width: 1.05em; height: 1.05em; stroke-width: 2.5; }
.chip-text { display: flex; flex-direction: column; }
.chip-hint { font-weight: 400; font-size: 0.875rem; color: var(--muted); }
.chip input:hover + .chip-face { border-color: var(--text); }
.chip input:checked + .chip-face {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-soft-ink);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.chip input:checked + .chip-face .chip-check { display: inline-flex; }
.chip input:checked + .chip-face .chip-hint { color: var(--text); }
.chip input:focus-visible + .chip-face { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip input:disabled + .chip-face { opacity: 0.55; }
.chip--rich { flex: 1 1 220px; }
.chip--rich .chip-face { border-radius: var(--radius-card); align-items: flex-start; padding: 12px 16px; width: 100%; }
.chip--rich .chip-check { margin-top: 2px; }

/* ------------------------------------------------------------------------------------------ */
/* 1–5 scale                                                                                   */
/* ------------------------------------------------------------------------------------------ */
.scale { container-type: inline-size; }
.scale-options {
  display: grid;
  grid-template-columns: repeat(var(--scale-n, 5), minmax(0, 1fr));
  gap: 6px;
}
.scale-option { position: relative; display: block; margin: 0; }
.scale-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.scale-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  height: 100%;
  min-height: 64px;
  padding: 8px 4px;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  text-align: center;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.scale-num { font-weight: 700; font-size: 1.125rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.scale-text { font-size: 0.8125rem; line-height: 1.25; color: var(--muted); }
.scale-option input:hover + .scale-face { border-color: var(--text); }
.scale-option input:checked + .scale-face {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
  color: var(--primary-soft-ink);
}
.scale-option input:checked + .scale-face .scale-text { color: var(--primary-soft-ink); font-weight: 600; }
.scale-option input:focus-visible + .scale-face { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Narrow containers: one option per row so the labels never get squeezed */
@container (max-width: 459px) {
  .scale-options { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .scale-face { flex-direction: row; align-items: center; gap: 12px; min-height: 44px; padding: 8px 14px; text-align: left; }
  .scale-num { min-width: 1.2em; }
  .scale-text { font-size: 0.9375rem; }
}

/* ------------------------------------------------------------------------------------------ */
/* Page header                                                                                 */
/* ------------------------------------------------------------------------------------------ */
.page { display: flex; flex-direction: column; gap: var(--s5); }
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3) var(--s5);
}
.page-heading { flex: 1 1 28ch; min-width: 0; }
.page-eyebrow {
  color: var(--primary);
  font-weight: 650;
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: var(--s1);
}
.page-lead { color: var(--muted); max-width: var(--readw); margin-top: var(--s2); font-size: 1.0625rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.page-body { display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }

/* ------------------------------------------------------------------------------------------ */
/* Cards                                                                                       */
/* ------------------------------------------------------------------------------------------ */
.card {
  --tone: var(--primary);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-width: 0;
  padding: var(--s4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}
@media (min-width: 768px) { .card { padding: var(--s5); } }
.card-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s2) var(--s3); }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 1.125rem; min-width: 0; }
.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
}
.card-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.card-body { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.card-footer { border-top: 1px solid var(--border); padding-top: var(--s3); display: flex; flex-wrap: wrap; gap: var(--s2); }

.card--primary { background: var(--primary-soft); border-color: transparent; }
.card--primary .card-icon { background: var(--primary); color: var(--primary-ink); }
.card--accent { border-color: var(--accent); border-left-width: 4px; }
.card--accent .card-icon { background: var(--accent-soft); color: var(--accent-ink); }
.card--success { border-left: 4px solid var(--success); }
.card--success .card-icon { background: var(--success-soft); color: var(--success-ink); }
.card--warning { border-left: 4px solid var(--warning); }
.card--warning .card-icon { background: var(--warning-soft); color: var(--warning-ink); }
.card--danger { border-left: 4px solid var(--danger); }
.card--danger .card-icon { background: var(--danger-soft); color: var(--danger-ink); }
.card--info { border-left: 4px solid var(--info); }
.card--info .card-icon { background: var(--info-soft); color: var(--info-ink); }
.card--muted { background: var(--surface-2); box-shadow: none; }
.card--muted .card-icon { background: var(--surface); color: var(--muted); }
.card--sample { border: 1.5px dashed var(--accent); box-shadow: none; }
.card--sample .card-icon { background: var(--accent-soft); color: var(--accent-ink); }

/* Stats */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
.stat-label { color: var(--muted); font-size: 0.9375rem; }

/* Meter (habit / goal progress bars); always pair with a text value */
.meter { height: 10px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter-fill { height: 100%; background: var(--primary); border-radius: inherit; transition: width var(--dur) var(--ease); }

/* ------------------------------------------------------------------------------------------ */
/* Notices, badges, status chips                                                               */
/* ------------------------------------------------------------------------------------------ */
.notice {
  --n-bg: var(--info-soft);
  --n-ink: var(--info-ink);
  --n-line: var(--info);
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-ctl);
  background: var(--n-bg);
  color: var(--text);
  border: 1px solid var(--n-line);
}
.notice-icon { color: var(--n-ink); flex: none; padding-top: 1px; }
.notice-content { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.notice-title { font-weight: 650; color: var(--n-ink); }
.notice--warning { --n-bg: var(--warning-soft); --n-ink: var(--warning-ink); --n-line: var(--warning); }
.notice--success { --n-bg: var(--success-soft); --n-ink: var(--success-ink); --n-line: var(--success); }
.notice--danger { --n-bg: var(--danger-soft); --n-ink: var(--danger-ink); --n-line: var(--danger); }
.notice--primary { --n-bg: var(--primary-soft); --n-ink: var(--primary-soft-ink); --n-line: var(--primary); }
.notice--neutral { --n-bg: var(--surface-2); --n-ink: var(--text); --n-line: var(--border); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.badge--primary { background: var(--primary-soft); color: var(--primary-soft-ink); }
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge--info { background: var(--info-soft); color: var(--info-ink); }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid;
  font-weight: 650;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: nowrap;
}
.status-chip .icon { width: 1.05em; height: 1.05em; stroke-width: 2.4; }
.status-pending { background: var(--warning-soft); color: var(--warning-ink); border-color: var(--warning); }
.status-approved { background: var(--success-soft); color: var(--success-ink); border-color: var(--success); }
.status-rejected { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); }

.sample-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 10px;
  border-radius: var(--radius-pill);
  border: 1.5px dashed var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 650;
  font-size: 0.875rem;
  line-height: 1.5;
}
.sample-badge .icon { width: 1.05em; height: 1.05em; }

/* ------------------------------------------------------------------------------------------ */
/* Empty state                                                                                 */
/* ------------------------------------------------------------------------------------------ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s2);
  padding: var(--s6) var(--s4);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
  margin-bottom: var(--s1);
}
.empty-icon .icon { width: 28px; height: 28px; }
.empty-title { font-weight: 650; font-size: 1.125rem; color: var(--text); }
.empty-body { color: var(--muted); max-width: 52ch; }
.empty-action { margin-top: var(--s2); }

/* ------------------------------------------------------------------------------------------ */
/* Disclosure                                                                                  */
/* ------------------------------------------------------------------------------------------ */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  background: var(--surface);
}
.disclosure > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 44px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-ctl);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { background: var(--surface-2); }
.disclosure-summary { display: inline-flex; align-items: center; gap: 8px; }
.disclosure-chevron { transition: transform var(--dur) var(--ease); color: var(--muted); }
.disclosure[open] > summary .disclosure-chevron { transform: rotate(180deg); }
.disclosure-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: var(--s2); }

/* ------------------------------------------------------------------------------------------ */
/* Progress steps                                                                              */
/* ------------------------------------------------------------------------------------------ */
.steps { display: flex; flex-direction: column; gap: var(--s2); }
.steps-label { font-weight: 650; color: var(--muted); font-size: 0.9375rem; }
.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
}
.step { margin: 0 !important; height: 6px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border); }
.step.is-done { background: var(--primary); border-color: var(--primary); }
.step.is-current { background: var(--primary); border-color: var(--primary); height: 6px; box-shadow: 0 0 0 2px var(--primary-soft); }

/* ------------------------------------------------------------------------------------------ */
/* Tabs                                                                                        */
/* ------------------------------------------------------------------------------------------ */
.tabs-list {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: var(--radius-ctl) var(--radius-ctl) 0 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75em;
  height: 1.6em;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .tab-count { background: var(--primary); color: var(--primary-ink); }
.tab-panel { padding-top: var(--s5); }
.tab-panel:focus-visible { outline-offset: 4px; }

/* ------------------------------------------------------------------------------------------ */
/* Dialog                                                                                      */
/* ------------------------------------------------------------------------------------------ */
.dialog {
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: auto;
  overscroll-behavior: contain;
}
.dialog--wide { width: min(760px, calc(100vw - 2 * var(--gutter))); }
.dialog[open] { animation: hf-pop var(--dur) var(--ease); }
.dialog::backdrop { background: var(--overlay); }
.dialog-overlay { position: fixed; inset: 0; z-index: 99; background: var(--overlay); }
.dialog--fallback { position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 100; }
.dialog-inner { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.dialog-title { font-size: 1.25rem; padding-top: 6px; }
.dialog-close { margin: -4px -8px 0 0; }
.dialog-body { display: flex; flex-direction: column; gap: var(--s3); }
.dialog-actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: var(--s2); }
@media (max-width: 480px) {
  .dialog-inner { padding: var(--s4); }
  .dialog-actions .btn { flex: 1 1 auto; }
}

/* ------------------------------------------------------------------------------------------ */
/* Toasts                                                                                      */
/* ------------------------------------------------------------------------------------------ */
.toast-region {
  position: fixed;
  z-index: 150;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  pointer-events: none;
}
@media (max-width: 767.98px) {
  body.has-tabbar .toast-region { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 768px) {
  .toast-region { left: auto; right: 24px; bottom: 24px; align-items: flex-end; }
}
/* Inside an open modal dialog (the page behind it is inert). */
.toast-region.toast-region--dialog {
  position: sticky;
  left: auto; right: auto; bottom: 0;
  align-items: stretch;
  padding: var(--s2) 0 0;
  pointer-events: auto;
}
.toast-region--dialog:empty { display: none; }
.toast {
  --t-line: var(--success);
  --t-ink: var(--success-ink);
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(440px, 100%);
  padding: 12px 8px 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--t-line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: hf-rise var(--dur) var(--ease);
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 180ms ease-out, transform 180ms ease-out; }
.toast--info { --t-line: var(--info); --t-ink: var(--info-ink); }
.toast--warning { --t-line: var(--warning); --t-ink: var(--warning-ink); }
.toast--error { --t-line: var(--danger); --t-ink: var(--danger-ink); }
.toast-icon { color: var(--t-ink); padding-top: 1px; flex: none; }
.toast-msg { flex: 1 1 auto; font-weight: 550; padding-top: 1px; min-width: 0; }
.toast-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -10px -2px -10px 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}
.toast-close:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------------------------------------------------------------------ */
/* Motion                                                                                      */
/* ------------------------------------------------------------------------------------------ */
@keyframes hf-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes hf-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes hf-pop { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    /* "none", not a tiny duration: transition-property defaults to "all", so a 0.01ms duration would
       start a colour transition on every element whenever the theme changes. */
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------------------------------ */
/* Forced colours (Windows high contrast): keep boundaries and selection visible               */
/* ------------------------------------------------------------------------------------------ */
@media (forced-colors: active) {
  .chip input:checked + .chip-face,
  .scale-option input:checked + .scale-face { outline: 3px solid Highlight; }
  .nav-link[aria-current="page"] { outline: 2px solid Highlight; }
  .btn { border-color: ButtonText; }
}

/* ------------------------------------------------------------------------------------------ */
/* Print                                                                                       */
/* ------------------------------------------------------------------------------------------ */
@media print {
  .site-header, .site-footer, .nav-main, .toast-region, .skip-link, .page-actions { display: none !important; }
  body { background: #fff; color: #000; padding: 0 !important; }
  .card { box-shadow: none; break-inside: avoid; }
}
