/* Decision Wheel — "carnival lacquer": a warm-white (or deep blue-grey) room,
   a wheel of twelve vivid colours on an indigo lacquered rim with gold studs,
   a coral needle. Rounded type, calm cards, springy motion. */

:root {
  color-scheme: light;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --bg: #faf6f0;
  --bg-glow: rgba(232, 71, 95, 0.12);
  --bg-glow-2: rgba(91, 76, 214, 0.1);
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --surface-3: #ebe4da;
  --ink: #1d1b2a;
  --muted: #605b6e;
  --line: rgba(40, 30, 60, 0.1);
  --line-strong: rgba(40, 30, 60, 0.18);
  --accent: #d0344f;
  --accent-2: #b8283f;
  --accent-text: #b8283f;
  --accent-soft: rgba(208, 52, 79, 0.1);
  --ca-accent: #d0344f; /* the accounts SDK's buttons and chip: white text on it ≥ 4.5:1 */
  --focus: #3b5bdb;
  --shadow: 0 12px 34px -16px rgba(45, 28, 70, 0.35);
  --shadow-lg: 0 30px 80px -30px rgba(30, 18, 50, 0.5);
  --danger: #c22c3d;
  --ok: #1f8f6a;
  --toast: #23202f;
  --toast-ink: #f6f3fa;
  /* the wheel (read by the canvas renderer) */
  --w-bg: #faf6f0;
  --w-rim1: #3d3394;
  --w-rim2: #191444;
  --w-peg: #f2cf76;
  --w-hub1: #ffffff;
  --w-hub2: #e6e1ef;
  --w-hub-ring: rgba(61, 51, 148, 0.16);
  --w-hub-icon: #d0344f;
  --w-pointer1: #ff6b7d;
  --w-pointer2: #c22c46;
  --w-pin: #241d5c;
  --w-shadow: rgba(40, 25, 70, 0.34);
  --w-separator: rgba(255, 255, 255, 0.92);
  --w-select: #1d1b2a;
  --w-empty: #ece5da;
  --w-empty-line: rgba(40, 30, 60, 0.22);
  --bar-h: 60px;
  --peek: 78px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --spring: cubic-bezier(0.2, 0.9, 0.25, 1.15);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121624;
    --bg-glow: rgba(122, 85, 255, 0.16);
    --bg-glow-2: rgba(255, 92, 110, 0.08);
    --surface: #1b2133;
    --surface-2: #232a40;
    --surface-3: #2c3450;
    --ink: #eef0f6;
    --muted: #a3a9bc;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --accent-text: #ff8d9d;
    --accent-soft: rgba(255, 110, 130, 0.14);
    --focus: #8fa8ff;
    --shadow: 0 14px 36px -16px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, 0.85);
    --danger: #ff7b88;
    --toast: #eef0f6;
    --toast-ink: #161a28;
    --w-bg: #121624;
    --w-rim1: #333a6e;
    --w-rim2: #0b0d1c;
    --w-peg: #f0cd76;
    --w-hub1: #f6f7fc;
    --w-hub2: #c7cbe0;
    --w-hub-ring: rgba(51, 58, 110, 0.25);
    --w-shadow: rgba(0, 0, 0, 0.66);
    --w-select: #ffffff;
    --w-empty: #232a40;
    --w-empty-line: rgba(255, 255, 255, 0.2);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121624;
  --bg-glow: rgba(122, 85, 255, 0.16);
  --bg-glow-2: rgba(255, 92, 110, 0.08);
  --surface: #1b2133;
  --surface-2: #232a40;
  --surface-3: #2c3450;
  --ink: #eef0f6;
  --muted: #a3a9bc;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent-text: #ff8d9d;
  --accent-soft: rgba(255, 110, 130, 0.14);
  --focus: #8fa8ff;
  --shadow: 0 14px 36px -16px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, 0.85);
  --danger: #ff7b88;
  --toast: #eef0f6;
  --toast-ink: #161a28;
  --w-bg: #121624;
  --w-rim1: #333a6e;
  --w-rim2: #0b0d1c;
  --w-peg: #f0cd76;
  --w-hub1: #f6f7fc;
  --w-hub2: #c7cbe0;
  --w-hub-ring: rgba(51, 58, 110, 0.25);
  --w-shadow: rgba(0, 0, 0, 0.66);
  --w-select: #ffffff;
  --w-empty: #232a40;
  --w-empty-line: rgba(255, 255, 255, 0.2);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(60vmax 50vmax at 30% 18%, var(--bg-glow), transparent 70%),
    radial-gradient(50vmax 40vmax at 85% 90%, var(--bg-glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
kbd { font: 600 0.82em/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; }

/* ---- buttons ---------------------------------------------------------------- */

.icon-btn, .round-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted);
  transition: background-color 0.18s, color 0.18s, transform 0.25s var(--spring);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.round-btn { width: 52px; height: 52px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.round-btn:hover { background: var(--surface-2); }
.round-btn.on { color: var(--accent-text); }
.icon-btn:active, .round-btn:active, .btn:active, .chip-btn:active, .spin-btn:active:not(:disabled), .swatch:active, .step:active { transform: scale(0.96); transition-duration: 0.06s; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 0;
  font-weight: 700; line-height: 1.2; text-align: center;
  background: var(--surface-2); color: var(--ink);
  transition: background-color 0.18s, transform 0.25s var(--spring), box-shadow 0.18s, opacity 0.18s;
}
.btn .i { width: 20px; height: 20px; }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 10px 22px -12px rgba(184, 40, 63, 0.75); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.soft:hover { background: var(--surface-3); }
.btn.big { min-height: 56px; padding: 12px 28px; font-size: 18px; border-radius: 18px; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.stack { flex-direction: column; gap: 2px; }
.btn.stack small { font-weight: 600; opacity: 0.82; font-size: 13px; }
.btn:disabled { opacity: 0.45; }
.link-btn { border: 0; background: none; color: var(--accent-text); font-weight: 700; padding: 10px 6px; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 40px; padding: 6px 12px 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 650; white-space: nowrap;
  transition: background-color 0.18s, transform 0.25s var(--spring), border-color 0.18s;
}
.chip-btn .i { width: 18px; height: 18px; color: var(--muted); }
.chip-btn:hover { background: var(--surface-2); }
.chip-btn.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.chip-btn.accent .i { color: currentColor; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 14px; background: var(--surface-2); flex-wrap: wrap; }
.seg button { flex: 1 1 auto; min-height: 40px; padding: 6px 12px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 650; font-size: 14px; transition: background-color 0.2s, color 0.2s; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px -3px rgba(0, 0, 0, 0.25); }
.seg.small button { min-height: 36px; min-width: 40px; padding: 4px 8px; font-size: 13px; }

.switch { position: relative; flex: none; width: 52px; height: 32px; padding: 0; border: 0; border-radius: 999px; background: var(--surface-3); transition: background-color 0.2s; }
.switch::before { content: ""; position: absolute; inset: -6px -2px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--spring); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---- the top bar ------------------------------------------------------------- */

.app { display: flex; flex-direction: column; height: 100dvh; padding: var(--safe-t) var(--safe-r) 0 var(--safe-l); }
.bar { flex: none; display: flex; align-items: center; gap: 8px; height: var(--bar-h); padding: 0 8px 0 14px; position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; filter: drop-shadow(0 4px 8px rgba(40, 20, 70, 0.25)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-title { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.chip-slot { display: grid; place-items: center; width: 44px; height: 44px; }
@media (max-width: 560px) { .brand-sub { visibility: hidden; } .brand-line { min-height: 0; height: 0; } }
@media (max-width: 480px) { .opt-help { display: none; } .brand-title { font-size: 16px; } }
@media (max-width: 420px) { .opt-settings { display: none; } .bar { padding-left: 10px; } }
@media (max-width: 359px) { .brand-title { display: none; } }

.brand-line { position: relative; display: block; min-height: 1.2em; }
.status {
  position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 6px;
  color: var(--ok); font-size: 12.5px; font-weight: 750; white-space: nowrap;
  opacity: 0; transform: translateY(3px); transition: opacity 0.3s, transform 0.3s var(--ease); pointer-events: none;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.show { opacity: 1; transform: none; }
.brand-sub { transition: opacity 0.3s; }
.brand-line:has(.status.show) .brand-sub { opacity: 0; }
.status.offline { color: #9a6200; }
:root[data-theme="dark"] .status.offline { color: #ffc970; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .status.offline { color: #ffc970; } }

/* ---- main layout ---------------------------------------------------------------- */

.main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.stage {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center;
  padding: 2px 0 calc(var(--peek) + var(--safe-b) + 10px);
}
.wheel-head { flex: none; width: 100%; max-width: 640px; padding: 0 12px; display: flex; justify-content: center; min-height: 48px; }
.wheel-name {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px;
  padding: 4px 12px; border: 0; border-radius: 12px; background: transparent;
  font-size: clamp(20px, 5.4vw, 28px); font-weight: 800; letter-spacing: -0.015em; line-height: 1.2;
}
.wheel-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wheel-name .i { width: 18px; height: 18px; color: var(--muted); opacity: 0.6; transition: opacity 0.2s; }
.wheel-name:hover { background: var(--surface-2); }
.wheel-name:hover .i, .wheel-name:focus-visible .i { opacity: 1; }
.wheel-name-input {
  width: min(100%, 420px); min-height: 44px; padding: 4px 14px; text-align: center;
  font-size: clamp(20px, 5.4vw, 28px); font-weight: 800; letter-spacing: -0.015em;
  border: 2px solid var(--focus); border-radius: 12px; background: var(--surface);
}
.wheel-box {
  position: relative; flex: 1 1 auto; min-height: 200px; width: 100%;
  display: grid; place-items: center;
}
#wheel { width: var(--wheel-size, 300px); height: var(--wheel-size, 300px); touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: grab; }
#wheel:active { cursor: grabbing; }
.callout {
  position: absolute; left: 50%; top: 2%; z-index: 2; margin: 0; max-width: 90%;
  padding: 6px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow), 0 0 0 1px var(--line);
  font-weight: 750; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transform: translate(-50%, -6px) scale(0.96); transition: opacity 0.25s, transform 0.3s var(--spring); pointer-events: none;
}
.callout.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.callout .dotc { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--c); vertical-align: 0; }
.callout .pc { color: var(--muted); font-weight: 650; margin-left: 6px; }

.empty {
  position: absolute; inset: 0; margin: auto; z-index: 3;
  width: min(84%, 340px); height: fit-content; padding: 18px 18px 16px; border-radius: 22px; text-align: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: pop-in 0.4s var(--spring) both;
}
.empty-title { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
.empty-body { margin: 0 0 12px; color: var(--muted); font-size: 14.5px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.empty-actions .btn { min-height: 44px; padding: 8px 14px; font-size: 15px; }

.spin-row { flex: none; display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 8px; padding: 0 12px; }
@media (max-width: 380px) { .spin-row { gap: 10px; } .spin-btn { padding: 10px 18px; } }
.spin-btn {
  position: relative; min-width: min(200px, calc(100vw - 150px)); max-width: calc(100vw - 140px); min-height: 66px; padding: 10px 30px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #e2475f 0%, var(--accent) 45%, var(--accent-2) 100%); color: #fff;
  font-weight: 850; font-size: 24px; letter-spacing: 0.1em; line-height: 1.1;
  box-shadow: 0 16px 30px -14px rgba(184, 40, 63, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.35s var(--spring), filter 0.2s, opacity 0.2s, background 0.2s;
}
.spin-btn:hover:not(:disabled) { filter: brightness(1.07); }
.spin-btn::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(208, 52, 79, 0.45); opacity: 0; pointer-events: none; }
.spin-btn.idle::after { animation: pulse 5s var(--ease) 2.5s infinite; }
.spin-btn:disabled { background: var(--surface-3); color: var(--muted); box-shadow: none; letter-spacing: 0.04em; }
.spin-btn.busy:disabled { background: linear-gradient(180deg, #e2475f, var(--accent-2)); color: rgba(255, 255, 255, 0.92); opacity: 0.82; }
.spin-label { display: block; overflow-wrap: anywhere; }
.spin-btn:disabled .spin-label { font-size: 15px; letter-spacing: 0; font-weight: 750; }
.spin-btn.busy:disabled .spin-label { font-size: 20px; letter-spacing: 0.06em; }
.spin-note { margin: 6px 0 0; min-height: 0; color: var(--muted); font-size: 13.5px; text-align: center; }

/* ---- the editor panel ------------------------------------------------------------ */

.panel {
  --sheet-h: calc(100dvh - var(--safe-t) - var(--bar-h) - 4px);
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; height: var(--sheet-h);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 40px -18px rgba(30, 18, 50, 0.45), 0 0 0 1px var(--line);
  transform: translateY(calc(var(--sheet-h) - var(--peek) - var(--safe-b) + var(--drag, 0px)));
  transition: transform 0.42s var(--spring);
  container: panel / inline-size;
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
}
.panel.open { transform: translateY(var(--drag, 0px)); }
.panel.dragging { transition: none; }
.handle { flex: none; display: grid; place-items: center; height: 26px; cursor: grab; touch-action: none; }
.handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); }
.panel-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px 10px 18px; min-height: 48px; }
.panel-title { margin: 0; font-size: 19px; font-weight: 800; }
.count { color: var(--muted); font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; margin-right: auto; }
.panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 10px 16px; transition: opacity 0.25s, filter 0.25s; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 10px; }
.locked-note { display: none; margin: 0 6px 8px; color: var(--muted); font-size: 13.5px; font-weight: 650; }
.panel.locked .locked-note { display: block; }
.panel.locked .tools, .panel.locked .slices, .panel.locked .add-row { opacity: 0.45; filter: grayscale(0.6); pointer-events: none; }

.slices { list-style: none; margin: 0; padding: 0; position: relative; }
.row {
  display: grid; align-items: center; gap: 0 6px;
  grid-template-columns: 30px 36px minmax(0, 1fr) auto 42px;
  grid-template-areas: "grip dot label step del" "grip dot meta step del";
  padding: 6px 4px; border-radius: 16px; background: var(--surface);
  transform: translateY(var(--dy, 0px));
  transition: transform 0.25s var(--ease), background-color 0.3s, opacity 0.3s;
}
.row + .row { margin-top: 2px; }
.row .grip { grid-area: grip; width: 30px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: grab; touch-action: none; display: grid; place-items: center; opacity: 0.7; }
.row .grip:hover { opacity: 1; background: var(--surface-2); }
.row .dot { grid-area: dot; width: 36px; height: 44px; padding: 0; border: 0; background: none; display: grid; place-items: center; }
.row .dot::before { content: ""; width: 24px; height: 24px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15), 0 0 0 2px var(--surface), 0 0 0 3px var(--line-strong); transition: transform 0.25s var(--spring); }
.row .dot:hover::before { transform: scale(1.12); }
.row .label {
  grid-area: label; width: 100%; min-width: 0; min-height: 36px; padding: 6px 10px;
  border: 1.5px solid transparent; border-radius: 10px; background: var(--surface-2);
  font-weight: 650; font-size: 16px; transition: border-color 0.18s, background-color 0.18s;
}
.row .label:hover { border-color: var(--line-strong); }
.row .label:focus { border-color: var(--focus); background: var(--surface); }
.row .label::placeholder { color: var(--muted); opacity: 0.8; font-weight: 600; }
.row .meta { grid-area: meta; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 4px 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .bar { flex: 1 1 auto; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.row .bar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--c, var(--accent)); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 0.35s var(--spring); }
.row .pct { flex: none; min-width: 4.4em; text-align: right; font-weight: 700; }
.row .badge { flex: none; font-weight: 750; color: var(--accent-text); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; }
.row .badge:empty { display: none; }
.row .stepper { grid-area: step; display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 12px; background: var(--surface-2); }
.row .step { width: 38px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); display: grid; place-items: center; transition: background-color 0.15s, transform 0.25s var(--spring); }
.row .step:hover:not(:disabled) { background: var(--surface); }
.row .step:disabled { opacity: 0.3; }
.row .step .i { width: 18px; height: 18px; stroke-width: 2.4; }
.row .weight { width: 40px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 16px; }
.row .weight:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--focus); }
.row .del { grid-area: del; width: 42px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--muted); display: grid; place-items: center; transition: color 0.15s, background-color 0.15s; }
.row .del:hover { color: var(--danger); background: var(--surface-2); }
.row .del .i { width: 20px; height: 20px; }
.row.out { opacity: 0.5; }
.row.out .label { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.row.dragging { z-index: 3; background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); transition: background-color 0.2s, box-shadow 0.2s; transform: translateY(var(--dy, 0px)) scale(1.02); }
.slices.sorting .row:not(.dragging) { transition: transform 0.22s var(--ease); }
.row.flip { transform: translateY(var(--fy)); transition: none; }
.row.flip.flip-go { transition: transform 0.3s var(--spring); }
.row.grow { animation: row-in 0.36s var(--spring) both; }
.row.flash { animation: flash 1.4s var(--ease); }
@container panel (max-width: 400px) {
  .row { grid-template-columns: 28px 34px minmax(0, 1fr) auto 40px; grid-template-areas: "grip dot label label del" "grip dot meta step step"; row-gap: 4px; }
  .row .stepper { justify-self: end; margin-right: 2px; }
}
.add-row {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; margin-top: 8px;
  border: 1.5px dashed var(--line-strong); border-radius: 16px; background: transparent; color: var(--muted); font-weight: 700;
  transition: background-color 0.18s, color 0.18s, border-color 0.18s;
}
.add-row:hover:not(:disabled) { color: var(--ink); border-color: var(--muted); background: var(--surface-2); }
.add-row kbd { margin-left: 4px; font-size: 11px; }
.add-row:disabled { opacity: 0.6; }
@media (hover: none) { .add-row kbd { display: none; } }

/* two columns: wheel + panel */
@media (min-width: 760px) {
  :root { --peek: 0px; }
  .main { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 34vw, 420px); grid-template-rows: minmax(0, 1fr); }
  .main.collapsed { grid-template-columns: minmax(0, 1fr) 0; }
  .stage { padding: 6px 20px 18px; }
  .panel {
    position: relative; inset: auto; height: auto; transform: none; transition: none;
    min-height: 0; overflow: hidden; margin: 0 12px 12px 0; border-radius: 22px; box-shadow: var(--shadow), 0 0 0 1px var(--line); padding: 8px 0 0;
  }
  .panel.open { transform: none; }
  .main.collapsed .panel { visibility: hidden; margin: 0; }
  .main:not(.collapsed) .panel { animation: fade-in 0.3s var(--ease) both; }
  .handle { display: none; }
  .panel-head { padding-top: 6px; }
  .wheel-box { width: 100%; }
}
@media (min-width: 1600px) {
  .stage { padding: 12px 40px 28px; }
  .wheel-name, .wheel-name-input { font-size: 38px; }
  .spin-btn { min-width: 260px; min-height: 80px; font-size: 30px; }
}
@media (max-height: 520px) and (orientation: landscape) and (max-width: 759px) {
  .wheel-head { min-height: 40px; }
  .wheel-name { font-size: 18px; min-height: 40px; }
}

/* ---- sheets ------------------------------------------------------------------ */

dialog { color: var(--ink); }
.sheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%;
  max-height: calc(100dvh - var(--safe-t) - 16px);
  background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden; display: none;
  animation: sheet-in 0.42s var(--spring) both;
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet.closing { animation: sheet-out 0.24s var(--ease) both; }
.sheet::backdrop { background: rgba(14, 12, 24, 0.42); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade-in 0.3s both; }
.sheet.closing::backdrop { animation: fade-out 0.24s both; }
.sheet-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px 10px 6px 20px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.sheet-sub { color: var(--muted); font-size: 14px; font-weight: 650; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sheet-head h2 + .icon-btn { margin-left: auto; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 6px 20px calc(20px + var(--safe-b)); }
.sheet.small .sheet-body { padding-top: 20px; }
.sheet.small h2 { margin: 0 0 8px; font-size: 20px; }
.sheet-lead { margin: 0 0 12px; color: var(--muted); }
@media (min-width: 640px) {
  .sheet { margin: auto; width: min(560px, 92vw); border-radius: 24px; max-height: min(86dvh, 820px); animation-name: dialog-in; }
  .sheet.small { width: min(420px, 92vw); }
  .sheet.closing { animation-name: dialog-out; }
  .sheet-body { padding-bottom: 22px; }
}
.drawer .sheet-body { padding-top: 10px; }
@media (min-width: 760px) {
  .drawer { margin: 0 auto 0 0; height: 100dvh; max-height: 100dvh; width: min(420px, 92vw); border-radius: 0 24px 24px 0; animation-name: drawer-in; padding-top: var(--safe-t); }
  .drawer.closing { animation-name: drawer-out; }
}

.big-text {
  width: 100%; min-height: 150px; padding: 12px 14px; resize: vertical;
  border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--surface-2);
  font-size: 16px; line-height: 1.5;
}
.big-text:focus { border-color: var(--focus); background: var(--surface); }
.code-text { min-height: 96px; font: 600 14px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.text-input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); font-size: 17px; font-weight: 650; }
.text-input:focus { border-color: var(--focus); background: var(--surface); }
.error { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 700; animation: shake 0.35s var(--ease); }
.summary-title { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; font-weight: 800; font-size: 18px; }
.summary { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.summary li { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-weight: 650; animation: row-in 0.35s var(--spring) both; animation-delay: calc(var(--i, 0) * 50ms); }
.summary li.good { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); color: color-mix(in srgb, var(--ok) 70%, var(--ink)); }
.summary li.warn { background: color-mix(in srgb, #e0a020 16%, var(--surface)); }

/* saved wheels */
.wheel-cards { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.wcard { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 10px; border-radius: 18px; background: var(--surface-2); transition: background-color 0.2s, transform 0.3s var(--spring); animation: row-in 0.35s var(--spring) both; animation-delay: calc(var(--i, 0) * 30ms); }
.wcard.current { box-shadow: inset 0 0 0 2px var(--accent); }
.wcard-open { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 0; border: 0; background: none; text-align: left; min-height: 56px; }
.wcard-open::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.wcard:hover { background: var(--surface-3); }
.wcard canvas { width: 54px; height: 54px; flex: none; border-radius: 50%; }
.wcard-text { display: flex; flex-direction: column; min-width: 0; }
.wcard-name { font-weight: 800; font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard-meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard-more { position: relative; z-index: 1; }
.menu {
  position: fixed; z-index: 2147483001; left: var(--x, 0); top: var(--y, 0); min-width: 190px; padding: 6px;
  border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line);
  animation: pop-in 0.25s var(--spring) both; transform-origin: top right;
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px; background: none; font-weight: 650; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu .i { width: 19px; height: 19px; }
.templates-empty { text-align: center; padding: 20px 6px 4px; }
.template-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tpl { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border: 0; border-radius: 18px; background: var(--surface-2); text-align: left; transition: background-color 0.2s, transform 0.3s var(--spring); }
.tpl:hover { background: var(--surface-3); }
.tpl canvas { width: 46px; height: 46px; border-radius: 50%; }
.tpl b { font-weight: 800; font-size: 15.5px; line-height: 1.25; }
.tpl small { color: var(--muted); font-size: 13px; line-height: 1.3; }
.tpl.blank { background: var(--accent-soft); }
.tpl.blank .i { width: 46px; height: 46px; padding: 9px; border-radius: 50%; background: var(--surface); color: var(--accent-text); }
.template-head { grid-column: 1 / -1; margin: 10px 2px 0; color: var(--muted); font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; }

/* history */
.history-count { margin: 0 0 10px; font-weight: 800; font-size: 17px; }
.history-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 4px; }
.history-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); animation: row-in 0.3s var(--spring) both; animation-delay: calc(var(--i, 0) * 25ms); }
.history-list .hdot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--c); }
.history-list .hlabel { flex: 1 1 auto; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-list .hmeta { flex: none; color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.history-empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0 0 12px; }

/* settings */
.settings .set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 650; }
.settings .set-row.column { flex-direction: column; align-items: stretch; gap: 8px; }
.settings select { min-height: 44px; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); font-weight: 650; max-width: 60%; }
.settings input[type="range"] { width: min(55%, 240px); accent-color: var(--accent); height: 32px; }
.set-head { margin: 20px 0 8px; font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.set-actions .btn { flex: 1 1 180px; }
.about { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.about img { border-radius: 12px; flex: none; }
.about-title { margin: 0; font-weight: 800; }
.about-body { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.version { color: var(--muted); font-size: 13px; font-weight: 600; }
.center { text-align: center; }

/* help */
.help .steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.help .steps li { display: flex; gap: 12px; }
.help .step-n { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-weight: 850; }
.help h3 { margin: 2px 0 2px; font-size: 16.5px; font-weight: 800; }
.help p { margin: 0; color: var(--muted); font-size: 15px; }
.help .example { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.help code { font: 650 13.5px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 6px 9px; border-radius: 8px; background: var(--surface-2); color: var(--ink); }
.help .fair { margin: 18px 0 0; padding: 14px 16px; border-radius: 18px; background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface-2); }
.help .fair h3 { display: flex; align-items: center; gap: 8px; }
.help .fair p { color: var(--ink); opacity: 0.86; }
.keys { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 14.5px; }
.keys th, .keys td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.keys th { font-weight: 600; width: 45%; }
.keys td { color: var(--muted); }

/* the result */
.result-dlg { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; }
.result-dlg::backdrop { background: rgba(14, 12, 24, 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade-in 0.35s both; }
.result-dlg.closing::backdrop { animation: fade-out 0.24s both; }
.result-dlg[open] { display: block; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.result-card {
  position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; margin: 0 auto;
  width: min(100%, 560px); padding: 26px 22px calc(22px + var(--safe-b)); border-radius: 28px 28px 0 0; text-align: center;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.28), transparent 60%), var(--win, var(--accent));
  color: var(--win-ink, #fff); box-shadow: var(--shadow-lg);
  animation: result-in 0.62s cubic-bezier(0.18, 1.35, 0.4, 1) both;
}
.result-dlg.closing .result-card { animation: sheet-out 0.24s var(--ease) both; }
@media (min-width: 640px) {
  .result-card { top: 50%; bottom: auto; border-radius: 30px; padding: 34px 30px 26px; transform: translateY(-50%); animation-name: result-in-center; }
  .result-dlg.closing .result-card { animation-name: result-out-center; }
}
.result-kicker { margin: 0 0 6px; font-weight: 750; font-size: 15px; opacity: 0.85; letter-spacing: 0.02em; }
.result-name { margin: 0; font-size: clamp(34px, 9vw, 60px); font-weight: 900; line-height: 1.08; letter-spacing: -0.02em; overflow-wrap: anywhere; }
@media (min-width: 900px) { .result-name { font-size: 60px; } }
.result-name .ch { display: inline-block; white-space: pre; animation: letter-in 0.5s var(--spring) both; animation-delay: calc(120ms + var(--i) * 34ms); }
.result-chance { margin: 10px 0 18px; font-weight: 750; font-size: 17px; opacity: 0.92; font-variant-numeric: tabular-nums; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-actions .btn:first-child { grid-column: 1 / -1; }
.btn.on-color { background: rgba(255, 255, 255, 0.94); color: #1b1b24; min-height: 52px; }
.btn.on-color.ghost { background: rgba(255, 255, 255, 0.2); color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; }
.result-dlg.dark-ink .btn.on-color.ghost { background: rgba(0, 0, 0, 0.08); }
.result-dlg.dark-ink .btn.on-color { background: #1b1b24; color: #fff; }
.result-note { margin: 10px 0 0; font-size: 13.5px; font-weight: 650; opacity: 0.85; }

/* colour picker */
.picker { position: fixed; z-index: 30; left: var(--x, 0); top: var(--y, 0); padding: 10px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); }
.picker.show { animation: pop-in 0.25s var(--spring) both; }
.picker-title { margin: 0 4px 8px; font-size: 13px; font-weight: 800; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(6, 44px); gap: 4px; }
.swatch { position: relative; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; transition: transform 0.25s var(--spring); }
.swatch::before { content: ""; width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15); transition: transform 0.2s var(--spring); }
.swatch:hover:not(:disabled)::before { transform: scale(1.12); }
.swatch.on::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; box-shadow: 0 0 0 3px var(--ink); }
.swatch.taken::before { opacity: 0.3; }
.swatch.taken::after { content: ""; position: absolute; width: 26px; height: 2.5px; border-radius: 2px; background: var(--ink); transform: rotate(-45deg); opacity: 0.6; }

/* the tour */
.tour { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.tour-ring { position: fixed; left: var(--rx); top: var(--ry); width: var(--rw); height: var(--rh); border-radius: var(--rr, 20px); box-shadow: 0 0 0 4px var(--accent), 0 0 0 9999px rgba(14, 12, 24, 0.42); transition: left 0.4s var(--spring), top 0.4s var(--spring), width 0.4s var(--spring), height 0.4s var(--spring); }
.tour-bubble { position: fixed; left: var(--bx); top: var(--by); width: min(320px, calc(100vw - 24px)); padding: 16px 16px 10px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); pointer-events: auto; animation: pop-in 0.35s var(--spring) both; }
.tour-step { margin: 0; color: var(--accent-text); font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.tour-text { margin: 4px 0 8px; font-weight: 700; font-size: 16px; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-actions .btn { min-height: 44px; padding: 8px 16px; }

/* toasts */
.toasts { position: fixed; z-index: 2147483001; inset: auto 0 calc(var(--peek) + var(--safe-b) + 14px) 0; width: auto; height: auto; margin: 0; border: 0; background: transparent; color: inherit; overflow: visible; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 12px; }
.toasts[popover]:not(:popover-open) { display: none; }
.toast {
  position: relative; display: flex; align-items: center; gap: 12px; max-width: min(520px, 100%); min-height: 48px; padding: 8px 8px 8px 18px; overflow: hidden;
  border-radius: 16px; background: var(--toast); color: var(--toast-ink); box-shadow: var(--shadow-lg);
  font-weight: 650; font-size: 15px; pointer-events: auto;
  animation: toast-in 0.4s var(--spring) both;
}
.toast:not(:has(.toast-undo)) { padding-right: 18px; }
.toast.leaving { animation: toast-out 0.22s var(--ease) both; }
.toast-text { flex: 1 1 auto; }
.toast-undo { flex: none; min-height: 40px; padding: 6px 14px; border: 0; border-radius: 11px; background: color-mix(in srgb, var(--toast-ink) 14%, transparent); color: inherit; font-weight: 800; }
.toast-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); transform-origin: left; animation: countdown var(--life) linear both; }
@media (min-width: 760px) { .toasts { inset: calc(var(--safe-t) + var(--bar-h) + 6px) 0 auto 0; } }

/* ---- the landing page ------------------------------------------------------------ */

.landing { min-height: 100dvh; padding: calc(var(--safe-t) + 64px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 28px) calc(var(--safe-l) + 18px); max-width: 1120px; margin: 0 auto; }
.landing-corner { position: fixed; z-index: 4; top: calc(var(--safe-t) + 10px); right: calc(var(--safe-r) + 12px); display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.landing-hero { display: grid; gap: 10px; justify-items: center; text-align: center; }
.landing-wheel { width: min(88vw, 460px); aspect-ratio: 1; display: grid; place-items: center; }
#landing-canvas { width: var(--wheel-size, 300px); height: var(--wheel-size, 300px); touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.landing-copy { display: grid; justify-items: center; gap: 4px; }
.landing-icon { width: 56px; height: 56px; border-radius: 16px; filter: drop-shadow(0 8px 16px rgba(40, 20, 70, 0.3)); }
.landing-title { margin: 6px 0 0; font-size: clamp(34px, 8vw, 54px); font-weight: 900; letter-spacing: -0.025em; line-height: 1.05; }
.landing-promise { margin: 0; font-size: clamp(19px, 4.6vw, 24px); font-weight: 800; color: var(--accent-text); }
.landing-lead { margin: 6px 0 0; max-width: 44ch; color: var(--muted); font-size: 17px; text-wrap: pretty; }
.landing-try { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; color: var(--muted); font-size: 14.5px; font-weight: 650; }
.landing-try .i { width: 18px; height: 18px; color: var(--accent-text); }
.landing-cards { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 12px; }
.card { padding: 18px 18px 16px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow), 0 0 0 1px var(--line); animation: row-in 0.5s var(--spring) both; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card h2 { margin: 10px 0 4px; font-size: 18px; font-weight: 800; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); }
.landing-cta { display: grid; justify-items: center; gap: 6px; margin: 28px auto 0; max-width: 460px; text-align: center; }
.landing-notice { margin: 0 0 6px; font-weight: 750; font-size: 16px; }
.landing-cta .btn.big { width: 100%; }
.landing-fine { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
@media (min-width: 860px) {
  .landing { padding-top: calc(var(--safe-t) + 40px); }
  .landing-hero { grid-template-columns: 1.05fr 1fr; align-items: center; text-align: left; justify-items: start; gap: 30px; }
  .landing-wheel { width: min(46vw, 520px); justify-self: center; }
  .landing-copy { justify-items: start; }
  .landing-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ---- motion ---------------------------------------------------------------------- */

@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { from { transform: none; opacity: 1; } to { transform: translateY(40%); opacity: 0; } }
@keyframes dialog-in { from { transform: translateY(18px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dialog-out { from { transform: none; opacity: 1; } to { transform: translateY(10px) scale(0.97); opacity: 0; } }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes drawer-out { from { transform: none; } to { transform: translateX(-100%); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes row-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes flash { 0%, 100% { background-color: var(--surface); } 15%, 55% { background-color: var(--accent-soft); } }
@keyframes pulse { 0% { opacity: 0.9; box-shadow: 0 0 0 0 rgba(208, 52, 79, 0.5); } 22% { opacity: 0; box-shadow: 0 0 0 16px rgba(208, 52, 79, 0); } 100% { opacity: 0; } }
@keyframes result-in { from { transform: translateY(105%); } to { transform: none; } }
@keyframes result-in-center { from { transform: translateY(calc(-50% + 60vh)); } to { transform: translateY(-50%); } }
@keyframes result-out-center { from { transform: translateY(-50%); opacity: 1; } to { transform: translateY(-40%); opacity: 0; } }
@keyframes letter-in { from { opacity: 0; transform: translateY(0.45em) scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* reduced motion (the system's, or the app's own setting): crossfades instead of travel */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="off"]) *, :root:not([data-motion="off"]) *::before, :root:not([data-motion="off"]) *::after { animation-duration: 0.18s !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; }
  :root:not([data-motion="off"]) .spin-btn.idle::after { animation: none !important; }
  :root:not([data-motion="off"]) .sheet, :root:not([data-motion="off"]) .result-card, :root:not([data-motion="off"]) .toast, :root:not([data-motion="off"]) .result-name .ch { animation-name: fade-in !important; }
}
:root[data-motion="on"] *, :root[data-motion="on"] *::before, :root[data-motion="on"] *::after { animation-duration: 0.18s !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; }
:root[data-motion="on"] .spin-btn.idle::after { animation: none !important; }
:root[data-motion="on"] .sheet, :root[data-motion="on"] .result-card, :root[data-motion="on"] .toast, :root[data-motion="on"] .result-name .ch { animation-name: fade-in !important; }
@media (min-width: 640px) {
  :root[data-motion="on"] .result-card { animation-name: fade-in !important; }
}
html:root .toast-bar { animation-duration: var(--life) !important; }
