:root {
  --bg: #05070b;
  --ink: #eaf6ff;
  --muted: #8aa0b6;
  --cyan: #48f5db;
  --blue: #69b9ff;
  --violet: #9d86ff;
  --glass: rgba(12, 20, 30, 0.55);
  --line: rgba(120, 180, 220, 0.16);
  --dock-h: clamp(118px, 20vh, 168px);
  color-scheme: dark;
  font-family: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
}

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

.noscript {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: 2rem; text-align: center; color: var(--muted);
}

/* ---------- Stage ---------- */
.stage {
  position: fixed;
  inset: 0;
  display: block;
}

#orb {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  /* Tapping the dots starts listening. */
  cursor: pointer;
}

/* ---------- Start screen ---------- */
.start {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: clamp(20px, 6vw, 48px);
}
.start-kicker {
  margin: 0;
  font: 600 0.72rem/1 'JetBrains Mono', monospace;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}
.start-title {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #f3fbff;
}
.start-sub {
  margin: 0;
  max-width: 30rem;
  font-size: clamp(0.95rem, 3.6vw, 1.1rem);
  line-height: 1.5;
  color: #cfe0ef;
}
.start-btn {
  margin-top: 10px;
  padding: 15px 28px;
  border: 0;
  border-radius: 999px;
  font-size: 1.02rem;
  font-weight: 600;
  color: #04121a;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 12px 36px rgba(72, 245, 219, 0.28);
}
.start-btn:hover { transform: translateY(-1px); box-shadow: 0 16px 44px rgba(72, 245, 219, 0.36); }
.start-btn:active { transform: translateY(0); }

/* ---------- Conversation thread ---------- */
.chat {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--dock-h);
  top: 0;
  z-index: 2;
  max-width: 760px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: clamp(16px, 5vw, 40px);
  padding-bottom: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: min(560px, 86%);
  padding: 11px 15px;
  border-radius: 16px;
  font-size: clamp(0.95rem, 3.4vw, 1.06rem);
  line-height: 1.45;
  letter-spacing: 0.005em;
  backdrop-filter: blur(7px);
  border: 1px solid var(--line);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  will-change: transform, opacity;
}

.msg.you {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(105, 185, 255, 0.22), rgba(72, 245, 219, 0.12));
  border-color: rgba(105, 185, 255, 0.3);
  color: #f3fbff;
}

.msg.seoul {
  align-self: flex-start;
  background: var(--glass);
  color: #dfeefc;
}

.msg .who {
  display: block;
  font: 600 0.62rem/1 'JetBrains Mono', monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Dock (mic always reachable) ---------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: var(--dock-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5, 7, 11, 0.92), rgba(5, 7, 11, 0));
}

.hint {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.85;
  transition: opacity 0.6s ease;
}
.hint.gone { opacity: 0; }

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, 100%);
}

.input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 16, 24, 0.6);
  color: var(--ink);
  font-size: 1rem;
  outline: none;
  opacity: 0.75;
  transition: opacity 0.3s ease, border-color 0.3s ease;
}
.input:focus { opacity: 1; border-color: rgba(105, 185, 255, 0.5); }
.input::placeholder { color: rgba(138, 160, 182, 0.7); }

.mic {
  position: relative;
  flex: 0 0 auto;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1px solid rgba(72, 245, 219, 0.45);
  background: radial-gradient(circle at 50% 35%, rgba(72, 245, 219, 0.32), rgba(8, 14, 22, 0.9));
  color: var(--cyan);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(72, 245, 219, 0.45), 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.mic:hover { transform: translateY(-1px); }
.mic:active { transform: scale(0.96); }
.mic svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.mic.listening {
  color: #fff;
  border-color: rgba(157, 134, 255, 0.7);
  background: radial-gradient(circle at 50% 35%, rgba(157, 134, 255, 0.55), rgba(8, 14, 22, 0.9));
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(157, 134, 255, 0.5), 0 10px 30px rgba(0,0,0,0.45); }
  70%  { box-shadow: 0 0 0 22px rgba(157, 134, 255, 0), 0 10px 30px rgba(0,0,0,0.45); }
  100% { box-shadow: 0 0 0 0 rgba(157, 134, 255, 0), 0 10px 30px rgba(0,0,0,0.45); }
}

/* Hands-free voice mode is on (persists between turns, even while idle). */
.mic.armed {
  color: #eafdf8;
  border-color: rgba(72, 245, 219, 0.65);
  box-shadow: 0 0 0 2px rgba(72, 245, 219, 0.45), 0 10px 30px rgba(0, 0, 0, 0.45);
}

.send {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 16, 24, 0.6);
  color: var(--blue);
  font-size: 1.25rem;
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.send:disabled, .mic:disabled { opacity: 0.4; cursor: default; }

/* ---------- Prototype preview ---------- */
.preview {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 8, 0.74);
  backdrop-filter: blur(8px);
  animation: rise 0.4s ease both;
}
.preview[hidden] { display: none; }

.preview-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: clamp(22px, 5vw, 34px);
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 22, 33, 0.96), rgba(7, 11, 18, 0.98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.preview-close {
  position: absolute; top: 12px; right: 14px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); font-size: 1.3rem; cursor: pointer;
}
.preview-kicker {
  margin: 0 0 6px;
  font: 600 0.66rem/1 'JetBrains Mono', monospace;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--cyan);
}
.preview-card h2 { margin: 0 0 16px; font-size: clamp(1.3rem, 5vw, 1.7rem); }

.preview-mock {
  display: grid; gap: 9px;
  padding: 16px; margin-bottom: 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(6, 10, 16, 0.7);
}
.mock-bar { height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--cyan), var(--blue)); opacity: 0.85; }
.mock-bar:nth-child(2) { width: 60%; opacity: 0.5; }
/* The "screen" — a little preview of the prototype taking shape. */
.mock-screen {
  margin-top: 6px; padding: 13px; border-radius: 10px;
  display: grid; gap: 9px;
  background: rgba(105, 185, 255, 0.08);
  border: 1px solid rgba(105, 185, 255, 0.22);
}
.mock-row { height: 8px; border-radius: 5px; background: rgba(207, 226, 242, 0.28); }
.mock-row.short { width: 55%; }
.mock-chip { margin-top: 3px; width: 92px; height: 22px; border-radius: 7px; background: linear-gradient(90deg, var(--cyan), var(--blue)); opacity: 0.85; }

.preview-text { color: #cfe2f2; line-height: 1.55; margin: 0 0 12px; }
.preview-status { font-size: 0.84rem; color: var(--muted); min-height: 1.2em; margin: 0 0 18px; }
.preview-status.ok { color: var(--cyan); }
.preview-status.warn { color: #ffcf8a; }

.preview-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.preview-primary, .preview-ghost {
  flex: 1; min-width: 140px;
  padding: 13px 16px; border-radius: 12px;
  font-size: 0.95rem; font-weight: 600; text-align: center;
  cursor: pointer; text-decoration: none;
}
.preview-primary {
  color: #04121a; border: 0;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
}
.preview-ghost {
  color: var(--ink); background: transparent;
  border: 1px solid var(--line);
}

/* ---------- identity gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(3, 5, 8, 0.82);
  backdrop-filter: blur(10px);
  animation: rise 0.4s ease both;
}
.gate[hidden] { display: none; }
.gate-card {
  width: min(420px, 100%);
  padding: clamp(24px, 6vw, 36px);
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 22, 33, 0.96), rgba(7, 11, 18, 0.98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.gate-kicker {
  margin: 0 0 8px;
  font: 600 0.66rem/1 'JetBrains Mono', monospace;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--cyan);
}
.gate-title { margin: 0 0 8px; font-size: clamp(1.3rem, 5vw, 1.6rem); }
.gate-blurb { margin: 0 0 18px; color: var(--muted); line-height: 1.5; font-size: 0.92rem; }
.gate-strong { color: var(--ink); }
.gate-label {
  display: block; margin: 0 0 6px;
  font-size: 0.78rem; color: var(--muted); letter-spacing: 0.02em;
}
.gate-input {
  width: 100%; margin: 0 0 14px;
  padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(6, 10, 16, 0.8);
  color: var(--ink); font: inherit; font-size: 1rem;
}
.gate-input:focus { outline: none; border-color: var(--cyan); }
.gate-code { letter-spacing: 0.5em; text-align: center; font-family: 'JetBrains Mono', monospace; }
.gate-btn {
  width: 100%; margin: 4px 0 0;
  padding: 14px 16px; border-radius: 12px; border: 0;
  font-size: 0.98rem; font-weight: 600; cursor: pointer;
  color: #04121a;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
}
.gate-btn:disabled { opacity: 0.55; cursor: default; }
.gate-link {
  display: block; width: 100%; margin: 12px 0 0;
  background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline;
}
.gate-link:hover { color: var(--ink); }
.gate-turnstile { display: flex; justify-content: center; margin: 4px 0 16px; min-height: 1px; }
.gate-google { display: flex; justify-content: center; margin: 4px 0 2px; }
.gate-status { margin: 14px 0 0; min-height: 1.2em; font-size: 0.84rem; color: var(--muted); }
.gate-status.ok { color: var(--cyan); }
.gate-status.warn { color: #ffcf8a; }

@media (prefers-reduced-motion: reduce) {
  .msg, .preview, .mic.listening, .gate { animation: none; }
}
