:root {
  color-scheme: light;
  --blue: #0c44ac;
  --blue-hover: #0a3a94;
  --ink: #1d2939;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --line: rgba(226, 232, 240, 0.9);
  --danger: #dc2626;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-x: hidden;
  background: #0c44ac;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
}

button, a { -webkit-tap-highlight-color: transparent; }

a { color: var(--blue); }

.animated-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  contain: paint;
  background: #0c44ac;
}

.aurora-shift {
  position: absolute;
  inset: -28%;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.45) 26%, transparent 52%),
    radial-gradient(ellipse at 18% 108%, rgba(211, 47, 47, 0.7) 0%, rgba(211, 47, 47, 0.25) 34%, transparent 62%),
    radial-gradient(ellipse at 82% 42%, rgba(10, 58, 160, 0.45) 0%, transparent 48%),
    linear-gradient(
      195deg,
      rgb(255, 255, 255) 0%,
      rgb(244, 247, 255) 16%,
      rgb(186, 208, 245) 30%,
      rgb(74, 122, 204) 42%,
      rgb(12, 68, 172) 52%,
      rgb(12, 68, 172) 62%,
      rgb(176, 62, 98) 76%,
      rgb(211, 47, 47) 88%,
      rgb(211, 47, 47) 100%
    );
  animation: ambientDrift 28s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes ambientDrift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-2.5%, 3%, 0) scale(1.06); }
  100% { transform: translate3d(2.5%, -2%, 0) scale(1.04); }
}

.stage {
  position: relative;
  z-index: 1;
  isolation: isolate;
  width: 100%;
  max-width: 450px;
  margin-top: auto;
  margin-bottom: auto;
}

.stage.mode-register { max-width: 460px; }

.stage.wide { max-width: 880px; }

.glass-card {
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 24px 60px -12px rgba(12, 38, 79, 0.12),
    0 8px 24px -6px rgba(0, 0, 0, 0.04),
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 1px 2px 0 rgba(0, 0, 0, 0.02);
  border-radius: 28px;
  padding: 28px;
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.mode-register .topbar { margin-bottom: 24px; }

.back, .back-spacer {
  width: 36px;
  height: 36px;
  flex: none;
}

.back {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--slate-600);
  border: 1px solid rgba(226, 232, 240, 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.back:hover { background: #fff; color: var(--slate-900); transform: scale(1.05); }

.back:active { transform: scale(0.95); }

.lang {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.8);
  font-size: 11px;
  font-weight: 500;
  color: var(--slate-600);
}

.lang button {
  border: 0;
  background: transparent;
  color: var(--slate-500);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.lang button:hover { color: #1e293b; }

.lang button.is-active {
  background: #fff;
  color: var(--slate-900);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.heading { text-align: center; margin-bottom: 28px; }

.brand-logo {
  display: block;
  width: min(280px, 78%);
  height: auto;
  margin: 0 auto 8px;
}

.heading h1, h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--slate-900);
}

.heading p {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--slate-500);
  overflow-wrap: anywhere;
}

h2 {
  margin: 22px 0 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--slate-900);
}

.stack h2:first-child { margin-top: 0; }

.form { display: flex; flex-direction: column; }

.form-login { gap: 20px; }

.form-register { gap: 18px; }

.label, .stack label, .check {
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-700);
}

.label { display: block; margin-bottom: 6px; }

.form-register .label, .form-register .label-row { margin-bottom: 4px; }

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.label-row .label { margin-bottom: 0; }

.aside {
  font-size: 11px;
  font-weight: 400;
  color: var(--slate-400);
  white-space: nowrap;
}

.optional { color: var(--slate-400); font-weight: 400; }

.forgot-link, .switch a, .text-link, .prose a, .error a, .ok a, .hint a, .terms a {
  color: var(--blue);
  font-weight: 500;
  text-decoration: none;
}

.forgot-link { font-size: 12px; font-weight: 500; }

.switch a { margin-left: 4px; font-weight: 500; }

.forgot-link:hover, .switch a:hover, .text-link:hover, .prose a:hover, .error a:hover, .ok a:hover, .hint a:hover, .terms a:hover {
  text-decoration: underline;
}

.field { position: relative; }

.apple-input, .stack input, .stack select, .stack textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.25;
  color: var(--slate-900);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition:
    background 0.2s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.apple-input::placeholder, .stack input::placeholder, .stack textarea::placeholder { color: var(--slate-400); }

.apple-input:focus, .stack input:focus, .stack select:focus, .stack textarea:focus {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(12, 68, 172, 0.12);
}

.with-icon .apple-input { padding-right: 42px; }

.invite-input {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.invite-input::placeholder { letter-spacing: 0.05em; }

.field-icon, .field-action {
  position: absolute;
  inset-block: 0;
  right: 0;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-400);
}

.field-action {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.field-action:hover { color: var(--slate-600); }

.field-action.spark:hover { color: var(--blue); }

.icon { width: 16px; height: 16px; display: block; }

.remember, .terms, .check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.remember { align-items: center; margin-top: 4px; font-size: 13px; font-weight: 400; color: var(--slate-600); }

.terms { margin-top: 4px; gap: 10px; font-size: 12.5px; line-height: 1.375; font-weight: 400; color: var(--slate-600); }

.terms p, .check span { margin: 0; }

.terms label { font-weight: 400; cursor: pointer; }

.remember input, .terms input, .check input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--blue);
  flex: none;
  padding: 0;
  box-shadow: none;
}

.remember input { margin-top: 0; }

.submit { margin-top: 8px; }

.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
}

.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.form .primary, .stack-buttons .primary, .stack-buttons .secondary { width: 100%; }

.primary:hover:not(:disabled) { background: var(--blue-hover); box-shadow: 0 4px 10px rgba(12, 68, 172, 0.2); }

.primary:active:not(:disabled), .secondary:active, .social-btn:active { transform: scale(0.99); }

.primary:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

.primary:disabled[data-busy="1"] {
  background: var(--blue);
  color: #fff;
  cursor: wait;
  opacity: 0.75;
}

.secondary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.secondary, .social-btn {
  background: #fff;
  color: var(--slate-700);
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.secondary:hover, .social-btn:hover { background: #f8fafc; border-color: #cbd5e1; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0;
  color: var(--slate-500);
  font-size: 12px;
  font-weight: 500;
}

.mode-register .divider { margin: 24px 0; }

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(226, 232, 240, 0.7);
}

.social { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  gap: 10px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: #fff;
  color: var(--slate-700);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
}

.social-btn .icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.switch {
  margin: 32px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  color: var(--slate-500);
}

.mode-register .switch { margin-top: 24px; }

.footnote {
  margin: 20px 8px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.625;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.25);
}

.mode-register .footnote { margin-top: 16px; }

.error, .ok, .hint { margin: 0; font-size: 13px; font-weight: 500; line-height: 1.45; }

.error { color: var(--danger); }

.ok { color: var(--blue); }

.hint, .muted { color: var(--slate-500); font-weight: 400; }

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

.stack + .stack { margin-top: 22px; }

.stack .label { margin-bottom: 0; }

.stack label.check { display: flex; align-items: center; gap: 8px; }

.notice-body { display: grid; gap: 16px; }

.notice-body > .primary,
.notice-body > .secondary,
.notice-body .stack-buttons .primary,
.notice-body .stack-buttons .secondary { width: 100%; }

.stack label { display: grid; gap: 4px; }

.stack select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.stack textarea { min-height: 180px; resize: vertical; line-height: 1.45; }

.grid-2 { display: grid; gap: 12px; }

.actions, .stack-buttons { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.stack-buttons { display: grid; justify-items: center; }

.text-link { font-size: 13px; font-weight: 500; }

.banner {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 248, 238, 0.92);
  border: 1px solid #ead7b4;
  color: var(--slate-700);
  font-size: 13px;
}

.banner p { margin: 0 0 10px; }

.meta { display: grid; gap: 8px; margin: 0; }

.meta div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }

.meta dt { color: var(--slate-500); font-weight: 500; }

.meta dd { margin: 0; color: var(--slate-900); font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 500;
}

.pill.ready { color: var(--blue); border-color: rgba(12, 68, 172, 0.25); background: rgba(12, 68, 172, 0.06); }

.prose p { margin: 0 0 12px; font-size: 14px; line-height: 1.55; color: var(--slate-700); }

.prose p:last-child { margin-bottom: 0; }

.tokens { display: flex; flex-wrap: wrap; gap: 8px; }

.tokens button, .inline {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--slate-700);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.tokens button:hover, .inline:hover { border-color: var(--blue); color: var(--blue); }

.preview {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.8);
  color: var(--ink);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.outbox { display: grid; gap: 12px; }

.outbox article { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid rgba(226, 232, 240, 0.9); }

.provider-slot {
  position: absolute;
  width: 320px;
  height: 44px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.apple-input:focus-visible, .stack input:focus-visible, .stack select:focus-visible, .stack textarea:focus-visible {
  outline: none;
}

@media (min-width: 640px) {
  body {
    padding:
      max(24px, env(safe-area-inset-top))
      max(24px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
  }

  .glass-card { padding: 36px; }

  .heading h1, h1 { font-size: 26px; }
}

@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
  body {
    padding-top: max(32px, env(safe-area-inset-top));
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 639px) {
  .actions .primary, .actions .secondary { width: 100%; }
}

@media (max-width: 430px) {
  .footnote { font-size: 10px; margin-left: 0; margin-right: 0; }
}

@media (max-width: 389px) {
  .social { grid-template-columns: 1fr; }

  .glass-card { border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .aurora-shift { animation: none; }
}

