/* Voice — standalone design. Dark, calm, one glowing orb. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #07080f;
  --bg-2: #0d0f1c;
  --panel: rgba(255, 255, 255, .04);
  --line: rgba(255, 255, 255, .09);
  --text: #e8e9f2;
  --dim: #8b8fa8;
  --accent: #7c6cff;
  --accent-2: #4cc9f0;
  --hot: #ff5d73;
  --orb-idle: radial-gradient(circle at 32% 28%, #9d8dff, #5a45e6 58%, #2d2180);
  --orb-rec:  radial-gradient(circle at 32% 28%, #ff8fa0, #e63f5c 58%, #7a1430);
  --orb-busy: radial-gradient(circle at 32% 28%, #7ee0ff, #2e9fd6 58%, #14486b);
}

html, body { height: 100%; }
body {
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1100px 600px at 50% -10%, #191c33 0%, transparent 60%),
    radial-gradient(900px 500px at 85% 110%, #101a2e 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Login gate ─────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: inherit;
}
.gate-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: min(340px, calc(100vw - 48px));
  padding: 40px 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(18px);
  text-align: center;
}
.gate-orb {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--orb-idle);
  box-shadow: 0 0 40px rgba(124, 108, 255, .55);
  animation: breathe 4s ease-in-out infinite;
}
.gate-card h1 { font-size: 1.5rem; letter-spacing: .16em; text-transform: uppercase; font-weight: 500; }
.gate-card p { font-size: .86rem; color: var(--dim); }
.gate-card input {
  width: 100%; margin-top: 8px; padding: 13px 16px;
  font: inherit; color: var(--text); text-align: center;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 12px;
  outline: none;
}
.gate-card input:focus { border-color: var(--accent); }
.gate-card button {
  width: 100%; padding: 13px; font: inherit; font-weight: 600; letter-spacing: .04em;
  color: #fff; background: linear-gradient(135deg, var(--accent), #5a45e6);
  border: 0; border-radius: 12px; cursor: pointer;
}
.gate-card button:hover { filter: brightness(1.12); }
.gate-error { min-height: 1.1em; font-size: .8rem; color: var(--hot); }

/* ── App shell ──────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 680px; margin: 0 auto; padding: 0 20px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 2px 14px;
}
.wordmark { display: flex; align-items: center; gap: 9px; font-size: .92rem; letter-spacing: .22em; text-transform: uppercase; color: var(--dim); }
.wordmark .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.head-actions { display: flex; gap: 6px; }
.ghost {
  font: inherit; font-size: .78rem; color: var(--dim);
  background: none; border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 14px; cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: var(--dim); }

/* ── Conversation feed ──────────────────────────────────── */
.feed { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 10px 2px 18px; scrollbar-width: thin; }
.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.hint { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.hint p { font-size: 1.02rem; }
.hint .dim { font-size: .86rem; color: var(--dim); font-style: italic; }

.msg { max-width: 85%; padding: 12px 16px; border-radius: 18px; font-size: .94rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .22s ease; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(124,108,255,.32), rgba(90,69,230,.22)); border: 1px solid rgba(124,108,255,.35); border-bottom-right-radius: 6px; }
.msg.bot  { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.err  { align-self: center; font-size: .82rem; color: var(--hot); background: rgba(255,93,115,.08); border: 1px solid rgba(255,93,115,.25); }
.msg.bot.streaming::after { content: "▍"; color: var(--accent-2); animation: blink 1s steps(2, start) infinite; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes blink { to { visibility: hidden; } }

/* Tool permission card */
.perm { align-self: stretch; padding: 14px 16px; border: 1px solid rgba(76,201,240,.4); border-radius: 16px; background: rgba(76,201,240,.06); display: flex; flex-direction: column; gap: 10px; animation: rise .22s ease; }
.perm .perm-title { font-size: .84rem; color: var(--accent-2); }
.perm .perm-tool { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }
.perm .perm-input { font-family: ui-monospace, Menlo, monospace; font-size: .74rem; color: var(--dim); max-height: 96px; overflow: auto; }
.perm .perm-actions { display: flex; gap: 8px; }
.perm button { font: inherit; font-size: .8rem; padding: 7px 18px; border-radius: 99px; cursor: pointer; border: 1px solid var(--line); background: none; color: var(--text); }
.perm button.allow { background: var(--accent-2); border-color: var(--accent-2); color: #04222e; font-weight: 700; }
.perm .perm-decided { font-size: .8rem; color: var(--dim); }

/* ── Orb dock ───────────────────────────────────────────── */
.dock { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 0 calc(30px + env(safe-area-inset-bottom, 0px)); }
.orb-wrap { position: relative; width: 108px; height: 108px; display: grid; place-items: center; }

.orb {
  width: 92px; height: 92px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--orb-idle);
  box-shadow: 0 0 46px rgba(124, 108, 255, .5), inset 0 -8px 22px rgba(0, 0, 0, .35);
  transition: transform .18s ease, box-shadow .3s ease;
  animation: breathe 4s ease-in-out infinite;
}
.orb:active { transform: scale(.94); }

.ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(124,108,255,.5); opacity: 0; pointer-events: none; }

/* recording — red = silence detected */
#app.recording .orb { background: var(--orb-rec); box-shadow: 0 0 56px rgba(230,63,92,.6), inset 0 -8px 22px rgba(0,0,0,.35); animation: none; }
#app.recording .ring { border-color: rgba(255,93,115,.55); }
#app.recording .r1 { animation: pulse 1.6s ease-out infinite; }
#app.recording .r2 { animation: pulse 1.6s ease-out .8s infinite; }

/* vad-active — green = speech detected */
#app.recording .orb.vad-active {
  background: radial-gradient(circle at 32% 28%, #80ffaa, #2ecc71 58%, #1a6b3c);
  box-shadow: 0 0 56px rgba(46, 204, 113, .65), inset 0 -8px 22px rgba(0, 0, 0, .35);
}
/* rings: toggle colour via a class on orb-wrap set by JS */
.orb-wrap.vad-active .ring { border-color: rgba(46, 204, 113, .55); }

/* thinking / speaking */
#app.thinking .orb, #app.speaking .orb { background: var(--orb-busy); box-shadow: 0 0 56px rgba(76,201,240,.55), inset 0 -8px 22px rgba(0,0,0,.35); }
#app.thinking .orb { animation: wobble 1.1s ease-in-out infinite; }
#app.speaking .orb { animation: talk .55s ease-in-out infinite; }
#app.speaking .ring { border-color: rgba(76,201,240,.5); }
#app.speaking .r1 { animation: pulse 1.2s ease-out infinite; }

/* deep thinking (adaptive reasoning engaged) — violet, slower, deliberate */
#app.thinking.deep .orb {
  background: radial-gradient(circle at 32% 28%, #b3a4ff, #6a54f0 58%, #2d2180);
  box-shadow: 0 0 64px rgba(124,108,255,.65), inset 0 -8px 22px rgba(0,0,0,.35);
  animation: ponder 2.2s ease-in-out infinite;
}
#app.thinking.deep .ring { border-color: rgba(124,108,255,.55); }
#app.thinking.deep .r1 { animation: pulse 2.2s ease-out infinite; }
#app.thinking.deep .r2 { animation: pulse 2.2s ease-out 1.1s infinite; }

@keyframes breathe { 50% { transform: scale(1.045); } }
@keyframes pulse { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.55); } }
@keyframes wobble { 50% { transform: scale(1.06) rotate(2deg); } }
@keyframes talk { 50% { transform: scale(1.07); } }
@keyframes ponder { 50% { transform: scale(1.05) rotate(-2deg); } }

.status { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); min-height: 1.2em; }
#app.recording .status { color: #ff8fa0; }
#app.speaking .status, #app.thinking .status { color: var(--accent-2); }
#app.thinking.deep .status { color: #b3a4ff; }

.voice-meter {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
#app.recording .voice-meter { opacity: 1; }
.voice-meter span {
  width: 4px;
  height: 4px;
  min-height: 4px;
  background: rgba(255, 143, 160, 0.75);
  border-radius: 3px;
  transition: height .07s ease;
}

.always-btn {
  font: inherit; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim); background: none;
  border: 1px solid var(--line); border-radius: 99px;
  padding: 5px 16px; cursor: pointer; transition: all .2s ease;
}
.always-btn:hover { color: var(--text); border-color: var(--dim); }
.always-btn.active {
  color: var(--accent-2);
  border-color: var(--accent-2);
  box-shadow: 0 0 12px rgba(76, 201, 240, .3);
}
/* listening pulse dot shown in always-on idle */
#app.always-on .orb { animation: breathe 2.5s ease-in-out infinite; }
