:root {
  --bg: #140d1c;
  --ink: #f4ecf6;
  --ink-2: #c6b6cc;
  --ink-3: #8c7b94;
  --line: rgba(244, 236, 246, .14);
  --glow: #e9a46a;
  --rec: #ff6b7a;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(110% 75% at 50% 30%, #2c1d38 0%, var(--bg) 62%) fixed, var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.bar {
  position: absolute; inset: 0 0 auto; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 10px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.bar .back { color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.bar .back:hover { color: var(--ink); }
.bar .who { margin: 0 auto; font-weight: 650; font-size: 14px; letter-spacing: .02em; }
.bar .who em { font-style: normal; font-weight: 400; color: var(--ink-3); }
.bar .mood { font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; background: rgba(20, 13, 28, .5); }
.bar .mood.changed { animation: pulse .9s ease; }
@keyframes pulse { 0% { border-color: var(--glow); color: var(--ink); } 100% { border-color: var(--line); } }
body.embed .bar .back { display: none; }

.stage { position: relative; flex: 1; min-height: 0; }
#stage { display: block; width: 100%; height: 100%; touch-action: none; }

.loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; text-align: center; color: var(--ink-2); transition: opacity .6s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading progress { width: 180px; accent-color: var(--glow); }

.caption {
  position: absolute; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(720px, calc(100% - 32px)); margin: 0; text-align: center;
  font-size: clamp(16px, 2.1vw, 21px); line-height: 1.35; color: var(--ink);
  text-shadow: 0 1px 12px rgba(0, 0, 0, .7), 0 0 2px rgba(0, 0, 0, .9);
  pointer-events: none;
}
.caption.you { color: var(--ink-2); font-style: italic; }

.dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 16px max(18px, env(safe-area-inset-bottom));
}
.status { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--ink-2); text-align: center; text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }

.hold {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 60px; padding: 0 28px 0 22px;
  border: 1px solid rgba(244, 236, 246, .28); border-radius: 999px;
  background: rgba(30, 20, 40, .72); color: var(--ink);
  font: 600 16px/1 var(--font); letter-spacing: .01em;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .15s, background .2s, border-color .2s;
}
.hold svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; position: relative; z-index: 1; }
.hold .label { position: relative; z-index: 1; }
.hold .level { position: absolute; left: 0; bottom: 0; width: 100%; height: 0; background: rgba(255, 107, 122, .35); transition: height .06s linear; }
.hold:hover { border-color: rgba(244, 236, 246, .5); }
.hold.recording { background: rgba(80, 22, 34, .82); border-color: var(--rec); transform: scale(1.05); }
.hold:disabled { opacity: .55; cursor: default; }
.hold:focus-visible, .type-toggle:focus-visible, .chat input:focus-visible, .chat button:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }

.type-toggle { background: none; border: 0; color: var(--ink-3); font: 13px var(--font); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px 8px; }
.type-toggle:hover { color: var(--ink-2); }

.chat { display: flex; gap: 8px; width: min(520px, 100%); }
.chat[hidden] { display: none; }
.chat input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(30, 20, 40, .72); color: var(--ink); font: 15px var(--font);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chat input::placeholder { color: var(--ink-3); }
.chat button { height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--ink); color: var(--bg); font: 600 14px var(--font); cursor: pointer; }
.chat button:disabled { opacity: .5; }

@media (max-width: 640px) {
  .bar .who em { display: none; }
  .caption { bottom: calc(140px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .hold { transition: none; } .hold.recording { transform: none; } }
