:root {
  color-scheme: dark;
  --room-bg: #080706;
  --console: #0f0d0b;
  --rail: #12100d;
  --panel: #17140f;
  --inset: #0a0908;
  --raised: #1e1a14;
  --line: #2b261e;
  --line-strong: #423a2f;
  --ink: #f4f0e6;
  --ink-muted: #aaa294;
  --ink-soft: #8a8173;
  --signal: #ff5c2b;
  --signal-hover: #ff754d;
  --signal-soft: rgba(255, 92, 43, 0.15);
  --signal-line: rgba(255, 92, 43, 0.46);
  --signal-ink: #1a0802;
  --danger: #ff9a8a;
  --key-edge: #8f8576;
  --key-ink: #17130e;
  --type-ui: system-ui, -apple-system, "Segoe UI", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --type-data: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --text-micro: 0.6875rem;
  --text-meta: 0.75rem;
  --text-body: 0.9375rem;
  --text-title: 1rem;
  --text-status: clamp(1.15rem, 1.8vw, 1.45rem);
  --r-field: 6px;
  --r-button: 10px;
  --r-card: 14px;
  --r-shell: 20px;
  --r-pill: 999px;
  --shadow-shell: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 32px 80px rgba(0, 0, 0, 0.55);
  --shadow-key: inset 0 1px 0 #ffffff, 0 2px 0 var(--key-edge), 0 8px 18px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--room-bg);
  color: var(--ink);
  font-family: var(--type-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(70% 46% at 50% -8%, rgba(255, 92, 43, 0.08), transparent 68%),
    radial-gradient(rgba(244, 240, 230, 0.035) 1px, transparent 1px);
  background-size: auto, 18px 18px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 100%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "topbar"
    "stage"
    "chat"
    "dock";
  width: 100%;
  max-width: 1060px;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--console);
  border: 0;
  border-radius: 0;
}

@media (min-width: 700px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }

  .app {
    height: min(880px, calc(100dvh - 48px));
    border: 1px solid var(--line);
    border-radius: var(--r-shell);
    box-shadow: var(--shadow-shell);
  }
}

/* Header */

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 0 20px;
  background: var(--console);
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  flex: none;
  width: 27px;
  height: 27px;
  color: var(--ink);
}

.mark-signal {
  fill: var(--signal);
}

.brand {
  display: flex;
  gap: 0.32em;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 750;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-accent {
  color: var(--signal);
}

.room {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 10px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--inset);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  color: var(--ink-muted);
  font-size: var(--text-micro);
}

.room-label {
  color: var(--ink-soft);
  font-size: 0.625rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#room-code {
  color: var(--ink);
  font-family: var(--type-data);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.room-lamp {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 3px transparent;
  transition: background-color 0.14s ease, box-shadow 0.14s ease;
}

body[data-state="waiting"] .room-lamp {
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

body[data-state="live"] .room-lamp {
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft), 0 0 12px rgba(255, 92, 43, 0.7);
}

body[data-state="requesting-mic"] .room-lamp,
body[data-state="connecting"] .room-lamp,
body[data-state="reconnecting"] .room-lamp {
  background: var(--signal);
  animation: lamp-pulse 1.5s ease-in-out infinite;
}

body[data-state="error"] .room-lamp {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 154, 138, 0.1);
}

/* Stage */

.stage {
  position: relative;
  grid-area: stage;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  background: var(--rail);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.stage > * {
  position: relative;
  z-index: 1;
}

.stage::after {
  content: "";
  position: absolute;
  top: 46%;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(244, 240, 230, 0.07) 1px, transparent 1.2px);
  background-size: 10px 10px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 36%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 36%);
}

@media (max-width: 939px) {
  .stage::after {
    display: none;
  }
}

.stage-head,
.dock-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.micro-label {
  flex: none;
  color: var(--ink-soft);
  font-size: var(--text-micro);
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stage-rule,
.dock-rule {
  flex: 1;
  height: 1px;
  background: var(--line);
}

#status {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  max-width: 26ch;
  min-height: 1.18em;
  margin: 0;
  color: var(--ink);
  font-size: var(--text-status);
  font-weight: 750;
  line-height: 1.18;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

#status::before {
  content: "";
  width: 9px;
  height: 9px;
  margin-top: 0.42em;
  border-radius: 50%;
  background: var(--line-strong);
}

body[data-state="idle"] #status {
  color: var(--ink-muted);
}

body[data-state="waiting"] #status::before {
  background: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-soft);
}

body[data-state="live"] #status {
  color: var(--ink);
}

body[data-state="live"] #status::before {
  background: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-soft), 0 0 12px rgba(255, 92, 43, 0.65);
}

body[data-state="requesting-mic"] #status,
body[data-state="connecting"] #status,
body[data-state="reconnecting"] #status {
  color: var(--ink-muted);
}

body[data-state="requesting-mic"] #status::before,
body[data-state="connecting"] #status::before,
body[data-state="reconnecting"] #status::before {
  background: var(--signal);
  animation: pulse 1.6s ease-in-out infinite;
}

body[data-state="error"] #status {
  color: var(--danger);
}

body[data-state="error"] #status::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 154, 138, 0.1);
}

body[data-state="error"] .controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  order: 1;
}

body[data-state="error"] .share {
  order: 2;
}

/* Share */

.share {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.share-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.share-label {
  color: var(--ink-muted);
  font-size: var(--text-meta);
  line-height: 1.4;
}

.share-row {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

#share-link {
  display: block;
  min-width: 0;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  background: var(--inset);
  color: var(--ink);
  font-family: var(--type-data);
  font-size: var(--text-micro);
  line-height: 1.35;
  overflow-wrap: anywhere;
  user-select: all;
}

#copy-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-button);
  background: var(--signal);
  color: var(--signal-ink);
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}

#copy-link:hover:not(:disabled) {
  background: var(--signal-hover);
}

#copy-link:active:not(:disabled) {
  transform: translateY(1px);
}

body[data-state="error"] #copy-link {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}

body[data-state="error"] #copy-link:hover:not(:disabled) {
  border-color: #5a5040;
  background: var(--raised);
}

.share-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.qr-code {
  display: block;
  width: 104px;
  height: 104px;
  padding: 6px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 18px rgba(0, 0, 0, 0.25);
}

.share-qr-label {
  color: var(--ink-soft);
  font-size: 0.625rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@media (max-width: 939px) {
  .share {
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
  }

  .share-copy {
    order: 2;
  }

  .share-qr {
    order: 1;
  }

  .qr-code {
    width: 92px;
    height: 92px;
  }
}

body[data-state="connecting"] .share,
body[data-state="live"] .share,
body[data-state="reconnecting"] .share {
  display: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.controls:not(:has(button:not([hidden]))) {
  display: none;
}

.controls button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-button);
  background: var(--raised);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 650;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}

.controls button:hover:not(:disabled) {
  border-color: #5a5040;
  background: #272219;
}

.controls button:active:not(:disabled) {
  transform: translateY(1px);
}

#retry,
#new-room {
  border-color: transparent;
  background: var(--signal);
  color: var(--signal-ink);
}

#retry:hover:not(:disabled),
#new-room:hover:not(:disabled) {
  border-color: transparent;
  background: var(--signal-hover);
}

/* Chat */

.chat {
  grid-area: chat;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--console);
}

.chat-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

#chat-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-title);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.chat-state {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--inset);
  color: var(--ink-muted);
  font-size: var(--text-micro);
  line-height: 1.2;
  white-space: nowrap;
}

.chat-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.chat-state[data-state="live"] {
  border-color: var(--signal-line);
  background: var(--signal-soft);
  color: var(--signal);
}

.chat-state[data-state="live"]::before {
  background: var(--signal);
  box-shadow: 0 0 8px rgba(255, 92, 43, 0.65);
}

.chat-state[data-state="connecting"]::before {
  background: var(--signal);
  animation: pulse 1.6s ease-in-out infinite;
}

.chat-state[data-state="error"] {
  border-color: rgba(255, 154, 138, 0.3);
  background: rgba(255, 154, 138, 0.06);
  color: var(--danger);
}

.chat-state[data-state="error"]::before {
  background: var(--danger);
}

.messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.chat-empty {
  display: flex;
  max-width: 34ch;
  margin: auto;
  padding: 24px 16px;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--ink-muted);
  font-size: 0.875rem;
  line-height: 1.55;
  text-align: center;
  text-wrap: balance;
}

.chat-empty::before {
  content: "";
  width: 56px;
  height: 56px;
  flex: none;
  background: url("./mark.svg") center / contain no-repeat;
  opacity: 0.28;
}

.message {
  max-width: min(76%, 46ch);
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  border-bottom-left-radius: 4px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  overflow-wrap: anywhere;
  animation: message-in 0.14s ease-out;
}

.message[data-grouped="true"] {
  margin-top: -3px;
}

.message[data-grouped="true"] .message-meta {
  display: none;
}

.message--self {
  align-self: flex-end;
  border-color: var(--signal-line);
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: var(--r-card);
  background: var(--signal-soft);
}

.message--system {
  display: flex;
  align-self: stretch;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  padding: 4px 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--ink-muted);
  font-size: 0.625rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  animation: none;
}

.message--system::before,
.message--system::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.message--system .message-text {
  flex: none;
  margin: 0;
  font-size: inherit;
  line-height: 1.4;
  white-space: normal;
}

.message-text {
  margin: 0;
  font-size: var(--text-body);
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-meta {
  display: block;
  margin-top: 3px;
  color: var(--ink-soft);
  font-family: var(--type-data);
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.message--self .message-meta {
  color: rgba(244, 240, 230, 0.55);
  text-align: right;
}

.typing {
  display: inline-flex;
  flex: none;
  align-self: flex-start;
  align-items: center;
  gap: 7px;
  margin: 0 20px 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-button);
  background: var(--panel);
  color: var(--ink-muted);
  font-size: 0.625rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: message-in 0.14s ease-out;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--signal);
  animation: typing-dot 1.2s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

#sound {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  margin: 0 16px 12px;
  padding: 0 14px;
  border: 1px solid var(--signal-line);
  border-radius: var(--r-button);
  background: var(--signal-soft);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 650;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

#sound:hover:not(:disabled) {
  border-color: var(--signal);
  background: rgba(255, 92, 43, 0.18);
}

.composer {
  display: flex;
  flex: none;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--console);
}

#chat-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-button);
  background: var(--inset);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-body);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

#chat-input::placeholder {
  color: var(--ink-soft);
}

#chat-input:focus {
  border-color: var(--signal);
}

#chat-input:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

#chat-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#chat-send {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-button);
  background: var(--raised);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 650;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

#chat-send svg {
  transition: color 0.14s ease;
}

#chat-send:hover:not(:disabled) {
  border-color: #5a5040;
  background: #29241b;
}

#chat-send:hover:not(:disabled) svg {
  color: var(--signal);
}

#chat-send:disabled {
  border-color: var(--line);
  background: var(--console);
  color: var(--ink-soft);
}

/* Transmit dock */

.dock {
  grid-area: dock;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 18px;
  background: var(--rail);
  border-top: 1px solid var(--line);
}

#ptt {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 58px;
  padding: 8px 12px;
  border: 1px solid var(--ink);
  border-radius: var(--r-card);
  background: var(--ink);
  color: var(--key-ink);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-key);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.08s ease;
}

.ptt-icon-wrap {
  display: grid;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(23, 19, 14, 0.08);
  transition: background-color 0.14s ease;
}

.ptt-icon {
  width: 20px;
  height: 20px;
}

#ptt-label {
  flex: 1;
  text-align: left;
}

.ptt-led {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b8afa0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  transition: background-color 0.14s ease, box-shadow 0.14s ease;
}

#ptt:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 #ffffff, 0 0 0 var(--key-edge), 0 3px 8px rgba(0, 0, 0, 0.3);
}

#ptt:disabled {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  box-shadow: none;
}

#ptt:disabled .ptt-icon-wrap {
  background: transparent;
}

#ptt:disabled .ptt-led {
  background: var(--line-strong);
}

#ptt.is-open {
  border-color: var(--signal);
  background: var(--signal);
  color: var(--signal-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 4px var(--signal-soft), 0 8px 30px rgba(255, 92, 43, 0.25);
}

#ptt.is-open .ptt-icon-wrap {
  background: rgba(26, 8, 2, 0.12);
}

#ptt.is-open .ptt-led {
  background: var(--signal-ink);
  box-shadow: 0 0 0 4px rgba(26, 8, 2, 0.12);
}

.levels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

body[data-state="live"] .levels {
  opacity: 1;
}

.level {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.level-label {
  color: var(--ink-soft);
  font-size: 0.625rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.meter {
  position: relative;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--inset);
}

.meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--signal);
  transform: scaleX(0);
  transform-origin: left center;
}

.level--remote .meter-fill {
  background: var(--ink);
}

.meter::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 5px, var(--inset) 5px 7px);
}

.dock-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.hint {
  min-width: 0;
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--text-meta);
  line-height: 1.4;
}

#stats {
  flex: none;
  max-width: 46%;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--type-data);
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Utilities */

#remote-audio {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.copy-field {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

button {
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

#copy-link:focus-visible,
#retry:focus-visible,
#new-room:focus-visible,
#ptt:focus-visible {
  outline-color: var(--ink);
}

#ptt:focus-visible {
  outline-width: 3px;
  outline-offset: 3px;
}

/* Motion */

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

@keyframes lamp-pulse {
  50% {
    opacity: 0.35;
    box-shadow: 0 0 0 3px transparent;
  }
}

@keyframes typing-dot {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* Layout */

@media (min-width: 940px) {
  .app {
    grid-template-columns: 318px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "topbar topbar"
      "stage chat"
      "dock chat";
  }

  .stage {
    gap: 18px;
    padding: 20px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .stage::after {
    right: 20px;
    bottom: 20px;
    left: 20px;
  }

  .dock {
    padding: 16px 20px 18px;
    border-right: 1px solid var(--line);
  }
}

@media (max-width: 939px) {
  .levels {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}

@media (max-width: 430px) {
  .topbar {
    min-height: 58px;
    padding: 0 14px;
  }

  .brand {
    font-size: 0.75rem;
    letter-spacing: 0.09em;
  }

  .brand-lockup {
    gap: 8px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
  }

  .room {
    gap: 7px;
    padding: 7px 9px;
  }

  .room-label {
    display: none;
  }

  .stage {
    gap: 14px;
    padding: 14px;
  }

  .stage::after {
    display: none;
  }

  .chat-head {
    padding: 12px 14px;
  }

  .messages {
    padding: 14px;
  }

  .composer {
    padding: 10px 12px;
  }

  .dock {
    padding: 14px 14px 16px;
  }

  #sound {
    margin: 0 12px 10px;
  }

  #stats {
    display: none;
  }

  .typing {
    margin: 0 14px 8px;
  }
}

@media (max-height: 700px) {
  .app {
    height: auto;
  }

  .chat {
    min-height: 240px;
  }
}

@media (max-width: 699px) and (max-height: 700px) {
  .app {
    min-height: 100vh;
    min-height: 100svh;
  }
}

@media (min-width: 700px) and (max-height: 700px) {
  .app {
    min-height: calc(100vh - 48px);
    min-height: calc(100svh - 48px);
  }
}

@media (max-width: 939px) and (max-height: 840px) {
  .topbar {
    min-height: 54px;
    padding: 0 14px;
  }

  .brand {
    font-size: 0.75rem;
    letter-spacing: 0.09em;
  }

  .brand-lockup {
    gap: 8px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
  }

  .room {
    gap: 7px;
    padding: 6px 9px;
  }

  .room-label {
    display: none;
  }

  .stage {
    gap: 10px;
    padding: 12px;
  }

  .stage::after {
    display: none;
  }

  #status {
    gap: 10px;
    max-width: 34ch;
    font-size: 1.05rem;
  }

  .share {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .share-qr {
    gap: 5px;
    padding-top: 0;
  }

  .share-qr-label {
    font-size: 0.5625rem;
    letter-spacing: 0.1em;
  }

  .share-copy {
    order: 2;
    gap: 4px;
  }

  .share-label {
    font-size: 0.6875rem;
  }

  .share-row {
    gap: 6px;
    margin-top: 0;
  }

  #share-link {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 0.625rem;
    line-height: 1.3;
  }

  #copy-link {
    min-height: 40px;
    font-size: 0.75rem;
  }

  .chat-head {
    padding: 10px 14px;
  }

  #chat-title {
    font-size: 0.9375rem;
  }

  .chat-empty {
    gap: 8px;
    padding: 12px;
    font-size: 0.8125rem;
  }

  .chat-empty::before {
    width: 40px;
    height: 40px;
  }

  .messages {
    padding: 12px;
    gap: 8px;
  }

  .composer {
    gap: 8px;
    padding: 8px 12px;
  }

  #chat-input {
    height: 44px;
    padding: 0 12px;
    font-size: 0.875rem;
  }

  #chat-send {
    height: 44px;
    padding: 0 12px;
    font-size: 0.75rem;
  }

  #chat-send svg {
    width: 14px;
    height: 14px;
  }

  .dock {
    gap: 8px;
    padding: 8px 14px;
  }

  #ptt {
    min-height: 48px;
    padding: 6px 10px;
    font-size: 0.9375rem;
  }

  .ptt-icon-wrap {
    width: 30px;
    height: 30px;
  }

  .ptt-icon {
    width: 18px;
    height: 18px;
  }

  .levels {
    display: none;
  }

  body[data-state="live"] .levels {
    display: grid;
  }

  .hint {
    font-size: 0.6875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .room-lamp,
  #status::before,
  .chat-state::before {
    animation: none !important;
  }

  .typing-dots i {
    animation: none;
    opacity: 0.6;
  }
}
