:root {
  --bg: #0f1115; --panel: #171a21; --line: #2a2f3a; --text: #e8eaf0; --muted: #9098a8;
  --accent: #3ddc84; --warn: #f5b041; --err: #ff6b6b; --live: #ff5a5f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
a { color: var(--accent); }
h1 { font-size: 1.25rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--err); }
.ok { color: var(--accent); }

.card { max-width: 420px; margin: 8vh auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.card label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: .9rem; }
.card input { width: 100%; padding: 12px; font-size: 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.card button, .btn { display: inline-block; margin-top: 18px; width: 100%; padding: 13px; font-size: 16px; font-weight: 600; border: 0; border-radius: 10px; background: var(--accent); color: #062312; text-align: center; text-decoration: none; }
.card button:disabled { opacity: .5; }

.app { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; min-height: calc(100dvh - 32px); }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pill { font-size: .8rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.ok { color: var(--accent); border-color: #1f5a3a; }
.pill.warn { color: var(--warn); border-color: #6b5220; }
.notice { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.notice .btn { margin-top: 12px; }

.talk { position: relative; align-self: center; width: min(62vw, 240px); aspect-ratio: 1; border-radius: 50%; border: 0; margin-top: 4vh;
  background: radial-gradient(circle at 50% 40%, #2b3140, #1a1e27); color: var(--text); font-size: 1.4rem; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 0 0 1px var(--line), 0 10px 40px rgba(0,0,0,.4); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.talk:disabled { opacity: .45; }
.talk .ring { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid transparent; }
.talk[aria-pressed="true"] { background: radial-gradient(circle at 50% 40%, #4a2027, #2a1418); }
.talk[aria-pressed="true"] .ring { border-color: var(--live); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.05); opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .talk .ring { animation: none !important; } }
.status { text-align: center; color: var(--muted); min-height: 1.5em; margin: 0; }

.draft { background: var(--panel); border: 1px solid #1f5a3a; border-radius: 12px; padding: 14px; }
.draft-head { font-weight: 600; margin-bottom: 8px; }
.draft pre { white-space: pre-wrap; font: inherit; margin: 0; }

.log-wrap summary { color: var(--muted); cursor: pointer; }
.log { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.log li { padding: 8px 10px; border-radius: 8px; background: var(--panel); overflow-wrap: anywhere; }
.log li.me { border-left: 3px solid var(--accent); }
.log li.ai { border-left: 3px solid #6c8cff; }
.log li.sys { color: var(--muted); font-size: .8rem; }

footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
footer form { margin: 0; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: .85rem; padding: 4px; }
