/* Jarvis HUD — mobile-first, dark only. */
:root {
  --bg: #03070c;
  --bg-2: #061019;
  --panel: rgba(9, 22, 34, 0.72);
  --panel-solid: #0a1824;
  --panel-2: rgba(16, 36, 54, 0.66);
  --line: rgba(110, 214, 255, 0.14);
  --line-2: rgba(110, 214, 255, 0.28);
  --cyan: #52e0ff;
  --cyan-2: #8ff0ff;
  --cyan-glow: rgba(82, 224, 255, 0.35);
  --violet: #9b98ff;
  --amber: #ffb84c;
  --red: #ff5c6c;
  --green: #3cf2b0;
  --text: #e4f5ff;
  --text-2: #b6cbd9;
  --muted: #7b95a8;
  --radius: 18px;
  --hud: 'Orbitron', 'Rajdhani', ui-sans-serif, system-ui, sans-serif;
  --hud-2: 'Rajdhani', ui-sans-serif, system-ui, sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --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);
  --vvh: 100dvh;
  --lvl: 0;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--text);
  font: 16px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
svg { width: 22px; height: 22px; flex: none; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- background ---------- */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(30, 110, 160, 0.20), transparent 60%),
    radial-gradient(80% 50% at 50% 100%, rgba(20, 70, 120, 0.18), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg)); }
.bg .grid { position: absolute; inset: 0; opacity: 0.5;
  background-image:
    linear-gradient(rgba(90, 200, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 200, 255, 0.045) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 35%, #000 20%, transparent 85%);
  mask-image: radial-gradient(70% 60% at 50% 35%, #000 20%, transparent 85%); }
.bg .vignette { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.55)); }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; z-index: 1; }
.boot-ring { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--cyan); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font-family: var(--hud-2); font-weight: 600; font-size: 17px; letter-spacing: 0.04em; transition: background .2s, border-color .2s, transform .1s; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(180deg, rgba(82, 224, 255, 0.28), rgba(40, 140, 200, 0.22)); border-color: rgba(120, 230, 255, 0.55); color: #eaffff;
  box-shadow: 0 0 0 1px rgba(82, 224, 255, 0.08) inset, 0 8px 30px -10px var(--cyan-glow); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255, 92, 108, 0.5); background: rgba(255, 92, 108, 0.12); color: #ffd5da; }
.btn.wide { width: 100%; }
.btn svg { width: 18px; height: 18px; }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--text-2); transition: background .2s, color .2s; }
.icon-btn:hover, .icon-btn:active { background: rgba(110, 214, 255, 0.08); color: var(--text); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 2; display: grid; place-items: center;
  padding: calc(var(--sat) + 24px) calc(var(--sar) + 20px) calc(var(--sab) + 24px) calc(var(--sal) + 20px); overflow-y: auto; }
.login-card { width: min(380px, 100%); text-align: center; animation: rise .6s cubic-bezier(.2,.8,.2,1) both; }
.login-orb { width: min(260px, 64vw); height: min(260px, 64vw); display: block; margin: 0 auto 8px; }
.brand { font-family: var(--hud); font-weight: 700; letter-spacing: 0.32em; font-size: 26px; margin: 6px 0 4px; padding-left: .32em;
  color: var(--cyan-2); text-shadow: 0 0 18px rgba(82, 224, 255, 0.5); }
.tagline { margin: 0 0 26px; color: var(--muted); font-family: var(--hud-2); letter-spacing: .16em; text-transform: uppercase; font-size: 13px; }
.login-form { display: grid; gap: 12px; }
.login-form input[type=password] { width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(4, 14, 22, 0.75);
  padding: 0 16px; font-size: 17px; letter-spacing: .08em; text-align: center; outline: none; transition: border-color .2s, box-shadow .2s; }
.login-form input[type=password]:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(82, 224, 255, 0.14); }
.login-err { min-height: 22px; margin: 4px 0 0; font-size: 14px; color: #ffb3bc; }
.login-err.wait { color: #ffd59a; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- main layout ---------- */
.main { position: fixed; left: 0; right: 0; top: 0; height: var(--vvh); z-index: 1; display: flex; flex-direction: column;
  padding: var(--sat) var(--sar) 0 var(--sal); }
.topbar { flex: none; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 8px; }
.title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-sm { font-family: var(--hud); font-weight: 700; letter-spacing: .3em; font-size: 15px; color: var(--cyan-2); text-shadow: 0 0 14px rgba(82, 224, 255, 0.45); padding-left: .3em; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line);
  background: rgba(6, 18, 28, 0.7); font-family: var(--hud-2); font-weight: 600; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.pill b { font-weight: 600; }
.pill[data-s=online] i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill[data-s=connecting] i, .pill[data-s=reconnecting] i { animation: blink 1s ease-in-out infinite; }
.pill[data-s=offline] i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.pill[data-s=offline] { color: #ffc2c9; border-color: rgba(255, 92, 108, .35); }
@keyframes blink { 50% { opacity: .25; } }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.orb-wrap { position: relative; flex: none; height: clamp(170px, 42vh, 420px); transition: height .45s cubic-bezier(.2,.8,.2,1); }
.main.has-msgs .orb-wrap { height: clamp(150px, 27vh, 300px); }
.orb-wrap canvas { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - 34px); display: block;
  transition: left .45s cubic-bezier(.2,.8,.2,1), width .45s cubic-bezier(.2,.8,.2,1), height .45s cubic-bezier(.2,.8,.2,1); }
.orb-hud { position: absolute; left: 16px; right: 16px; top: 10px; display: flex; justify-content: space-between; font-family: var(--hud); font-size: 9px; letter-spacing: .3em; color: rgba(130, 200, 230, 0.35); pointer-events: none; }
/* compact header orb (mobile): once there's a conversation */
@media (max-width: 1023.98px) {
  .main.compact .orb-wrap { height: 60px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(4, 12, 20, 0), rgba(4, 12, 20, .55)); }
  .main.compact .orb-wrap canvas { left: 8px; width: 60px; height: 60px; }
  .main.compact .orb-hud { opacity: 0; }
  .main.compact .orb-status { left: 74px; right: 12px; top: 0; height: 60px; justify-content: flex-start; padding: 0 4px; }
  .main.compact .state-detail { max-width: none; flex: 1; }
  .main.compact .state-label { font-size: 11px; }
  .orb-hud { transition: opacity .3s; }
  .orb-status { transition: left .45s cubic-bezier(.2,.8,.2,1), height .45s cubic-bezier(.2,.8,.2,1); }
}
.orb-status { position: absolute; left: 0; right: 0; bottom: 0; height: 34px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px; min-width: 0; }
.state-label { font-family: var(--hud); font-size: 12px; letter-spacing: .32em; text-transform: uppercase; color: var(--cyan-2); white-space: nowrap; transition: color .3s; }
.state-detail { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 60vw; }
.main[data-st=working] .state-label { color: var(--amber); }
.main[data-st=thinking] .state-label { color: #c4c2ff; }
.main[data-st=offline] .state-label, .main[data-st=error] .state-label { color: #ff9aa5; }
.main[data-st=thinking] .state-label::after, .main[data-st=working] .state-label::after, .main[data-st=transcribing] .state-label::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.panel { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.new-pill { position: absolute; z-index: 3; left: 50%; bottom: calc(150px + var(--sab)); transform: translateX(-50%); min-height: 36px; padding: 0 16px; border-radius: 18px;
  border: 1px solid rgba(120, 230, 255, 0.5); background: rgba(8, 30, 46, 0.94); color: var(--cyan-2); font: 600 13px var(--hud-2); letter-spacing: .12em; text-transform: uppercase;
  box-shadow: 0 8px 24px -8px #000, 0 0 18px -6px var(--cyan-glow); animation: rise .25s cubic-bezier(.2,.8,.2,1) both; }
.new-pill::before { content: ''; position: absolute; inset: -5px -2px; }
/* instant "thinking" shimmer before the first token */
.think { display: inline-flex; gap: 6px; align-items: center; height: 1.4em; padding: 0 2px; }
.think i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); opacity: .25; animation: think 1.1s ease-in-out infinite; }
.think i:nth-child(2) { animation-delay: .15s; } .think i:nth-child(3) { animation-delay: .3s; }
@keyframes think { 40% { opacity: 1; transform: translateY(-3px); box-shadow: 0 0 10px var(--cyan); } }
.msg.asst.streaming .bubble:has(.think)::after { display: none; }
.msg.asst .bubble:has(.think) { background: linear-gradient(100deg, rgba(9, 22, 34, .72) 30%, rgba(40, 110, 150, .32) 50%, rgba(9, 22, 34, .72) 70%); background-size: 300% 100%; animation: shimmer 1.6s linear infinite; }
/* devices */
.dev-list { display: grid; gap: 6px; margin: 2px 0 10px; }
.dev { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(3, 10, 16, 0.55); }
.dev.cur { border-color: rgba(120, 230, 255, 0.4); }
.dev-top { display: flex; align-items: center; gap: 8px; }
.dev-top b { font-weight: 600; font-size: 15px; }
.dev small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.tag { font: 600 10.5px var(--hud-2); letter-spacing: .12em; text-transform: uppercase; color: var(--green); border: 1px solid rgba(60, 242, 176, .4); border-radius: 99px; padding: 1px 8px; }
.dev-skel { height: 52px; margin: 0; }
.dev-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dev-actions .btn { font-size: 15px; padding: 0 10px; }
.btn:disabled { opacity: .4; }

/* ---------- transcript ---------- */
.transcript { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px 14px 14px; scroll-padding-bottom: 14px;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 16px); mask-image: linear-gradient(180deg, transparent 0, #000 16px); }
.empty { text-align: center; padding: 6px 8px 10px; color: var(--text-2); animation: rise .6s .1s both; }
.greet { font-family: var(--hud-2); font-weight: 600; font-size: 24px; letter-spacing: .03em; margin: 2px 0 6px; color: var(--text); }
.hint { margin: 0 auto 16px; max-width: 34ch; font-size: 14px; color: var(--muted); }
.suggest { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 2px 14px 4px; scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent); mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent); }
.suggest::-webkit-scrollbar { display: none; }
.suggest .chip-btn { flex: none; scroll-snap-align: center; white-space: nowrap; }
.suggest .chip-btn:first-child { margin-left: auto; }
.suggest .chip-btn:last-child { margin-right: auto; }
.chip-btn { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: rgba(10, 28, 42, 0.6); color: var(--text-2); font-size: 14px; transition: border-color .2s, color .2s, background .2s; }
.chip-btn:hover, .chip-btn:active { border-color: var(--line-2); color: var(--text); background: rgba(20, 50, 72, 0.6); }

.msg { display: flex; flex-direction: column; margin: 10px 0; max-width: 100%; animation: msgin .32s cubic-bezier(.2,.8,.2,1) both; }
@keyframes msgin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { align-items: flex-end; }
.msg .bubble { position: relative; max-width: min(86%, 620px); padding: 10px 14px; border-radius: var(--radius); word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.user .bubble { background: linear-gradient(180deg, rgba(60, 170, 220, 0.30), rgba(30, 110, 170, 0.26)); border: 1px solid rgba(110, 214, 255, 0.30); border-bottom-right-radius: 6px; color: #eefaff; }
.msg.user .bubble.pending { color: var(--muted); font-style: italic; }
.msg.user .bubble.pending::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--cyan); animation: blink 1s infinite; vertical-align: middle; }
.msg.user .via { font-size: 11px; color: var(--muted); margin: 3px 6px 0; font-family: var(--hud-2); letter-spacing: .1em; text-transform: uppercase; }
.msg.asst { align-items: flex-start; }
.msg.asst .bubble { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; font-size: 16.5px; line-height: 1.5;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .8); }
.msg.asst .bubble::before { content: ''; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 2px; border-radius: 2px; background: linear-gradient(var(--cyan), transparent); opacity: .8; }
.msg.asst .bubble:empty { display: none; }
.msg.asst.streaming .bubble::after { content: ''; display: inline-block; width: 8px; height: 1.05em; margin-left: 3px; vertical-align: -2px; background: var(--cyan); border-radius: 1px; animation: blink .9s steps(2) infinite; }
.msg.err .bubble { border-color: rgba(255, 92, 108, .4); color: #ffd0d6; }
.msg.cancelled .bubble { opacity: .75; }

.tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; max-width: 100%; }
.tools:empty { display: none; }
.tool { display: inline-flex; align-items: center; gap: 6px; max-width: min(100%, 520px); height: 28px; padding: 0 10px; border-radius: 99px;
  border: 1px solid rgba(255, 184, 76, 0.30); background: rgba(255, 184, 76, 0.08); color: #ffdca6; font-size: 12.5px; font-family: var(--mono); }
.tool svg { width: 14px; height: 14px; opacity: .85; }
.tool span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.tool.live { border-color: rgba(255, 184, 76, 0.65); box-shadow: 0 0 14px -4px rgba(255, 184, 76, .6); }
.tool.live svg { animation: spin 1.6s linear infinite; }

.details { width: min(100%, 680px); margin-top: 8px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5, 15, 24, 0.75); overflow: hidden; }
.details > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; cursor: pointer;
  font-family: var(--hud-2); font-weight: 600; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan-2); -webkit-user-select: none; user-select: none; }
.details > summary::-webkit-details-marker { display: none; }
.details > summary svg { width: 16px; height: 16px; transition: transform .2s; }
.details[open] > summary svg { transform: rotate(90deg); }
.details > summary small { margin-left: auto; color: var(--muted); letter-spacing: .06em; font-weight: 500; text-transform: none; font-family: var(--ui); font-size: 12px; }
.md { padding: 2px 16px 14px; font-size: 15px; line-height: 1.55; color: var(--text-2); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 4px; }
.md h3, .md h4, .md h5, .md h6 { color: var(--text); margin: 14px 0 6px; line-height: 1.3; }
.md h3 { font-size: 17px; } .md h4 { font-size: 16px; } .md h5, .md h6 { font-size: 15px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--cyan); }
.md strong { color: var(--text); }
.md a { color: var(--cyan-2); text-decoration: underline; text-decoration-color: rgba(143, 240, 255, .4); text-underline-offset: 2px; }
.md code { font-family: var(--mono); font-size: .88em; padding: 1px 5px; border-radius: 5px; background: rgba(110, 214, 255, 0.10); color: #c9f4ff; }
.md blockquote { margin: 8px 0; padding: 2px 12px; border-left: 2px solid var(--line-2); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.md .task { display: inline-block; width: 13px; height: 13px; border: 1px solid var(--line-2); border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.md .task.on { background: var(--cyan); border-color: var(--cyan); }
.md .code { margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; background: #030a10; overflow: hidden; }
.md .code-h { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 4px 0 12px; border-bottom: 1px solid var(--line); font: 12px var(--mono); color: var(--muted); }
.md .copy { min-width: 44px; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text-2); font: 600 12px var(--hud-2); letter-spacing: .1em; text-transform: uppercase; }
.md .copy.ok { color: var(--green); border-color: rgba(60, 242, 176, .4); }
.md pre { margin: 0; padding: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; font: 13px/1.5 var(--mono); color: #d6f3ff; tab-size: 2; }
.md pre code { padding: 0; background: none; font-size: inherit; color: inherit; white-space: pre; }
.md .table { overflow-x: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.md th { color: var(--text); background: rgba(110, 214, 255, 0.06); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }

.meta { display: flex; align-items: center; gap: 4px; margin: 4px 2px 0; min-height: 30px; font-size: 12px; color: var(--muted); font-family: var(--hud-2); letter-spacing: .06em; }
.meta:empty { display: none; }
.meta .replay { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; height: 44px; margin: -7px 0 -7px -10px; padding: 0 10px; border: 0; background: none; color: var(--cyan); border-radius: 10px;
  font: 600 12px var(--hud-2); letter-spacing: .12em; text-transform: uppercase; }
.meta .replay svg { width: 14px; height: 14px; }
.meta .replay:hover { background: rgba(110, 214, 255, 0.08); }
.meta .replay[aria-busy=true] { opacity: .5; }
.meta .dot::before { content: '·'; margin: 0 6px; }
.meta .dot:first-child::before { content: none; }
.meta .dot.warn { color: #ffb3bc; }

/* ---------- dock ---------- */
.dock { flex: none; padding: 8px 12px calc(10px + var(--sab)); background: linear-gradient(180deg, rgba(3, 7, 12, 0), rgba(3, 7, 12, 0.88) 30%); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 14px; border-radius: 24px; border: 1px solid var(--line); background: rgba(7, 20, 31, 0.85);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: var(--line-2); box-shadow: 0 0 0 4px rgba(82, 224, 255, 0.07); }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent; font-size: 16px; line-height: 22px; padding: 10px 0; max-height: 132px; color: var(--text); }
.composer textarea::placeholder { color: var(--muted); }
.send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--cyan); color: #032; transition: opacity .2s, transform .15s, background .2s; }
.send:disabled { background: rgba(110, 214, 255, 0.14); color: var(--muted); }
.send:not(:disabled):active { transform: scale(.94); }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-top: 10px; }
.ctl { justify-self: center; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 76px; min-height: 52px; padding: 4px 10px; border-radius: 16px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); font: 600 11px var(--hud-2); letter-spacing: .14em; text-transform: uppercase; transition: color .2s, background .2s, border-color .2s, opacity .2s; }
.ctl svg { width: 22px; height: 22px; }
.ctl:not(:disabled):active { background: rgba(110, 214, 255, 0.08); }
.ctl[aria-pressed=true] { color: var(--green); border-color: rgba(60, 242, 176, .35); background: rgba(60, 242, 176, .08); box-shadow: 0 0 18px -6px rgba(60, 242, 176, .6); }
.ctl.stop:not(:disabled) { color: #ffb3bc; border-color: rgba(255, 92, 108, .35); background: rgba(255, 92, 108, .08); }
.ctl:disabled { opacity: .35; }

.mic { position: relative; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; touch-action: none; -webkit-touch-callout: none;
  border: 1px solid rgba(130, 230, 255, 0.55); color: #eaffff;
  background: radial-gradient(circle at 50% 35%, rgba(110, 230, 255, 0.45), rgba(20, 90, 140, 0.55) 60%, rgba(8, 30, 48, 0.9));
  box-shadow: 0 0 0 6px rgba(82, 224, 255, 0.06), 0 0 34px -6px var(--cyan-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform .15s, box-shadow .25s, background .25s; }
.mic svg.mic-ico { width: 30px; height: 30px; position: relative; }
.mic:active { transform: scale(.96); }
.mic-ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(82, 224, 255, 0.0); transform: scale(calc(1 + var(--lvl) * 0.12)); transition: border-color .2s; pointer-events: none; }
.mic.rec { background: radial-gradient(circle at 50% 35%, rgba(255, 140, 150, 0.55), rgba(190, 40, 70, 0.6) 60%, rgba(60, 10, 24, 0.9)); border-color: rgba(255, 150, 160, 0.7);
  box-shadow: 0 0 0 6px rgba(255, 92, 108, 0.10), 0 0 40px -4px rgba(255, 92, 108, 0.55); }
.mic.rec .mic-ring { border-color: rgba(255, 120, 135, 0.7); }
.mic.hf { background: radial-gradient(circle at 50% 35%, rgba(120, 255, 210, 0.45), rgba(20, 130, 110, 0.55) 60%, rgba(6, 40, 34, 0.9)); border-color: rgba(120, 255, 210, 0.6);
  box-shadow: 0 0 0 6px rgba(60, 242, 176, 0.08), 0 0 36px -6px rgba(60, 242, 176, 0.55); }
.mic.hf .mic-ring { border-color: rgba(60, 242, 176, 0.55); }
.mic.dis { opacity: .5; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 4, 8, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity .25s; }
.scrim.on { opacity: 1; }
.drawer { position: fixed; z-index: 21; top: 0; bottom: 0; left: 0; width: min(360px, 88vw); display: flex; flex-direction: column;
  padding: calc(var(--sat) + 8px) 12px calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  background: linear-gradient(180deg, rgba(8, 22, 34, 0.98), rgba(4, 12, 20, 0.98)); border-right: 1px solid var(--line);
  transform: translateX(-104%); transition: transform .3s cubic-bezier(.2,.8,.2,1); box-shadow: 20px 0 60px -20px rgba(0, 0, 0, .8); }
.drawer.on { transform: none; }
.drawer-h, .sheet-h { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.drawer h2, .sheet h2 { margin: 0 0 0 6px; font-family: var(--hud); font-size: 14px; letter-spacing: .28em; text-transform: uppercase; color: var(--cyan-2); font-weight: 600; }
.new-btn { margin: 6px 0 12px; }
.conv-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; -webkit-overflow-scrolling: touch; }
.conv { display: flex; align-items: stretch; gap: 2px; margin: 4px 0; border-radius: 14px; border: 1px solid transparent; transition: background .2s, border-color .2s; }
.conv:hover { background: rgba(110, 214, 255, 0.05); }
.conv.cur { border-color: var(--line-2); background: rgba(82, 224, 255, 0.08); }
.conv-open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 10px 12px; min-height: 56px; border-radius: 14px; }
.conv-open b { display: block; font-weight: 600; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-open small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.conv .icon-btn { align-self: center; color: var(--muted); }
.conv .icon-btn:hover { color: #ffb3bc; }
.conv-empty, .conv-loading { padding: 24px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.skel { height: 56px; margin: 6px 0; border-radius: 14px; background: linear-gradient(90deg, rgba(110, 214, 255, 0.04), rgba(110, 214, 255, 0.10), rgba(110, 214, 255, 0.04)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- settings sheet ---------- */
.sheet { position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(560px, 100%); max-height: calc(var(--vvh) - var(--sat) - 24px); display: flex; flex-direction: column;
  padding: 6px calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px);
  border-radius: 24px 24px 0 0; border: 1px solid var(--line-2); border-bottom: 0; background: linear-gradient(180deg, rgba(10, 26, 40, 0.98), rgba(5, 14, 22, 0.99));
  transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, .9); }
.sheet.on { transform: none; }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(140, 200, 230, 0.3); margin: 4px auto 2px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.field { margin: 14px 0 18px; }
.label { display: block; font-family: var(--hud-2); font-weight: 600; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row output { font-family: var(--hud-2); font-weight: 700; font-size: 16px; color: var(--cyan-2); }
.sub { display: block; color: var(--muted); font-size: 13px; margin: 0; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px; border-radius: 16px; background: rgba(3, 10, 16, 0.7); border: 1px solid var(--line); }
.seg button { min-height: 52px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 2px; transition: background .2s, color .2s, border-color .2s; }
.seg button b { font-family: var(--hud-2); font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.seg button small { font-size: 11px; color: var(--muted); }
.seg button[aria-checked=true] { background: linear-gradient(180deg, rgba(82, 224, 255, 0.24), rgba(40, 140, 200, 0.16)); border-color: rgba(120, 230, 255, 0.5); color: #fff; }
.seg button[aria-checked=true] small { color: var(--cyan-2); }
.row { display: flex; gap: 8px; }
.select { position: relative; flex: 1; min-width: 0; }
.select select { width: 100%; height: 48px; appearance: none; -webkit-appearance: none; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(3, 10, 16, 0.7); padding: 0 40px 0 14px; font-size: 16px; color: var(--text); }
.select svg { position: absolute; right: 12px; top: 13px; width: 20px; height: 20px; transform: rotate(90deg); color: var(--muted); pointer-events: none; }
input[type=range] { width: 100%; height: 44px; -webkit-appearance: none; appearance: none; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--cyan) var(--fill, 37.5%), rgba(110, 214, 255, 0.16) var(--fill, 37.5%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%; background: #dff9ff; border: 0; box-shadow: 0 0 0 5px rgba(82, 224, 255, 0.22), 0 2px 8px rgba(0, 0, 0, .5); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(110, 214, 255, 0.16); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--cyan); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #dff9ff; border: 0; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-row .label { margin-bottom: 2px; }
.switch { flex: none; position: relative; width: 62px; height: 44px; border: 0; background: none; padding: 0; }
.switch::before { content: ''; position: absolute; left: 2px; right: 2px; top: 5px; bottom: 5px; border-radius: 17px; border: 1px solid var(--line-2); background: rgba(3, 10, 16, 0.8); transition: background .2s, border-color .2s; }
.switch i { position: absolute; top: 9px; left: 6px; width: 26px; height: 26px; border-radius: 50%; background: #9fb4c2; transition: transform .22s cubic-bezier(.2,.8,.2,1), background .2s; }
.switch[aria-checked=true]::before { background: rgba(82, 224, 255, 0.3); border-color: rgba(120, 230, 255, 0.6); }
.switch[aria-checked=true] i { transform: translateX(24px); background: #eaffff; box-shadow: 0 0 12px rgba(82, 224, 255, .7); }
kbd { font: 600 12px var(--mono); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: rgba(110, 214, 255, 0.06); color: var(--text-2); }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.ver { font: 11px var(--mono); color: var(--muted); }

/* ---------- confirm ---------- */
.confirm { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 4, 8, 0.6);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); padding: 16px calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px); animation: fade .2s both; }
.confirm-card { width: min(420px, 100%); padding: 20px 18px 16px; border-radius: 22px; border: 1px solid var(--line-2); background: linear-gradient(180deg, #0c2132, #07131d); box-shadow: 0 30px 80px -20px #000; animation: rise .28s cubic-bezier(.2,.8,.2,1) both; }
.confirm h3 { margin: 0 0 6px; font-size: 18px; }
.confirm p { margin: 0 0 18px; color: var(--text-2); font-size: 15px; overflow-wrap: anywhere; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 50; left: 50%; top: calc(var(--sat) + 60px); transform: translate(-50%, -8px); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 14px;
  background: rgba(10, 28, 42, 0.96); border: 1px solid var(--line-2); color: var(--text); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; box-shadow: 0 10px 30px -10px #000; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(255, 92, 108, 0.5); color: #ffd0d6; }

/* ---------- desktop ---------- */
@media (min-width: 1024px) {
  .topbar { height: 64px; padding: 0 20px; }
  .stage { flex-direction: row; gap: 8px; padding: 0 24px 0 12px; }
  .orb-wrap, .main.has-msgs .orb-wrap { height: auto; flex: 1 1 50%; min-width: 0; align-self: stretch; margin-bottom: 24px; }
  .orb-wrap canvas { height: calc(100% - 48px); }
  .orb-status { height: 48px; }
  .state-label { font-size: 14px; }
  .state-detail { max-width: 26vw; }
  .orb-hud { top: 24px; left: 40px; right: 40px; font-size: 10px; }
  .panel { flex: 0 1 720px; min-width: 520px; margin: 0 auto; border-left: 1px solid var(--line); padding-left: 8px;
    background: linear-gradient(90deg, rgba(5, 14, 22, 0.35), transparent 40%); }
  .transcript { padding: 18px 22px; }
  .dock { padding: 10px 22px 22px; }
  .toast { top: 76px; }
  .new-pill { bottom: 170px; }
  .greet { font-size: 28px; margin-top: 24px; }
  .sheet { bottom: auto; top: 50%; border-radius: 24px; border-bottom: 1px solid var(--line-2); transform: translateY(-46%) scale(.97); opacity: 0; pointer-events: none; transition: transform .25s, opacity .25s; max-height: 86vh; }
  .sheet.on { transform: translateY(-50%); opacity: 1; pointer-events: auto; }
  .sheet-grab { display: none; }
  .confirm { align-items: center; }
}
@media (hover: none) { .kbd-help { display: none; } }

@media (max-width: 360px) {
  .ctl { min-width: 64px; padding: 4px 6px; }
  .brand-sm { letter-spacing: .2em; }
  .seg button small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .mic-ring { transform: none; }
}
