:root {
  --bg: #05080f;
  --bg2: #0a1120;
  --fg: #dce6f5;
  --muted: #6b7c98;
  --accent: #2f7dff;
  --accent-warm: #44e0c8;
  --listen: #2f7dff;
  --think: #f0a830;
  --speak: #44e0c8;
  --danger: #ff5470;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  /* Stop tap-and-hold from selecting the status / brand / orb text. The app
     has no selectable content, and this is the clean fix for the iOS
     "hold the button → highlight text instead" quirk (better than a
     transparent overlay div, which can swallow the touch events). */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0; height: 100%;
  /* No text selection / drag-callout anywhere on the page. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  background: radial-gradient(1200px 800px at 50% -10%, #0d1730 0%, var(--bg) 60%);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}

.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 4px 8px;
}
.brand { font-weight: 700; letter-spacing: 0.35em; font-size: 14px; color: var(--muted); }
.status {
  font-size: 13px; padding: 4px 12px; border-radius: 999px;
  background: rgba(47,125,255,0.12); color: var(--accent);
  transition: all .25s ease;
}
.status[data-state="listening"] { color: var(--listen); background: rgba(47,125,255,0.18); }
.status[data-state="thinking"]  { color: var(--think);  background: rgba(240,168,48,0.16); }
.status[data-state="speaking"]  { color: var(--speak);  background: rgba(68,224,200,0.16); }
.status[data-state="error"]     { color: var(--danger); background: rgba(255,84,112,0.16); }

.orb-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }

.orb {
  position: relative;
  width: min(72vw, 320px); height: min(72vw, 320px);
  border-radius: 50%;
  border: none; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, #15224a 0%, #0a1020 70%);
  box-shadow:
    0 0 60px rgba(47,125,255,0.25),
    inset 0 0 40px rgba(47,125,255,0.15);
  transition: box-shadow .25s ease, transform .12s ease;
  touch-action: none;
  user-select: none;
}
.orb:active { transform: scale(0.98); }
.orb.listening { box-shadow: 0 0 90px rgba(47,125,255,0.55), inset 0 0 50px rgba(47,125,255,0.3); }
.orb.thinking  { box-shadow: 0 0 80px rgba(240,168,48,0.45), inset 0 0 50px rgba(240,168,48,0.25); }
.orb.speaking  { box-shadow: 0 0 100px rgba(68,224,200,0.55), inset 0 0 50px rgba(68,224,200,0.3); }

#viz { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; pointer-events: none; }

.orb-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 16px; letter-spacing: 0.04em; color: var(--fg); pointer-events: none;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}

.transcript-section { padding: 0 4px; }
.transcript-toggle {
  background: none; border: none; color: var(--muted);
  font-size: 13px; cursor: pointer; padding: 8px 0; letter-spacing: 0.05em;
}
.transcript-toggle[aria-expanded="true"] { color: var(--accent); }
.transcript {
  max-height: 34vh; overflow-y: auto;
  transition: max-height .3s ease, opacity .3s ease, padding .3s ease;
  opacity: 1;
}
.transcript.collapsed { max-height: 0; opacity: 0; padding: 0; overflow: hidden; }
.msg { margin: 8px 0; line-height: 1.4; font-size: 15px; }
.msg .who { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 2px; }
.msg.user .bubble  { color: var(--fg); }
.msg.jarvis .bubble { color: var(--accent-warm); }

.hint { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 16px; min-height: 1.2em; }

.playbtn {
  margin-top: 10px;
  background: var(--speak);
  color: #04201c;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ── login page ── */
.login-stage { align-items: center; justify-content: center; }
.login-card {
  width: min(90vw, 360px);
  margin: auto;
  background: rgba(13, 23, 48, 0.6);
  border: 1px solid rgba(47,125,255,0.2);
  border-radius: 18px;
  padding: 32px 26px;
  text-align: center;
  box-shadow: 0 0 60px rgba(47,125,255,0.15);
}
.login-card .brand { font-size: 22px; letter-spacing: 0.4em; margin-bottom: 4px; }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%; box-sizing: border-box;
  margin: 7px 0; padding: 13px 14px;
  background: #0a1020; color: var(--fg);
  border: 1px solid rgba(47,125,255,0.25); border-radius: 10px;
  font-size: 16px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.remember {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; margin: 12px 2px 18px; text-align: left;
}
.remember input { width: 16px; height: 16px; }
#loginBtn {
  width: 100%; padding: 14px; border: none; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer;
}
#loginBtn:disabled { opacity: 0.6; }
.login-msg { color: var(--danger); font-size: 13px; min-height: 1.2em; margin-top: 12px; }

.signout {
  position: fixed; top: calc(env(safe-area-inset-top) + 10px); right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 12px; cursor: pointer; opacity: 0.6;
}
.signout:hover { opacity: 1; color: var(--fg); }

.enable-voice {
  display: block; margin: 14px auto 0; padding: 10px 18px;
  background: rgba(68, 224, 200, 0.12); color: var(--fg);
  border: 1px solid var(--speaking, #44e0c8); border-radius: 999px;
  font-size: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.enable-voice:hover { background: rgba(68, 224, 200, 0.22); }
.enable-voice.hidden { display: none; }
