:root {
  --bg: #07060e;
  --bg2: #100c1d;
  --panel: rgba(23, 18, 40, 0.88);
  --panel-border: rgba(177, 140, 255, 0.16);
  --ink: #ece6fa;
  --muted: #9a8fb8;
  --green: #8aff6a;
  --purple: #b18cff;
  --red: #ff5d6c;
  --paper: #f2ead2;
  --paper-ink: #241b10;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  background: var(--bg);
  color: var(--ink);
  font-family: "Outfit", system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- Atmosphere layers ---------- */

.bg-grad {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 55% at 50% -12%, rgba(110, 60, 220, 0.22), transparent 70%),
    radial-gradient(ellipse 70% 45% at 85% 105%, rgba(60, 220, 120, 0.07), transparent 70%),
    radial-gradient(ellipse 60% 40% at 8% 90%, rgba(110, 60, 220, 0.09), transparent 70%);
}

.fog {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.4;
}
.fog.f1 { top: -20vmax; left: -15vmax; background: radial-gradient(circle, rgba(120, 70, 220, 0.12), transparent 60%); animation: fog-drift 30s ease-in-out infinite alternate; }
.fog.f2 { bottom: -25vmax; right: -18vmax; background: radial-gradient(circle, rgba(70, 220, 130, 0.07), transparent 60%); animation: fog-drift 38s ease-in-out infinite alternate-reverse; }

@keyframes fog-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(7vmax, 3vmax) scale(1.12); }
}

#fx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
}

.wrap {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* ---------- Type ---------- */

h1 {
  font-weight: 700;
  font-size: clamp(2.1rem, 6vw, 3.3rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--green);
  text-shadow: 0 0 28px rgba(138, 255, 106, 0.35), 0 0 70px rgba(138, 255, 106, 0.12);
}

h2 {
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  color: var(--purple);
  margin-bottom: 0.75rem;
}

.tagline { text-align: center; color: var(--muted); margin: 0.35rem auto 0.5rem; max-width: 560px; }

/* ---------- The hat ---------- */

.hat-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 0 0.5rem;
}

.hat-stage-inner { position: relative; display: flex; flex-direction: column; align-items: center; }

.hat-float {
  width: clamp(264px, 60vw, 440px);
  /* The canvas carries transparent head/foot room for the pull animation;
     these margins collapse that padding out of the page layout. */
  margin: -12% 0 -9%;
  animation: hat-bob 4.5s ease-in-out infinite;
  will-change: transform;
  outline: none;
}

.hat-float:focus-visible .hat-render { filter: drop-shadow(0 0 26px rgba(177, 140, 255, 0.7)); }

.hat-render {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 100 / 115;
  filter: drop-shadow(0 10px 34px rgba(122, 92, 255, 0.26));
}

@keyframes hat-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hat-shadow {
  width: 55%;
  height: 22px;
  margin-top: -4px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.7), transparent 70%);
  animation: shadow-squash 4.5s ease-in-out infinite;
}

@keyframes shadow-squash {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(0.9); opacity: 0.55; }
}

.hat-float.gulp .hat-render { animation: hat-gulp 0.4s ease-out; }

@keyframes hat-gulp {
  0% { filter: drop-shadow(0 10px 34px rgba(122, 92, 255, 0.26)) brightness(1); }
  30% { filter: drop-shadow(0 0 55px rgba(138, 255, 106, 0.75)) brightness(1.8); }
  100% { filter: drop-shadow(0 10px 34px rgba(122, 92, 255, 0.26)) brightness(1); }
}

.hat-hint { color: var(--muted); font-size: 0.9rem; margin-top: 0.4rem; text-align: center; }

.count-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.9rem auto 0;
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 0.95rem;
}
.count-chip strong { color: var(--green); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.count-chip.bump strong { animation: count-bump 0.4s ease-out; }

@keyframes count-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.5); color: #fff; }
  100% { transform: scale(1); }
}

/* ---------- Cards & forms ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.6rem;
  margin: 1.5rem 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

label { display: block; color: var(--muted); font-size: 0.88rem; margin: 0.9rem 0 0.3rem; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  background: rgba(7, 6, 14, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  transition: border-color 0.15s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(177, 140, 255, 0.16);
}

textarea { min-height: 110px; resize: vertical; }

input, textarea, .reveal-text, .hist-item { -webkit-user-select: text; user-select: text; }

/* Custom scrollbars on our scrollable surfaces. */
textarea, .drawer-body, .reveal-slip {
  scrollbar-width: thin;
  scrollbar-color: rgba(177, 140, 255, 0.4) transparent;
}
textarea::-webkit-scrollbar, .drawer-body::-webkit-scrollbar, .reveal-slip::-webkit-scrollbar { width: 10px; }
textarea::-webkit-scrollbar-track, .drawer-body::-webkit-scrollbar-track, .reveal-slip::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb, .drawer-body::-webkit-scrollbar-thumb, .reveal-slip::-webkit-scrollbar-thumb {
  background: rgba(177, 140, 255, 0.35);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
textarea::-webkit-scrollbar-thumb:hover, .drawer-body::-webkit-scrollbar-thumb:hover, .reveal-slip::-webkit-scrollbar-thumb:hover {
  background: rgba(177, 140, 255, 0.6);
  background-clip: padding-box;
}
textarea::-webkit-scrollbar-corner { background: transparent; }
textarea::-webkit-resizer { background: transparent; }

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(160deg, #7444e0, #4b2a99);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.8rem 1.7rem;
  cursor: pointer;
  margin-top: 1.1rem;
  transition: transform 0.12s, filter 0.15s;
  box-shadow: 0 6px 24px rgba(116, 68, 224, 0.35);
}

button:hover { filter: brightness(1.15); transform: translateY(-1px); }
button:disabled { opacity: 0.5; cursor: wait; transform: none; }

button.big {
  display: block;
  width: 100%;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  padding: 0.95rem;
  background: linear-gradient(160deg, #1f8a32, #145220);
  box-shadow: 0 6px 28px rgba(31, 138, 50, 0.35);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
  padding: 0.45rem 0.9rem;
  margin-top: 0;
  box-shadow: none;
}
button.ghost:hover { color: var(--ink); border-color: var(--purple); }
button.danger:hover { color: var(--red); border-color: var(--red); }

.msg { margin-top: 0.9rem; padding: 0.7rem 1rem; border-radius: 10px; display: none; }
.msg.show { display: block; animation: msg-in 0.25s ease-out; }
.msg.ok { background: rgba(138, 255, 106, 0.1); color: var(--green); border: 1px solid rgba(138, 255, 106, 0.35); }
.msg.err { background: rgba(255, 93, 108, 0.1); color: var(--red); border: 1px solid rgba(255, 93, 108, 0.35); }

@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.charcount { text-align: right; color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }

.footer { text-align: center; margin-top: 2rem; color: var(--muted); font-size: 0.9rem; }
.footer a { color: var(--purple); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.topbar .actions { display: flex; gap: 0.5rem; }

a { color: var(--purple); }

/* ---------- Flying slip ---------- */

.flying-slip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  max-width: 240px;
  padding: 0.7rem 0.9rem;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 0.82rem;
  line-height: 1.4;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- Reveal overlay ---------- */

.reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(5, 4, 10, 0.88);
  animation: overlay-in 0.6s ease-out;
}

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.reveal-slip {
  width: min(660px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background:
    radial-gradient(ellipse 120% 100% at 50% 0%, rgba(255, 250, 235, 0.5), transparent 60%),
    var(--paper);
  color: var(--paper-ink);
  border-radius: 8px;
  padding: clamp(1.4rem, 4vw, 2.4rem);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 30px 90px rgba(0, 0, 0, 0.9);
  will-change: transform;
}

.reveal-kind {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7a4a2f;
  border-bottom: 1px solid rgba(36, 27, 16, 0.2);
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
}

.reveal-text {
  font-size: clamp(1.25rem, 3.2vw, 1.7rem);
  font-weight: 500;
  line-height: 1.5;
  min-height: 3em;
  overflow-wrap: break-word;
}

.reveal-text.typing::after { content: "▌"; animation: caret 0.7s steps(1) infinite; color: #7a4a2f; }

@keyframes caret { 50% { opacity: 0; } }

.reveal-meta {
  font-size: 0.85rem;
  color: #6b5d44;
  margin-top: 1.4rem;
  border-top: 1px solid rgba(36, 27, 16, 0.2);
  padding-top: 0.8rem;
}

.reveal-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1.2rem; }
.reveal-actions button { margin-top: 0; }
.reveal-actions .ghost { color: #55492f; border-color: rgba(36, 27, 16, 0.35); }
.reveal-actions .ghost:hover { color: #241b10; border-color: #241b10; }

/* ---------- History drawer ---------- */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 55;
  width: min(440px, 100vw);
  height: 100dvh;
  background: rgba(13, 10, 24, 0.97);
  border-left: 1px solid var(--panel-border);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.6);
  transform: translateX(105%);
  transition: transform 0.3s cubic-bezier(.2,.8,.3,1);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem 0.8rem;
  border-bottom: 1px solid var(--panel-border);
}
.drawer-head h2 { margin: 0; font-size: 1.15rem; }

.drawer-body { overflow-y: auto; padding: 0.5rem 1.25rem 2rem; flex: 1; }

.hist-item {
  border-bottom: 1px solid rgba(177, 140, 255, 0.1);
  padding: 1rem 0;
}
.hist-item .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.3rem; }
.hist-item .actions { display: flex; gap: 0.4rem; margin-top: 0.55rem; }

/* ---------- Write / Record toggle ---------- */

.mode-row { display: flex; gap: 0.5rem; margin: 0.3rem 0 0.9rem; }
.mode-btn { border-radius: 999px; padding: 0.45rem 1.2rem; }
.mode-btn.active { color: var(--green); border-color: var(--green); background: rgba(138, 255, 106, 0.09); }

/* ---------- Voice recorder ---------- */

.rec-start {
  margin-top: 0;
  background: linear-gradient(160deg, #b3324a, #7c1f31);
  box-shadow: 0 6px 24px rgba(179, 50, 74, 0.35);
}

.rec-note { color: var(--muted); font-size: 0.85rem; margin-top: 0.6rem; }

.rec-live {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(7, 6, 14, 0.65);
}

.rec-live[hidden] { display: none; }

.rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff4d5e;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.5); }
  50% { opacity: 0.55; box-shadow: 0 0 0 7px rgba(255, 77, 94, 0); }
}

.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.1rem; }
.rec-total { color: var(--muted); }

.rec-warn { color: #ffb03a; font-weight: 600; }
.rec-live.warning { border-color: rgba(255, 176, 58, 0.6); }
.rec-live.warning .rec-time { color: #ffb03a; }

.rec-live-btns { display: flex; gap: 0.5rem; margin-left: auto; }
.rec-live-btns button { margin-top: 0; padding: 0.45rem 1rem; font-size: 0.9rem; }

.rec-player { margin-top: 0; }
.rec-done-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }
.rec-len { color: var(--muted); font-size: 0.9rem; }

.rec-msg { margin-top: 0.7rem; padding: 0.7rem 1rem; border-radius: 10px; background: rgba(255, 93, 108, 0.1); color: var(--red); border: 1px solid rgba(255, 93, 108, 0.35); }

/* ---------- Custom audio player ---------- */

.player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  margin-top: 0.6rem;
}

.pl-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  padding: 0;
}

.pl-btn svg { width: 15px; height: 15px; fill: currentColor; display: block; }

.pl-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: none;
}

/* Fatter invisible hit area for fingers. */
.pl-track::before { content: ""; position: absolute; inset: -10px 0; }

.pl-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  border-radius: 999px;
  pointer-events: none;
}

.pl-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: box-shadow 0.15s;
}

.pl-time { font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }

/* Dark variant: form preview + history. */
.player-dark { background: rgba(7, 6, 14, 0.75); border: 1px solid var(--panel-border); }
.player-dark .pl-btn { background: linear-gradient(160deg, #7444e0, #4b2a99); color: #fff; box-shadow: 0 4px 16px rgba(116, 68, 224, 0.35); }
.player-dark .pl-track { background: rgba(177, 140, 255, 0.16); }
.player-dark .pl-fill { background: linear-gradient(90deg, #7444e0, var(--green)); }
.player-dark .pl-knob { background: #ece6fa; }
.player-dark.playing .pl-knob { box-shadow: 0 0 12px rgba(138, 255, 106, 0.7); }
.player-dark .pl-time { color: var(--muted); }

/* Compact variant for history rows. */
.player-sm { padding: 0.35rem 0.65rem; gap: 0.6rem; }
.player-sm .pl-btn { width: 30px; height: 30px; }
.player-sm .pl-btn svg { width: 12px; height: 12px; }
.player-sm .pl-time { font-size: 0.72rem; }

/* Paper variant: the drawn card. Ink on parchment. */
.player-paper { background: rgba(36, 27, 16, 0.07); border: 1px solid rgba(36, 27, 16, 0.28); }
.player-paper .pl-btn { background: #332612; color: var(--paper); box-shadow: none; }
.player-paper .pl-btn:hover { filter: brightness(1.35); }
.player-paper .pl-track { background: rgba(36, 27, 16, 0.2); }
.player-paper .pl-fill { background: #7a4a2f; }
.player-paper .pl-knob { background: #241b10; }
.player-paper.playing .pl-knob { box-shadow: 0 0 8px rgba(122, 74, 47, 0.8); }
.player-paper .pl-time { color: #6b5d44; }

.reveal-audio-len { font-size: 0.9rem; color: #6b5d44; }
.preview-note { font-size: 0.8rem; color: #7a4a2f; font-style: italic; margin-top: 0.5rem; }

/* ---------- Confirm dialog ---------- */

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(5, 4, 10, 0.72);
  animation: overlay-in 0.2s ease-out;
}

.confirm-box {
  background: rgba(23, 18, 40, 0.97);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.5rem;
  width: min(400px, 92vw);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8);
  animation: pop-in 0.18s ease-out;
}

.confirm-box p { margin: 0 0 1.2rem; }

.confirm-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }
.confirm-actions button { margin-top: 0; }

button.solid-danger {
  background: linear-gradient(160deg, #d43f55, #8f2436);
  box-shadow: 0 6px 24px rgba(212, 63, 85, 0.35);
}

@keyframes pop-in {
  from { transform: scale(0.92) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ---------- The Studio ---------- */

.wrap-wide { max-width: 860px; }

.peer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
  margin: 1.2rem 0;
}

.studio-tag { margin-bottom: 0.25rem; }

/* Join screen: a floating mic with sonar rings. */
.join-card { text-align: center; padding-top: 2rem; }
.join-card h2 { text-align: center; margin-top: 0.4rem; }
.join-copy { color: var(--muted); max-width: 520px; margin: 0 auto 1.3rem; }
.join-btn { margin-top: 0; font-size: 1.1rem; padding: 0.9rem 2.2rem; letter-spacing: 0.03em; }

.mic-emblem {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 0 auto 0.4rem;
  display: grid;
  place-items: center;
  animation: hat-bob 4.5s ease-in-out infinite;
}
.mic-emblem svg {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  fill: var(--green);
  filter: drop-shadow(0 0 14px rgba(138, 255, 106, 0.55));
}
.mic-emblem .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(177, 140, 255, 0.7);
  opacity: 0;
  animation: sonar 3s ease-out infinite;
}
.mic-emblem .r2 { animation-delay: 1s; }
.mic-emblem .r3 { animation-delay: 2s; }

@keyframes sonar {
  0% { transform: scale(0.45); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- Booths (one per host) ---------- */

.peer-card {
  --hue: 270;
  --lvl: 0%;
  --lvln: 0;
  --pk: 0%;
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 0.95rem 1rem 1rem;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s;
}
.peer-card::before {
  /* Soft tint of the host's colour in the top-left corner. */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 60% at 0% 0%, hsla(var(--hue), 85%, 65%, 0.13), transparent 70%);
}
.peer-card.talking {
  border-color: hsla(var(--hue), 90%, 72%, 0.65);
  box-shadow: 0 0 0 1px hsla(var(--hue), 90%, 72%, 0.25), 0 14px 44px hsla(var(--hue), 80%, 60%, 0.2);
  transform: translateY(-2px);
}
.peer-card.is-rec { border-color: rgba(255, 77, 94, 0.5); }
.peer-card.is-rec.talking { border-color: rgba(255, 120, 135, 0.85); }
.peer-card.is-muted .avatar { filter: saturate(0.25) brightness(0.75); }

.booth-top { display: flex; align-items: center; gap: 0.75rem; position: relative; }
.booth-id { min-width: 0; flex: 1; }

.avatar {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 28%, hsl(var(--hue) 92% 74%), hsl(var(--hue) 70% 38%) 75%);
  box-shadow: 0 6px 18px hsla(var(--hue), 80%, 50%, 0.35), inset 0 -3px 8px rgba(0, 0, 0, 0.25);
  transition: filter 0.2s;
}
.avatar-letter {
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.avatar-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid hsla(var(--hue), 92%, 75%, 0.9);
  opacity: calc(var(--lvln) * 2.2);
  transform: scale(calc(1 + var(--lvln) * 0.4));
  transition: transform 0.08s linear, opacity 0.1s linear;
  pointer-events: none;
}

.peer-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-tags { color: var(--muted); font-size: 0.8rem; margin-top: 0.1rem; min-height: 1.2em; }
.peer-card.is-rec .peer-tags { color: #ff8d99; }

.booth-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  border: 1px solid rgba(255, 93, 108, 0.5);
  background: rgba(255, 93, 108, 0.1);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

/* Mini oscilloscope: the host's live waveform in their own colour. */
.scope {
  display: block;
  width: 100%;
  height: 46px;
  margin: 0.7rem 0 0.55rem;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.035)) 50% 50% / 100% 1px no-repeat,
    rgba(7, 6, 14, 0.6);
  border: 1px solid rgba(177, 140, 255, 0.08);
}

/* Segmented LED meter with a sinking peak marker. */
.vu {
  position: relative;
  height: 10px;
  border-radius: 4px;
  background: rgba(7, 6, 14, 0.7);
  overflow: hidden;
}
.vu-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #35d67a 0%, #8aff6a 55%, #ffd23a 78%, #ff5d6c 100%);
  clip-path: inset(0 calc(100% - var(--lvl)) 0 0);
  transition: clip-path 0.06s linear;
}
.vu::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 6px, rgba(7, 6, 14, 0.85) 6px 8px);
}
.vu-peak {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pk);
  width: 2px;
  background: #fff;
  opacity: 0.75;
  transition: left 0.06s linear;
}

/* ---------- ON AIR sign ---------- */

.onair {
  position: sticky;
  top: 0.5rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.7rem 0.55rem 0.55rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: rgba(13, 10, 24, 0.92);
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  transition: border-color 0.3s, box-shadow 0.4s, background 0.3s;
}
.onair[data-state="rec"] {
  border-color: rgba(255, 77, 94, 0.55);
  background: rgba(45, 9, 16, 0.94);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45), 0 0 40px rgba(255, 59, 92, 0.18);
}
.onair[data-state="paused"] {
  border-color: rgba(255, 176, 58, 0.55);
  background: rgba(50, 36, 6, 0.94);
}

.onair-sign {
  border-radius: 10px;
  padding: 0.35rem 0.95rem;
  background: #050409;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.9);
}
.onair-tube {
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.14);
  -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.14);
  transition: color 0.3s, text-shadow 0.3s;
}
.onair[data-state="rec"] .onair-tube {
  color: #fff0f2;
  -webkit-text-stroke: 0;
  text-shadow: 0 0 6px #ff3b5c, 0 0 14px #ff3b5c, 0 0 30px rgba(255, 59, 92, 0.85), 0 0 56px rgba(255, 59, 92, 0.5);
  animation: neon-on 1.4s steps(1, end) 1, neon-hum 2.6s ease-in-out 1.4s infinite;
}
.onair[data-state="paused"] .onair-tube {
  color: #fff4dc;
  -webkit-text-stroke: 0;
  text-shadow: 0 0 6px #ffb03a, 0 0 14px #ffb03a, 0 0 28px rgba(255, 176, 58, 0.6);
}

@keyframes neon-on {
  0% { opacity: 0.25; }
  9% { opacity: 1; }
  14% { opacity: 0.3; }
  22% { opacity: 1; }
  28% { opacity: 0.55; }
  37% { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes neon-hum {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.92; }
}

.onair-deck { display: flex; align-items: center; gap: 0.8rem; flex: 1; min-width: 0; }

.reels {
  width: 64px;
  height: 28px;
  flex-shrink: 0;
  color: rgba(177, 140, 255, 0.32);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  transition: color 0.3s;
}
.reels .hub { fill: currentColor; stroke: none; }
.reels .tape { stroke-width: 1.2; opacity: 0.6; }
.reels .reel { transform-box: fill-box; transform-origin: center; }
.onair[data-state="rec"] .reels { color: #ff8d99; }
.onair[data-state="rec"] .reel { animation: reel-spin 1.6s linear infinite; }
.onair[data-state="paused"] .reels { color: #ffd58a; }
.onair[data-state="paused"] .reel { animation: reel-spin 1.6s linear infinite; animation-play-state: paused; }

@keyframes reel-spin { to { transform: rotate(360deg); } }

.onair-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  transition: color 0.3s, text-shadow 0.3s;
}
.onair[data-state="rec"] .onair-time { color: #ffd1d6; text-shadow: 0 0 12px rgba(255, 93, 108, 0.7); }
.onair[data-state="paused"] .onair-time { color: #ffe3ad; text-shadow: 0 0 12px rgba(255, 176, 58, 0.6); }

.onair-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.onair[data-state="rec"] .onair-label { color: #ff8d99; }
.onair[data-state="paused"] .onair-label { color: #ffd58a; }

/* ---------- Console (controls) ---------- */

.rec-main {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0;
  padding: 0.7rem 1.4rem 0.7rem 1rem;
  border-radius: 999px;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  background: linear-gradient(160deg, #d43f55, #8f2436);
  box-shadow: 0 6px 24px rgba(212, 63, 85, 0.35);
}
.rec-main-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  transition: border-radius 0.2s;
}
.rec-main:hover .rec-main-dot { animation: rec-pulse 1.2s ease-in-out infinite; }
.rec-main.is-live { background: linear-gradient(160deg, #3a2a4d, #201733); box-shadow: 0 0 0 1px rgba(255, 93, 108, 0.45), 0 6px 24px rgba(255, 93, 108, 0.2); }
.rec-main.is-live .rec-main-dot { border-radius: 3px; background: #ff5d6c; box-shadow: 0 0 10px rgba(255, 93, 108, 0.9); animation: rec-pulse 1.2s ease-in-out infinite; }

.icon-btn { display: inline-flex; align-items: center; gap: 0.45rem; }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.icon-btn.is-muted { color: var(--red); border-color: rgba(255, 93, 108, 0.55); background: rgba(255, 93, 108, 0.1); }
.icon-btn.is-muted svg { animation: mute-shake 0.35s ease-out 1; }
.icon-btn.is-on { color: var(--green); border-color: rgba(138, 255, 106, 0.5); background: rgba(138, 255, 106, 0.08); }

@keyframes mute-shake {
  0%, 100% { transform: rotate(0); }
  30% { transform: rotate(-14deg); }
  60% { transform: rotate(10deg); }
}

.mic-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0 0 0 0.6rem;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(7, 6, 14, 0.65);
  color: var(--muted);
  font-size: inherit;
  max-width: 100%;
}
.mic-pick svg { width: 15px; height: 15px; fill: currentColor; flex-shrink: 0; }
.mic-pick:focus-within { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(177, 140, 255, 0.16); }
.mic-mem {
  flex-shrink: 0;
  margin-right: 0.5rem;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  border: 1px solid rgba(138, 255, 106, 0.4);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}
.mic-mem[hidden] { display: none; }

.now-playing {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: rgba(20, 40, 18, 0.9);
  border: 1px solid rgba(138, 255, 106, 0.45);
  color: var(--green);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.now-playing[hidden] { display: none; }
.now-playing button { margin-top: 0; }

.stage { padding: 0.9rem; margin: 0 0 1rem; }
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; color: var(--muted); font-size: 0.9rem; }
.stage-head button { margin-top: 0; }
.stage-label { font-weight: 600; color: var(--ink); }
.stage-tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-left: auto; }
.zoom-tools { display: inline-flex; align-items: center; gap: 0.25rem; }
.zoom-tools button { padding: 0.3rem 0.65rem; font-size: 0.95rem; line-height: 1; }
.z-val { min-width: 3.2em; text-align: center; font-variant-numeric: tabular-nums; font-size: 0.8rem; }

.stage-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 62vh;
  overflow: hidden;
  background: #000;
  border-radius: 10px;
  touch-action: none;
  user-select: none;
}
.stage-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  will-change: transform;
}
.stage-frame.zoomed { cursor: grab; }
.stage-frame.dragging { cursor: grabbing; }
.stage-frame:fullscreen { max-height: none; border-radius: 0; aspect-ratio: auto; }

/* ---------- Mix controls (what you hear) ---------- */

.mix { display: inline-flex; align-items: center; gap: 0.4rem; }
.mix-mute {
  margin-top: 0;
  padding: 0.2rem 0.45rem;
  font-size: 0.95rem;
  line-height: 1;
  border-radius: 8px;
}
.mix-mute.is-muted { color: var(--red); border-color: rgba(255, 93, 108, 0.55); background: rgba(255, 93, 108, 0.1); }
.mix-vol {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  border-radius: 999px;
  background: rgba(177, 140, 255, 0.25);
  outline: none;
  cursor: pointer;
}
.mix-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 8px rgba(177, 140, 255, 0.6);
}
.mix-vol::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--purple); }
.mix-vol:focus-visible { box-shadow: 0 0 0 3px rgba(177, 140, 255, 0.25); }
.mix-val { font-size: 0.75rem; color: var(--muted); min-width: 2.8em; font-variant-numeric: tabular-nums; }
.booth-mix { margin-top: 0.6rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; }
.booth-mix .mix { flex: 1; min-width: 0; }
.booth-mix .mix-vol { flex: 1; width: auto; min-width: 60px; }
.booth-mix-lbl {
  flex-basis: 100%;
  order: -1;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sess-item .actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.ctl-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.ctl-row button { margin-top: 0; }
.ctl-row select {
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.4rem 0.55rem 0;
  max-width: 220px;
  min-width: 0;
  outline: none;
}
.ctl-row select option { background: #100c1d; color: var(--ink); }
.ctl-row select:disabled { opacity: 0.55; cursor: not-allowed; }

.ctl-note { color: var(--muted); font-size: 0.85rem; margin-top: 0.9rem; }

.drawer-wide { width: min(620px, 100vw); }

.hat-frame { flex: 1; border: none; width: 100%; background: var(--bg); }

.sess-item { border-bottom: 1px solid rgba(177, 140, 255, 0.1); padding: 1rem 0; }
.sess-head { margin-bottom: 0.5rem; }
.sess-item .actions { margin-top: 0.6rem; }

.track-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.track-btns { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }
.track-btns button { margin-top: 0; padding: 0.35rem 0.8rem; font-size: 0.85rem; }

.dl-btn {
  display: inline-block;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}
.dl-btn:hover { color: var(--ink); border-color: var(--purple); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%) translateY(20px);
  z-index: 70;
  background: rgba(23, 18, 40, 0.97);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  padding: 0.8rem 1.3rem;
  border-radius: 12px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 92vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255, 93, 108, 0.5); color: #ffb3ba; }

/* ---------- Misc ---------- */

.hat-mini .hat-float { width: clamp(160px, 36vw, 220px); }
.hat-mini .hat-shadow { height: 14px; }

@media (prefers-reduced-motion: reduce) {
  .hat-float, .hat-shadow, .fog, .mic-emblem, .mic-emblem .ring, .onair-tube, .reel, .rec-main-dot, .icon-btn svg { animation: none !important; }
  .mic-emblem .ring { opacity: 0.35; transform: scale(1); }
  .avatar-ring, .vu-fill, .vu-peak, .peer-card { transition: none !important; }
  .scope { display: none; }
}

@media (max-width: 520px) {
  .onair-sign { padding: 0.25rem 0.7rem; }
  .onair-tube { font-size: 1rem; letter-spacing: 0.16em; }
  .reels { width: 50px; height: 22px; }
  .onair-time { font-size: 1.15rem; }
  .mic-pick { width: 100%; }
  .ctl-row select { max-width: none; flex: 1; }
}

/* ---------- Show view: the whole studio fitted to one screen ---------- */

body.show-mode { overflow: hidden; }
body.show-mode #roomBox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.7rem 1rem 1rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 55% at 50% -12%, rgba(110, 60, 220, 0.22), transparent 70%),
    radial-gradient(ellipse 70% 45% at 85% 105%, rgba(60, 220, 120, 0.07), transparent 70%),
    var(--bg);
}
body.show-mode .onair { position: static; margin: 0; flex: 0 0 auto; }
body.show-mode .now-playing { margin: 0; flex: 0 0 auto; }

/* Shares: a grid that always fits. */
body.show-mode #stages {
  display: grid;
  gap: 0.6rem;
  flex: 1 1 0;
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
  grid-template-columns: 1fr;
}
body.show-mode #roomBox[data-shares="0"] #stages { display: none; }
body.show-mode #roomBox[data-shares="2"] #stages,
body.show-mode #roomBox[data-shares="3"] #stages,
body.show-mode #roomBox[data-shares="4"] #stages { grid-template-columns: 1fr 1fr; }
body.show-mode #roomBox[data-shares="5"] #stages,
body.show-mode #roomBox[data-shares="6"] #stages { grid-template-columns: 1fr 1fr 1fr; }
body.show-mode .stage { margin: 0; min-height: 0; min-width: 0; display: flex; flex-direction: column; padding: 0.5rem 0.6rem 0.6rem; }
body.show-mode .stage-head { margin-bottom: 0.4rem; }
body.show-mode .stage-frame { flex: 1 1 0; min-height: 0; aspect-ratio: auto; max-height: none; }
body.show-mode .stage-full { display: none; }

/* Booths: a strip under the shares, or the whole stage when nobody is sharing. */
body.show-mode .peer-grid { margin: 0; flex: 0 0 auto; }
body.show-mode #roomBox:not([data-shares="0"]) .peer-grid {
  display: flex;
  gap: 0.6rem;
  overflow: hidden;
}
body.show-mode #roomBox:not([data-shares="0"]) .peer-card { flex: 1 1 0; min-width: 0; padding: 0.55rem 0.75rem 0.6rem; }
body.show-mode #roomBox:not([data-shares="0"]) .scope { height: 30px; margin: 0.4rem 0 0.35rem; }
body.show-mode #roomBox:not([data-shares="0"]) .booth-mix { margin-top: 0.35rem; }
body.show-mode #roomBox:not([data-shares="0"]) .booth-mix-lbl { display: none; }

body.show-mode #roomBox[data-shares="0"] .peer-grid {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  align-content: center;
  gap: 1.2rem;
  padding: 0.5rem 4vw;
}
body.show-mode #roomBox[data-shares="0"] .peer-card { padding: 1.3rem 1.4rem; }
body.show-mode #roomBox[data-shares="0"] .avatar { width: 72px; height: 72px; }
body.show-mode #roomBox[data-shares="0"] .avatar-letter { font-size: 1.9rem; }
body.show-mode #roomBox[data-shares="0"] .peer-name { font-size: 1.35rem; }
body.show-mode #roomBox[data-shares="0"] .peer-tags { font-size: 0.95rem; }
body.show-mode #roomBox[data-shares="0"] .scope { height: 90px; }
body.show-mode #roomBox[data-shares="0"] .vu { height: 14px; }

/* The console floats top-right, in the empty half of the ON AIR row, and
   fades away when idle, so it never covers a share or a booth. */
body.show-mode .console {
  position: absolute;
  top: 0.7rem;
  right: 1rem;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.45rem 0.6rem;
  border-radius: 12px;
  z-index: 45; /* above the sticky ON AIR bar, which it overlaps */
  transition: opacity 0.35s;
}
body.show-mode .console .ctl-note { display: none; }
body.show-mode .console .ctl-row { justify-content: flex-end; gap: 0.4rem; }
body.show-mode .console .rec-main { padding: 0.5rem 1rem 0.5rem 0.8rem; font-size: 0.95rem; }
body.show-mode .console .mic-pick select { max-width: 150px; }
body.show-mode #roomBox[data-shares="3"] .stage:last-child { grid-column: span 2; }
body.show-mode .stage-tools, body.show-mode .booth-mix { transition: opacity 0.35s; }
body.show-mode.idle .console,
body.show-mode.idle .stage-tools,
body.show-mode.idle .booth-mix { opacity: 0; pointer-events: none; }
body.show-mode.idle { cursor: none; }

/* "Go fullscreen" only shows in show view when fullscreen has been lost
   (the share picker does that), never in the normal layout. */
.fs-chip { display: none; }
body.show-mode:not(.is-fs) .fs-chip { display: inline-flex; color: var(--green); border-color: rgba(138, 255, 106, 0.5); }

/* ---------- The drawn card, over the whole studio ---------- */

.studio-reveal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(5, 4, 10, 0.45);
  pointer-events: none; /* onlookers keep using the studio underneath */
}
.studio-reveal[hidden] { display: none; }
.studio-reveal.mine { pointer-events: auto; background: rgba(5, 4, 10, 0.72); }
.studio-reveal .reveal-slip { pointer-events: auto; transform-origin: 50% 100%; }
.studio-reveal.in .reveal-slip { animation: slip-fly 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.08) both; }
.studio-reveal .reveal-actions .danger:hover { color: var(--red); border-color: var(--red); }
.reveal-wait { font-size: 0.9rem; color: #6b5d44; font-style: italic; }

@keyframes slip-fly {
  0% { transform: translateY(70vh) rotate(-9deg) scale(0.55); opacity: 0; }
  55% { transform: translateY(-2vh) rotate(2.5deg) scale(1.03); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* Console buttons that only make sense in show view (the top bar is covered). */
.show-only { display: none; }
body.show-mode .show-only { display: inline-flex; }

@media (prefers-reduced-motion: reduce) {
  .studio-reveal.in .reveal-slip { animation: none; }
}

/* ---------- Crew chat ---------- */

.chat-btn { position: relative; }
.chat-badge {
  display: inline-block;
  min-width: 1.35em;
  margin-left: 0.3em;
  padding: 0 0.35em;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  vertical-align: middle;
}
.chat-badge[hidden] { display: none; }

.chat-drawer { width: min(400px, 100vw); }
.chat-head-btns { display: flex; gap: 0.4rem; align-items: center; }
.chat-head-btns button { margin-top: 0; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(177, 140, 255, 0.4) transparent;
  -webkit-user-select: text;
  user-select: text;
}
.chat-empty { color: var(--muted); font-size: 0.9rem; padding: 1rem 0; text-align: center; }

.chat-msg { --hue: 270; position: relative; padding: 0.45rem 0.7rem 0.5rem; border-radius: 12px; background: rgba(7, 6, 14, 0.55); border: 1px solid rgba(177, 140, 255, 0.08); }
.chat-msg.mine { background: rgba(116, 68, 224, 0.12); border-color: rgba(177, 140, 255, 0.18); }
.chat-msg.cont { margin-top: -0.35rem; }
.chat-msg.cont .chat-meta { display: none; }
.chat-meta { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.15rem; }
.chat-who { font-weight: 600; font-size: 0.85rem; color: hsl(var(--hue) 90% 74%); }
.chat-time { font-size: 0.7rem; color: var(--muted); }
.chat-del {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  margin: 0;
  padding: 0 0.4rem;
  font-size: 0.85rem;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.15s;
}
.chat-msg:hover .chat-del, .chat-msg:focus-within .chat-del { opacity: 1; }
.chat-body { font-size: 0.93rem; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-body a { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }
.chat-img { display: block; margin-top: 0.4rem; }
.chat-img img { display: block; max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid rgba(177, 140, 255, 0.15); }

.chat-form { padding: 0.6rem 0.9rem 0.9rem; border-top: 1px solid var(--panel-border); }
.chat-form.drag { outline: 2px dashed var(--purple); outline-offset: -6px; }
.chat-row { display: flex; align-items: flex-end; gap: 0.4rem; }
.chat-row textarea { flex: 1; min-height: 42px; max-height: 160px; resize: none; padding: 0.6rem 0.75rem; font-size: 0.93rem; line-height: 1.4; }
.chat-file { display: inline-flex; align-items: center; justify-content: center; margin: 0; padding: 0.55rem 0.6rem; border: 1px solid var(--panel-border); border-radius: 12px; color: var(--muted); cursor: pointer; }
.chat-file:hover { color: var(--ink); border-color: var(--purple); }
.chat-file svg { width: 18px; height: 18px; fill: currentColor; }
.chat-row button[type="submit"] { margin-top: 0; padding: 0.6rem 1rem; font-size: 0.93rem; }
.chat-attach { position: relative; display: inline-block; margin-bottom: 0.5rem; }
.chat-attach[hidden] { display: none; }
.chat-attach img { display: block; max-height: 110px; max-width: 100%; border-radius: 8px; border: 1px solid var(--panel-border); }
.chat-attach button { position: absolute; top: -0.5rem; right: -0.5rem; margin: 0; padding: 0.1rem 0.45rem; font-size: 0.8rem; background: rgba(13, 10, 24, 0.97); }
.chat-note { color: var(--muted); font-size: 0.82rem; margin-top: 0.45rem; }

/* In show view the chat docks beside the studio instead of covering it. */
body.show-mode.chat-open #roomBox { right: min(400px, 100vw); }
body.show-mode .chat-drawer { z-index: 45; }
