:root {
  --bg: #141413; --bg-2: #181816; --surface: #1f1e1c; --surface-2: #272522; --line: #2f2d2a;
  --text: #ebe7df; --muted: #8f8b82; --faint: #5f5c55;
  --clay: #d87656; --clay-d: #b25f43; --ink: #1b1511; --bad: #c9705f;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

/* top bar */
.top { display: flex; align-items: center; gap: 8px; padding: 10px 14px 0; }
.grow { flex: 1; }
.chip { font: 12px ui-monospace, "SF Mono", "Roboto Mono", monospace; color: var(--muted); letter-spacing: .04em; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pill[hidden] { display: none; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: transform .15s; }
.pill.on { color: var(--text); border-color: var(--clay-d); }
.pill.on .dot { background: var(--clay); }
.pill.hearing .dot { transform: scale(1.8); } /* the mic picked up speech */
.pill:disabled { opacity: .4; }
#focus-pill { font: 13px ui-monospace, monospace; color: var(--text); }

.icon { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.icon.sm { width: 36px; height: 36px; background: transparent; border-color: transparent; color: var(--muted); }
.icon.sm svg { width: 20px; height: 20px; }
.icon:disabled { opacity: .4; }
.icon.send { background: var(--clay); border-color: var(--clay); color: var(--ink); }
.icon.live { background: var(--clay-d); border-color: var(--clay); color: var(--text); animation: ring 1.6s ease-out infinite; }
@keyframes ring { from { box-shadow: 0 0 0 0 rgba(216, 118, 86, .3); } to { box-shadow: 0 0 0 12px rgba(216, 118, 86, 0); } }

/* stage */
.stage { position: relative; flex: none; height: clamp(180px, 37dvh, 350px);
  background: radial-gradient(ellipse 60% 55% at 50% 72%, #22201d 0%, rgba(20, 20, 19, 0) 100%); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.stage.flat canvas { display: none; }
.stage.flat::before { content: ""; position: absolute; inset: 0; background: url(icons/icon-192.png) center / 120px no-repeat; }
.status { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; min-height: 1.2em;
  font: 12px ui-monospace, "SF Mono", monospace; letter-spacing: .04em; color: var(--muted); pointer-events: none; }

/* chat */
.log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 14px;
  display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; }
.msg.me { align-self: flex-end; }
.bub { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pet .bub { background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 5px; }
.me .bub { background: var(--surface-2); border-top-right-radius: 5px; }
.bub.err { color: var(--bad); border-color: #4a2f2a; }
.bub:empty::after { content: "···"; letter-spacing: 4px; color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.bub code { font: .88em ui-monospace, "SF Mono", Consolas, monospace; background: #151514; padding: 1px 5px; border-radius: 5px; }
.bub pre { background: #151514; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 6px 0; overflow-x: auto; white-space: pre; }
.bub pre code { padding: 0; background: none; }

.gate { margin: auto; text-align: center; display: grid; gap: 14px; justify-items: center; padding: 0 12px; color: var(--muted); }
.gate small { font-size: 12px; }
.primary { background: var(--clay); color: var(--ink); border: 0; border-radius: 999px; padding: 12px 26px; font-weight: 600; }

.quick { display: flex; gap: 8px; overflow-x: auto; padding: 4px 12px; scrollbar-width: none; }
.quick:empty { display: none; }
.quick button { flex: none; background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.quick button:active { background: var(--surface); color: var(--text); }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px 12px; }
#input { flex: 1; min-width: 0; resize: none; max-height: 120px; padding: 11px 16px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line); outline: none; line-height: 1.4; }
#input:focus { border-color: var(--faint); }
#input::placeholder { color: var(--faint); }

@media (max-height: 520px) { .stage { height: 22dvh; } }

/* dialogs */
dialog { margin: auto; width: min(520px, calc(100vw - 24px)); max-height: 88dvh; padding: 0; overflow: auto;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .62); }
.sheet { display: grid; gap: 18px; padding: 18px; }
.sheet header { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { font-size: 18px; font-weight: 600; }
.sheet h3 { font: 12px ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.sheet section, .sheet .grid { display: grid; gap: 12px; }
.sheet [hidden] { display: none !important; }
.sheet label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.sheet label.check { display: flex; gap: 10px; align-items: center; font-size: 15px; color: var(--text); }
.sheet input:not([type=checkbox]):not([type=range]), .sheet select, .sheet textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 16px; }
.sheet input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--clay); }
.sheet input[type=range] { accent-color: var(--clay); }
.sheet textarea { resize: vertical; }
.sheet #s-profile { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row a { color: var(--clay); font-size: 14px; }
.ghost, .sheet .row button { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; color: var(--text); }
.danger { background: transparent; border: 1px solid #4a2f2a; color: var(--bad); border-radius: 12px; padding: 10px 14px; }
.note { font-size: 13px; color: var(--muted); }
.note.bad { color: var(--bad); }
.big { font: 600 56px/1 ui-monospace, "SF Mono", monospace; text-align: center; letter-spacing: .02em; padding: 8px 0; }
#focus-presets[hidden], #focus-stop[hidden] { display: none; }
#focus-presets { justify-content: center; }

@media (prefers-reduced-motion: reduce) { .icon.live, .bub:empty::after { animation: none; } }
