/* ApsuaTech design system v3 — glass surfaces, no hairline borders, rationed brand gradient. */
@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

:root,
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #06110d;
  --bg-elev: #0a1a14;
  --surface: rgb(255 255 255 / 0.045);
  --surface-2: rgb(255 255 255 / 0.07);
  --surface-hover: rgb(255 255 255 / 0.1);
  --glass: rgb(16 36 28 / 0.55);
  --glass-strong: rgb(14 30 24 / 0.78);
  --glass-edge: inset 0 1px 0 rgb(255 255 255 / 0.07), inset 0 0 0 1px rgb(255 255 255 / 0.035);
  --border: rgb(255 255 255 / 0.06);
  --border-strong: rgb(255 255 255 / 0.12);
  --text: #eef5f1;
  --text-2: rgb(238 245 241 / 0.76);
  --text-3: rgb(238 245 241 / 0.56);
  --accent: #34d27b;
  --icon-accent: var(--accent);
  --accent-hover: #52e092;
  --accent-ink: #03140b;
  --accent-soft: rgb(52 210 123 / 0.14);
  --brand-red: #e5352b;
  --danger: #ff7b6b;
  --danger-soft: rgb(255 123 107 / 0.13);
  --warning: #f0c35a;
  --warning-soft: rgb(240 195 90 / 0.13);
  --info: #6cc4ff;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.25);
  --shadow-2: 0 10px 30px -8px rgb(0 0 0 / 0.45);
  --shadow-3: 0 30px 80px -20px rgb(0 0 0 / 0.7), 0 8px 24px -8px rgb(0 0 0 / 0.4);
  --ring: 0 0 0 4px rgb(52 210 123 / 0.28);
  --aura-1: rgb(52 210 123 / 0.22);
  --aura-2: rgb(34 195 181 / 0.16);
  --aura-3: rgb(255 122 89 / 0.09);
}
[data-theme='light'] {
  color-scheme: light;
  --bg: #f3f6f2;
  --bg-elev: #fbfcfa;
  --surface: rgb(255 255 255 / 0.7);
  --surface-2: rgb(19 32 26 / 0.05);
  --surface-hover: rgb(19 32 26 / 0.08);
  --glass: rgb(255 255 255 / 0.62);
  --glass-strong: rgb(255 255 255 / 0.82);
  --glass-edge: inset 0 1px 0 rgb(255 255 255 / 0.9), inset 0 0 0 1px rgb(19 32 26 / 0.04);
  --border: rgb(19 32 26 / 0.07);
  --border-strong: rgb(19 32 26 / 0.14);
  --text: #12201a;
  --text-2: rgb(18 32 26 / 0.76);
  --text-3: rgb(18 32 26 / 0.64);
  --accent: #1fae5b;
  --icon-accent: #0b2c20;
  --accent-hover: #189a4f;
  --accent-ink: #ffffff;
  --accent-soft: rgb(31 174 91 / 0.12);
  --danger: #d9543f;
  --danger-soft: rgb(217 84 63 / 0.1);
  --warning: #b8860b;
  --warning-soft: rgb(184 134 11 / 0.1);
  --shadow-1: 0 1px 2px rgb(19 32 26 / 0.06);
  --shadow-2: 0 12px 32px -10px rgb(19 32 26 / 0.16);
  --shadow-3: 0 30px 80px -20px rgb(19 32 26 / 0.25);
  --ring: 0 0 0 4px rgb(31 174 91 / 0.22);
  --aura-1: rgb(52 210 123 / 0.2);
  --aura-2: rgb(34 195 181 / 0.14);
  --aura-3: rgb(255 122 89 / 0.1);
}
:root {
  --font-brand: 'Gilmer', 'Noto Sans', sans-serif;
  --font: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Noto Sans', monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 22px;
  --fs-2xl: clamp(28px, 3.6vw, 40px);
  --fs-3xl: clamp(34px, 6vw, 64px);
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 16px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --grid-gap: var(--s-5);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 160ms;
  --t: 280ms;
  --t-base: 280ms;
  --t-slow: 480ms;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --spring: cubic-bezier(0.34, 1.35, 0.64, 1);
  --ink: var(--text);
  --muted: var(--text-2);
  --faint: var(--text-3);
  --hover: var(--surface-hover);
  --press: var(--surface-2);
  --soft: var(--surface);
  --scrim: rgb(3 10 7 / 0.42);
  --raised: var(--glass-strong);
  --control-h: 40px;
  --blur: blur(28px) saturate(170%);
  --grad: linear-gradient(90deg, #34d27b, #22c3b5 35%, #b6f06a 65%, #ff7a59);
  --grad-conic: conic-gradient(from var(--angle), #34d27b, #22c3b5, #b6f06a, #ff7a59, #34d27b);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html:has(dialog[open]) {
  overflow: hidden;
}
.preload *,
.preload *::before,
.preload *::after {
  transition: none !important;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-new(root) {
  animation: theme-reveal var(--t-slow) var(--ease);
}
@keyframes theme-reveal {
  from {
    clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 0));
  }
  to {
    clip-path: circle(150vmax at var(--vt-x, 50%) var(--vt-y, 0));
  }
}
@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.page-in {
  animation: page-in 400ms var(--ease) both;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
img,
svg {
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: inherit;
}
:focus {
  outline: none;
}
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
::selection {
  background: rgb(52 210 123 / 0.3);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Ambient aura so glass has something to refract */
.aura {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.aura i {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.9;
  animation: aura-drift 26s var(--ease) infinite alternate;
}
.aura i:nth-child(1) {
  background: var(--aura-1);
  top: -25vmax;
  left: -15vmax;
}
.aura i:nth-child(2) {
  background: var(--aura-2);
  bottom: -30vmax;
  right: -20vmax;
  animation-duration: 32s;
  animation-delay: -8s;
}
.aura i:nth-child(3) {
  background: var(--aura-3);
  top: 30%;
  left: 45%;
  width: 36vmax;
  height: 36vmax;
  animation-duration: 38s;
  animation-delay: -16s;
}
@keyframes aura-drift {
  50% {
    transform: translate(8vmax, 6vmax) scale(1.1);
  }
  100% {
    transform: translate(-6vmax, 10vmax) scale(0.95);
  }
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glass-edge), var(--shadow-2);
}
.floating {
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glass-edge), var(--shadow-3);
  border-radius: var(--r-full);
}

/* Gemini-style glowing rim on focus: an animated conic gradient masked to the edge */
.glow {
  position: relative;
  isolation: isolate;
}
.glow::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  pointer-events: none;
  background: var(--grad-conic);
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
  -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);
}
.glow {
  transition: box-shadow var(--t-slow) var(--ease);
}
.glow:focus-within,
.glow.is-busy {
  box-shadow:
    var(--glass-edge),
    0 18px 50px -18px rgb(52 210 123 / 0.55),
    0 0 40px -10px rgb(34 195 181 / 0.35),
    0 10px 60px -24px rgb(255 122 89 / 0.45);
}
.glow:focus-within::before {
  opacity: 0.85;
}
.glow.is-busy::before {
  opacity: 1;
  animation: spin 1.4s linear infinite;
}
@keyframes spin {
  to {
    --angle: 360deg;
  }
}

/* Gradient text sweep while a model is generating */
.shimmer-text {
  background: linear-gradient(
      100deg,
      currentColor 30%,
      #7ff0b0 45%,
      #22c3b5 50%,
      #ffb199 55%,
      currentColor 70%
    )
    0 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: sweep 2.2s linear infinite;
}
@keyframes sweep {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Icons */
.ico {
  width: 18px;
  height: 18px;
  flex: none;
  display: block;
  transition: transform var(--t) var(--ease);
}
.ico-lg .ico,
.ico.ico-lg {
  width: 22px;
  height: 22px;
}
.ico-draw * {
  stroke-dasharray: none;
  stroke-dashoffset: 0;
  animation: ico-draw 0.6s var(--ease) forwards;
}
.ico-draw *:nth-child(2) {
  animation-delay: 0.08s;
}
.ico-draw *:nth-child(3) {
  animation-delay: 0.16s;
}
@keyframes ico-draw {
  0%,
  100% {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }
  0.01%,
  99.99% {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
  }
  45% {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
  }
}
[aria-pressed='true'] > .ico-bookmark {
  fill: currentColor;
}

/* Buttons: pills without outlines */
.btn {
  --h: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--h);
  padding: 0 var(--s-5);
  border-radius: var(--r-full);
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--t-fast),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t),
    opacity var(--t-fast),
    color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover {
  background: var(--surface-hover);
}
.btn:active:not(:disabled) {
  transform: scale(0.96);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 24px -10px rgb(52 210 123 / 0.8);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 10px 30px -8px rgb(52 210 123 / 0.9);
}
.btn-primary:disabled {
  box-shadow: none;
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-soft);
}
.btn-sm {
  --h: 32px;
  padding: 0 var(--s-3);
  font-size: var(--fs-xs);
}
.btn-lg {
  --h: 50px;
  padding: 0 var(--s-6);
  font-size: var(--fs-md);
}
.btn-block {
  width: 100%;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--icon-control-size, 36px);
  height: var(--icon-control-size, 36px);
  flex: none;
  border-radius: var(--r-full);
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
  transition:
    background var(--t-fast),
    color var(--t-fast),
    transform var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn:active:not(:disabled) {
  transform: scale(0.9);
}
.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.icon-btn[aria-pressed='true'],
.icon-btn[aria-expanded='true'] {
  color: var(--icon-accent);
  background: var(--accent-soft);
}
.icon-btn.is-done {
  color: var(--icon-accent);
  background: var(--accent-soft);
}

/* Tooltips (mouse only) */
@media (hover: hover) {
  body:not(.custom-tooltips) [data-tip] {
    position: relative;
  }
  body:not(.custom-tooltips) [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    z-index: 50;
    transform: translate(-50%, 4px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    padding: 8px 8px;
    border-radius: var(--r-full);
    background: var(--glass-strong);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    box-shadow: var(--glass-edge), var(--shadow-2);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    transition:
      opacity var(--t-fast),
      transform var(--t-fast) var(--ease);
  }
  body:not(.custom-tooltips) [data-tip]:hover::after {
    opacity: 1;
    transform: translate(-50%, 0);
    transition-delay: 0.35s;
  }
  [data-tip-pos='bottom']::after {
    bottom: auto;
    top: calc(100% + 10px);
  }
  [data-tip-align='end']::after {
    left: auto;
    right: 0;
    transform: translateY(4px);
  }
  [data-tip-align='end']:hover::after {
    transform: none;
  }
  [data-tip-align='start']::after {
    left: 0;
    transform: translateY(4px);
  }
  [data-tip-align='start']:hover::after {
    transform: none;
  }
}

/* Surfaces */
.card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--glass-edge);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 8px;
  border-radius: 6px;
  font: 600 11px/1 var(--mono);
  color: var(--text-3);
  background: var(--surface-2);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.badge-ok {
  color: var(--accent);
  background: var(--accent-soft);
}
.badge-warn {
  color: var(--warning);
  background: var(--warning-soft);
}
.badge-err {
  color: var(--danger);
  background: var(--danger-soft);
}
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.muted {
  color: var(--text-2);
}
.subtle {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: var(--r-full);
  background: var(--surface-2);
}
.segmented :is(button, a) {
  text-decoration: none;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 0 16px;
  min-height: var(--segment-control-size, 30px);
  border-radius: var(--r-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition:
    background var(--t),
    color var(--t-fast),
    box-shadow var(--t);
  white-space: nowrap;
}
.segmented :is(button, a):hover {
  color: var(--text);
}
.segmented a[aria-current='page'],
.segmented :is(button, a)[aria-selected='true'],
.segmented :is(button, a)[aria-pressed='true'],
.segmented :is(button, a)[aria-checked='true'] {
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: var(--glass-edge), var(--shadow-1);
}

.segmented-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}
.segmented-scroll::-webkit-scrollbar {
  display: none;
}
.segmented-scroll > :is(button, a) {
  flex: 0 0 auto;
}

/* Equal-width segments share one geometry across forms and popovers. */
.segmented-equal {
  display: flex;
  width: 100%;
  min-width: 0;
}
.segmented-equal > :is(button, a) {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  white-space: nowrap;
}

/* Popovers and menus */
.popover {
  margin: 0;
  inset: auto;
  position: fixed;
  border: 0;
  padding: 8px;
  min-width: 200px;
  border-radius: var(--r-lg);
  color: var(--text);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glass-edge), var(--shadow-3);
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  transform-origin: top right;
  transition:
    opacity var(--t-fast) var(--ease-in),
    transform var(--t-fast) var(--ease-in),
    display var(--t-fast) allow-discrete,
    overlay var(--t-fast) allow-discrete;
}
.popover:popover-open {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--t) var(--ease),
    transform var(--t) var(--spring),
    display var(--t) allow-discrete,
    overlay var(--t) allow-discrete;
}
@starting-style {
  .popover:popover-open {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
}
.popover.menu > * {
  transition:
    opacity var(--t) var(--ease),
    transform var(--t) var(--ease);
}
.popover.menu:popover-open > * {
  opacity: 1;
  transform: none;
}
@starting-style {
  .popover.menu:popover-open > * {
    opacity: 0;
    transform: translateY(-4px);
  }
}
.popover.menu > :nth-child(2) {
  transition-delay: 20ms;
}
.popover.menu > :nth-child(3) {
  transition-delay: 40ms;
}
.popover.menu > :nth-child(4) {
  transition-delay: 60ms;
}
.menu {
  display: grid;
  gap: 2px;
}
.popover.menu:not(:popover-open) {
  display: none;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  text-align: left;
  transition:
    background var(--t-fast),
    color var(--t-fast);
}
.menu button:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}
.menu button:disabled,
.popover.menu button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.menu button[aria-checked='true'] {
  color: var(--text);
  background: var(--accent-soft);
}
.studio-menu,
.account-select-menu.studio-menu {
  padding: var(--s-1);
  border-radius: var(--r-xl);
  background: var(--glass);
  box-shadow: var(--glass-edge), var(--shadow-2);
}
.studio-menu.menu > button {
  display: flex;
  width: 100%;
  min-height: 44px;
  padding: 0 calc(var(--s-2) + var(--s-1));
  gap: var(--s-2);
  border-radius: var(--r-full);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text);
}

.studio-menu.menu > button.danger,
.studio-menu.menu > button.danger:hover:not(:disabled),
.studio-menu.menu > button.danger:focus-visible {
  color: var(--danger);
}

/* Fields */
.field {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-4);
  border-radius: var(--r-full);
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  transition:
    background var(--t-fast),
    box-shadow var(--t);
}
.field:hover {
  background: var(--surface-hover);
}
.field::placeholder {
  color: var(--text-3);
  opacity: 1;
}
.field:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* Empty states */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  padding: var(--s-10) var(--s-4);
  text-align: center;
  color: var(--text-2);
}
.empty .empty-ico {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  margin-bottom: var(--s-2);
}
.empty .empty-ico .ico {
  width: 22px;
  height: 22px;
}
.empty strong {
  color: var(--text);
  font-size: var(--fs-md);
}
.empty p {
  margin: 0;
  max-width: 34ch;
  font-size: var(--fs-sm);
}

/* Toasts */
.toasts {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-radius: var(--r-full);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glass-edge), var(--shadow-3);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: toast-in var(--t-slow) var(--ease-spring);
}
.toast.is-leaving {
  animation: toast-out var(--t) var(--ease) forwards;
}
.toast > span {
  flex: 1;
}
.toast-success .ico:first-child {
  color: var(--icon-accent);
}
.toast-error .ico:first-child {
  color: var(--danger);
}
.toast-info .ico:first-child {
  color: var(--info);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* Loading: brand-gradient shimmer */
.skeleton {
  border-radius: var(--r-full);
  background: linear-gradient(
      90deg,
      var(--surface-2) 0%,
      rgb(52 210 123 / 0.22) 35%,
      rgb(34 195 181 / 0.2) 50%,
      rgb(255 122 89 / 0.12) 62%,
      var(--surface-2) 80%
    )
    0 0 / 250% 100%;
  animation: sweep 1.6s linear infinite;
  color: transparent !important;
}

/* Entrance motion */
.rise {
  animation: rise var(--t-slow) var(--ease) both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.stagger > * {
  animation: rise var(--t-slow) var(--ease) both;
}
.stagger > *:nth-child(2) {
  animation-delay: 50ms;
}
.stagger > *:nth-child(3) {
  animation-delay: 100ms;
}
.stagger > *:nth-child(4) {
  animation-delay: 150ms;
}
.stagger > *:nth-child(5) {
  animation-delay: 200ms;
}
.stagger > *:nth-child(n + 6) {
  animation-delay: 250ms;
}

/* Dialog */
.dialog {
  border: 0;
  border-radius: var(--r-xl);
  padding: 0;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--text);
  box-shadow: var(--glass-edge), var(--shadow-3);
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 48px);
}
.dialog[open] {
  animation: dialog-in var(--t-slow) var(--ease-spring);
}
.dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .ico-draw * {
    stroke-dashoffset: 0;
  }
  .aura i {
    animation: none;
  }
  .shimmer-text {
    -webkit-text-fill-color: currentColor;
    background: none;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .glass,
  .floating,
  .card,
  .popover,
  .toast,
  .dialog {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--bg-elev);
  }
}

/* iOS focuses small text fields by zooming: keep editable text legible. */
@media (max-width: 859px) {
  html
    body
    input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='button']):not(
      [type='submit']
    ),
  html body :is(textarea, select, [contenteditable='true']) {
    font-size: max(16px, 1rem);
  }
}

/* Shared horizontal overflow: JS supplies continuous edge widths. */
.scroll-fade {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    #000 var(--fade-left, 0px),
    #000 calc(100% - var(--fade-right, 0px)),
    transparent
  );
  mask-image: linear-gradient(
    to right,
    transparent,
    #000 var(--fade-left, 0px),
    #000 calc(100% - var(--fade-right, 0px)),
    transparent
  );
}
.scroll-fade-contents {
  display: flex;
  align-items: center;
  gap: inherit;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.scroll-fade-contents::-webkit-scrollbar {
  display: none;
}

/* Collection controls: books, vocabulary and future searchable lists. */
.collection-toolbar {
  --control-h: 40px;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  width: 100%;
}
.collection-search {
  flex: 1;
  min-width: 0;
}
.collection-search .field {
  min-height: var(--control-h);
}
.collection-create {
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .collection-toolbar {
    --control-h: 44px;
  }
  .collection-create > span:not(.anim-ico) {
    display: none;
  }
  .collection-create {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex: 0 0 44px;
    padding: 0;
  }
}

/* Native checkbox state with one shared ApsuaTech appearance. */
.checkbox-control {
  display: inline-grid;
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: middle;
}
.checkbox-control > input {
  appearance: none;
  grid-area: 1 / 1;
  margin: 0;
  padding: 0;
  min-height: 0;
  width: 18px;
  height: 18px;
  border: 1px solid var(--muted);
  border-radius: var(--r-full);
  background: transparent;
  cursor: pointer;
}
.checkbox-control > input:checked {
  border-color: var(--accent);
  background: var(--accent);
}
.checkbox-control-mark {
  display: grid;
  place-items: center;
  grid-area: 1 / 1;
  color: white;
  pointer-events: none;
  visibility: hidden;
}
.checkbox-control-mark .ico {
  width: 12px;
  height: 12px;
}
.checkbox-control > input:checked + .checkbox-control-mark {
  visibility: visible;
}
.checkbox-control > input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.checkbox-control:has(input:disabled) {
  opacity: 0.45;
}
.checkbox-control > input:disabled {
  cursor: default;
}
