:root { --bg:#0d1117; --panel:#161b22; --line:#2a313c; --fg:#e8edf3; --muted:#8b96a5; --accent:#3b82f6; --bad:#ef4444; --warn:#f59e0b; --ok:#22c55e; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--fg); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; }
.app { display:flex; flex-direction:column; height:100%; max-width:760px; margin:0 auto; }
header { display:flex; align-items:center; justify-content:space-between; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; border-bottom:1px solid var(--line); }
header h1 { font-size:20px; margin:0; letter-spacing:.5px; }
header .mode { font-size:12px; padding:3px 8px; border-radius:999px; background:var(--panel); border:1px solid var(--line); color:var(--muted); }
header .mode.auto { color:var(--ok); border-color:var(--ok); }
main { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.view { display:none; padding:14px 16px 24px; }
.view.on { display:block; }
nav { display:flex; border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom); background:var(--panel); }
nav button { flex:1; background:none; border:0; padding:10px 0 8px; color:var(--muted); font-size:12px; display:flex; flex-direction:column; align-items:center; gap:2px; }
nav button .i { font-size:20px; }
nav button.on { color:var(--accent); }

/* talk */
#talk.on { display:flex; flex-direction:column; min-height:100%; padding-bottom:0; }
#msgs { flex:1; display:flex; flex-direction:column; gap:10px; padding-bottom:12px; }
.msg { max-width:88%; padding:10px 12px; border-radius:14px; white-space:pre-wrap; word-wrap:break-word; }
.msg.me { align-self:flex-end; background:var(--accent); color:#fff; border-bottom-right-radius:4px; }
.msg.j { align-self:flex-start; background:var(--panel); border:1px solid var(--line); border-bottom-left-radius:4px; }
.msg.sys { align-self:center; color:var(--muted); font-size:13px; background:none; }
.msg .play { display:inline-block; margin-top:6px; background:none; border:1px solid var(--line); border-radius:999px; padding:2px 10px; font-size:13px; color:var(--muted); }
.hint { color:var(--muted); font-size:14px; text-align:center; margin:30px 10px; }
.chips { display:flex; gap:8px; overflow-x:auto; padding:4px 0 10px; }
.chips button { white-space:nowrap; background:var(--panel); border:1px solid var(--line); border-radius:999px; padding:6px 12px; font-size:14px; }
.composer { position:sticky; bottom:0; background:var(--bg); padding:8px 0 10px; display:flex; gap:8px; align-items:flex-end; }
.composer textarea { flex:1; resize:none; background:var(--panel); border:1px solid var(--line); color:var(--fg); border-radius:20px; padding:10px 14px; font:inherit; max-height:120px; }
.round { width:48px; height:48px; border-radius:50%; border:0; display:flex; align-items:center; justify-content:center; font-size:22px; flex:none; }
#send { background:var(--panel); border:1px solid var(--line); }
#mic { background:var(--accent); color:#fff; width:58px; height:58px; font-size:26px; }
#mic.rec { background:var(--bad); animation:pulse 1.2s infinite; }
#mic.busy { background:var(--line); }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(239,68,68,.6)} 100%{box-shadow:0 0 0 18px rgba(239,68,68,0)} }
.speak { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted); justify-content:center; padding-bottom:4px; }

/* fleet */
.when { color:var(--muted); font-size:13px; margin:0 0 12px; }
.tiles { display:grid; grid-template-columns:repeat(2, 1fr); gap:10px; }
.tile { background:var(--panel); border:1px solid var(--line); border-left:4px solid var(--line); border-radius:10px; padding:10px 12px; }
.tile.bad { border-left-color:var(--bad); } .tile.warn { border-left-color:var(--warn); } .tile.good { border-left-color:var(--ok); }
.tile b { display:block; font-size:26px; font-variant-numeric:tabular-nums; }
.tile span { font-size:12px; color:var(--muted); }
h2 { font-size:16px; margin:20px 0 8px; }
.list { background:var(--panel); border:1px solid var(--line); border-radius:10px; }
.row { padding:10px 12px; border-bottom:1px solid var(--line); font-size:14px; }
.row:last-child { border-bottom:0; }
.row small { display:block; color:var(--muted); font-size:12px; margin-top:2px; }
.row .hi { color:var(--bad); font-weight:600; } .row .md { color:var(--warn); font-weight:600; }
.empty { padding:12px; color:var(--muted); font-size:14px; }

/* reports */
.grid { display:grid; grid-template-columns:repeat(2, 1fr); gap:10px; }
.grid button { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:16px 10px; text-align:left; }
.grid button .i { font-size:22px; display:block; margin-bottom:4px; }
pre.report { white-space:pre-wrap; word-wrap:break-word; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px; }
.back { background:none; border:0; color:var(--accent); padding:0; margin-bottom:8px; }

/* settings */
.modes { display:flex; flex-direction:column; gap:10px; }
.modes button { text-align:left; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px; }
.modes button.on { border-color:var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.modes button small { display:block; color:var(--muted); font-size:13px; margin-top:2px; }
.danger { width:100%; margin-top:24px; background:none; border:1px solid var(--line); border-radius:10px; padding:12px; color:var(--bad); }
.note { color:var(--muted); font-size:13px; }

/* login */
.login { display:flex; flex-direction:column; justify-content:center; min-height:100%; padding:24px; max-width:380px; margin:0 auto; gap:14px; }
.login h1 { font-size:34px; margin:0; text-align:center; letter-spacing:1px; }
.login p { color:var(--muted); text-align:center; margin:0; }
.login input { background:var(--panel); border:1px solid var(--line); color:var(--fg); border-radius:12px; padding:14px; font:inherit; }
.login button { background:var(--accent); border:0; color:#fff; border-radius:12px; padding:14px; font-weight:600; }
.err { color:var(--bad); text-align:center; min-height:1.4em; font-size:14px; }

/* start-up screen */
#boot { position:fixed; inset:0; z-index:50; background:radial-gradient(circle at 50% 42%, #0b2a4a 0%, #05080d 70%); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:18px; transition:opacity .6s; cursor:pointer; }
#boot.gone { opacity:0; pointer-events:none; }
#boot h1 { margin:0; font-size:30px; letter-spacing:10px; color:#7cc4ff; font-weight:300; text-shadow:0 0 18px rgba(80,170,255,.7); }
#boot p { margin:0; color:#5f86a8; letter-spacing:3px; font-size:13px; text-transform:uppercase; }
.ring { width:170px; height:170px; border-radius:50%; border:2px solid rgba(90,180,255,.6); position:relative; box-shadow:0 0 30px rgba(60,160,255,.45), inset 0 0 30px rgba(60,160,255,.25); }
.ring2 { position:absolute; inset:16px; border-radius:50%; border:6px dashed rgba(120,200,255,.55); }
.core { position:absolute; inset:58px; border-radius:50%; background:radial-gradient(circle, #d8f0ff 0%, #4aa8ff 45%, rgba(20,80,160,0) 75%); box-shadow:0 0 40px #4aa8ff; }
@media (prefers-reduced-motion: no-preference) {
  .ring2 { animation: spin 9s linear infinite; }
  .core { animation: glow 2.4s ease-in-out infinite; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow { 50% { box-shadow:0 0 70px #7cc4ff; transform: scale(1.06); } }
.speak { flex-wrap:wrap; gap:14px; }
#hfState { color:var(--accent); min-height:0; }

/* conversation mode */
.talkbtn { width:100%; margin:4px 0 10px; padding:14px; border:0; border-radius:14px; font-size:17px; font-weight:600; color:#fff;
  background:linear-gradient(135deg, #1d4ed8, #3b82f6); box-shadow:0 4px 18px rgba(59,130,246,.35); }
#convo { position:fixed; inset:0; z-index:40; background:radial-gradient(circle at 50% 40%, #0b2a4a 0%, #05080d 72%);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:22px; padding:24px; text-align:center; }
#convo[hidden] { display:none; }
.orb { width:190px; height:190px; border-radius:50%; position:relative; border:2px solid rgba(90,180,255,.5);
  box-shadow:0 0 40px rgba(60,160,255,.4), inset 0 0 40px rgba(60,160,255,.25); transition: transform .3s; }
.orb-core { position:absolute; inset:45px; border-radius:50%; background:radial-gradient(circle, #e2f3ff 0%, #4aa8ff 45%, rgba(20,80,160,0) 75%); box-shadow:0 0 50px #4aa8ff; }
#convo[data-state="thinking"] .orb { border-style:dashed; }
#convo[data-state="speaking"] .orb-core { background:radial-gradient(circle, #fff 0%, #7cc4ff 40%, rgba(20,80,160,0) 75%); }
@media (prefers-reduced-motion: no-preference) {
  #convo[data-state="listening"] .orb { animation: listen 1.6s ease-in-out infinite; }
  #convo[data-state="thinking"] .orb { animation: spin 2.5s linear infinite; }
  #convo[data-state="speaking"] .orb-core { animation: talk .45s ease-in-out infinite alternate; }
}
@keyframes listen { 50% { transform: scale(1.07); box-shadow:0 0 70px rgba(90,180,255,.7), inset 0 0 40px rgba(60,160,255,.3); } }
@keyframes talk { from { transform: scale(.9); } to { transform: scale(1.12); } }
.cap { color:#cfe8ff; font-size:17px; line-height:1.45; max-width:520px; margin:0; min-height:1.4em; }
.heard { color:#6f93b5; font-size:14px; margin:0; min-height:1.2em; max-width:520px; }
.endbtn { background:none; border:1px solid #2a4a6a; color:#9cc8ef; border-radius:999px; padding:10px 22px; }

.state { color:#7cc4ff; letter-spacing:4px; text-transform:uppercase; font-size:13px; margin:0; min-height:1.2em; }
.convo-foot { position:absolute; bottom: calc(env(safe-area-inset-bottom) + 28px); display:flex; flex-direction:column; align-items:center; gap:14px; }
.words { color:#5f86a8; font-size:13px; }

.dash-lang { background:var(--panel); color:var(--fg); border:1px solid var(--line); border-radius:8px; padding:4px 8px; font:inherit; font-size:13px; }
#convo .dash-lang { background:#0b2238; color:#9cc8ef; border-color:#2a4a6a; }
