:root {
  --bg: #0f1720; --panel: #17212c; --panel-2: #1f2b38; --text: #e8eef4; --muted: #8fa1b3;
  --accent: #36c2ff; --accent-2: #0a84c6; --user: #1d4f6e; --danger: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#login { display: grid; place-items: center; height: 100%; padding: 16px; }
.card { background: var(--panel); padding: 32px 24px; border-radius: 20px; width: min(380px, 100%); text-align: center; }
.card h1 { margin: 8px 0 4px; }
.card p { color: var(--muted); }
.card form { display: grid; gap: 10px; }
.card input { padding: 14px; border-radius: 12px; border: 1px solid var(--panel-2); background: var(--bg); color: var(--text); font-size: 16px; }
.card button { padding: 14px; border: 0; border-radius: 12px; background: var(--accent-2); font-weight: 600; }
.error { color: var(--danger); }

#app { display: flex; flex-direction: column; height: 100%; max-width: 820px; margin: 0 auto; }
header { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--panel-2); }
.who { display: flex; align-items: center; gap: 8px; }
.who #person-name { color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 8px #3ddc84; }
nav { display: flex; gap: 4px; }
nav button { background: none; border: 0; padding: 8px 10px; border-radius: 10px; color: var(--muted); font-size: 14px; }
nav button.active { background: var(--panel-2); color: var(--text); }

.menu { position: absolute; right: 16px; top: 56px; z-index: 5; background: var(--panel); border: 1px solid var(--panel-2); border-radius: 14px; padding: 8px; display: grid; gap: 4px; min-width: 260px; max-width: calc(100% - 32px); }
.menu button, .menu label { background: none; border: 0; text-align: left; padding: 10px; border-radius: 10px; display: flex; gap: 8px; align-items: center; }
.menu .menu-link { color: inherit; text-decoration: none; padding: 10px; border-radius: 10px; display: flex; gap: 8px; align-items: center; }
.menu .menu-form { display: grid; gap: 6px; padding: 4px 10px 10px; }
.menu .menu-form button { background: var(--panel-2); justify-content: center; }
.menu .menu-link:hover, .menu button:hover { background: var(--panel-2); }

main { flex: 1; overflow-y: auto; padding: 16px; }
#messages { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 4px; }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg.thinking { color: var(--muted); font-style: italic; }
.empty { color: var(--muted); text-align: center; margin-top: 15vh; }
.empty b { color: var(--text); }

.list-card { background: var(--panel); border-radius: 14px; padding: 12px 16px; margin-bottom: 12px; }
.list-card h3 { margin: 0 0 6px; text-transform: capitalize; }
.list-card ul { margin: 0; padding-left: 20px; }

footer { padding: 8px 12px 12px; border-top: 1px solid var(--panel-2); }
.status { min-height: 20px; font-size: 13px; color: var(--muted); text-align: center; }
#chat-form { display: flex; gap: 8px; align-items: center; }
#chat-input { flex: 1; min-width: 0; padding: 14px 16px; border-radius: 24px; border: 1px solid var(--panel-2); background: var(--panel); color: var(--text); font-size: 16px; }
#send-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--panel-2); }
#mic-btn { width: 60px; height: 60px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; display: grid; place-items: center; flex: none; transition: transform .15s; }
#mic-btn.recording { background: var(--danger); animation: pulse 1.2s infinite; }
#mic-btn.busy { opacity: .5; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,107,.6); } 50% { box-shadow: 0 0 0 14px rgba(255,107,107,0); } }

.wake-badge { font-size: 12px; color: var(--accent); border: 1px solid var(--accent-2); border-radius: 10px; padding: 1px 8px; }
.wake-badge.heard { background: var(--accent-2); color: #fff; }

/* Terminal (Claude Code) */
.code-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 12px; position: sticky; top: -16px; background: var(--bg); padding: 4px 0; }
.code-bar select, .code-bar button { background: var(--panel); color: var(--text); border: 1px solid var(--panel-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.code-bar #code-state { flex: 1; }
#code-cancel { border-color: var(--danger); color: var(--danger); }
#code-log { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.tl { white-space: pre-wrap; word-wrap: break-word; }
.tl.user { color: var(--accent); font-weight: 600; margin-top: 10px; }
.tl.text { background: var(--panel); border-radius: 10px; padding: 8px 12px; }
.tl.tool { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl.done { border-left: 3px solid #3ddc84; background: var(--panel); border-radius: 6px; padding: 8px 12px; }
.tl.fail { border-left: 3px solid var(--danger); background: var(--panel); border-radius: 6px; padding: 8px 12px; }
.tl .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.tl pre, .msg pre { background: var(--bg); padding: 8px; border-radius: 8px; overflow-x: auto; font-size: 12px; }
.tl code, .msg code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
body.code-mode #mic-btn { background: linear-gradient(135deg, #b48cff, #6b4fd8); }
