/* =========================================================================
   style.css — design foundation: variables, themes, layout, base components.
   Feel: calm, modern, high-quality (towards Apple Fitness / Premium Health).
   ========================================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
/* Two-tone focus ring: text colour inside (≥ 3:1 on any background), an outer
   accent glow – the accent colour alone reached only ≈ 2.3:1 on a light background (UI-20). */
:focus-visible {
  outline: 2px solid var(--text); outline-offset: 2px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 45%, transparent);
}
/* The hidden attribute must beat display rules with class specificity. */
[hidden] { display: none !important; }

/* Skip link: first tab stop, visible only on keyboard focus. */
.skip-link {
  position: fixed; left: var(--sp-3); top: calc(env(safe-area-inset-top) + var(--sp-2));
  z-index: 100; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill); background: var(--text); color: var(--bg);
  font-weight: 700; font-size: 0.9rem;
  transform: translateY(-200%);
}
.skip-link:focus, .skip-link:focus-visible { transform: none; }

/* ---------- Theme variables ---------- */
:root {
  --accent: #18b48a;
  --accent-contrast: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 8%, transparent);
  --accent-strong: color-mix(in srgb, var(--accent) 78%, #000 22%);
  /* Accent as TEXT on a light background (≥ 4.5:1); surfaces keep using --accent (UI-12). */
  --accent-text: color-mix(in srgb, var(--accent) 55%, #000);

  --good: #2bb673;
  --warn: #f5a623;
  --bad:  #ef5d6c;
  --info: #3d8bff;
  /* Strong surfaces for WHITE text (toasts) – ≥ 4.5:1 in both themes (UI-12). */
  --good-strong: #1b7a4b;
  --bad-strong: #b3263a;
  --info-strong: #1f5fcc;
  /* Second colour of the hero gradients – away from the text colour; app.js computes it per accent. */
  --accent-hero-end: color-mix(in srgb, var(--accent) 78%, #fff);

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-num: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --header-h: 56px;
  --nav-h: 64px;
  --maxw: 720px;
}

/* Light (default) */
:root, [data-theme="light"] {
  --bg: #eef1f5;
  --bg-elev: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f7;
  --surface-3: #e7ecf1;
  --text: #161b21;
  --text-2: #58646f;
  --text-3: #626c78;   /* previously #8893a0: 2.75:1 – now ≥ 4.5:1 (UI-12) */
  /* Status colours as TEXT (≥ 4.5:1 on page and cards); the surfaces stay --good etc. */
  --good-text: #1b7a4b;
  --warn-text: #9a5b00;
  --bad-text: #b3263a;
  --info-text: #1f5fcc;
  --border: rgba(20, 27, 33, 0.08);
  --border-2: rgba(20, 27, 33, 0.14);
  --nav-bg: rgba(246, 248, 251, 0.82);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-3: 0 16px 40px rgba(16, 24, 40, 0.16);
  --scrim: rgba(20, 27, 33, 0.42);
  color-scheme: light;
}

/* Dark */
[data-theme="dark"] {
  --bg: #0c0f13;
  --bg-elev: #11151b;
  --surface: #161b22;
  --surface-2: #1d242c;
  --surface-3: #262f39;
  --text: #eef2f6;
  --text-2: #9aa7b4;
  --text-3: #8a96a1;   /* previously #69757f: 3.6:1 on cards */
  --good-text: #2bb673;
  --warn-text: #f5a623;
  --bad-text: #ff7a87;
  --info-text: #6aa6ff;
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.15);
  --nav-bg: rgba(18, 22, 28, 0.72);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 6px 20px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 18px 44px rgba(0, 0, 0, 0.55);
  --scrim: rgba(0, 0, 0, 0.6);
  /* Dark: LIGHTEN accent text and soft buttons instead of darkening them (UI-12, UI-32). */
  --accent-text: color-mix(in srgb, var(--accent) 70%, #fff);
  --accent-strong: color-mix(in srgb, var(--accent) 70%, #fff 30%);
  color-scheme: dark;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
h1, h2, h3 { line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
small { font-size: 0.82em; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ---------- App shell ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.view {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-6));
  outline: none;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.app-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--header-h);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}
.app-header__titles { flex: 1 1 auto; min-width: 0; }
.app-header__title {
  width: fit-content; max-width: 100%;   /* focus ring (after a page change) sits tight against the text */
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__title:focus-visible { outline-offset: 3px; border-radius: 6px; box-shadow: none; }
.app-header__title:focus:not(:focus-visible) { outline: none; }
.app-header__subtitle {
  font-size: 0.78rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__actions { display: flex; align-items: center; gap: var(--sp-2); }
/* Public demo only (demo-mode.js): what the demo is, its PIN, the language, the project link. */
.demo-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap; row-gap: 4px;
  padding: 6px var(--sp-4);
  background: var(--accent-soft); color: var(--accent-strong);
  font-size: 0.8rem; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.demo-bar__pin { font-weight: 550; }
.demo-bar__lang { font: inherit; padding: 2px 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.demo-bar a { margin-left: auto; color: inherit; font-weight: 700; display: inline-flex; align-items: center; min-height: 32px; }
.header-back { margin-left: -6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  font-weight: 650;
  font-size: 0.96rem;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 1.25em; height: 1.25em; flex: 0 0 auto; }
.btn--primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-2); }
.btn--ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--border-2); }
.btn--soft { background: var(--accent-soft); color: var(--accent-strong); }
.btn--danger { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad-text); }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 56px; font-size: 1.05rem; border-radius: var(--r-lg); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  color: var(--text);
  transition: background 0.2s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  color: var(--text-3);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.2s ease;
}
.bottom-nav__item svg { width: 24px; height: 24px; }
.bottom-nav__item.is-active { color: var(--accent-text); }
.bottom-nav__item:active { opacity: 0.6; }
/* ＋ Log: round accent button in the middle of the tab bar. */
.bottom-nav__plus {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-contrast);
  box-shadow: var(--shadow-2);
}
.bottom-nav__plus svg { width: 22px; height: 22px; }
.bottom-nav__item--capture { color: var(--text-2); gap: 2px; }

/* ---------- Sidebar (iPad / desktop, activated via media query) ---------- */
.sidebar { display: none; }

/* ---------- Signed out: no menus (only the login dashboard visible) ---------- */
body.is-anon .bottom-nav { display: none; }
body.is-anon #manage-banner { display: none; }
/* Without a bottom nav, no placeholder for its height is needed at the bottom. */
body.is-anon .view { padding-bottom: calc(env(safe-area-inset-bottom) + var(--sp-6)); }

/* ---------- Account header (More sheet, sidebar footer) ---------- */
.account { display: flex; flex-direction: column; gap: var(--sp-2); }
.account__row { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.account__avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.25rem; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent-text);
}
.account__meta { flex: 1 1 auto; min-width: 0; }
.account__name { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account__role { font-size: 0.78rem; color: var(--text-2); }
.account__logout { flex: 0 0 auto; min-height: 44px; padding: 0 var(--sp-3); }
.account__managing {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  font-size: 0.84rem; font-weight: 650;
}
.account__managing-text { flex: 1 1 auto; min-width: 0; }
.account__back { min-height: 40px; padding: 0 var(--sp-3); font-size: 0.86rem; }

/* ---------- "More": groups and current entry ---------- */
.more-sheet > .account {
  padding: var(--sp-3); margin-bottom: var(--sp-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.more-group__title {
  margin: var(--sp-3) var(--sp-1) 6px;
  font-size: 0.72rem; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-2);
}
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.more-tile {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 52px; padding: 6px var(--sp-3);
  border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 650; font-size: 0.9rem; line-height: 1.2;
}
.more-tile__icon {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: var(--r-xs);
  background: var(--accent-soft); color: var(--accent-text);
}
.more-tile__icon svg { width: 18px; height: 18px; }
.more-tile__label { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.more-tile.is-active {
  background: var(--accent-soft); color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ---------- ＋ Log ---------- */
.capture-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.capture-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 96px; padding: var(--sp-3);
  border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border);
  text-align: left;
}
.capture-tile:active { transform: scale(0.98); }
.capture-tile__icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-text);
}
.capture-tile__icon svg { width: 20px; height: 20px; }
.capture-tile__label { font-weight: 700; }
.capture-tile__hint { font-size: 0.78rem; color: var(--text-2); line-height: 1.3; }

/* ---------- "Progress" tab (Training · Body · Badges · Reports) ---------- */
.progress-tabs {
  display: flex; width: 100%; margin-bottom: var(--sp-4);
  overflow-x: auto; scrollbar-width: none;
}
.progress-tabs::-webkit-scrollbar { display: none; }
.progress-tabs .segmented__opt {
  flex: 1 0 auto; text-align: center; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Form fields ---------- */
.field { display: block; margin-bottom: var(--sp-4); }
.field__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238893a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  padding-right: var(--sp-8);
}
.field__row { display: flex; gap: var(--sp-3); }
.field__row > .field { flex: 1; margin-bottom: 0; }

/* Segmented control */
.segmented {
  display: inline-flex;
  max-width: 100%;   /* longer labels in other languages must not widen the page */
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.segmented__opt {
  padding: var(--sp-2) var(--sp-4);
  border-radius: calc(var(--r-md) - 3px);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-2);
  /* One line where it fits; otherwise wrap (hyphenated in the page language) instead of overflowing. */
  min-width: 0;
  text-align: center;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.segmented__opt.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
/* A bar inside a container that scrolls sideways: every option keeps the width of its word. Without this the
   options shrink to the container, and a long word ("Beweglichkeit") runs out of its box where the browser has no
   hyphenation for the language or the font is wider. */
.segmented--scroll { max-width: none; }
.segmented--scroll .segmented__opt { flex: 0 0 auto; white-space: nowrap; hyphens: manual; -webkit-hyphens: manual; }

/* Stepper (+/- for workout logging) */
.stepper { display: inline-flex; align-items: center; gap: var(--sp-3); }
.stepper__btn {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border);
}
.stepper__btn:active { transform: scale(0.9); }
.stepper__val { min-width: 56px; text-align: center; font-size: 1.3rem; font-weight: 700; }

/* Switch */
/* inline-flex instead of the default `inline` of a <label>: this way width/height
   ALWAYS apply – even outside a flex container. Otherwise the switch collapses
   to 0×0 and the knob covers the label (e.g. in a block `field`). */
.switch { display: inline-flex; position: relative; width: 50px; height: 30px; flex: 0 0 auto; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  transition: background 0.2s ease;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1);
  transition: transform 0.2s ease;
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }

/* ---------- Chips / Badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 0.76rem; font-weight: 650;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
/* A chip that is a button (filters by region, team …): at least 32 px to tap. */
button.chip { min-height: 32px; }
.chip--accent { background: var(--accent-soft); color: var(--accent-strong); }
.chip--good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good-text); }
.chip--warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn-text); }
.chip--bad  { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad-text); }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-contrast);
  font-size: 0.7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Section headings ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: var(--sp-6) 0 var(--sp-3);
}
.section-head:first-child { margin-top: var(--sp-1); }
.section-head__title { font-size: 1.04rem; font-weight: 750; }
/* Small text action next to a heading: a target of at least 32 px without moving the line (WCAG 2.5.8). */
.section-head__action { font-size: 0.84rem; font-weight: 650; color: var(--accent-text); display: inline-flex; align-items: center; min-height: 32px; padding: 0 4px; margin: -6px -4px; }

/* ---------- Modal / bottom sheet ---------- */
.modal-root {
  position: fixed; inset: 0; z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-root.is-open { display: flex; }
.modal-scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  animation: fade-in 0.2s ease;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  max-height: 92dvh;
  background: var(--bg-elev);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet__grip {
  width: 38px; height: 5px; border-radius: var(--r-pill);
  background: var(--border-2);
  margin: var(--sp-2) auto var(--sp-1);
  flex: 0 0 auto;
}
.sheet__head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
}
/* The dialog itself receives focus when opened (announces the title) – without an outline. */
.sheet:focus, .sheet:focus-visible { outline: none; box-shadow: var(--shadow-3); }
.sheet__title { flex: 1; font-size: 1.1rem; font-weight: 750; }
.sheet__body { padding: var(--sp-2) var(--sp-4) var(--sp-5); overflow-y: auto; }
.sheet__foot {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--sp-3);
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-3));
  z-index: 70;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  pointer-events: none;
}
/* A toast lets taps through to what lies below (a dialog's "Save" on a wide screen) – only its own
   button ("Undo") takes them. */
.toast {
  pointer-events: none;
  max-width: calc(var(--maxw) - 32px);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text) 90%, transparent);
  color: var(--bg);
  font-size: 0.88rem; font-weight: 600;
  box-shadow: var(--shadow-3);
  display: flex; align-items: center; gap: var(--sp-2);
  animation: toast-in 0.24s ease;
}
.toast--good { background: var(--good-strong); color: #fff; }
.toast--bad  { background: var(--bad-strong); color: #fff; }
/* Icon in the toast: fixed size – without it, it was sometimes 0 px, sometimes 105 px (UI-27). */
.toast svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- Sync indicator ---------- */
.sync-indicator {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  right: 12px;
  z-index: 40;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: var(--shadow-1);
  font-size: 0.72rem; font-weight: 650; color: var(--text-2);
}
.sync-indicator__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
}
.sync-indicator[data-state="syncing"] .sync-indicator__dot { background: var(--info); animation: pulse 1s infinite; }
.sync-indicator[data-state="offline"] .sync-indicator__dot { background: var(--warn); }
.sync-indicator[data-state="error"] .sync-indicator__dot { background: var(--bad); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-2);
}
.empty__icon {
  width: 64px; height: 64px; margin: 0 auto var(--sp-4);
  color: var(--text-3);
  opacity: 0.7;
}
.empty__icon svg { width: 100%; height: 100%; }
.empty__title { font-weight: 700; color: var(--text); margin-bottom: var(--sp-1); }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.center { text-align: center; }
.hidden { display: none !important; }
/* Complete spacing scale (1–6): missing steps otherwise led to "dead" classes
   (e.g. `mt-3`/`gap-4` without effect) and thus to uneven spacing. */
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); }
.mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.text-good { color: var(--good-text); } .text-bad { color: var(--bad-text); } .text-warn { color: var(--warn-text); }
.text-accent { color: var(--accent-text); }
.fade-in { animation: fade-in 0.3s ease; }

/* ---------- Animations ---------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; }

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

/* ---------- "…" menu (action list with text) ---------- */
.action-list { display: flex; flex-direction: column; gap: 2px; }
.action-item {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 52px; padding: var(--sp-2);
  border-radius: var(--r-md); text-align: left;
}
.action-item:hover { background: var(--surface-2); }
.action-item__icon {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-text);
}
.action-item__icon svg { width: 20px; height: 20px; }
.action-item__text { display: flex; flex-direction: column; min-width: 0; }
.action-item__label { font-weight: 650; }
.action-item__hint { font-size: 0.78rem; color: var(--text-2); }
.action-item--danger .action-item__icon { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad-text); }
.action-item--danger .action-item__label { color: var(--bad-text); }

/* Toast action ("Undo") – large target, clearly recognisable as a button */
.toast__action {
  pointer-events: auto;
  margin-left: var(--sp-2); min-height: 36px; padding: 0 var(--sp-3);
  border-radius: var(--r-pill); font-weight: 750; font-size: 0.86rem;
  background: color-mix(in srgb, currentColor 18%, transparent); color: inherit;
}
/* Chip as a button (quick pick): target ≥ 36 px tall */
.chip--btn { min-height: 36px; padding: 6px 14px; font-size: 0.84rem; cursor: pointer; }

/* Jump bar (settings) and section headers below the sticky header (UI-15) */
.jump-nav { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.section-head { scroll-margin-top: calc(var(--header-h) + env(safe-area-inset-top) + 48px); }

/* Error right at the field (UI-35) */
.field__error {
  display: block;
  margin-top: var(--sp-1);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bad-text);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent);
}

/* ⓘ on metrics (DOC-19/UI-21): muted, full hit area */
.info-btn { color: var(--text-3); flex: 0 0 auto; }
.info-btn svg { width: 18px; height: 18px; }
.info-btn:hover, .info-btn:focus-visible { color: var(--accent-text); }
.section-head .info-btn { width: 36px; height: 36px; margin: -6px 0; }
@media (pointer: coarse) { .section-head .info-btn { width: 44px; height: 44px; margin: -10px 0; } }
