:root {
  --bg: #0f1419; --panel: #171e26; --line: #26313d; --text: #e6edf3; --muted: #8b98a5;
  --accent: #c8102e; --accent2: #e8364f; --me: #1f2a36; --ok: #2ea043; --warn: #d29922;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: .6rem 1rem;
  background: var(--accent); color: #fff; }
button:hover { background: var(--accent2); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.ghost:hover { border-color: var(--muted); }
button.danger { color: #ff7b72; }
input, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem .8rem; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); display: grid;
  place-items: center; font-weight: 700; font-size: 1.6rem; margin: 0 auto; }
.logo.small { width: 28px; height: 28px; font-size: .95rem; border-radius: 8px; display: inline-grid;
  margin: 0 .5rem 0 0; vertical-align: middle; }

.view { height: 100%; }
#login { display: grid; place-items: center; padding: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 2rem; }
.login { width: min(380px, 100%); display: flex; flex-direction: column; gap: 1rem; text-align: left; }
.login h1 { text-align: center; margin: .2rem 0 .5rem; }
.login label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: var(--muted); }
.error { color: #ff7b72; min-height: 1.2em; margin: 0; }

#app { display: flex; flex-direction: column; max-width: 900px; margin: 0 auto; }
#app > header { display: flex; justify-content: space-between; align-items: center;
  padding: calc(.7rem + env(safe-area-inset-top)) 1rem .7rem; border-bottom: 1px solid var(--line); }
#app > header .title { font-weight: 600; }
#app nav { display: flex; gap: .5rem; }
#app nav button { padding: .4rem .8rem; }

#chat { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .8rem; }
.msg { max-width: 85%; padding: .7rem .9rem; border-radius: 14px; line-height: 1.45; white-space: pre-wrap;
  word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line);
  border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--muted); font-style: italic; }
.msg a { color: #79c0ff; }
.empty { margin: auto; text-align: center; color: var(--muted); }

footer { display: flex; gap: .6rem; align-items: flex-end;
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
#chat-form { flex: 1; display: flex; gap: .5rem; align-items: flex-end; }
#chat-form textarea { resize: none; max-height: 40vh; }
#chat-form button { height: 46px; }
.mic { width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 1.2rem; flex: none; }
.mic.live { background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(46,160,67,.6)} 70%{box-shadow:0 0 0 14px rgba(46,160,67,0)} 100%{box-shadow:0 0 0 0 rgba(46,160,67,0)} }
#voice-status { text-align: center; color: var(--muted); font-size: .85rem; padding-bottom: .5rem; }
#pending-hint { margin: 0 1rem .5rem; padding: .6rem .8rem; border: 1px solid var(--warn); border-radius: 10px;
  color: var(--warn); font-size: .9rem; }

#settings { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; justify-content: flex-end; }
#settings .panel { width: min(520px, 100%); height: 100%; overflow-y: auto; background: var(--panel);
  padding: calc(1rem + env(safe-area-inset-top)) 1.2rem 2rem; }
#settings header { display: flex; justify-content: space-between; align-items: center; }
#settings h3 { margin: 1.5rem 0 .6rem; font-size: .95rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; }
.conn { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .7rem 0;
  border-bottom: 1px solid var(--line); }
.conn .state { font-size: .85rem; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; background: var(--muted); }
.dot.on { background: var(--ok); } .dot.off { background: #f85149; }
.pending { padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; font-size: .9rem; }
.audit { font-family: ui-monospace, Consolas, monospace; font-size: .75rem; color: var(--muted); max-height: 260px;
  overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; }
.muted { color: var(--muted); font-size: .85rem; }
