/* ==========================================================================
   components.css — shared UI components (used by landing AND app pages)
   Load order: tokens.css → base.css → components.css → landing.css | app.css

   Static-review hooks: every interactive component also answers to
   .is-hover / .is-active / .is-focus so styleguide.html can show those
   states without a pointer.
   ========================================================================== */

/* ==========================================================================
   Icons & brand
   ========================================================================== */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  font: 500 1.375rem/1 var(--font-serif);
  letter-spacing: var(--ls-heading);
  color: var(--ink);
  text-decoration: none;
}
.brand__mark { width: 28px; height: 28px; flex: none; }
.brand__mark circle { fill: none; stroke: currentColor; stroke-width: 2; }
.brand__mark .arc { fill: none; stroke: var(--accent); stroke-width: 2.75; stroke-linecap: round; }
.brand__ai {
  padding: 3px 6px 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font: 600 .625rem/1 var(--font-sans);
  letter-spacing: .14em;
  color: var(--ink-soft);
}

/* ==========================================================================
   Buttons
   Variants: --primary (gold) | --secondary (outline) | --ghost | --danger
   Sizes:    --sm | (md default) | --lg        Icon-only: --icon
   ========================================================================== */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-border: transparent;
  --btn-bg-hover: var(--btn-bg);
  --btn-fg-hover: var(--btn-fg);
  --btn-border-hover: var(--btn-border);
  --btn-bg-active: var(--btn-bg-hover);

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-5);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 600 .9375rem/1 var(--font-sans);
  letter-spacing: .01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}

.btn:hover:not(:disabled):not([aria-disabled="true"]),
.btn.is-hover {
  background: var(--btn-bg-hover);
  color: var(--btn-fg-hover);
  border-color: var(--btn-border-hover);
}

.btn:active:not(:disabled):not([aria-disabled="true"]),
.btn.is-active {
  background: var(--btn-bg-active);
  color: var(--btn-fg-hover);
  border-color: var(--btn-border-hover);
  transform: translateY(1px);
}

.btn.is-focus { outline: 2px solid var(--focus-ring); outline-offset: 3px; }

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--tint);
  color: color-mix(in srgb, var(--ink) 45%, transparent);
  border-color: var(--line);
  cursor: not-allowed;
}

/* Sizes — .btn--sm is visually 36px but keeps a 44px hit area (::after). */
.btn--sm { min-height: 36px; padding: 0 var(--sp-4); font-size: .8125rem; }
.btn--sm::after { content: ""; position: absolute; inset: -4px 0; }
.btn--lg { min-height: 56px; padding: 0 var(--sp-6); font-size: 1rem; }
.btn--block { width: 100%; }

.btn--icon { width: 44px; padding: 0; }
.btn--icon.btn--lg { width: 56px; }

/* Variants */
.btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--on-accent);
  --btn-bg-hover: var(--accent-hot);
  --btn-bg-active: var(--accent-press);
}

.btn--secondary {
  --btn-border: var(--ink);
  --btn-bg-hover: var(--ink);
  --btn-fg-hover: var(--bg);
  --btn-border-hover: var(--ink);
  --btn-bg-active: color-mix(in srgb, var(--ink) 88%, var(--bg));
}

.btn--ghost {
  --btn-bg-hover: color-mix(in srgb, var(--ink) 8%, transparent);
  --btn-bg-active: color-mix(in srgb, var(--ink) 14%, transparent);
}

.btn--danger {
  --btn-bg: var(--danger);
  --btn-fg: var(--on-danger);
  --btn-bg-hover: color-mix(in srgb, var(--danger) 88%, #000);
  --btn-bg-active: color-mix(in srgb, var(--danger) 76%, #000);
}

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

/* Text link with an arrow that nudges on hover. */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  align-self: flex-start;
}
.link-arrow .icon { transition: transform var(--dur-1) var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--tint);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font: 600 var(--fs-xs)/1.2 var(--font-sans);
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge--accent { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.badge--success { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--line)); background: color-mix(in srgb, var(--success) 10%, var(--bg-raised)); }
.badge--danger  { color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));  background: color-mix(in srgb, var(--danger) 10%, var(--bg-raised)); }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: grid; gap: var(--sp-2); align-content: start; }

.fieldset { display: grid; gap: var(--sp-2); align-content: start; min-width: 0; margin: 0; padding: 0; border: 0; }

.label,
.legend {
  padding: 0;
  font: 600 var(--fs-sm)/1.3 var(--font-sans);
  color: var(--ink);
}
.label__opt { font-weight: 400; color: var(--ink-soft); }

.help,
.error-msg {
  max-width: none;
  font-size: .8125rem;
  line-height: 1.5;
}
.help { color: var(--ink-soft); }
.error-msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger);
  font-weight: 500;
}
.error-msg .icon { margin-top: 2px; width: 1em; height: 1em; }

/* Text / number / select share one control skin. */
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  color: var(--ink);
  line-height: 1.4;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.input::placeholder { color: color-mix(in srgb, var(--ink-soft) 80%, var(--bg-raised)); opacity: 1; }
.input:hover:not(:disabled) { border-color: var(--ink-soft); }
.input:focus-visible { border-color: var(--ink); outline-offset: 2px; }
.input:disabled { background: var(--tint); color: var(--ink-soft); border-color: var(--line); cursor: not-allowed; }
.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);   /* 2px edge without shifting layout */
}

/* Number input with a unit suffix (kg, cm, kcal…). Spinners removed: they are
   tiny touch targets; steppers are built where needed. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.input-group { position: relative; }
.input-group .input { padding-right: 3.5rem; }
.input-group__suffix {
  position: absolute;
  top: 50%;
  right: var(--sp-4);
  transform: translateY(-50%);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  pointer-events: none;
}

/* Select: native control (best mobile UX), custom chevron drawn with borders
   so it inherits currentColor in both themes. */
.select { position: relative; }
.select select.input { appearance: none; -webkit-appearance: none; padding-right: 2.75rem; cursor: pointer; }
.select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--sp-4);
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Checkbox + radio: native inputs (keyboard, form semantics, screen readers
   for free), restyled. The whole row is the label, so the target is ≥44px. */
.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 44px;
  padding: 10px 0;
  line-height: 1.4;
  cursor: pointer;
}
.choice__input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-raised);
  transition: border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.choice__input[type="checkbox"] { border-radius: 6px; }
.choice__input[type="radio"] { border-radius: 50%; }
.choice__input:hover:not(:disabled) { border-color: var(--ink); }
.choice__input:checked { border-color: var(--ink); }
.choice__input[type="checkbox"]:checked {
  /* Check mark is a fixed forest-ink stroke: it always sits on gold. */
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2310231C' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.choice__input[type="radio"]:checked {
  background: radial-gradient(circle, var(--accent) 0 38%, var(--bg-raised) 42%);
}
.choice__input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.choice__input:disabled { background: var(--tint); border-color: var(--line); cursor: not-allowed; }
.choice__input:disabled + .choice__text { color: var(--ink-soft); }
.choice:has(.choice__input:disabled) { cursor: not-allowed; }

/* Range slider — fill is driven by --fill (set from JS on input). */
.range {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--accent) 0 var(--fill), var(--track) var(--fill) 100%);
}
.range::-moz-range-track { height: 6px; border-radius: var(--r-pill); background: var(--track); }
.range::-moz-range-progress { height: 6px; border-radius: var(--r-pill); background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -9px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-1) var(--ease);
}
.range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
}
.range:hover::-webkit-slider-thumb { transform: scale(1.08); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.range:focus-visible::-moz-range-thumb { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.range[aria-invalid="true"]::-webkit-slider-thumb { border-color: var(--danger); }
.range[aria-invalid="true"]::-moz-range-thumb { border-color: var(--danger); }

.range-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); }
.range-head output { font-weight: 600; color: var(--ink); }

/* Segmented control — radios underneath, so arrow keys + form value just work. */
.segmented {
  display: inline-flex;
  align-self: start;
  justify-self: start;   /* don't stretch to the grid column */
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--tint);
}
.segmented--error { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.segmented__item { position: relative; display: block; }
.segmented__item input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.segmented__item span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 44px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-pill);
  font: 600 var(--fs-sm)/1 var(--font-sans);
  color: var(--ink-soft);
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.segmented__item:hover input:not(:checked) + span { color: var(--ink); }
.segmented__item input:checked + span { background: var(--accent); color: var(--on-accent); }
.segmented__item input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-raised);
}
.card__title { font-size: var(--fs-h3); }

/* Stat card — one big tabular number. Gold-toned text only for the key figure. */
.stat { gap: var(--sp-2); }
.stat__label { font: 600 var(--fs-xs)/1.2 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.stat__value {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  font: 600 clamp(2.125rem, 4vw, 2.75rem)/1 var(--font-sans);
  letter-spacing: var(--ls-heading);
  font-variant-numeric: tabular-nums;
}
.stat__value--accent { color: var(--accent-text); }
.stat__unit { font-size: 1rem; font-weight: 500; letter-spacing: 0; color: var(--ink-soft); }
.stat__meta { display: flex; align-items: center; gap: 6px; font-size: .8125rem; color: var(--ink-soft); }
.stat__delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.stat__delta .icon { width: 1em; height: 1em; }
.is-good { color: var(--success); }
.is-warn { color: var(--ink); }
.is-bad  { color: var(--danger); }

/* Photo slot — real photography is dropped in later; until then a calm tinted
   frame with a caption keeps the layout finished. Width/height live on the <img>. */
.photo {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--ink) 4%, transparent) 14px 15px),
    var(--tint);
}
.photo--wide { aspect-ratio: 16 / 9; }
.photo::before {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  text-align: center;
  font: 600 var(--fs-xs)/1.4 var(--font-sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.photo picture, .photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* If a file is missing, never show the alt text over the placeholder (ui.js also hides the <img>). */
.photo img { color: transparent; }

/* Meal card */
.meal {
  position: relative;
  padding: 0;
  gap: 0;
  overflow: hidden;
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.meal:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.meal__body { display: grid; gap: var(--sp-3); padding: var(--sp-5); }
.meal__meta { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); }
.meal__slot { font: 600 var(--fs-xs)/1.2 var(--font-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.meal__name { font-size: 1.5rem; }
.meal__kcal { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.meal__kcal strong { font-size: 1.75rem; line-height: 1; letter-spacing: var(--ls-heading); }
.meal__kcal span { font-size: var(--fs-sm); color: var(--ink-soft); }
.macro-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: var(--sp-2) 0 0;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.macro-row div + div { padding-left: var(--sp-3); border-left: 1px solid var(--line); }
.macro-row dt { font: 600 .6875rem/1.2 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.macro-row dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Pricing card */
.price { position: relative; gap: var(--sp-5); padding: var(--sp-6) var(--sp-5); }
.price__name { font: 600 var(--fs-xs)/1.2 var(--font-sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); }
.price__amount { display: flex; align-items: baseline; gap: var(--sp-2); font-variant-numeric: tabular-nums; }
.price__amount strong { font: 400 clamp(2.5rem, 5vw, 3.25rem)/1 var(--font-serif); letter-spacing: var(--ls-heading); }
.price__amount span { color: var(--ink-soft); font-size: var(--fs-sm); }
.price__features { display: grid; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.price__features li { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: .9375rem; line-height: 1.45; }
.price__features .icon { margin-top: 1px; color: var(--success); }
.price__cta { margin-top: auto; }
.price--popular {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);   /* gold border, no heavy fill */
}
.price__flag {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
}

/* ==========================================================================
   Progress
   ========================================================================== */
/* Ring: both circles use pathLength="100", so a value of 0–100 maps straight
   onto stroke-dashoffset (100 → empty, 0 → full). Animate by changing --value. */
.ring {
  --value: 0;
  --ring-size: 160px;
  position: relative;
  width: var(--ring-size);
  aspect-ratio: 1;
}
.ring--lg { --ring-size: 200px; }
.ring--md { --ring-size: 140px; }
.ring--sm { --ring-size: 84px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring__track { stroke: var(--track); }
.ring__fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--value));
  transition: stroke-dashoffset 1.1s var(--ease);
}
.ring.is-resetting .ring__fill { transition: none; }
.ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 2px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ring__value { font: 600 calc(var(--ring-size) * .19)/1 var(--font-sans); letter-spacing: var(--ls-heading); }
.ring__unit { font-size: max(.6875rem, calc(var(--ring-size) * .075)); color: var(--ink-soft); line-height: 1.2; }
.ring--sm .ring__unit { display: none; }

/* Linear macro bar — fill animates with transform: scaleX (GPU-only). */
.macro { --p: 0; display: grid; gap: var(--sp-2); }
.macro__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); font-size: var(--fs-sm); }
.macro__name { font-weight: 600; }
.macro__val { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.macro__val strong { color: var(--ink); }
.macro__track { height: 8px; overflow: hidden; border-radius: var(--r-pill); background: var(--track); }
.macro__fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(var(--p));
  transform-origin: left center;
  transition: transform .9s var(--ease);
}
.macro.is-resetting .macro__fill { transition: none; }
.macro--warn .macro__fill { background: var(--warn); }
.macro--danger .macro__fill { background: var(--danger); }

/* Streak badge */
.streak {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--bg-raised);
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.streak__icon { color: var(--accent); fill: color-mix(in srgb, var(--accent) 28%, transparent); }
.streak__best { font-weight: 400; font-size: .8125rem; color: var(--ink-soft); padding-left: var(--sp-2); border-left: 1px solid var(--line); }
.streak--idle .streak__icon { color: var(--ink-soft); fill: none; }

/* ==========================================================================
   Navigation
   ========================================================================== */
/* The bar's background lives on ::before so it can "shrink" with transform: scaleY
   (compositor-only). The header's real height never changes → zero layout shift. */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  transform-origin: top center;
  transition: transform var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.site-header__inner { transition: transform var(--dur-2) var(--ease); }
/* nav.js toggles .is-scrolled past 40px: blur + a slimmer bar (72px → ~62px). */
.site-header.is-scrolled::before {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transform: scaleY(.86);
}
.site-header.is-scrolled .site-header__inner { transform: translateY(-5px); }

.site-header--static { position: relative; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg); }
.site-header--static::before { display: none; }
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: var(--header-h);
  width: var(--container);
  margin-inline: auto;
}
.site-header--static .site-header__inner { width: auto; padding-inline: var(--sp-5); }
.site-header__actions { display: flex; align-items: center; gap: var(--sp-2); }
.site-header__cta { display: none; }
.site-header__menu { display: inline-flex; }

.nav { display: none; align-items: center; gap: var(--sp-5); margin: 0; padding: 0; list-style: none; }
.nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  font: 500 .9375rem/1 var(--font-sans);
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}
.nav__link::after {                      /* active indicator: the one gold accent in the header */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--dur-2) var(--ease);
}
.nav__link:hover { color: var(--ink); }
.nav__link:hover::after { transform: scaleX(.35); }
.nav__link[aria-current]:not([aria-current="false"]) { color: var(--ink); }
.nav__link[aria-current]:not([aria-current="false"])::after { transform: scaleX(1); }

@media (min-width: 768px) {
  .nav { display: flex; }
  .site-header__cta { display: inline-flex; }
  .site-header__menu { display: none; }
}

/* Theme toggle — shows the icon of the theme you will switch TO. */
.theme-toggle .theme-toggle__sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-toggle__sun { display: inline-block; }
html[data-theme="dark"] .theme-toggle .theme-toggle__moon { display: none; }

/* Mobile bottom tab bar (≤1023px). ≥1024px the app uses a sidebar instead. */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-tabbar);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-raised);
  border-top: 1px solid var(--line);
}
.tabbar ul { display: grid; grid-template-columns: repeat(5, 1fr); margin: 0; padding: 0; list-style: none; }
.tabbar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 44px;
  min-height: 60px;
  padding: 8px 4px;
  font: 500 var(--fs-xs)/1.1 var(--font-sans);
  color: var(--ink-soft);
  text-decoration: none;
  transition: color var(--dur-1) var(--ease);
}
.tabbar__item .icon { width: 24px; height: 24px; }
.tabbar__item::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 28%;
  right: 28%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform var(--dur-2) var(--ease);
}
.tabbar__item:hover { color: var(--ink); }
.tabbar__item[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabbar__item[aria-current="page"]::before { transform: scaleX(1); }
.tabbar--static { position: relative; }
@media (min-width: 1024px) {
  .tabbar:not(.tabbar--static) { display: none; }
}

.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-2); margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--ink-soft); }
.breadcrumb li { display: inline-flex; align-items: center; gap: var(--sp-2); }
.breadcrumb li + li::before { content: "/"; opacity: .55; }
.breadcrumb a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: .25em; }
.breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ==========================================================================
   Feedback: toast · modal · empty state · skeleton · alert
   ========================================================================== */
.toast-region {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  left: var(--sp-4);
  z-index: var(--z-toast);
  display: grid;
  justify-items: end;
  gap: var(--sp-3);
  pointer-events: none;
}
@media (max-width: 1023.98px) {
  .toast-region { bottom: calc(76px + env(safe-area-inset-bottom)); } /* clear the tab bar */
}

.toast {
  --toast-c: var(--ink-soft);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  width: min(100%, 400px);
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-left: 4px solid var(--toast-c);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-2) var(--ease) both;
}
.toast--success { --toast-c: var(--success); }
.toast--warn    { --toast-c: var(--warn); }
.toast--danger  { --toast-c: var(--danger); }
.toast.is-leaving { animation: toast-out 200ms var(--ease) both; }
.toast__icon { margin-top: 1px; color: var(--toast-c); width: 1.375em; height: 1.375em; }
.toast__text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: .9375rem; line-height: 1.45; }
.toast__title { font-weight: 600; }
.toast__msg { color: var(--ink-soft); max-width: none; }
.toast__close { margin: -10px -10px -10px 0; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(14px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px); } }

/* Modal — native <dialog>: focus trap, Esc, inert background, focus return. */
.modal {
  width: min(520px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.modal[open] { animation: modal-in var(--dur-2) var(--ease) both; }
.modal::backdrop { background: rgba(6, 16, 12, .6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal[open]::backdrop { animation: fade-in var(--dur-2) var(--ease) both; }
.modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5) var(--sp-5) 0; }
.modal__title { font-size: 1.75rem; }
.modal__body { padding: var(--sp-3) var(--sp-5) var(--sp-5); color: var(--ink-soft); }
.modal__footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); }

@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes fade-in  { from { opacity: 0; } }

/* Empty state */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--ink-soft);
}
.empty__icon .icon { width: 28px; height: 28px; }
.empty__title { font-size: 1.5rem; line-height: 1.15; }
.empty p { color: var(--ink-soft); max-width: 40ch; margin-inline: auto; }
.empty .btn { margin-top: var(--sp-2); }

/* Skeleton — shimmer is a translated gradient: transform only. */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--track);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg-raised) 75%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s var(--ease) infinite;
}
.skeleton--text  { height: 1em; }
.skeleton--title { height: 1.75rem; width: 60%; }
.skeleton--short { width: 40%; }
.skeleton--img   { aspect-ratio: 4 / 3; border-radius: 0; }
.skeleton--circle { width: 56px; height: 56px; border-radius: 50%; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Inline alert */
.alert {
  --alert-c: var(--ink-soft);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid color-mix(in srgb, var(--alert-c) 45%, var(--line));
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--alert-c) 8%, var(--bg-raised));
  font-size: .9375rem;
  line-height: 1.5;
}
.alert--success { --alert-c: var(--success); }
.alert--warn    { --alert-c: var(--warn); }
.alert--danger  { --alert-c: var(--danger); }
.alert .icon { margin-top: 2px; color: var(--alert-c); width: 1.25em; height: 1.25em; }
.alert__title { display: block; font-weight: 600; }
.alert p { color: var(--ink-soft); max-width: none; }
