:root {
  --bg: #0a0804; --panel: #14100a; --line: #3a2c12;
  --accent: #EF9F27; --accent2: #FAC775; --text: #FAEEDA; --muted: #8a7347; --hot: #FF3B2A;
  color-scheme: dark;
}
[data-theme="violet"] {
  --bg: #0b0816; --panel: #120e24; --line: #2b2461;
  --accent: #7F77DD; --accent2: #AFA9EC; --text: #EEEDFE; --muted: #6d669f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; transition: background .6s;
}
#app {
  height: 100dvh; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 14px calc(env(safe-area-inset-bottom) + 10px);
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; margin: 4px 0; }
[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.primary { background: var(--accent); color: var(--bg); border: 0; font-weight: 600; }

.top { display: flex; align-items: center; justify-content: space-between; height: 44px; font-size: 11px; letter-spacing: 1px; color: var(--accent2); flex: none; }
.srv { display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: #3ecf8e; } .dot.bad { background: var(--hot); }
.clock { color: var(--muted); }
.ghost { background: none; border: 0; color: var(--accent2); padding: 8px; margin-right: -8px; }

.menu {
  position: absolute; top: calc(env(safe-area-inset-top) + 44px); right: max(14px, calc(50vw - 266px));
  z-index: 5; width: 250px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.menu button { text-align: left; background: none; border: 0; padding: 10px 10px; border-radius: 8px; color: var(--text); }
.menu button:active { background: var(--line); }

.stage-wrap { flex: none; text-align: center; }
.stage { width: min(100%, 42dvh); aspect-ratio: 1; margin: 0 auto; }
#core { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: manipulation; }
.name { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: 10px; padding-left: 10px; color: var(--accent2); }
.status { margin: 2px 0 8px; font-size: 12px; color: var(--muted); min-height: 18px; }

.login, .composer, .chips, .banner { flex: none; }
.login { display: flex; flex-direction: column; gap: 10px; width: min(100%, 340px); margin: 6px auto 0; }
input {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; font-size: 16px;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }
.login .primary { padding: 12px; border-radius: 12px; font-size: 16px; }
.err { color: var(--hot); font-size: 13px; text-align: center; min-height: 20px; margin: 0; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 8px; }
.banner a { text-decoration: none; padding: 8px 12px; border-radius: 10px; white-space: nowrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--accent2); }
.chips button:active { border-color: var(--accent); }

.log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px 0 8px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--line); color: var(--text); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 13px; text-align: center; }
.msg.err { align-self: center; color: var(--hot); background: none; font-size: 13px; text-align: center; }
.msg.live { opacity: .6; }

.composer { display: flex; gap: 8px; align-items: center; padding-top: 6px; }
.composer input { flex: 1; min-width: 0; border-radius: 999px; padding-left: 16px; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--accent2); display: grid; place-items: center; padding: 0; flex: none; }
.round.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
#mic.on { background: var(--hot); border-color: var(--hot); color: #070509; }

body[data-view="login"] .top button, body[data-view="login"] .chips, body[data-view="login"] .log, body[data-view="login"] .composer, body[data-view="login"] .banner { display: none; }
body[data-view="app"] .login { display: none; }
body[data-view="login"] .stage { width: min(100%, 50dvh); }

@media (prefers-reduced-motion: reduce) { body { transition: none; } }
