.toast-layer {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  display: grid;
  justify-items: end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid rgba(53, 102, 214, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: #244a9f;
  padding: 11px 13px;
  font-weight: 750;
  backdrop-filter: blur(12px);
  animation: toast-in 160ms ease-out;
}

.toast.error {
  border-color: rgba(217, 87, 61, 0.22);
  color: #9d2b18;
}

.pull-refresh-indicator {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: calc(var(--z-mobile-command) + 2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 999px;
  background: rgba(20, 30, 44, 0.9);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
  color: #ffffff;
  padding: 9px 13px;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50%, calc(-72px + var(--pull-refresh-distance, 0px)), 0) scale(calc(0.92 + (var(--pull-refresh-progress, 0) * 0.08)));
  transition:
    opacity 130ms ease,
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
  -webkit-backdrop-filter: blur(16px) saturate(1.14);
  backdrop-filter: blur(16px) saturate(1.14);
  will-change: opacity, transform;
}

.pull-refresh-indicator.is-visible {
  opacity: 1;
}

.pull-refresh-indicator.is-ready {
  border-color: rgba(149, 232, 190, 0.76);
  background: rgba(28, 93, 70, 0.92);
}

.pull-refresh-indicator.is-refreshing {
  transform: translate3d(-50%, 0, 0) scale(1);
}

.pull-refresh-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  transform: rotate(calc(var(--pull-refresh-progress, 0) * 210deg));
}

.pull-refresh-icon .icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

.pull-refresh-indicator.is-refreshing .pull-refresh-icon {
  animation: pull-refresh-spin 760ms linear infinite;
}

.pull-refresh-label {
  white-space: nowrap;
}

.touch-debug-layer {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 1000;
  width: min(520px, calc(100vw - 20px));
  max-height: min(46vh, 360px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(24, 33, 47, 0.28);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.34);
  color: #e5edf7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.touch-debug-head {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(229, 237, 247, 0.16);
  padding: 7px;
}

.touch-debug-head strong {
  margin-right: auto;
  color: white;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.touch-debug-head button {
  border: 1px solid rgba(229, 237, 247, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #e5edf7;
  padding: 4px 6px;
  font: inherit;
}

.touch-debug-log {
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 45;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: var(--origin-y);
  left: var(--origin-x);
  display: block;
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) rotate(0deg) scale(0.36);
  animation: confetti-burst var(--duration) cubic-bezier(0.18, 0.82, 0.18, 1) var(--delay) forwards;
}

.confetti-piece.ribbon {
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.28);
}

.confetti-piece.sparkle {
  border-radius: 999px;
  box-shadow:
    0 0 12px currentColor,
    0 0 24px rgba(255, 255, 255, 0.44);
}

.confetti-piece.firework-trail {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  box-shadow:
    0 0 14px currentColor,
    0 0 28px rgba(255, 255, 255, 0.5);
  animation: firework-launch var(--duration) cubic-bezier(0.19, 0.92, 0.22, 1) var(--delay) forwards;
}

.confetti-piece.firework-spark {
  border-radius: 999px;
  box-shadow:
    0 0 12px currentColor,
    0 0 26px rgba(255, 255, 255, 0.5);
  animation: firework-bloom var(--duration) cubic-bezier(0.16, 0.78, 0.22, 1) var(--delay) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pull-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes confetti-burst {
  0% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) rotate(0deg) scale(0.36);
  }

  8% {
    opacity: 1;
  }

  42% {
    opacity: 0.98;
    transform: translate3d(var(--mid-x), var(--mid-y), 0) rotate(var(--mid-spin)) scale(var(--scale, 1));
  }

  to {
    opacity: 0;
    transform: translate3d(var(--tx), calc(var(--ty) + var(--fall)), 0) rotate(var(--spin)) scale(0.2);
  }
}

@keyframes firework-launch {
  0% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(0.42);
  }

  12% {
    opacity: 1;
  }

  82% {
    opacity: 1;
    transform: translate3d(var(--tx), var(--ty), 0) scale(1.2);
  }

  to {
    opacity: 0;
    transform: translate3d(var(--tx), var(--ty), 0) scale(0.24);
  }
}

@keyframes firework-bloom {
  0% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(0.24);
  }

  10% {
    opacity: 1;
  }

  60% {
    opacity: 0.96;
    transform: translate3d(var(--tx), var(--ty), 0) scale(var(--scale, 1));
  }

  to {
    opacity: 0;
    transform: translate3d(var(--tx), calc(var(--ty) + var(--fall)), 0) scale(0.14);
  }
}

@keyframes lock-ready-vibrate {
  0%,
  100% {
    transform: rotate(0deg) translateX(0);
  }

  18% {
    transform: rotate(-15deg) translateX(-2px);
  }

  36% {
    transform: rotate(14deg) translateX(2px);
  }

  54% {
    transform: rotate(-11deg) translateX(-2px);
  }

  72% {
    transform: rotate(9deg) translateX(2px);
  }
}

@keyframes lock-button-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  18% {
    transform: translate3d(-2px, -1px, 0) rotate(-1.6deg);
  }

  36% {
    transform: translate3d(2px, 1px, 0) rotate(1.4deg);
  }

  54% {
    transform: translate3d(-1px, 1px, 0) rotate(-1.1deg);
  }

  72% {
    transform: translate3d(1px, -1px, 0) rotate(0.9deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .er-dialog,
  .er-dialog-backdrop {
    animation: none;
  }

  .icon-btn.strong[data-action="lock-inline"]:not(:disabled):hover,
  .icon-btn.strong[data-action="lock-inline"]:not(:disabled):focus-visible,
  .icon-btn.strong[data-action="lock-inline"]:not(:disabled):hover .icon,
  .icon-btn.strong[data-action="lock-inline"]:not(:disabled):focus-visible .icon {
    animation: none;
  }
}
