/* Layout: one-screen voice app. Slim header, scrolling conversation, bottom dock with one large mic button and a text row. Settings and login slide over the whole app. */
:root {
  --bg: #EDF1EF; --surface: #FFFFFF; --fg: #14211F; --muted: #566A66; --line: #D3DCD9;
  --accent: #0B6B62; --on-accent: #FFFFFF; --live: #C2410C; --on-live: #FFFFFF; --bad: #B42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1514; --surface: #162120; --fg: #E3EDEA; --muted: #93A8A3; --line: #263634;
    --accent: #45C1B2; --on-accent: #062421; --live: #FB923C; --on-live: #1F0F03; --bad: #F97066;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { position: relative; display: flex; flex-direction: column; height: 100%; max-width: 640px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.top h1 { margin: 0; font-size: 1.4rem; line-height: 1.1; letter-spacing: -0.01em; }
.top-actions { display: flex; gap: 8px; }
.ghost { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 0.9rem; }

.log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-block: 8px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; min-width: 0; }
.msg p { margin: 0 0 0.6em; }
.msg p:last-child { margin-bottom: 0; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.error { align-self: flex-start; border: 1px dashed var(--live); background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 0.92rem; text-align: left; }
.chip:hover { border-color: var(--accent); }

.dock { display: grid; gap: 10px; padding-top: 10px; padding-bottom: 10px; border-top: 1px solid var(--line); }
.hint { margin: 0; font-size: 0.88rem; border: 1px dashed var(--live); border-radius: 12px; padding: 8px 12px; }
.mic-wrap { display: grid; justify-items: center; gap: 6px; }
.mic { position: relative; width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.mic svg { display: none; }
.mic[data-state="idle"] .i-mic, .mic[data-state="listening"] .i-mic { display: block; }
.mic[data-state="thinking"] .i-think { display: block; }
.mic[data-state="speaking"] .i-stop { display: block; }
.mic[data-state="listening"] { background: var(--live); color: var(--on-live); }
.mic[data-state="listening"]::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--live); animation: pulse 1.4s ease-out infinite; }
.i-think { animation: spin 1s linear infinite; }
@keyframes pulse { from { transform: scale(0.92); opacity: 0.9; } to { transform: scale(1.25); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mic[data-state="listening"]::after, .i-think { animation: none; } }
.status { margin: 0; font-size: 0.9rem; color: var(--muted); min-height: 1.4em; text-align: center; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 11px 14px; }
.send { border: 0; background: var(--fg); color: var(--bg); border-radius: 14px; padding: 0 18px; font-weight: 600; }
#player { width: 100%; }

.sheet { position: absolute; inset: 0; z-index: 5; background: var(--bg); overflow-y: auto; padding-block: 10px; display: flex; flex-direction: column; gap: 16px; }
#login { z-index: 9; }
.sheet h2 { margin: 0; font-size: 1.2rem; line-height: 1.2; }
.sheet h3 { margin: 4px 0 0; font-size: 1rem; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.92rem; }
.field input[type="password"], .field input[type="text"], .field select, .field textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; width: 100%; }
.field textarea { min-height: 260px; resize: vertical; line-height: 1.45; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
small, .note { color: var(--muted); font-size: 0.88rem; }
.err { margin: 0; color: var(--bad); font-size: 0.92rem; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.primary { border: 0; background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 9px 20px; font-weight: 600; }
.box { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; margin: 0; }
