/* ==========================================================================================================
   Robi – base styles: design tokens, reset, typography, layout helpers and the shared components
   (buttons, cards, forms, tables, tabs, chips, progress, spinner, modal, toast, empty states).
   Themes (css/themes.css) only override the tokens below; the layout is identical in every theme.
   ========================================================================================================== */

:root {
  /* ---- colour tokens (neutral theme). Pairs used for text are checked for WCAG AA in test/e2e/core-contrast.mjs */
  --bg: #f3f6fc;
  --bg-2: #e6edf9;
  --surface: #ffffff;
  --surface-2: #eef2fa;
  --surface-3: #e1e8f5;
  --text: #1c2742;
  --text-muted: #4f5d7a;
  --text-inverse: #ffffff;
  --border: #d3dbec;
  --border-strong: #b7c3dc;

  --primary: #2459d6;
  --primary-dark: #17399a;
  --primary-soft: #dbe6ff;
  --on-primary: #ffffff;

  --accent: #ff9a1f;
  --accent-dark: #c26a00;
  --accent-soft: #ffe8c7;
  --on-accent: #2d1700;

  --success: #17803d;
  --success-dark: #0f5c2b;
  --success-soft: #d6f5e0;
  --on-success: #ffffff;

  --warning: #f2a900;
  --warning-soft: #fff0c2;
  --on-warning: #2d2000;

  --danger: #c4263b;
  --danger-dark: #8f1a2a;
  --danger-soft: #fde1e5;
  --on-danger: #ffffff;

  --info-soft: #dff1ff;
  --focus: #c24e00;
  --header-focus: var(--focus);

  /* block categories (editor + palette) */
  --blk-move: #2563eb;      --blk-move-dark: #1a45a8;     --blk-move-soft: #dce9ff;
  --blk-loop: #f59f0b;      --blk-loop-dark: #b36d00;     --blk-loop-soft: #ffeccb;
  --blk-cond: #7c3aed;      --blk-cond-dark: #5521b5;     --blk-cond-soft: #ebe2ff;
  --blk-proc: #0a8660;      --blk-proc-dark: #066245;     --blk-proc-soft: #d3f5e7;
  /* 3.8: the own counter blocks ("Számláló legyen", "Növeld a számlálót") */
  --blk-count: #475569;     --blk-count-dark: #334155;    --blk-count-soft: #e2e8f0;
  --on-blk: #ffffff;
  --on-blk-loop: #2f1b00;
  /* 3.0: the "Távolságmérő" section (map header, certificates) */
  --sec-sensor: #0e7490;
  /* 3.4: the "Színek" section */
  --sec-color: #be185d;
  /* 3.5: the "Ütközés" section */
  --sec-bump: #9a3412;
  /* 3.6: the "Útvesztő" section */
  --sec-maze: #4d7c0f;
  /* 3.7: the "Kincskereső" section */
  --sec-radar: #a16207;
  /* 3.8: the "Számolás" section */
  --sec-count: #475569;

  /* decorations are set by the themes */
  --deco-pattern: none;
  --deco-header: none;
  --deco-opacity: 1;

  /* ---- typography */
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-xxl: 2.25rem;
  --fs-display: 3rem;
  --lh: 1.45;

  /* ---- spacing, radius, elevation */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 56px;
  --r-sm: 8px; --r-md: 14px; --r-lg: 22px; --r-xl: 30px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(28, 39, 66, 0.10), 0 1px 1px rgba(28, 39, 66, 0.06);
  --sh-2: 0 4px 10px rgba(28, 39, 66, 0.12), 0 1px 3px rgba(28, 39, 66, 0.08);
  --sh-3: 0 14px 34px rgba(28, 39, 66, 0.20), 0 3px 8px rgba(28, 39, 66, 0.10);

  --tap: 48px;           /* minimum touch target (spec: >= 44px) */
  --gutter: 16px;
  --page-max: 1180px;
  --header-h: 64px;
  --bottom-nav-h: 0px;

  --ease: cubic-bezier(0.22, 0.8, 0.26, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  overflow-x: hidden;
  overscroll-behavior-y: none; /* no pull-to-refresh / rubber band on tablets: on the root it acts on the page scroller itself */
  scroll-padding-top: calc(var(--header-h, 64px) + 8px); /* focus / scrollIntoView never ends up under the sticky top bar (all pages, staff too) */
  touch-action: manipulation; /* no double-tap zoom delay on tablets (the drag handles set their own touch-action) */
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  /* clip, not hidden: "overflow-x: hidden" made the body a scroll container of its own (overflow-y then computes to auto).
     That body never scrolls, yet together with overscroll-behavior it could swallow the mouse wheel before the page got it
     (2.2.2: the admin pages did not scroll down), and the sticky top bar stuck to it instead of the window. Browsers that
     do not know "clip" simply skip it: html above already hides the sideways overflow. */
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

img, svg, canvas { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
p { margin: 0 0 var(--sp-3); }
h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.2; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 800; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

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

.skip-link {
  position: fixed; left: var(--sp-3); top: -100px; z-index: 1000;
  background: var(--primary); color: var(--on-primary);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-weight: 800;
}
.skip-link:focus { top: var(--sp-3); }

/* ------------------------------------------------------------------------------------------ layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-6); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.row-center { justify-content: center; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.row-nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: var(--sp-4); }
.grid-auto { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.grid-2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.page {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter) var(--sp-10);
}
.page-narrow { max-width: 640px; }
.page-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-5);
}
.page-header h1 { margin: 0; font-size: var(--fs-xl); }
.page-header .subtitle { margin: var(--sp-1) 0 0; color: var(--text-muted); font-size: var(--fs-md); }

/* ------------------------------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-edge: var(--border-strong);
  --btn-border: var(--border-strong);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0.55em 1.15em;
  font-weight: 800; font-size: var(--fs-md); line-height: 1.1;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 0 var(--btn-edge);
  text-decoration: none; text-align: center;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s var(--ease), box-shadow 0.08s var(--ease), filter 0.15s;
  vertical-align: middle;
}
.btn:hover { filter: brightness(1.04); color: var(--btn-fg); }
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; filter: none; }
.btn svg { width: 1.25em; height: 1.25em; flex: none; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-edge: var(--primary-dark); --btn-border: var(--primary-dark); }
.btn-accent { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-edge: var(--accent-dark); --btn-border: var(--accent-dark); }
.btn-success { --btn-bg: var(--success); --btn-fg: var(--on-success); --btn-edge: var(--success-dark); --btn-border: var(--success-dark); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: var(--on-danger); --btn-edge: var(--danger-dark); --btn-border: var(--danger-dark); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--primary); --btn-edge: transparent; --btn-border: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-ghost:active:not(:disabled) { transform: none; background: var(--primary-soft); }
.btn-soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-dark); --btn-edge: var(--border-strong); --btn-border: transparent; }
.btn-lg { min-height: 58px; padding: 0.6em 1.5em; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn-sm { min-height: 44px; padding: 0.4em 0.9em; font-size: var(--fs-sm); }
.btn-icon { padding: 0.4em; width: var(--tap); }
.btn-block { display: flex; width: 100%; }
.btn.is-busy { pointer-events: none; opacity: 0.85; }
.btn.is-busy::after {
  content: ""; width: 1em; height: 1em; margin-left: 0.4em; flex: none;
  border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.link-btn {
  background: none; border: 0; padding: var(--sp-2) var(--sp-1); min-height: 44px;
  color: var(--primary); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ------------------------------------------------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: var(--sp-5);
}
.card-flat { box-shadow: none; }
.card-soft { background: var(--surface-2); border-color: transparent; }
.card-title { margin: 0 0 var(--sp-3); font-size: var(--fs-lg); }
.card-link { display: block; color: inherit; text-decoration: none; transition: transform 0.12s var(--ease), box-shadow 0.12s; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--sh-2); color: inherit; }

/* ------------------------------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.field > .label, label.label { font-weight: 800; font-size: var(--fs-md); }
.field .hint { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
.field .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%;
  min-height: 54px;
  padding: 0.55em 0.9em;
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 120px; resize: vertical; }
.select { appearance: none; -webkit-appearance: none; padding-right: 2.6em;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 15px) 50%;
  background-size: 7px 7px, 7px 7px; background-repeat: no-repeat; }
.input::placeholder { color: var(--text-muted); opacity: 1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input.is-valid { border-color: var(--success); }
.field-error { color: var(--danger); font-weight: 700; font-size: var(--fs-sm); margin: 0; display: flex; gap: 0.4em; align-items: flex-start; }
.field-error::before { content: "!"; flex: none; width: 1.3em; height: 1.3em; border-radius: 50%; background: var(--danger); color: var(--on-danger); font-weight: 900; font-size: 0.85em; display: inline-flex; align-items: center; justify-content: center; margin-top: 0.1em; }
.field-ok { color: var(--success); font-weight: 700; font-size: var(--fs-sm); margin: 0; }
.field-note { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
.input-group { position: relative; display: flex; }
.input-group .input { padding-right: 3.4em; }
.input-group .input-addon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.form-error {
  background: var(--danger-soft); color: var(--danger-dark); border: 2px solid var(--danger);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-weight: 700; margin-bottom: var(--sp-4);
}
.form-info {
  background: var(--info-soft); color: var(--text); border: 2px solid var(--primary-soft);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
}
.check { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); cursor: pointer; font-weight: 700; }
.check input { width: 26px; height: 26px; accent-color: var(--primary); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); cursor: pointer; font-weight: 700; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { width: 58px; height: 34px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform 0.15s var(--ease); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(24px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }

/* segmented control (radio group look) */
.segmented { display: inline-flex; background: var(--surface-3); border-radius: var(--r-pill); padding: 4px; gap: 2px; }
.segmented button {
  min-height: 44px; padding: 0 1em; border: 0; background: transparent; border-radius: var(--r-pill);
  font-weight: 800; color: var(--text-muted);
}
.segmented button[aria-pressed="true"], .segmented button[aria-checked="true"] { background: var(--surface); color: var(--primary-dark); box-shadow: var(--sh-1); }

/* ------------------------------------------------------------------------------------------ tables */
.table-wrap { width: 100%; overflow-x: auto; border: 2px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 0.7em 0.9em; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--surface-2); font-weight: 800; white-space: nowrap; position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .ctr { text-align: center; }
.table th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3em; min-height: 32px; font-weight: 800; }
.table th button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.table th[aria-sort="ascending"] button::after { content: "▲"; font-size: 0.7em; }
.table th[aria-sort="descending"] button::after { content: "▼"; font-size: 0.7em; }
.table-empty { padding: var(--sp-6); text-align: center; color: var(--text-muted); }

/* ------------------------------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: var(--sp-2); overflow-x: auto; padding: 4px; margin-bottom: var(--sp-4); scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 0.4em;
  min-height: var(--tap); padding: 0 1.1em; font-weight: 800; font-size: var(--fs-md);
  color: var(--text-muted); background: var(--surface-2); border: 2px solid transparent; border-radius: var(--r-pill); cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab[aria-selected="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary-dark); }
.tab .tab-badge { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 0.5em; font-size: var(--fs-xs); min-width: 1.6em; text-align: center; }
.tab-panel { outline: none; }

/* ------------------------------------------------------------------------------------------ chips, badges, avatar */
.chip {
  display: inline-flex; align-items: center; gap: 0.35em; min-height: 32px;
  padding: 0 0.8em; border-radius: var(--r-pill); font-weight: 800; font-size: var(--fs-sm);
  background: var(--surface-3); color: var(--text); white-space: nowrap;
}
.chip-primary { background: var(--primary-soft); color: var(--primary-dark); }
.chip-success { background: var(--success-soft); color: var(--success-dark); }
.chip-warning { background: var(--warning-soft); color: #6b4a00; }
.chip-danger { background: var(--danger-soft); color: var(--danger-dark); }
.chip-accent { background: var(--accent-soft); color: #6b3a00; }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em; height: 1.6em; padding: 0 0.4em;
  border-radius: 999px; background: var(--danger); color: var(--on-danger); font-size: var(--fs-xs); font-weight: 900;
}

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--size, 48px); height: var(--size, 48px); border-radius: 50%;
  font-size: calc(var(--size, 48px) * 0.56); line-height: 1; background: var(--bg-2);
  border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--border-strong), var(--sh-1);
  user-select: none;
}

/* ------------------------------------------------------------------------------------------ progress, spinner */
.progress { position: relative; height: 16px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-lg { height: 24px; }
.progress-bar {
  height: 100%; width: calc(var(--value, 0) * 1%); min-width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.5s var(--ease);
}
.progress-success .progress-bar { background: linear-gradient(90deg, var(--success), #4fd17f); }
.progress-label { display: flex; justify-content: space-between; font-weight: 800; font-size: var(--fs-sm); margin-bottom: var(--sp-1); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 44px; height: 44px; border-radius: 50%;
  border: 6px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
.spinner-sm { width: 24px; height: 24px; border-width: 4px; }
.view-loading { display: flex; justify-content: center; padding: var(--sp-12) 0; opacity: 0; animation: fade-in 0.3s 0.25s forwards; }
@keyframes fade-in { to { opacity: 1; } }
.loading-box { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-8); color: var(--text-muted); font-weight: 700; }

/* ------------------------------------------------------------------------------------------ empty / error states */
.state-page, .state-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: var(--sp-2); padding: var(--sp-10) var(--sp-4); max-width: 520px; margin: 0 auto;
}
.state-page { min-height: 55vh; }
.state-box { background: var(--surface); border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: var(--sp-8) var(--sp-5); }
.state-icon { font-size: 4rem; line-height: 1.15; margin-bottom: var(--sp-2); }
.state-page h1, .state-box h2 { margin-bottom: var(--sp-1); }
.state-page p, .state-box p { color: var(--text-muted); max-width: 40ch; }

/* ------------------------------------------------------------------------------------------ modal */
.modal-root { position: relative; z-index: 900; }
.modal-backdrop {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4); background: rgba(20, 28, 52, 0.55); backdrop-filter: blur(3px);
  animation: fade-in-bg 0.2s var(--ease);
  overscroll-behavior: contain;
}
@keyframes fade-in-bg { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 2 * var(--sp-4)); max-height: calc(100dvh - 2 * var(--sp-4));
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border-radius: var(--r-xl); box-shadow: var(--sh-3);
  border: 3px solid var(--surface); outline: none;
  animation: pop-in 0.28s var(--ease-bounce);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(0.94); } to { opacity: 1; transform: none; } }
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 860px; }
.modal-header { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-2); }
.modal-title { flex: 1; margin: 0; font-size: var(--fs-lg); }
.modal-close { flex: none; margin: -6px -8px 0 0; }
.modal-body { padding: var(--sp-2) var(--sp-5) var(--sp-4); overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.modal-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5) var(--sp-5); }
.modal-footer .btn { flex: 0 1 auto; }
body.modal-open { overflow: hidden; }

/* ------------------------------------------------------------------------------------------ toast */
.toast-root {
  position: fixed; left: 50%; bottom: calc(var(--sp-4) + var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 950; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  width: min(560px, calc(100vw - 2 * var(--sp-4))); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  background: #1c2742; color: #ffffff; border-radius: var(--r-md); box-shadow: var(--sh-3);
  font-weight: 700; font-size: var(--fs-md); border-left: 8px solid var(--primary);
  animation: toast-in 0.3s var(--ease-bounce);
}
.toast.is-leaving { opacity: 0; transform: translateY(10px); transition: opacity 0.25s, transform 0.25s; }
.toast-success { border-left-color: #3ddc84; }
.toast-error { border-left-color: #ff6b7d; }
.toast-warn { border-left-color: #ffc43d; }
.toast-icon { font-size: 1.4em; flex: none; line-height: 1; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .btn { --btn-bg: rgba(255, 255, 255, 0.14); --btn-fg: #fff; --btn-edge: transparent; --btn-border: transparent; box-shadow: none; min-height: 44px; }
.toast .btn:hover { filter: none; background: rgba(255, 255, 255, 0.24); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------------------------------ stars */
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars svg { width: var(--star, 24px); height: var(--star, 24px); }
.stars .star-on { fill: #ffc400; stroke: #d98c00; stroke-width: 1.4; stroke-linejoin: round; }
.stars .star-off { fill: var(--surface-3); stroke: var(--border-strong); stroke-width: 1.4; stroke-linejoin: round; }
.stars-lg { --star: 44px; gap: 6px; }
.stars-sm { --star: 18px; gap: 1px; }
.stars.is-animated .star-on-wrap { animation: star-pop 0.5s var(--ease-bounce) both; animation-delay: calc(var(--i, 0) * 0.22s); }
@keyframes star-pop { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------------------------------ misc */
.divider { height: 2px; background: var(--border); border: 0; margin: var(--sp-5) 0; border-radius: 2px; }
.kbd { font-family: var(--font-mono); background: var(--surface-3); border-radius: 6px; padding: 0.1em 0.5em; border: 1px solid var(--border-strong); font-size: 0.9em; }
.callout { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-4); border-radius: var(--r-md); background: var(--warning-soft); border: 2px solid var(--warning); color: var(--text); }
.callout-info { background: var(--info-soft); border-color: var(--primary-soft); }
.callout-success { background: var(--success-soft); border-color: var(--success); }
.callout .callout-icon { font-size: 1.6em; line-height: 1; }

@media (min-width: 768px) {
  :root { --gutter: 24px; }
  h1 { font-size: var(--fs-xxl); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .spinner { animation: none; border-top-color: var(--primary); border-right-color: var(--primary); }
  .btn.is-busy::after { animation: none; }
}
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
