:root {
  color-scheme: dark;
  --bg: #020812;
  --bg-2: #061a2a;
  --cyan: #3be8ff;
  --cyan-2: rgba(59, 232, 255, .55);
  --cyan-3: rgba(59, 232, 255, .14);
  --gold: #ffc35a;
  --red: #ff4f61;
  --text: #dff9ff;
  --muted: #7ea7b6;
  --card: rgba(6, 26, 40, .92);
  --glow: 0 0 8px rgba(59, 232, 255, .7), 0 0 24px rgba(59, 232, 255, .3);
  --hud: "Orbitron", "Segoe UI", system-ui, sans-serif;
  --body: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; overflow: hidden; user-select: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.bg { position: fixed; inset: 0; background:
  radial-gradient(60% 45% at 50% 42%, rgba(18, 92, 128, .45), transparent 70%),
  radial-gradient(120% 90% at 50% 120%, rgba(255, 140, 40, .07), transparent 60%),
  linear-gradient(180deg, #020a14, var(--bg) 60%); }
.bg::after { content: ""; position: absolute; inset: 0; opacity: .35;
  background-image: linear-gradient(rgba(59,232,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(59,232,255,.06) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at 50% 45%, #000 20%, transparent 70%); }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .18; z-index: 30;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.4) 0 1px, transparent 1px 3px); }

.screen { position: fixed; inset: 0; padding: calc(12px + var(--sat)) max(16px, var(--sar)) calc(12px + var(--sab)) max(16px, var(--sal)); }

/* ---------- boot ---------- */
#boot { display: grid; place-items: center; z-index: 20; transition: opacity .7s ease, filter .7s ease; }
#boot.out { opacity: 0; filter: blur(8px); pointer-events: none; }
.boot-core { display: grid; justify-items: center; gap: 14px; text-align: center; }
.wordmark { font-family: var(--hud); font-weight: 800; letter-spacing: .32em; color: var(--cyan); text-shadow: var(--glow); padding-left: .32em; }
.wordmark.big { font-size: clamp(40px, 12vw, 84px); animation: flick 4s infinite; }
.tagline { font-family: var(--hud); font-size: 10px; letter-spacing: .34em; color: var(--muted); padding-left: .34em; }
.init { position: relative; margin-top: 46px; width: 168px; height: 168px; border-radius: 50%; border: 2px solid var(--cyan);
  background: radial-gradient(circle, rgba(59,232,255,.28), rgba(59,232,255,.04) 60%, transparent 72%); color: var(--cyan);
  font-family: var(--hud); font-weight: 700; letter-spacing: .2em; font-size: 13px; box-shadow: var(--glow), inset 0 0 34px rgba(59,232,255,.35);
  animation: breathe 2.4s ease-in-out infinite; }
.init::before, .init::after { content: ""; position: absolute; border-radius: 50%; inset: -16px; border: 2px dashed var(--cyan-2); animation: spin 14s linear infinite; }
.init::after { inset: -32px; border: 2px solid transparent; border-top-color: var(--gold); border-bottom-color: var(--cyan-2); animation-duration: 5s; animation-direction: reverse; }
.boot-hint { color: var(--muted); font-size: 15px; margin-top: 38px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { box-shadow: 0 0 26px rgba(59,232,255,.9), 0 0 70px rgba(59,232,255,.4), inset 0 0 44px rgba(59,232,255,.5); } }
@keyframes flick { 0%, 91%, 100% { opacity: 1 } 92% { opacity: .45 } 94% { opacity: 1 } 96% { opacity: .75 } }

/* ---------- main ---------- */
#hud { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; animation: rise .9s ease; }
@keyframes rise { from { opacity: 0; transform: scale(1.04); filter: blur(6px); } }
.bar { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .wordmark { font-size: 17px; letter-spacing: .3em; }
.mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--cyan); box-shadow: var(--glow); position: relative; }
.mark::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--cyan); box-shadow: var(--glow); }
.bar-actions { display: flex; gap: 6px; }
.ic { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: transparent; border: 1px solid transparent; color: var(--cyan); }
.ic:hover { background: var(--cyan-3); }
.ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.soft { border-color: var(--cyan-3); background: rgba(6, 26, 40, .5); }

.stage { position: relative; min-height: 0; display: grid; place-items: center; }
#orb { position: absolute; inset: 0; width: 100%; height: 100%; }
.orb-hit { position: relative; width: min(56vmin, 340px); aspect-ratio: 1; max-width: 100%; border-radius: 50%; border: 0; background: transparent; }

.status { text-align: center; min-height: 64px; display: grid; gap: 8px; align-content: start; justify-items: center; }
#statusText { font-family: var(--hud); font-size: 12px; letter-spacing: .34em; padding-left: .34em; color: var(--muted); transition: color .3s; }
#statusText.on { color: var(--cyan); text-shadow: var(--glow); }
.caption { max-width: min(640px, 100%); font-size: 18px; line-height: 1.4; color: var(--text); opacity: .9; user-select: text;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.dock { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 8px; }
.type { flex: 1; max-width: 560px; display: flex; gap: 8px; animation: rise .3s ease; }
.type input { flex: 1; min-width: 0; height: 46px; padding: 0 18px; border-radius: 23px; background: rgba(6, 26, 40, .8); border: 1px solid var(--cyan-2); outline: none; font-size: 17px; }
.type input::placeholder { color: var(--muted); }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--cyan); color: #01131c; display: grid; place-items: center; flex: none; }
.send svg { width: 20px; height: 20px; fill: currentColor; }
#voiceGlyph { font-size: 20px; line-height: 1; }
.credit { text-align: center; font-family: var(--hud); font-size: 8.5px; letter-spacing: .3em; color: rgba(126, 167, 182, .55); padding-top: 10px; }

/* ---------- sheets & drawer ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: grid; place-items: end center; background: rgba(0, 4, 10, .6); backdrop-filter: blur(6px);
  padding: calc(12px + var(--sat)) max(12px, var(--sar)) calc(12px + var(--sab)) max(12px, var(--sal)); }
@media (min-width: 700px) { .sheet { place-items: center; } }
.card { width: min(480px, 100%); max-height: 100%; overflow-y: auto; background: var(--card); border: 1px solid var(--cyan-3); border-radius: 22px;
  padding: 22px; box-shadow: 0 20px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(59,232,255,.15); animation: up .35s ease; user-select: text; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-title { font-family: var(--hud); font-size: 13px; letter-spacing: .26em; color: var(--cyan); margin-bottom: 16px; }
.voices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.voice { display: grid; justify-items: center; gap: 4px; padding: 20px 10px; border-radius: 18px; background: rgba(59,232,255,.05); border: 1px solid var(--cyan-3); }
.voice.on { border-color: var(--cyan); background: rgba(59,232,255,.13); box-shadow: var(--glow); }
.v-icon { font-size: 34px; color: var(--cyan); }
.voice b { font-family: var(--hud); letter-spacing: .2em; font-size: 12px; }
.voice small { color: var(--muted); font-size: 14px; }
.fine { color: var(--muted); font-size: 14px; line-height: 1.4; }
.btn { height: 48px; border-radius: 24px; padding: 0 20px; border: 1px solid var(--cyan-2); background: transparent; color: var(--cyan); font-family: var(--hud); font-size: 11px; letter-spacing: .2em; }
.btn.primary { background: var(--cyan); color: #01131c; border-color: var(--cyan); font-weight: 700; }
.btn.ghost { border-color: var(--cyan-3); color: var(--muted); }
.btn.small { height: 38px; padding: 0 14px; font-size: 10px; flex: none; }
.btn.wide { width: 100%; margin-top: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid rgba(59,232,255,.08); }
.row.col { flex-direction: column; align-items: stretch; }
.row b { display: block; font-size: 17px; }
.row small { color: var(--muted); font-size: 14px; }
.seg { display: flex; border: 1px solid var(--cyan-2); border-radius: 20px; overflow: hidden; flex: none; }
.seg button { border: 0; background: transparent; padding: 8px 12px; font-family: var(--hud); font-size: 9px; letter-spacing: .14em; color: var(--muted); }
.seg button.on { background: var(--cyan); color: #01131c; }
.tog { appearance: none; width: 50px; height: 30px; border-radius: 15px; background: rgba(126,167,182,.25); position: relative; flex: none; transition: background .2s; }
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog:checked { background: var(--cyan); }
.tog:checked::after { transform: translateX(20px); }
.sel, .txt { height: 42px; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid var(--cyan-3); padding: 0 12px; max-width: 55%; }
.txt { max-width: none; width: 100%; font-size: 16px; }
.about { text-align: center; padding: 18px 0 6px; }
.about .wordmark { font-size: 16px; }
.about p { color: var(--muted); margin: 8px 0 0; line-height: 1.5; }
.about b { color: var(--text); }

.drawer { position: fixed; z-index: 35; top: 0; bottom: 0; right: 0; width: min(420px, 100%); background: var(--card); border-left: 1px solid var(--cyan-3);
  display: flex; flex-direction: column; padding: calc(14px + var(--sat)) max(16px, var(--sar)) calc(14px + var(--sab)) 16px; animation: slidein .3s ease; user-select: text; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--hud); font-size: 12px; letter-spacing: .24em; color: var(--cyan); }
.log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 12px 0; }
.m { line-height: 1.45; font-size: 16px; overflow-wrap: anywhere; }
.m.me { align-self: flex-end; background: rgba(59,232,255,.1); border: 1px solid var(--cyan-3); padding: 8px 12px; border-radius: 14px 14px 4px 14px; max-width: 88%; }
.m.ai { border-left: 2px solid var(--cyan); padding-left: 10px; max-width: 94%; }
.m small { display: block; font-family: var(--hud); font-size: 8px; letter-spacing: .2em; color: var(--muted); margin-bottom: 3px; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(110px + var(--sab)); transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--card); border: 1px solid var(--cyan-2); color: var(--text); padding: 10px 18px; border-radius: 20px; text-align: center; font-size: 15px; box-shadow: var(--glow); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
