:root {
  color-scheme: dark;

  --bg: oklch(0.152 0.020 242);
  --surface: oklch(0.205 0.026 242);
  --surface-2: oklch(0.245 0.028 242);
  --surface-3: oklch(0.295 0.030 242);
  --line: oklch(0.335 0.030 242);
  --line-soft: oklch(0.285 0.026 242);

  --text: oklch(0.965 0.010 220);
  --text-2: oklch(0.815 0.016 235);
  --text-3: oklch(0.685 0.022 235);

  --accent: oklch(0.80 0.135 218);
  --accent-bright: oklch(0.885 0.125 212);
  --accent-deep: oklch(0.675 0.135 226);
  --accent-ink: oklch(0.215 0.055 235);
  --accent-soft: oklch(0.80 0.135 218 / 0.14);

  --focus: oklch(0.88 0.08 222);

  --danger: oklch(0.745 0.145 25);
  --danger-soft: oklch(0.745 0.145 25 / 0.13);
  --success: oklch(0.82 0.13 165);
  --success-soft: oklch(0.82 0.13 165 / 0.13);
  --warn: oklch(0.83 0.12 78);
  --warn-soft: oklch(0.83 0.12 78 / 0.13);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --radius: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(74px, 9vh, 104px) clamp(16px, 3.5vw, 56px) clamp(16px, 3.5vw, 56px);
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crystal {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  object-fit: contain;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -20%, oklch(0.27 0.035 242) 0%, transparent 60%),
    linear-gradient(180deg, oklch(0.175 0.02 242), var(--bg) 70%);
}

.backdrop__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}

.backdrop__glow--crystal {
  width: 46rem;
  height: 46rem;
  top: -18rem;
  right: -14rem;
  background: radial-gradient(circle, oklch(0.72 0.13 215 / 0.45), transparent 68%);
}

.backdrop__glow--deep {
  width: 40rem;
  height: 40rem;
  bottom: -20rem;
  left: -14rem;
  background: radial-gradient(circle, oklch(0.55 0.09 248 / 0.32), transparent 68%);
}

.backdrop__grain {
  position: absolute;
  inset: -50%;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  width: 100%;
  max-width: 640px;
  display: grid;
  gap: clamp(30px, 5vw, 48px);
}

.masthead {
  position: fixed;
  top: clamp(16px, 3vw, 28px);
  left: clamp(16px, 3vw, 28px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  z-index: 3;
}

.masthead__seal {
  display: block;
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 5px 16px oklch(0.04 0.02 250 / 0.75));
}

.masthead__name {
  font-weight: 650;
  letter-spacing: 0.005em;
}

.session {
  position: fixed;
  top: clamp(16px, 3vw, 28px);
  right: clamp(16px, 3vw, 28px);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, calc(100vw - 220px));
  min-height: 36px;
  padding: 0 4px 0 12px;
  color: var(--text);
  background: oklch(0.16 0.02 242 / 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.session__account {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.brand__title {
  margin: 0 0 14px;
  font-size: clamp(1.9rem, 1.35rem + 2.2vw, 2.5rem);
  line-height: 1.08;
  font-weight: 660;
  letter-spacing: -0.02em;
}

.brand__lead {
  margin: 0 0 26px;
  max-width: 60ch;
  color: var(--text-2);
}

.facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.fact {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: var(--text-2);
  font-size: 14.5px;
}

.fact .icon {
  margin-top: 2px;
  font-size: 18px;
  color: var(--text-3);
}

.panel {
  position: relative;
  border-radius: var(--radius);
  background: linear-gradient(180deg, oklch(0.23 0.026 242), oklch(0.19 0.022 242));
  border: 1px solid var(--line-soft);
  box-shadow:
    0 40px 90px -50px oklch(0.03 0.02 258 / 0.95),
    inset 0 1px 0 oklch(1 0 0 / 0.06);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset-inline: 12%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, oklch(0.80 0.135 218 / 0.5), transparent);
}

.flow__head {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

.steps__item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.steps__item::before {
  content: "";
  position: absolute;
  top: 13px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--line);
  transition: background 0.3s var(--ease);
}

.steps__item:first-child::before {
  display: none;
}

.steps__item.is-active::before,
.steps__item.is-done::before {
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
}

.steps__dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: color 0.3s, background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.steps__item.is-active .steps__dot {
  color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.steps__item.is-done .steps__dot {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: oklch(0.80 0.135 218 / 0.35);
}

.steps__check {
  display: none;
  font-size: 14px;
}

.steps__item.is-done .steps__num {
  display: none;
}

.steps__item.is-done .steps__check {
  display: block;
}

.steps__label {
  font-size: 12.5px;
  font-weight: 520;
  color: var(--text-3);
  transition: color 0.3s;
}

.steps__item.is-active .steps__label {
  color: var(--text);
}

.notice {
  margin: 0;
  padding: 14px 28px;
  font-size: 14.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border-bottom: 1px solid oklch(0.745 0.145 25 / 0.24);
}

.flow__body {
  padding: clamp(24px, 4vw, 34px) 28px clamp(26px, 4vw, 36px);
}

.panel-step {
  display: none;
}

#flow[data-step="loading"] [data-panel="loading"],
#flow[data-step="auth"] [data-panel="auth"],
#flow[data-step="period"] [data-panel="period"],
#flow[data-step="review"] [data-panel="review"],
#flow[data-step="done"] [data-panel="done"],
#flow[data-step="blocked"] [data-panel="blocked"] {
  display: block;
}

#flow[data-step="loading"] .flow__head,
#flow[data-step="done"] .flow__head,
#flow[data-step="blocked"] .flow__head {
  display: none;
}

.step__title {
  margin: 0 0 10px;
  font-size: clamp(1.4rem, 1.1rem + 1.1vw, 1.75rem);
  font-weight: 640;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.step__title:focus {
  outline: none;
}

.step__lead {
  margin: 0 0 22px;
  color: var(--text-2);
  max-width: 52ch;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.15s var(--ease),
    background-color 0.18s,
    border-color 0.18s,
    box-shadow 0.18s,
    color 0.18s,
    opacity 0.18s;
}

.btn .icon {
  font-size: 18px;
}

.btn--wide {
  width: 100%;
}

.btn--primary {
  color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep));
  box-shadow:
    0 16px 34px -18px oklch(0.80 0.135 218 / 0.9),
    inset 0 1px 0 oklch(1 0 0 / 0.5);
}

.btn--ghost {
  color: var(--text);
  background: oklch(1 0 0 / 0.04);
  border-color: var(--line);
}

.session .logout {
  flex: none;
  min-height: 28px;
  padding: 0 10px;
  color: var(--text-2);
  background: transparent;
  border-color: transparent;
}

.btn:active {
  transform: scale(0.985);
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.timeline {
  position: relative;
  height: 62px;
  margin: 10px 0 4px;
}

.timeline__rail {
  position: absolute;
  top: 20px;
  left: 11px;
  right: 11px;
  height: 12px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: oklch(0.16 0.02 242);
  box-shadow: inset 0 1px 3px oklch(0 0 0 / 0.6), inset 0 0 0 1px var(--line-soft);
  transition: box-shadow 0.2s;
}

.timeline__band {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 55%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent-bright));
  box-shadow: 0 0 24px -6px oklch(0.80 0.135 218 / 0.85);
  transition: left 0.16s var(--ease), width 0.16s var(--ease);
}

.timeline__input {
  position: absolute;
  top: 20px;
  left: 0;
  width: 100%;
  height: 40px;
  margin: 0;
  transform: translateY(-50%);
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: grab;
  z-index: 2;
}

.timeline__input:active {
  cursor: grabbing;
}

.timeline__input:focus-visible {
  outline: none;
}

.timeline:has(.timeline__input:focus-visible) .timeline__rail {
  box-shadow: inset 0 1px 3px oklch(0 0 0 / 0.6), 0 0 0 2px var(--focus);
}

.timeline__input::-webkit-slider-runnable-track {
  height: 40px;
  background: transparent;
  border: 0;
}

.timeline__input::-moz-range-track {
  height: 40px;
  background: transparent;
  border: 0;
}

.timeline__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: 9px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep));
  border: 2px solid oklch(0.98 0.02 215);
  box-shadow: 0 6px 18px -6px oklch(0.80 0.135 218 / 0.95);
  transition: box-shadow 0.15s;
}

.timeline__input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep));
  border: 2px solid oklch(0.98 0.02 215);
  box-shadow: 0 6px 18px -6px oklch(0.80 0.135 218 / 0.95);
}

.timeline__months {
  position: absolute;
  top: 42px;
  left: 11px;
  right: 11px;
  height: 16px;
}

.timeline__month {
  position: absolute;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin: 14px 0 22px;
}

.readout__cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 0.028);
  border: 1px solid var(--line-soft);
}

.readout__label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.readout__value {
  font-family: var(--font-mono);
  font-size: 15.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.readout__value--muted {
  color: var(--text-2);
  font-size: 14px;
}

.callout {
  margin: 0 0 18px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
}

.callout--warn {
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid oklch(0.83 0.12 78 / 0.24);
}

.amount {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 6px 0 6px;
}

.amount .crystal {
  width: 36px;
  height: 36px;
  align-self: center;
  filter: drop-shadow(0 4px 16px oklch(0.80 0.135 218 / 0.55));
}

.amount__value {
  font-family: var(--font-mono);
  font-size: clamp(2.5rem, 1.7rem + 3vw, 3.6rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-bright);
}

.amount__unit {
  font-size: 15px;
  color: var(--text-2);
}

.amount--compact .crystal {
  width: 28px;
  height: 28px;
}

.amount__caption {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--text-3);
}

.risk {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  border: 1px solid oklch(0.745 0.145 25 / 0.3);
}

.risk .icon {
  margin-top: 1px;
  font-size: 19px;
  color: var(--danger);
}

.risk p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: oklch(0.91 0.05 28);
}

.ack {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 0 0 6px;
  cursor: pointer;
  font-size: 14.5px;
  color: var(--text);
  min-height: 44px;
}

.ack input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.ack__box {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  margin-top: 1px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: oklch(1 0 0 / 0.03);
  color: var(--accent-ink);
  transition: background 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.ack__box .icon {
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.14s;
}

.ack input:checked + .ack__box {
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent;
}

.ack input:checked + .ack__box .icon {
  opacity: 1;
}

.ack input:focus-visible + .ack__box {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.ack.is-invalid {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  color: var(--danger);
}

.ack.is-invalid .ack__box {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.ack.is-invalid .ack__text {
  color: var(--danger);
}

.field-error {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.actions .btn--primary {
  flex: 1;
}

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.result__seal {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: 14px;
  font-size: 30px;
}

.result__seal[data-tone="ok"] {
  color: var(--success);
  background: var(--success-soft);
  box-shadow: 0 0 0 1px oklch(0.815 0.13 158 / 0.3), 0 0 40px -8px oklch(0.815 0.13 158 / 0.5);
}

.result__seal[data-tone="warn"] {
  color: var(--warn);
  background: var(--warn-soft);
  box-shadow: 0 0 0 1px oklch(0.83 0.12 78 / 0.3), 0 0 40px -8px oklch(0.83 0.12 78 / 0.5);
}

.result .step__title {
  margin-bottom: 8px;
}

.result__message {
  margin: 0 0 4px;
  max-width: 46ch;
  color: var(--text-2);
}

.result .amount {
  justify-content: center;
  margin-top: 22px;
}

.result .amount__caption {
  margin-bottom: 20px;
}

.skeleton {
  display: grid;
  gap: 14px;
}

.skeleton__line,
.skeleton__block {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, oklch(0.24 0.024 242), oklch(0.29 0.026 242), oklch(0.24 0.024 242));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton__line {
  height: 12px;
}

.skeleton__line--sm {
  width: 34%;
}

.skeleton__line--lg {
  width: 72%;
  height: 22px;
}

.skeleton__line--md {
  width: 54%;
}

.skeleton__block {
  height: 96px;
  margin-top: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  border: 2px solid oklch(0.215 0.055 235 / 0.35);
  border-top-color: var(--accent-ink);
  animation: spin 0.8s linear infinite;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  15% {
    transform: translateX(-7px);
  }
  30% {
    transform: translateX(6px);
  }
  45% {
    transform: translateX(-4px);
  }
  60% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
}

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

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (hover: hover) {
  .btn--primary:hover {
    transform: translateY(-1px);
    box-shadow:
      0 20px 40px -18px oklch(0.80 0.135 218 / 1),
      inset 0 1px 0 oklch(1 0 0 / 0.5);
  }

  .btn--ghost:hover {
    background: oklch(1 0 0 / 0.07);
    border-color: var(--line);
  }

  .ack:hover .ack__box {
    border-color: var(--accent-deep);
  }
}

@media (max-width: 560px) {
  .masthead__name {
    display: none;
  }

  .session {
    max-width: calc(100vw - 88px);
  }

  .flow__head {
    padding: 20px 20px 16px;
  }

  .flow__body {
    padding: 22px 20px 26px;
  }

  .notice {
    padding: 13px 20px;
  }

  .readout {
    grid-template-columns: 1fr 1fr;
  }

  .readout__cell:last-child {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .steps__label {
    font-size: 11.5px;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
  }
}

@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;
  }
}

@media (prefers-reduced-motion: no-preference) {
  #flow[data-step="auth"] [data-panel="auth"],
  #flow[data-step="period"] [data-panel="period"],
  #flow[data-step="review"] [data-panel="review"],
  #flow[data-step="done"] [data-panel="done"],
  #flow[data-step="blocked"] [data-panel="blocked"] {
    animation: rise 0.4s var(--ease) both;
  }
}
