/* React Bits components ported to vanilla JS for Novinky — https://reactbits.dev
   MIT + Commons Clause, © David Haz. Colours mapped onto the Novinky tokens (app.css). */

/* ------------------------------- Lattice Loader ------------------------------ */

.lattice-loader {
  --ll-n: 3; --ll-cell: 6px; --ll-gap: 2px; --ll-font: 14px; --ll-color: currentColor;
  --ll-mark: #22c55e; --ll-idle: 0.15; --ll-glow: currentColor; --ll-mark-glow: #22c55e; --ll-peak: 1; --ll-cycle: 864ms;
  --ll-ease-out: cubic-bezier(0.23, 1, 0.32, 1); --ll-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  position: relative; display: inline-flex; align-items: center; gap: calc(var(--ll-font) * 0.625);
  font-family: inherit; font-size: var(--ll-font); line-height: 1;
}
.lattice-loader__grid { display: grid; flex: none; }
.lattice-loader__layer { grid-area: 1 / 1; display: grid; grid-template-columns: repeat(var(--ll-n), var(--ll-cell)); gap: var(--ll-gap); }
.lattice-loader__cell { width: var(--ll-cell); height: var(--ll-cell); border-radius: max(1px, calc(var(--ll-cell) * 0.25)); background: var(--ll-color); opacity: var(--ll-idle); }
.lattice-loader[data-shape='round'] .lattice-loader__cell { border-radius: 50%; }
.lattice-loader[data-glow] .lattice-loader__run .lattice-loader__cell:not([data-hole]) { box-shadow: 0 0 calc(var(--ll-cell) * 1.2) calc(var(--ll-cell) * 0.12) var(--ll-glow); }
.lattice-loader[data-glow] .lattice-loader__mark .lattice-loader__cell[data-on] { box-shadow: 0 0 calc(var(--ll-cell) * 1.2) calc(var(--ll-cell) * 0.12) var(--ll-mark-glow); }
.lattice-loader__run { transition: opacity 200ms ease; }
.lattice-loader__run .lattice-loader__cell { animation: lattice-on var(--ll-cycle) var(--ll-ease-in-out) infinite; }
.lattice-loader__run .lattice-loader__cell[data-lit='45'] { animation-name: lattice-on-45; }
.lattice-loader__run .lattice-loader__cell[data-lit='35'] { animation-name: lattice-on-35; }
.lattice-loader__run .lattice-loader__cell[data-lit='25'] { animation-name: lattice-on-25; }
.lattice-loader__run .lattice-loader__cell[data-hole] { animation: none; opacity: calc(var(--ll-idle) * 0.47); }
.lattice-loader__mark { opacity: 0; transform: scale(0.9); transform-origin: center; transition: opacity 160ms var(--ll-ease-out), transform 160ms var(--ll-ease-out); }
.lattice-loader__mark .lattice-loader__cell { transition: opacity 200ms ease, background-color 200ms ease; }
.lattice-loader__mark .lattice-loader__cell[data-on] { background: var(--ll-mark); opacity: var(--ll-peak); }
.lattice-loader:not([data-status='working']) .lattice-loader__run { opacity: 0; }
.lattice-loader:not([data-status='working']) .lattice-loader__run .lattice-loader__cell { animation-play-state: paused; }
.lattice-loader:not([data-status='working']) .lattice-loader__mark { opacity: 1; transform: none; transition: opacity 200ms ease, transform 200ms var(--ll-ease-out); }
.lattice-loader__label { position: relative; display: inline-block; font-weight: 500; }
.lattice-loader__text { position: absolute; top: 0; left: 0; white-space: nowrap; opacity: 0; filter: blur(2px); transition: opacity 200ms ease, filter 200ms ease; }
.lattice-loader__text[data-active] { position: static; opacity: 1; filter: blur(0); }
.lattice-loader__timer { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: calc(var(--ll-font) * 0.875); font-variant-numeric: tabular-nums; opacity: 0.6; }
.lattice-loader__sr, .call-chip__sr, .thought-line__sr, .fuse-button__status, .hold-button__sr, .pulse-heart__sr, .counter__sr, .blur-text__sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
@keyframes lattice-on { 0%, 100% { opacity: var(--ll-idle); } 18%, 42% { opacity: var(--ll-peak); } 62% { opacity: var(--ll-idle); } }
@keyframes lattice-on-45 { 0%, 100% { opacity: var(--ll-idle); } 13%, 31% { opacity: var(--ll-peak); } 45% { opacity: var(--ll-idle); } }
@keyframes lattice-on-35 { 0%, 100% { opacity: var(--ll-idle); } 10%, 24% { opacity: var(--ll-peak); } 35% { opacity: var(--ll-idle); } }
@keyframes lattice-on-25 { 0%, 100% { opacity: var(--ll-idle); } 7%, 17% { opacity: var(--ll-peak); } 25% { opacity: var(--ll-idle); } }

/* --------------------------------- Call Chip --------------------------------- */

.call-chip {
  --cc-size: 30px; --cc-font: 12px; --cc-pad: 10px; --cc-gap: 7px; --cc-radius: 9px; --cc-expected: 2500ms;
  --cc-surface: var(--fill-2); --cc-progress: var(--accent); --cc-done: var(--ok); --cc-error: var(--danger);
  --cc-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  position: relative; display: inline-flex; align-items: center; gap: var(--cc-gap); max-width: 100%;
  height: var(--cc-size); padding: 0 var(--cc-pad); border-radius: var(--cc-radius); overflow: hidden;
  background: var(--cc-surface); color: var(--text); font-size: var(--cc-font); line-height: 1; white-space: nowrap;
  box-shadow: inset 0 0 0 0.5px var(--line-2); user-select: none; transition: transform 160ms var(--cc-ease-out);
}
.call-chip__fill { position: absolute; inset: 0; background: color-mix(in srgb, var(--cc-progress) 12%, transparent); transform: scaleX(0); transform-origin: left center; clip-path: inset(0 0 0 0); pointer-events: none; }
.call-chip[data-status='running'] .call-chip__fill { transition: transform var(--cc-expected) linear; }
.call-chip[data-status='done'] .call-chip__fill { background: color-mix(in srgb, var(--cc-done) 14%, transparent); clip-path: inset(100% 0 0 0); transition: transform 200ms var(--cc-ease-out), background-color 120ms ease, clip-path 400ms var(--cc-ease-out) 200ms; }
.call-chip[data-status='error'] .call-chip__fill { background: color-mix(in srgb, var(--cc-error) 14%, transparent); transition: background-color 200ms ease; }
.call-chip:not([data-mounted]) .call-chip__fill, .call-chip:not([data-mounted]) .call-chip__glyph { transition: none !important; }
.call-chip__slot { position: relative; flex: none; width: calc(var(--cc-font) + 3px); height: calc(var(--cc-font) + 3px); overflow: hidden; }
.call-chip__glyph { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transform: translateY(70%); filter: blur(3px); }
.call-chip__glyph svg { width: 100%; height: 100%; }
.call-chip__glyph[data-state='in'] { opacity: 1; transform: none; filter: blur(0); transition: opacity 240ms var(--cc-ease-out), transform 240ms var(--cc-ease-out), filter 240ms var(--cc-ease-out); }
.call-chip__glyph[data-state='out'] { transform: translateY(-70%); transition: opacity 160ms var(--cc-ease-out), transform 160ms var(--cc-ease-out), filter 160ms var(--cc-ease-out); }
.call-chip[data-status='running'] .call-chip__glyph[data-state='in'] { color: var(--accent); }
.call-chip[data-status='done'] .call-chip__glyph[data-state='in'] { color: var(--cc-done); }
.call-chip[data-status='error'] .call-chip__glyph[data-state='in'] { color: var(--cc-error); }
.call-chip__name, .call-chip__arg, .call-chip__timer { position: relative; }
.call-chip__name { font-weight: 600; }
.call-chip__arg { opacity: 0.75; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.call-chip__timer { min-width: 6ch; font-variant-numeric: tabular-nums; text-align: right; opacity: 0.5; margin-left: auto; }

/* -------------------------------- Thought Line -------------------------------- */

.thought-line {
  --tl-ease-out: cubic-bezier(0.23, 1, 0.32, 1); --tl-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --tl-font: 16px; --tl-color: currentColor; --tl-glyph: var(--accent); --tl-settle: 350ms; --tl-blur: 2px; --tl-shimmer: 1.8s; --tl-done: 0.75; --tl-timer: 0.55;
  display: inline-flex; flex-direction: column; align-items: flex-start; max-width: 100%;
  color: var(--tl-color); font-size: var(--tl-font); font-weight: 600; line-height: 1.2;
}
.thought-line__head { position: relative; display: inline-flex; align-items: center; gap: 0.3em; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; white-space: nowrap; outline: none; cursor: default; }
.thought-line__head[data-toggle] { cursor: pointer; }
.thought-line__head:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 4px; border-radius: 6px; }
.thought-line__glyph { display: inline-flex; flex: none; width: 1.1em; height: 1.1em; margin-right: 0.2em; color: var(--tl-glyph); }
.thought-line__glyph svg { display: block; width: 100%; height: 100%; }
.thought-line__label { display: inline-grid; }
.thought-line__text { grid-area: 1 / 1; width: max-content; opacity: 0; filter: blur(var(--tl-blur)); transition: opacity var(--tl-settle) var(--tl-ease-out), filter var(--tl-settle) var(--tl-ease-out); }
.thought-line__text[data-active] { opacity: 1; filter: blur(0); }
.thought-line__text--done[data-active] { opacity: var(--tl-done); }
.thought-line__breath { display: inline-block; }
.thought-line[data-working] .thought-line__breath[data-shimmer] {
  background: linear-gradient(100deg, color-mix(in srgb, var(--text) 45%, transparent) 30%, var(--text) 50%, color-mix(in srgb, var(--text) 45%, transparent) 70%);
  background-size: 250% 100%; background-position: 125% 0; -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  animation: thought-line-shimmer var(--tl-shimmer) linear infinite;
}
@keyframes thought-line-shimmer { to { background-position: -125% 0; } }
.thought-line__timer { font-variant-numeric: tabular-nums; font-weight: 500; opacity: var(--tl-timer); transition: opacity var(--tl-settle) ease, transform var(--tl-settle) var(--tl-ease-in-out); }
.thought-line__timer[data-done] { opacity: var(--tl-done); }
.thought-line__chevron { display: inline-flex; margin-left: 0.1em; opacity: 0; transition: opacity 200ms ease, transform 200ms var(--tl-ease-out); }
.thought-line__chevron[data-on] { opacity: 0.55; }
.thought-line[data-open] .thought-line__chevron { transform: rotate(180deg); }
.thought-line__trace { display: grid; grid-template-rows: 0fr; width: 0; min-width: 100%; transition: grid-template-rows var(--tl-settle) var(--tl-ease-out); }
.thought-line__trace[data-open] { grid-template-rows: 1fr; }
.thought-line__fold { min-height: 0; overflow-x: visible; overflow-y: clip; }
.thought-line__steps { display: flex; flex-direction: column; gap: 0.5em; padding: 0.7em 0 0.2em 1.6em; font-size: 0.8em; font-weight: 400; }
.thought-line__step { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; opacity: 1; transform: translateY(0); transition: opacity 200ms var(--tl-ease-out), transform 200ms var(--tl-ease-out); }
@starting-style { .thought-line__step { opacity: 0; transform: translateY(-4px); } }
.thought-line__mark { display: inline-grid; flex: none; place-items: center; width: 1em; height: 1em; opacity: 0.55; }
.thought-line__mark svg { width: 100%; height: 100%; }
.thought-line__pulse { display: block; width: 0.42em; height: 0.42em; border-radius: 50%; background: currentColor; animation: thought-line-pulse 1.6s var(--tl-ease-in-out) infinite; }
@keyframes thought-line-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.thought-line__step-text { transition: opacity var(--tl-settle) ease; }
.thought-line__step[data-done] .thought-line__step-text { opacity: 0.6; }
.thought-line__step[data-done] .thought-line__step-text:has(.call-chip, a) { opacity: 1; }

/* --------------------------------- Fuse Button -------------------------------- */

.fuse-button {
  --fb-ink: #fff; --fb-bg: var(--accent); --fb-fuse: #fde047; --fb-fuse-h: 1.5px; --fb-radius: 18px; --fb-fade: 200ms; --fb-press: 0.97;
  --fb-h: 32px; --fb-fs: 13px; --fb-icon: 14px; --fb-px: 14px; --fb-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  position: relative; display: inline-grid; grid-template-columns: minmax(0, 1fr); height: var(--fb-h); border-radius: var(--fb-radius);
  background: var(--fb-bg); color: var(--fb-ink); font-size: var(--fb-fs); font-weight: 500; line-height: 1; letter-spacing: 0.01em;
  overflow: hidden; isolation: isolate; outline: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform 160ms var(--fb-ease-out), background-color 200ms ease;
}
.fuse-button--neutral { --fb-ink: var(--text); --fb-bg: var(--fill); --fb-fuse: var(--warn); }
.fuse-button--danger { --fb-ink: var(--danger); --fb-bg: color-mix(in srgb, var(--danger) 10%, transparent); --fb-fuse: var(--danger); }
.fuse-button[data-phase='armed'] { --fb-bg: var(--fill); --fb-ink: var(--text); }
.fuse-button[data-phase='settled'] { --fb-bg: color-mix(in srgb, var(--ok) 14%, transparent); --fb-ink: var(--ok); }
.fuse-button[data-pressed] { transform: scale(var(--fb-press)); }
.fuse-button:has(:focus-visible) { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 3px; }
.fuse-button__idle:focus-visible, .fuse-button__undo:focus-visible { outline: none; }
.fuse-button__face {
  position: relative; grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; height: 100%; min-width: 0;
  margin: 0; padding: 0 var(--fb-px); border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; white-space: nowrap; cursor: pointer;
  opacity: 0; filter: blur(2px); visibility: hidden;
  transition: opacity var(--fb-fade) ease, filter var(--fb-fade) ease, visibility 0s linear var(--fb-fade), background-color 160ms ease;
}
.fuse-button[data-phase='idle'] .fuse-button__idle, .fuse-button[data-phase='armed'] .fuse-button__undo, .fuse-button[data-phase='settled'] .fuse-button__settled { opacity: 1; filter: blur(0); visibility: visible; transition-delay: 0s; }
.fuse-button[data-instant] .fuse-button__face { transition-duration: 0s; }
.fuse-button__idle:disabled, .fuse-button__settled { cursor: default; }
.fuse-button__icon { display: inline-flex; width: var(--fb-icon); height: var(--fb-icon); }
.fuse-button__icon svg { width: 100%; height: 100%; }
.fuse-button__icon--undo { transform: rotate(-70deg); transition: transform var(--fb-fade) var(--fb-ease-out); }
.fuse-button[data-phase='armed'] .fuse-button__icon--undo { transform: rotate(0deg); }
.fuse-button__fuse { position: absolute; left: 0; right: 0; bottom: 0; height: var(--fb-fuse-h); background: var(--fb-fuse); transform-origin: left center; pointer-events: none; }
.fuse-button__rim { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; opacity: 0; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--fb-fuse) 60%, transparent)); transition: opacity var(--fb-fade) ease; }
.fuse-button[data-phase='armed'] .fuse-button__rim { opacity: 1; }
.fuse-button__rim rect {
  x: calc(var(--fb-fuse-h) / 2); y: calc(var(--fb-fuse-h) / 2); width: calc(100% - var(--fb-fuse-h)); height: calc(100% - var(--fb-fuse-h));
  rx: max(0px, calc(var(--fb-radius) - var(--fb-fuse-h) / 2)); fill: none; stroke: var(--fb-fuse); stroke-width: var(--fb-fuse-h); stroke-linecap: round; stroke-dasharray: 1;
}
@media (hover: hover) and (pointer: fine) { .fuse-button__idle:not(:disabled):hover, .fuse-button__undo:hover { background: color-mix(in srgb, var(--fb-ink) 8%, transparent); } }

/* --------------------------------- Hold Button -------------------------------- */

.hold-button {
  --hb-radius: 18px; --hb-bg: color-mix(in srgb, var(--danger) 10%, transparent); --hb-fill: var(--danger); --hb-text: var(--danger); --hb-fill-text: #fff;
  --hb-hold: 1200ms; --hb-release: 200ms; --hb-press: 0.97; --hb-wave: 6px; --hb-w: 0px; --hb-h: 0px; --hb-cycles: 1; --hb-p: 0;
  --hb-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --hb-glow: 0 8px 24px -6px color-mix(in srgb, var(--hb-fill) 55%, transparent);
  position: relative; display: inline-grid; place-items: center; isolation: isolate; margin: 0; border: 0; border-radius: var(--hb-radius);
  background: var(--hb-bg); color: var(--hb-text); font-family: inherit; font-weight: 500; letter-spacing: 0.01em; line-height: 1;
  cursor: pointer; outline: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform 160ms var(--hb-ease-out), background-color 160ms ease, box-shadow var(--hb-release) var(--hb-ease-out);
}
.hold-button--sm { height: 32px; padding: 0 14px; font-size: 13px; }
.hold-button--md { height: 40px; padding: 0 18px; font-size: 14px; }
.hold-button--lg { height: 48px; padding: 0 24px; font-size: 16px; }
@media (hover: hover) and (pointer: fine) { .hold-button:not(:disabled):hover { background: color-mix(in srgb, var(--danger) 16%, transparent); } }
.hold-button[data-phase='holding'][data-input='pointer'] { transform: scale(var(--hb-press)); }
.hold-button[data-glow='true'][data-phase='holding'], .hold-button[data-glow='true'][data-phase='done'] { box-shadow: var(--hb-glow); }
.hold-button[data-glow='true'][data-phase='holding'] { transition: transform 160ms var(--hb-ease-out), background-color 160ms ease, box-shadow var(--hb-hold) linear; }
.hold-button:focus-visible { outline: 2px solid var(--hb-fill); outline-offset: 3px; }
.hold-button:disabled { opacity: 0.5; cursor: default; pointer-events: none; }
.hold-button__pulse { position: absolute; inset: 0; z-index: 0; border-radius: var(--hb-radius); pointer-events: none; opacity: 0; }
.hold-button[data-glow='true'][data-phase='done'] .hold-button__pulse { animation: hb-pulse 600ms var(--hb-ease-out) forwards; }
@keyframes hb-pulse { from { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--hb-fill) 55%, transparent); } to { opacity: 0; box-shadow: 0 0 0 14px color-mix(in srgb, var(--hb-fill) 0%, transparent); } }
.hold-button__label { position: relative; z-index: 2; display: grid; place-items: center; }
.hold-button__label > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: opacity 200ms ease, filter 200ms ease; }
.hold-button__icon { display: inline-flex; flex: none; width: 15px; height: 15px; }
.hold-button__icon svg { width: 100%; height: 100%; }
.hold-button__done { opacity: 0; filter: blur(2px); }
.hold-button[data-phase='done'] .hold-button__idle { opacity: 0; filter: blur(2px); }
.hold-button[data-phase='done'] .hold-button__done { opacity: 1; filter: blur(0); }
.hold-button__clip { position: absolute; inset: 0; z-index: 3; clip-path: inset(0 round var(--hb-radius)); pointer-events: none; }
.hold-button__fill { position: absolute; inset: 0; display: grid; place-items: center; background: var(--hb-fill); color: var(--hb-fill-text); clip-path: inset(0 calc((1 - var(--hb-p)) * (100% + 0.75 * var(--hb-wave)) - var(--hb-p) * 0.25 * var(--hb-wave)) 0 0); }
.hold-button__crest {
  position: absolute; inset: 0; display: grid; place-items: center; background: var(--hb-fill); color: var(--hb-fill-text);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='200' viewBox='0 0 20 200' preserveAspectRatio='none'%3E%3Cpath d='M0 0H10C18 8 18 25.3 10 33.3S2 58.7 10 66.7S18 92 10 100S2 125.3 10 133.3S18 158.7 10 166.7S2 192 10 200H0Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='200' viewBox='0 0 20 200' preserveAspectRatio='none'%3E%3Cpath d='M0 0H10C18 8 18 25.3 10 33.3S2 58.7 10 66.7S18 92 10 100S2 125.3 10 133.3S18 158.7 10 166.7S2 192 10 200H0Z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: repeat-y; mask-repeat: repeat-y;
  -webkit-mask-size: var(--hb-wave) calc(var(--hb-h) * 2); mask-size: var(--hb-wave) calc(var(--hb-h) * 2);
  -webkit-mask-position-x: calc(-1 * var(--hb-wave) + var(--hb-p) * (var(--hb-w) + var(--hb-wave))); mask-position-x: calc(-1 * var(--hb-wave) + var(--hb-p) * (var(--hb-w) + var(--hb-wave)));
  -webkit-mask-position-y: calc(-1 * var(--hb-p) * var(--hb-cycles) * var(--hb-h)); mask-position-y: calc(-1 * var(--hb-p) * var(--hb-cycles) * var(--hb-h));
}
.hold-button__label--fill { z-index: auto; }

/* -------------------------------- Squish Switch ------------------------------- */

.squish-switch {
  --ss-w: 51px; --ss-h: 31px; --ss-inset: 2px; --ss-thumb: 27px; --ss-r: 16px; --ss-thumb-r: 14px;
  --ss-track: rgba(255, 255, 255, 0.14); --ss-track-on: var(--accent); --ss-thumb-color: #fff; --ss-fade: 280ms;
  position: relative; display: inline-block; margin: 0; padding: 0; border: 0; background: none; cursor: pointer; outline: none; flex: none;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.squish-switch::after { content: ''; position: absolute; inset: -8px; }
.squish-switch:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 3px; border-radius: var(--ss-r); }
.squish-switch[data-held] { cursor: grabbing; }
.squish-switch__track { position: relative; display: block; width: var(--ss-w); height: var(--ss-h); border-radius: var(--ss-r); background: var(--ss-track); transition: background-color var(--ss-fade) ease; }
.squish-switch[data-on] .squish-switch__track { background: var(--ss-track-on); }
.squish-switch__thumb { position: absolute; top: var(--ss-inset); left: 0; width: var(--ss-thumb); height: var(--ss-thumb); border-radius: var(--ss-thumb-r); background: var(--ss-thumb-color); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }

/* --------------------------------- Jelly Radio -------------------------------- */

.jelly-radio {
  --jr-chip: var(--fill-2); --jr-active: var(--accent); --jr-text: var(--text); --jr-active-text: #0a0910; --jr-gap: 8px; --jr-radius: 18px; --jr-h: 36px; --jr-font: 13px; --jr-px: 16px; --jr-pad-x: 16px; --jr-pad-y: 6px;
  --jr-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--jr-gap); padding: var(--jr-pad-y) var(--jr-pad-x); margin: 0 calc(-1 * var(--jr-pad-x)); user-select: none; -webkit-user-select: none;
}
.jelly-radio__chip { position: relative; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; outline: none; transform-origin: 50% 50%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.jelly-radio__chip[data-on='true'] { cursor: default; }
.jelly-radio__chip:focus-visible .jelly-radio__skin { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.jelly-radio__skin {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.45em; height: var(--jr-h); padding: 0 var(--jr-px); border-radius: var(--jr-radius); overflow: hidden;
  background: var(--jr-chip); color: var(--jr-text); font-size: var(--jr-font); font-weight: 500; line-height: 1; white-space: nowrap; box-shadow: inset 0 0 0 0.5px var(--line);
  transition: transform 160ms var(--jr-ease-out), background-color 200ms ease, color 200ms ease;
}
.jelly-radio__skin::before { content: ''; position: absolute; inset: 0; background: var(--jr-text); opacity: 0; pointer-events: none; transition: opacity 160ms ease; }
@media (hover: hover) and (pointer: fine) { .jelly-radio__chip[data-on='false']:hover .jelly-radio__skin::before { opacity: 0.08; } }
.jelly-radio__chip:active .jelly-radio__skin { transform: scale(0.97); }
.jelly-radio__chip[data-on='true'] .jelly-radio__skin { background: var(--jr-active); color: var(--jr-active-text); box-shadow: none; }
.jelly-radio__icon { display: inline-flex; width: 1.15em; height: 1.15em; }
.jelly-radio__icon svg { width: 100%; height: 100%; }

/* --------------------------------- Swipe Toast -------------------------------- */

.swipe-toast-stack { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.swipe-toast { --st-slide: 400ms; --st-ease-out: cubic-bezier(0.23, 1, 0.32, 1); display: grid; grid-template-rows: 1fr; width: 100%; transition: grid-template-rows var(--st-slide) var(--st-ease-out); pointer-events: auto; }
.swipe-toast:not([data-mounted]), .swipe-toast[data-phase='closing'], .swipe-toast[data-phase='gone'] { grid-template-rows: 0fr; }
.swipe-toast[data-phase='closing'] { transition-duration: calc(var(--st-slide) * 0.7); }
.swipe-toast__gate { min-height: 0; }
.swipe-toast__lift { opacity: 1; transform: translateY(0); transition: transform var(--st-slide) var(--st-ease-out), opacity calc(var(--st-slide) * 0.6) ease; }
.swipe-toast:not([data-mounted]) .swipe-toast__lift, .swipe-toast[data-phase='closing'] .swipe-toast__lift { opacity: 0; transform: translateY(100%); }
.swipe-toast[data-phase='gone'] .swipe-toast__lift { opacity: 0; visibility: hidden; }
.swipe-toast__card {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; overflow: hidden;
  background: var(--glass-strong); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  box-shadow: inset 0 0 0 0.5px var(--glass-edge), 0 0 0 0.5px var(--line), var(--shadow-2);
  font-size: 0.92rem; font-weight: 500; line-height: 1.4; cursor: grab; outline: none; touch-action: none; user-select: none; -webkit-user-select: none;
}
.swipe-toast__card[data-swiping] { cursor: grabbing; }
.swipe-toast__card:focus-visible { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-2); }
.swipe-toast__icon { display: inline-flex; flex: none; width: 19px; height: 19px; }
.swipe-toast__icon svg { width: 100%; height: 100%; }
.swipe-toast--ok .swipe-toast__icon { color: var(--ok); }
.swipe-toast--err .swipe-toast__icon { color: var(--danger); }
.swipe-toast--info .swipe-toast__icon { color: var(--accent); }
.swipe-toast__body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 1px; min-width: 0; }
.swipe-toast__desc { color: var(--text-2); font-weight: 400; font-size: 0.85rem; }
.swipe-toast__action { flex: none; height: 26px; padding: 0 10px; border: 0; border-radius: 7px; background: var(--text); color: var(--bg); font: inherit; font-size: 12px; cursor: pointer; }
.swipe-toast__fuse {
  position: absolute; right: 0; bottom: 0; left: 0; height: 2px; transform-origin: left center; pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, currentColor 18%, transparent) 9%, color-mix(in srgb, currentColor 50%, transparent) 20%, currentColor 38%, currentColor 62%, color-mix(in srgb, currentColor 50%, transparent) 80%, transparent 100%);
}
.swipe-toast--ok .swipe-toast__fuse { color: var(--ok); }
.swipe-toast--err .swipe-toast__fuse { color: var(--danger); }
.swipe-toast--info .swipe-toast__fuse { color: var(--accent); }
.swipe-toast[data-fuse='none'] .swipe-toast__fuse { opacity: 0; }

/* --------------------------------- Pulse Heart -------------------------------- */

.pulse-heart {
  --ph-size: 22px; --ph-corner: 999px; --ph-pill: var(--fill-2); --ph-idle: var(--text-2); --ph-liked: #f472b6; --ph-text: var(--text); --ph-roll: 350ms; --ph-stroke: 1.5px;
  --ph-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  position: relative; display: inline-flex; align-items: center; justify-content: center; margin: 0; padding: 0; border: 0; border-radius: var(--ph-corner); background: none;
  color: var(--ph-text); font-family: inherit; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; outline: none;
  transition: transform 160ms var(--ph-ease-out);
}
.pulse-heart[data-pressed] { transform: scale(0.97); }
.pulse-heart:focus-visible { outline: 2px solid color-mix(in srgb, var(--ph-liked) 60%, transparent); outline-offset: 3px; }
.pulse-heart__pill { display: inline-flex; align-items: center; gap: calc(var(--ph-size) * 0.3); padding: calc(var(--ph-size) * 0.38) calc(var(--ph-size) * 0.7) calc(var(--ph-size) * 0.38) calc(var(--ph-size) * 0.45); border-radius: var(--ph-corner); background: var(--ph-pill); box-shadow: inset 0 0 0 0.5px var(--line); transform-origin: center; }
.pulse-heart__heart { display: block; width: var(--ph-size); height: var(--ph-size); color: var(--ph-idle); transform-origin: center; transition: color 160ms ease; }
.pulse-heart__heart svg { display: block; width: 100%; height: 100%; overflow: visible; fill: none; stroke: currentColor; stroke-width: var(--ph-stroke); stroke-linecap: round; stroke-linejoin: round; }
.pulse-heart[data-liked='true'] .pulse-heart__heart svg { fill: currentColor; }
.pulse-heart[data-liked='true'] .pulse-heart__heart { color: var(--ph-liked); }
.pulse-heart[data-running] .pulse-heart__heart { transition: none; }
@media (hover: hover) and (pointer: fine) { .pulse-heart:not([data-liked='true']):hover .pulse-heart__heart { color: color-mix(in srgb, var(--ph-idle) 45%, var(--ph-liked)); } }
.pulse-heart__count { display: inline-flex; font-size: calc(var(--ph-size) * 0.68); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.pulse-heart__count > span { display: block; height: 1em; }
.pulse-heart__label { font-size: calc(var(--ph-size) * 0.62); font-weight: 500; color: var(--text-2); }
.pulse-heart__slot { position: relative; overflow: hidden; }
.pulse-heart__roll { display: flex; flex-direction: column; transition: transform var(--ph-roll) var(--ph-ease-out); }
.pulse-heart__roll > span { display: block; height: 1em; line-height: 1; }

.click-spark { position: relative; display: inline-flex; }
.click-spark__canvas { position: absolute; pointer-events: none; z-index: 2; }

/* ----------------------------------- Counter ---------------------------------- */

.counter { position: relative; display: inline-flex; align-items: baseline; line-height: 1; white-space: nowrap; direction: ltr; }
.counter__row { display: inline-flex; align-items: baseline; user-select: none; }
.counter__digit { position: relative; display: inline-block; line-height: 1.15; text-align: center; font-variant-numeric: tabular-nums; }
.counter__sizer { visibility: hidden; }
.counter__window { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.counter__strip { position: absolute; inset: 0; }
.counter__numeral { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* -------------------------------- Rubber Segment ------------------------------- */

.rubber-segment {
  --rs-track: rgba(255, 255, 255, 0.06); --rs-thumb: linear-gradient(180deg, #3a3449 0%, #2a2537 100%); --rs-ink: var(--text-2); --rs-ink-active: var(--text);
  --rs-radius: 11px; --rs-inset: 3px; --rs-thumb-radius: 8px; --rs-h: 36px; --rs-font: 13.5px; --rs-pad: 14px; --rs-min: 44px; --rs-idle: 1; --rs-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: auto; vertical-align: middle; padding: var(--rs-inset); border-radius: var(--rs-radius); background: var(--rs-track);
  font-family: inherit; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}

.rubber-segment[data-equal] { grid-auto-columns: minmax(0, 1fr); }
.rubber-segment__item {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: calc(var(--rs-h) - var(--rs-inset) * 2); min-width: var(--rs-min); margin: 0; padding: 0 var(--rs-pad);
  border: 0; border-radius: var(--rs-thumb-radius); background: none; color: var(--rs-ink); opacity: var(--rs-idle); font: inherit; font-size: var(--rs-font); font-weight: 500; line-height: 1;
  white-space: nowrap; cursor: pointer; outline: none; transition: opacity 160ms ease, transform 160ms var(--rs-ease-out), color 160ms ease;
}
.rubber-segment__item[aria-checked='true'] { cursor: default; }
.rubber-segment[data-draggable] .rubber-segment__item[aria-checked='true'] { cursor: grab; }
.rubber-segment[data-held], .rubber-segment[data-held] .rubber-segment__item { cursor: grabbing; }
.rubber-segment__item[data-pressed] { transform: scale(0.96); }
.rubber-segment__item:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .rubber-segment__item[aria-checked='false']:hover { color: var(--text); } }
.rubber-segment__thumb {
  position: absolute; inset: var(--rs-inset); display: grid; grid-auto-flow: column; grid-auto-columns: auto; background: var(--rs-thumb); color: var(--rs-ink-active); pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 10px -4px rgba(0, 0, 0, 0.7); transition: opacity 200ms ease;
}
.rubber-segment[data-none] .rubber-segment__thumb { opacity: 0; }
.rubber-segment[data-equal] .rubber-segment__thumb { grid-auto-columns: minmax(0, 1fr); }
.rubber-segment__copy { color: inherit; opacity: 1; font-weight: 600; }

/* ------------------------- Spotlight / Specular / Aurora ------------------------ */

.spotlight-card { position: relative; isolation: isolate; }
.spotlight-card__light, .spotlight-card__edge { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; }
.spotlight-card__light { z-index: -1; }
.spotlight-card__edge {
  z-index: 3; padding: 1px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.specular-button { isolation: isolate; }
.specular-button__light { position: absolute; inset: -24px; z-index: 1; display: block; width: calc(100% + 48px); height: calc(100% + 48px); pointer-events: none; }
.specular-button > :not(canvas) { position: relative; z-index: 2; }

.soft-aurora { overflow: hidden; }
.soft-aurora__canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

/* ------------------------------- Text animations ------------------------------- */

.shiny-text { background-repeat: no-repeat; background-size: 100% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.blur-text__piece { display: inline-block; will-change: transform, filter, opacity; }

/* -------------------------------- Reduced motion ------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .lattice-loader__run { --ll-peak: 0.7; }
  .lattice-loader__run .lattice-loader__cell { animation-delay: 0ms !important; animation-duration: 1400ms !important; }
  .lattice-loader .lattice-loader__mark { transform: none; }
  .lattice-loader .lattice-loader__text, .thought-line__text { filter: none !important; }
  .call-chip[data-status='done'] .call-chip__fill { clip-path: inset(0 0 0 0); transition: background-color 120ms ease; }
  .call-chip__glyph { transform: none !important; filter: none !important; }
  .thought-line__step { transform: none !important; }
  .fuse-button .fuse-button__face { filter: none; }
  .hold-button__fill { clip-path: inset(0); opacity: 0; transition: opacity var(--hb-release) ease; }
  .hold-button__crest { display: none; }
  .hold-button[data-phase='holding'] .hold-button__fill, .hold-button[data-phase='done'] .hold-button__fill { opacity: 1; transition: opacity var(--hb-hold) linear; }
  .swipe-toast__lift { transform: none !important; transition: opacity 200ms ease; }
}
@media (prefers-reduced-transparency: reduce) {
  .swipe-toast__card { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
