:root {
  --celeste: #6cace4;
  --celeste-dark: #2b5f93;
  --gold: #f6b40e;
  --ink: #1c2733;
  --muted: #5d6b78;
  --card: rgba(255, 255, 255, 0.92);
  --sky-top: #d9ecfb;
  --sky-bottom: #fff7e8;
  --shadow: 0 8px 28px rgba(28, 39, 51, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eef3f8; --muted: #a9b6c3; --card: rgba(24, 33, 44, 0.9);
    --sky-top: #14243a; --sky-bottom: #2a2234; --shadow: 0 8px 28px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  --ink: #eef3f8; --muted: #a9b6c3; --card: rgba(24, 33, 44, 0.9);
  --sky-top: #14243a; --sky-bottom: #2a2234; --shadow: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--sky-bottom);
}
#sky {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(246,180,14,.22), transparent 42%),
    linear-gradient(var(--sky-top), var(--sky-bottom));
}
#stage { position: fixed; inset: 0; }
#stage canvas { width: 100%; height: 100%; display: block; cursor: pointer; }

#top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 8px;
}
#title { display: flex; flex-direction: column; gap: 2px; }
#title b { font-size: 20px; letter-spacing: .2px; color: var(--celeste-dark); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #title b { color: var(--celeste); } }
#status { font-size: 13px; color: var(--muted); }
#status.live::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #e5484d; margin-right: 6px; animation: pulse 1s infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

#chat {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; gap: 8px;
  max-width: 640px; margin: 0 auto;
}
#transcript {
  align-self: flex-end; max-width: 85%;
  background: var(--celeste); color: #fff;
  padding: 8px 12px; border-radius: 16px 16px 4px 16px; font-size: 14px;
  box-shadow: var(--shadow);
}
#bubble {
  background: var(--card); backdrop-filter: blur(8px);
  border-radius: 18px 18px 18px 4px; padding: 12px 14px;
  box-shadow: var(--shadow); max-height: 34vh; overflow-y: auto;
  font-size: 15px; line-height: 1.4;
}
#replyText { white-space: pre-wrap; overflow-wrap: anywhere; }
#links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#links:empty { display: none; }
#links a {
  font-size: 12.5px; text-decoration: none; color: var(--celeste-dark);
  background: rgba(108,172,228,.16); border: 1px solid rgba(108,172,228,.5);
  padding: 4px 10px; border-radius: 999px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #links a { color: #bfe0ff; } }

#composer { display: flex; gap: 8px; align-items: center; }
#textInput {
  flex: 1; min-width: 0; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--card); border: 1px solid rgba(108,172,228,.45);
  border-radius: 999px; padding: 12px 16px; outline: none; box-shadow: var(--shadow);
}
#textInput:focus { border-color: var(--celeste); }
button { font: inherit; }
.icon {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--card); color: var(--celeste-dark); font-size: 18px; box-shadow: var(--shadow);
}
#micBtn {
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  background: linear-gradient(145deg, var(--celeste), var(--celeste-dark)); color: #fff;
  box-shadow: 0 6px 18px rgba(43,95,147,.45);
  display: grid; place-items: center; transition: transform .15s;
}
#micBtn:active { transform: scale(.94); }
#micBtn.rec { background: linear-gradient(145deg, #ff6b6b, #c92a2a); animation: ring 1.2s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 100% { box-shadow: 0 0 0 18px rgba(229,72,77,0); } }

dialog { border: 0; border-radius: 16px; padding: 20px; width: min(420px, calc(100% - 32px));
  background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin: 0 0 12px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
dialog input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(108,172,228,.5); background: transparent; color: var(--ink); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 0; }
dialog menu button { border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; background: rgba(108,172,228,.18); color: var(--ink); }
dialog menu #cfgSave { background: var(--celeste-dark); color: #fff; }

.top-right { display: flex; align-items: center; gap: 10px; }
#who { font-size: 13px; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
