:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --ink: #0e1a35;
  --muted: rgba(14, 26, 53, 0.56);
  --line: rgba(14, 26, 53, 0.12);
  --blue: #1f7bff;
  --blue-2: #1a6ff5;
  --blue-hi: #3393ff;
  --danger: #d93a2b;
  --bg-hi: #ffffff;
  --logo-ink: #0e1a35;
  --bar-1: #3393ff;
  --bar-2: #1a6ff5;
  --streak: 31, 123, 255;
  --fab-bg: #0e1a35;
  --fab-fg: #ffffff;
  --scrim: rgba(14, 26, 53, 0.28);
  --shadow: rgba(14, 26, 53, 0.16);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

/* Dark tokens: used when the system is dark (unless forced light), or when forced dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070b16; --bg-hi: #0f1931; --surface: #0d1426;
    --ink: #eef2fa; --muted: rgba(238, 242, 250, 0.58); --line: rgba(238, 242, 250, 0.14);
    --logo-ink: #f4f6fb; --bar-1: #4da3ff; --bar-2: #2a7cff; --streak: 92, 160, 255;
    --fab-bg: #f4f6fb; --fab-fg: #0e1a35; --scrim: rgba(0, 0, 0, 0.55); --shadow: rgba(0, 0, 0, 0.5);
    --danger: #ff7a6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070b16; --bg-hi: #0f1931; --surface: #0d1426;
  --ink: #eef2fa; --muted: rgba(238, 242, 250, 0.58); --line: rgba(238, 242, 250, 0.14);
  --logo-ink: #f4f6fb; --bar-1: #4da3ff; --bar-2: #2a7cff; --streak: 92, 160, 255;
  --fab-bg: #f4f6fb; --fab-fg: #0e1a35; --scrim: rgba(0, 0, 0, 0.55); --shadow: rgba(0, 0, 0, 0.5);
  --danger: #ff7a6b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: radial-gradient(110% 80% at 50% 45%, var(--bg-hi) 0%, var(--bg) 70%) fixed, var(--bg);
  color: var(--ink);
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#field { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Stage & logo ---------- */

.stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
}

.mark {
  width: min(70vw, 560px);
  height: auto;
  overflow: visible;
  display: block;
  margin-top: -3vh;
}
/* Hidden until the intro animates them in; the CSS fallback shows them if JS never runs. */
.mark .bar, .mark .letters { opacity: 0; animation: fallback-show 0.6s ease 3s forwards; }
@keyframes fallback-show { to { opacity: 1; } }
.mark .bar, .mark .letters, .mark .shine { transform-box: fill-box; }
.mark .bar { transform-origin: right center; }
.mark .letters { fill: var(--logo-ink); transition: fill 0.4s ease; }
#barGrad stop:first-child { stop-color: var(--bar-1); }
#barGrad stop:last-child { stop-color: var(--bar-2); }
.mark .letters { transform-origin: left bottom; }

.notice {
  position: fixed; left: 0; right: 0;
  bottom: max(36px, calc(env(safe-area-inset-bottom) + 16px));
  padding: 0 96px;
  text-align: center;
  font-size: 12px; letter-spacing: 0.06em; line-height: 1.5;
  color: var(--muted);
  opacity: 0;
  transition: opacity 1.2s ease 0.3s;
  pointer-events: none;
}
.ready .notice { opacity: 0.85; }

.skip-hint {
  position: fixed; left: 0; right: 0; top: max(24px, env(safe-area-inset-top));
  margin: 0; text-align: center;
  font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--muted);
  opacity: 0; animation: hint 0.8s ease 0.6s forwards;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
@keyframes hint { to { opacity: 0.6; } }
.ready .skip-hint { opacity: 0 !important; animation: none; }

/* ---------- Contact button ---------- */

.contact-fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  display: inline-flex; align-items: center; gap: 0;
  height: 56px; min-width: 56px; padding: 0 17px;
  border-radius: 999px;
  border: 0;
  background: var(--fab-bg);
  color: var(--fab-fg);
  font: inherit; font-size: 14px; font-weight: 400; letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0; transform: translateY(16px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out), background 0.25s, gap 0.45s var(--ease-out), box-shadow 0.25s;
  box-shadow: 0 10px 30px rgba(14, 26, 53, 0.22);
}
.ready .contact-fab { opacity: 1; transform: none; pointer-events: auto; }
.contact-fab svg { flex: none; }
.fab-label {
  max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0;
  transition: max-width 0.45s var(--ease-out), opacity 0.3s ease;
}
.contact-fab:hover, .contact-fab:focus-visible {
  background: var(--blue-2);
  color: #fff;
  gap: 10px;
  box-shadow: 0 12px 34px rgba(31, 123, 255, 0.35);
}
.contact-fab:hover .fab-label, .contact-fab:focus-visible .fab-label { max-width: 90px; opacity: 1; }
.contact-fab:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

/* ---------- Panel ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.4s ease;
}
.scrim.open { opacity: 1; }

.panel {
  position: fixed; z-index: 40;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 100%);
  display: flex; flex-direction: column;
  padding: max(28px, env(safe-area-inset-top)) 32px max(28px, env(safe-area-inset-bottom));
  background: var(--surface);
  box-shadow: -24px 0 70px var(--shadow);
  transform: translateX(100%);
  transition: transform 0.55s var(--ease-out);
  overflow-y: auto;
}
.panel.open { transform: none; }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 36px; }
.eyebrow { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--blue); font-weight: 500; }
.panel h2 { margin: 0; font-weight: 400; font-size: 30px; letter-spacing: -0.01em; }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  cursor: pointer; transition: border-color 0.2s, transform 0.3s var(--ease-out);
}
.icon-btn:hover { border-color: var(--blue); transform: rotate(90deg); }
.icon-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.form { display: flex; flex-direction: column; gap: 22px; }

.field { position: relative; }
.field input, .field textarea {
  width: 100%;
  padding: 22px 0 10px;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 400;
  border-radius: 0; outline: none; resize: vertical;
  transition: border-color 0.3s;
}
.field textarea { min-height: 120px; line-height: 1.5; }
.field label {
  position: absolute; left: 0; top: 22px;
  color: var(--muted); font-size: 16px;
  pointer-events: none; transform-origin: left top;
  transition: transform 0.3s var(--ease-out), color 0.3s;
}
.field .opt { font-size: 0.85em; opacity: 0.7; }
.field::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, var(--blue-hi), var(--blue-2));
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}
.field:focus-within::after { transform: scaleX(1); }
.field input:focus + label, .field textarea:focus + label,
.field input:not(:placeholder-shown) + label, .field textarea:not(:placeholder-shown) + label {
  transform: translateY(-20px) scale(0.74);
  color: var(--blue-2);
}
.field.invalid input, .field.invalid textarea { border-bottom-color: var(--danger); }
.field.invalid label { color: var(--danger); }

.turnstile:empty { display: none; }
.turnstile { margin: -4px 0 0; min-height: 0; }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.form-status { min-height: 1.4em; margin: -4px 0 0; font-size: 14px; color: var(--muted); }
.form-status.error { color: var(--danger); }

.submit {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; margin-top: 6px;
  border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-hi), var(--blue-2));
  color: #fff; font: inherit; font-size: 15px; font-weight: 500; letter-spacing: 0.02em;
  cursor: pointer;
  transform: skewX(-10deg);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s, opacity 0.3s;
  box-shadow: 0 10px 26px rgba(31, 123, 255, 0.28);
}
.submit > * { transform: skewX(10deg); }
.submit:hover { transform: skewX(-10deg) translateY(-1px); box-shadow: 0 14px 34px rgba(31, 123, 255, 0.4); }
.submit:hover .submit-arrow { transform: skewX(10deg) translateX(3px); }
.submit-arrow { transition: transform 0.3s var(--ease-out); }
.submit:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.submit[disabled] { opacity: 0.65; cursor: progress; }
.submit.loading .submit-arrow { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sent {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding-bottom: 60px;
  animation: rise 0.6s var(--ease-out);
}
.sent h3 { margin: 18px 0 0; font-weight: 400; font-size: 24px; }
.sent p { margin: 0 0 24px; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.ghost {
  height: 44px; padding: 0 26px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  font: inherit; font-weight: 400; cursor: pointer; transition: border-color 0.2s;
}
.ghost:hover { border-color: var(--blue); }
.ghost:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

/* ---------- Hidden theme switch ---------- */

.theme-zone {
  position: fixed; left: 0; bottom: 0; z-index: 15;
  width: 200px; height: 130px;
  display: flex; align-items: flex-end;
  padding: 0 0 max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  visibility: hidden;
}
.ready .theme-zone { visibility: visible; }

.theme-toggle {
  position: relative; display: flex; gap: 2px; padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 26px var(--shadow);
  opacity: 0; transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.45s var(--ease-out);
}
.theme-zone:hover .theme-toggle,
.theme-zone:focus-within .theme-toggle,
.theme-zone.reveal .theme-toggle { opacity: 1; transform: none; pointer-events: auto; }

.theme-toggle button {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; transition: color 0.25s;
}
.theme-toggle button:hover { color: var(--ink); }
.theme-toggle button[aria-checked="true"] { color: var(--blue); }
.theme-toggle button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.theme-thumb {
  position: absolute; top: 4px; left: 4px; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(var(--streak), 0.14);
  transform: translateX(calc(var(--idx, 0) * 38px));
  transition: transform 0.4s var(--ease-out);
}

@media (max-width: 560px) {
  .theme-zone { padding-bottom: max(76px, calc(env(safe-area-inset-bottom) + 60px)); height: 170px; }
  .mark { width: 84vw; }
  .notice { padding: 0 88px 0 20px; text-align: left; font-size: 11px; }
  .panel {
    top: auto; width: 100%; max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding-left: 22px; padding-right: 22px;
    transform: translateY(100%);
  }
  .panel.open { transform: none; }
  .panel-head { margin-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .scrim, .notice, .contact-fab { transition-duration: 0.01s !important; transition-delay: 0s !important; }
  .skip-hint { display: none; }
}
