/* ==========================================================================
   Quants Brain · "Synapse" design system
   Ink-black surfaces, one signature gradient (ion → iris → violet), amber sparks for
   moments that matter, green/red reserved for money. Geist for UI, Instrument Serif
   italics for voice, Geist Mono for every number.
   ========================================================================== */

@property --angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

:root {
  color-scheme: dark;
  --bg: #04050a;
  --bg-2: #070912;
  --surface: rgba(15, 18, 30, 0.72);
  --surface-solid: #0b0e18;
  --surface-2: #10131f;
  --surface-3: #161a2a;
  --line: rgba(148, 160, 214, 0.1);
  --line-2: rgba(148, 160, 214, 0.17);
  --line-3: rgba(148, 160, 214, 0.28);
  --text: #eef0f8;
  --text-2: #a5abc3;
  --text-3: #6e7491;
  --ion: #3fc8ff;
  --iris: #7b6cff;
  --violet: #b26bff;
  --spark: #ffb547;
  --up: #2ee59d;
  --down: #ff5a7a;
  --warn: #ffb547;
  --info: #3fc8ff;
  --grad: linear-gradient(120deg, #3fc8ff 0%, #7b6cff 52%, #b26bff 100%);
  --grad-text: linear-gradient(100deg, #8fe3ff 0%, #a89dff 45%, #d9a8ff 100%);
  --grad-soft: linear-gradient(120deg, rgba(63, 200, 255, 0.14), rgba(123, 108, 255, 0.14) 52%, rgba(178, 107, 255, 0.14));
  --ring: 0 0 0 1px rgba(123, 108, 255, 0.55), 0 0 0 4px rgba(123, 108, 255, 0.18);
  --shadow-1: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-2: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 16px 40px -16px rgba(0, 0, 0, 0.75);
  --shadow-3: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 40px 90px -24px rgba(0, 0, 0, 0.9);
  --r-xs: 8px; --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 28px; --r-full: 999px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --gutter: clamp(16px, 4vw, 40px);
  --max: 1200px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f5fa;
  --bg-2: #eceef6;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-solid: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef0f7;
  --line: rgba(22, 26, 52, 0.08);
  --line-2: rgba(22, 26, 52, 0.13);
  --line-3: rgba(22, 26, 52, 0.22);
  --text: #0b0e1b;
  --text-2: #4a5170;
  --text-3: #7c829c;
  --ion: #0b9fd8;
  --iris: #5b4ce8;
  --violet: #8f47e6;
  --spark: #d98a12;
  --up: #0c9f68;
  --down: #e0344f;
  --warn: #c98010;
  --grad-text: linear-gradient(100deg, #0b8fc4 0%, #5b4ce8 50%, #8f47e6 100%);
  --shadow-1: 0 1px 2px rgba(22, 26, 52, 0.06);
  --shadow-2: 0 12px 32px -14px rgba(22, 26, 52, 0.18);
  --shadow-3: 0 30px 70px -24px rgba(22, 26, 52, 0.28);
}

/* ------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv11';
}
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: rgba(123, 108, 255, 0.4); color: #fff; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono, .num { font-family: var(--font-mono); font-feature-settings: 'tnum', 'zero'; letter-spacing: -0.01em; }
.serif { font-family: var(--font-display); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.grad-text { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* Film grain over everything: kills gradient banding and adds tooth. */
.grain::after {
  content: ''; position: fixed; inset: -50%; z-index: 1000; pointer-events: none; opacity: 0.045;
  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='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .8 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); } 60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } }

/* ------------------------------------------------------------ logo */

.qb-logo { display: inline-flex; align-items: center; gap: 11px; font-weight: 650; letter-spacing: 0.16em; text-transform: uppercase; font-size: 13px; white-space: nowrap; }
.qb-mark { width: 30px; height: 30px; flex: none; }
.qb-mark .ring { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 1.4s var(--ease) 0.15s forwards; }
.qb-mark .tail { stroke-dasharray: 12; stroke-dashoffset: 12; animation: draw 0.7s var(--ease) 0.9s forwards; }
.qb-mark .bell { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw 1s var(--ease) 0.5s forwards; }
.qb-mark .node { transform-origin: 16px 12.6px; animation: pop 0.6s var(--spring) 1.1s both; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.qb-logo b { font-weight: 650; }
.qb-logo b + b { color: var(--text-2); font-weight: 500; margin-left: -4px; }

/* ------------------------------------------------------------ buttons */

.btn {
  --h: 42px; --px: 18px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: var(--h); padding: 0 var(--px); border-radius: 12px; font-weight: 560; font-size: 14.5px; white-space: nowrap;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.35s var(--ease), color 0.2s, opacity 0.2s;
  user-select: none; -webkit-tap-highlight-color: transparent; isolation: isolate;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-lg { --h: 52px; --px: 26px; font-size: 16px; border-radius: 14px; }
.btn-sm { --h: 34px; --px: 12px; font-size: 13.5px; border-radius: 10px; }
.btn-xs { --h: 28px; --px: 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-block { width: 100%; }

.btn-primary { color: #fff; background: var(--grad); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 10px 30px -10px rgba(123, 108, 255, 0.8); }
.btn-primary::before { content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: -1; background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%); background-size: 250% 100%; background-position: 130% 0; transition: background-position 0.9s var(--ease); }
.btn-primary:hover:not(:disabled)::before { background-position: -30% 0; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 16px 44px -10px rgba(123, 108, 255, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.08); transform: translateY(-1px); }

/* Signature CTA: a slowly orbiting light around the border. */
.btn-halo { color: var(--text); background: var(--surface-solid); }
.btn-halo::before { content: ''; position: absolute; inset: -1px; border-radius: inherit; z-index: -2; background: conic-gradient(from var(--angle), transparent 0 55%, #3fc8ff 68%, #7b6cff 78%, #b26bff 86%, transparent 94%); animation: orbit 3.6s linear infinite; }
.btn-halo::after { content: ''; position: absolute; inset: 1px; border-radius: calc(12px - 1px); z-index: -1; background: linear-gradient(180deg, #121628, #0a0d18); }
.btn-halo:hover { transform: translateY(-1px); box-shadow: 0 14px 40px -12px rgba(123, 108, 255, 0.7); }
@keyframes orbit { to { --angle: 360deg; } }

.btn-ghost { color: var(--text); background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line-2); backdrop-filter: blur(10px); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); border-color: var(--line-3); }
[data-theme='light'] .btn-ghost { background: rgba(255, 255, 255, 0.7); }
[data-theme='light'] .btn-ghost:hover:not(:disabled) { background: #fff; }
.btn-quiet { color: var(--text-2); }
.btn-quiet:hover:not(:disabled) { color: var(--text); background: rgba(148, 160, 214, 0.08); }
.btn-danger { color: #fff; background: linear-gradient(135deg, #ff5a7a, #e0344f); box-shadow: 0 10px 30px -12px rgba(255, 90, 122, 0.8); }
.btn-danger:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 40px -12px rgba(255, 90, 122, 0.95); }
.btn-danger-ghost { color: var(--down); border: 1px solid rgba(255, 90, 122, 0.3); background: rgba(255, 90, 122, 0.06); }
.btn-danger-ghost:hover:not(:disabled) { background: rgba(255, 90, 122, 0.12); border-color: rgba(255, 90, 122, 0.5); }
.btn-icon { --h: 38px; width: var(--h); padding: 0; border-radius: 11px; }
.btn-icon.btn-sm { --h: 32px; }

.btn .spin { display: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading .spin { display: block; position: absolute; inset: 0; margin: auto; color: #fff; }
.btn-ghost.is-loading .spin, .btn-quiet.is-loading .spin { color: var(--text); }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Hold-to-confirm (kill switches): the fill tracks how long you have held. */
.hold { --p: 0; overflow: hidden; }
.hold .hold-fill { position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.12)); transform-origin: left; transform: scaleX(var(--p)); }
.hold.done { animation: thump 0.4s var(--spring); }
@keyframes thump { 50% { transform: scale(1.04); } }

/* ------------------------------------------------------------ fields */

.field { position: relative; display: block; }
.field input, .field select, .field textarea, .input {
  width: 100%; height: 52px; padding: 22px 16px 8px; border-radius: 13px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.025); color: var(--text); font-size: 15.5px; outline: none;
  transition: border-color 0.2s, box-shadow 0.25s var(--ease), background 0.2s;
}
[data-theme='light'] .field input, [data-theme='light'] .field select, [data-theme='light'] .field textarea, [data-theme='light'] .input { background: #fff; }
.field textarea { height: auto; min-height: 104px; padding-top: 26px; resize: vertical; line-height: 1.5; }
.field select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23878ea8' stroke-width='1.8'%3E%3Cpath d='m2.5 4.5 3.5 3.5 3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
.field label { position: absolute; left: 17px; top: 16px; color: var(--text-3); font-size: 15px; pointer-events: none; transform-origin: left top; transition: transform 0.25s var(--ease), color 0.2s; }
.field input:focus + label, .field input:not(:placeholder-shown) + label, .field textarea:focus + label, .field textarea:not(:placeholder-shown) + label, .field select + label { transform: translateY(-9px) scale(0.76); color: var(--text-2); }
.field input::placeholder, .field textarea::placeholder { color: transparent; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: rgba(123, 108, 255, 0.65); box-shadow: 0 0 0 4px rgba(123, 108, 255, 0.14); background: rgba(123, 108, 255, 0.04); }
.field.invalid input, .field.invalid select { border-color: rgba(255, 90, 122, 0.6); box-shadow: 0 0 0 4px rgba(255, 90, 122, 0.12); }
.field .hint { display: block; margin: 7px 2px 0; font-size: 12.5px; color: var(--text-3); }
.field.invalid .hint { color: var(--down); }
.field .suffix { position: absolute; right: 10px; top: 10px; }
.input { height: 42px; padding: 0 14px; font-size: 14.5px; border-radius: 11px; }

/* Six boxes for a one-time code; paste anywhere fills them all. */
.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.otp input {
  height: 62px; width: 100%; text-align: center; font: 600 26px/1 var(--font-mono); border-radius: 14px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.025); color: var(--text); outline: none; caret-color: var(--iris);
  transition: border-color 0.2s, box-shadow 0.25s var(--ease), transform 0.25s var(--spring), background 0.2s;
}
[data-theme='light'] .otp input { background: #fff; }
.otp input:focus { border-color: rgba(123, 108, 255, 0.7); box-shadow: 0 0 0 4px rgba(123, 108, 255, 0.16); transform: translateY(-2px); }
.otp input.filled { border-color: var(--line-3); background: rgba(123, 108, 255, 0.07); }
.otp.gap-3 input:nth-child(3) { margin-right: 10px; }
.otp.error input { border-color: rgba(255, 90, 122, 0.6); animation: shake 0.45s var(--ease); }
.otp.success input { border-color: rgba(46, 229, 157, 0.7); background: rgba(46, 229, 157, 0.08); }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

.switch { position: relative; display: inline-flex; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 24px; background: var(--surface-3); border: 1px solid var(--line-2); transition: background 0.25s var(--ease), border-color 0.25s; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); transition: transform 0.35s var(--spring); }
.switch input:checked + i { background: var(--grad); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: var(--ring); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); font-size: 13.5px; font-weight: 500; background: rgba(255, 255, 255, 0.02); transition: all 0.2s var(--ease); }
.chip:hover { color: var(--text); border-color: var(--line-3); }
.chip[aria-pressed='true'], .chip.on { color: var(--text); border-color: rgba(123, 108, 255, 0.6); background: rgba(123, 108, 255, 0.12); box-shadow: 0 0 0 3px rgba(123, 108, 255, 0.1); }

/* ------------------------------------------------------------ surfaces */

.card {
  position: relative; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-2); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
}
/* Pointer spotlight: JS sets --mx/--my on hover. */
.spot::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 0.4s var(--ease);
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(123, 108, 255, 0.5), rgba(63, 200, 255, 0.18) 30%, transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; padding: 1px;
}
.spot::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 0.4s var(--ease); background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 50%), rgba(123, 108, 255, 0.07), transparent 45%); }
.spot:hover::before, .spot:hover::after { opacity: 1; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; border: 1px solid var(--line-2); color: var(--text-2); background: rgba(255, 255, 255, 0.03); white-space: nowrap; }
.badge.up { color: var(--up); border-color: rgba(46, 229, 157, 0.3); background: rgba(46, 229, 157, 0.08); }
.badge.down { color: var(--down); border-color: rgba(255, 90, 122, 0.3); background: rgba(255, 90, 122, 0.08); }
.badge.warn { color: var(--warn); border-color: rgba(255, 181, 71, 0.3); background: rgba(255, 181, 71, 0.08); }
.badge.info { color: var(--ion); border-color: rgba(63, 200, 255, 0.3); background: rgba(63, 200, 255, 0.08); }
.badge.iris { color: #b3aaff; border-color: rgba(123, 108, 255, 0.35); background: rgba(123, 108, 255, 0.1); }
[data-theme='light'] .badge.iris { color: var(--iris); }

.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.live { background: var(--up); box-shadow: 0 0 10px rgba(46, 229, 157, 0.8); }
.dot.live::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--up); animation: ping 1.8s var(--ease) infinite; }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px rgba(255, 181, 71, 0.7); }
.dot.down { background: var(--down); box-shadow: 0 0 10px rgba(255, 90, 122, 0.7); }
.dot.iris { background: var(--iris); box-shadow: 0 0 10px rgba(123, 108, 255, 0.8); }
@keyframes ping { 0% { transform: scale(0.6); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }

kbd, .kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; font: 500 11.5px/1 var(--font-mono); color: var(--text-2); background: rgba(255, 255, 255, 0.03); }

.skeleton { position: relative; overflow: hidden; border-radius: 8px; background: rgba(148, 160, 214, 0.08); }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(148, 160, 214, 0.12), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.divider { display: flex; align-items: center; gap: 14px; color: var(--text-3); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.12em; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }

/* ------------------------------------------------------------ toasts */

.toasts { position: fixed; z-index: 900; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px 14px 14px 16px; border-radius: 16px;
  background: rgba(16, 19, 32, 0.92); border: 1px solid var(--line-2); box-shadow: var(--shadow-3); backdrop-filter: blur(20px);
  animation: toast-in 0.5s var(--spring); transform-origin: bottom right; font-size: 14px;
}
[data-theme='light'] .toast { background: rgba(255, 255, 255, 0.95); }
.toast.leaving { animation: toast-out 0.3s var(--ease) forwards; }
.toast .t-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.toast .t-icon svg { width: 13px; height: 13px; }
.toast.ok .t-icon { background: rgba(46, 229, 157, 0.15); color: var(--up); }
.toast.error .t-icon { background: rgba(255, 90, 122, 0.15); color: var(--down); }
.toast.info .t-icon { background: rgba(123, 108, 255, 0.18); color: #b3aaff; }
.toast.warn .t-icon { background: rgba(255, 181, 71, 0.15); color: var(--warn); }
.toast b { display: block; font-weight: 600; margin-bottom: 2px; }
.toast span { color: var(--text-2); }
.toast .t-close { color: var(--text-3); width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; }
.toast .t-close:hover { color: var(--text); background: rgba(148, 160, 214, 0.1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.94); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px) scale(0.96); } }

/* ------------------------------------------------------------ dialogs */

dialog.modal {
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line-2); border-radius: 24px; color: var(--text);
  background: linear-gradient(180deg, rgba(20, 24, 40, 0.96), rgba(11, 14, 24, 0.98)); box-shadow: var(--shadow-3), 0 0 0 1px rgba(255, 255, 255, 0.02);
  overflow: auto; overscroll-behavior: contain;
}
dialog.modal.wide { width: min(640px, calc(100vw - 32px)); }
[data-theme='light'] dialog.modal { background: #fff; }
dialog.modal[open] { animation: modal-in 0.5s var(--spring); }
dialog.modal::backdrop { background: rgba(3, 4, 9, 0.62); backdrop-filter: blur(8px); animation: fade-in 0.3s var(--ease); }
[data-theme='light'] dialog.modal::backdrop { background: rgba(20, 24, 48, 0.28); }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(0.95); } }
@keyframes fade-in { from { opacity: 0; } }
.modal-body { padding: 28px; }
.modal-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.modal-head h3 { font-size: 19px; font-weight: 640; letter-spacing: -0.015em; }
.modal-head p { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.modal-icon { width: 44px; height: 44px; flex: none; border-radius: 13px; display: grid; place-items: center; background: var(--grad-soft); border: 1px solid rgba(123, 108, 255, 0.3); color: #c3bbff; }
.modal-icon svg { width: 22px; height: 22px; }
.modal-icon.danger { background: rgba(255, 90, 122, 0.1); border-color: rgba(255, 90, 122, 0.35); color: var(--down); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--text-3); }
.modal-close:hover { background: rgba(148, 160, 214, 0.1); color: var(--text); }

/* Second-factor tabs and bodies (shared with the step-up dialog). */
.factor-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.factor-tab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; border-radius: 10px; font-size: 13px; font-weight: 520; color: var(--text-3); transition: all 0.25s var(--ease); }
.factor-tab .i { width: 16px; height: 16px; }
.factor-tab:hover { color: var(--text); }
.factor-tab.on { color: var(--text); background: var(--surface-3); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line-2); }
.factor-copy { color: var(--text-2); font-size: 14px; margin-bottom: 16px; }
.factor-body { animation: step-in 0.4s var(--ease); }


.avatar { --s: 32px; width: var(--s); height: var(--s); flex: none; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 650; font-size: calc(var(--s) * 0.38); letter-spacing: 0.02em; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 4px 14px -4px rgba(0, 0, 0, 0.5); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }

/* ------------------------------------------------------------ icons */

.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------ reveal motion */

.reveal { opacity: 0; transform: translateY(24px); filter: blur(6px); transition: opacity 1s var(--ease), transform 1s var(--ease), filter 1s var(--ease); transition-delay: var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; filter: none; }
.split-line { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.split-line > span { display: inline-block; transform: translateY(105%); transition: transform 1.1s var(--ease); transition-delay: var(--d, 0ms); }
.in .split-line > span, .split-line.in > span { transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; filter: none; }
  .split-line > span { transform: none; }
  .grain::after { display: none; }
}
