:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101316;
  color: #eef2f5;
  --border: #2a3037;
  --panel: #171b20;
  --panel-soft: #1d2228;
  --text-muted: #a8b2bd;
  --text-soft: #cbd3db;
  --accent: #58c096;
  --rail-width: 116px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  background: #101316;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid #eef2f5;
  border-radius: 6px;
  padding: 0 14px;
  background: #eef2f5;
  color: #101316;
  cursor: pointer;
}

button:disabled {
  border-color: #303741;
  background: #222831;
  color: #7f8a95;
  cursor: default;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: #12161a;
  padding: 16px;
}

.toolbar-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.settings-toggle {
  display: none;
}

.join-form {
  display: grid;
  grid-template-columns:
    minmax(220px, 1.2fr)
    repeat(3, minmax(140px, 1fr))
    minmax(130px, 0.5fr)
    minmax(110px, 0.45fr)
    minmax(72px, 0.25fr)
    minmax(80px, 0.25fr)
    auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #333b45;
  border-radius: 6px;
  padding: 8px 10px;
  background: #0f1216;
  color: #eef2f5;
}

input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.toggle-label {
  min-width: 0;
}

.toggle-control {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #eef2f5;
  font-size: 0.9rem;
  font-weight: 650;
}

.actions {
  display: flex;
  gap: 8px;
}

.status {
  min-height: 24px;
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 650;
}

.room-grid {
  flex: 1;
  min-height: 0;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  overflow: hidden;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.15rem;
  color: #eef2f5;
}

h2 {
  font-size: 0.95rem;
  color: #eef2f5;
}

.transcript-panel,
.side-panel {
  min-width: 0;
}

.transcript-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.transcript {
  list-style: none;
  margin: 16px 0 0;
  padding: 0 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.utterance {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 3px;
  align-items: start;
  padding: 6px 0;
  min-width: 0;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    opacity 180ms ease;
}

.utterance::before {
  content: attr(data-avatar);
  grid-row: 1 / span 2;
  align-self: start;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.2);
  color: #101316;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
}

.utterance.draft {
  color: #eef2f5;
}

.utterance.final {
  color: #eef2f5;
}

.utterance.live {
  color: #f5fff9;
}

.utterance.latest-final {
  color: #eef2f5;
}

.utterance.latest-final .utterance-state,
.utterance.latest-final .utterance-time {
  color: #b8c0ca;
}

.utterance.older-final {
  color: #9fa9b4;
}

.utterance.older-final::before {
  opacity: 0.72;
  filter: saturate(0.72);
}

.utterance-meta {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: left;
}

.utterance-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.utterance-state {
  color: #6f7b87;
  font-size: 0.64rem;
  font-weight: 650;
  text-transform: uppercase;
}

.utterance.draft .utterance-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
}

.utterance.draft .utterance-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgb(88 192 150 / 0.48);
  animation: livePulse 1.25s ease-out infinite;
}

.utterance-time {
  color: #7f8a95;
  font-size: 0.64rem;
  font-weight: 650;
}

.utterance-text {
  grid-column: 2;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: pre-wrap;
  line-height: 1.35;
  color: #eef2f5;
  font-size: 1rem;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    opacity 180ms ease;
}

.utterance.live .utterance-text {
  color: #f4fff9;
  text-shadow: 0 0 14px rgb(88 192 150 / 0.16);
}

.utterance.latest-final .utterance-text {
  color: #eef2f5;
}

.utterance.older-final .utterance-text {
  color: #aeb7c1;
}

.transcript[data-display-mode="bubbles"] {
  gap: 10px;
}

.transcript[data-display-mode="bubbles"] .utterance {
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 14px;
  row-gap: 7px;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.transcript[data-display-mode="bubbles"] .utterance::before {
  grid-row: 1 / span 2;
  align-self: start;
}

.transcript[data-display-mode="bubbles"] .utterance.draft {
  border-left: 4px solid var(--accent);
  box-shadow: 0 0 0 1px rgb(88 192 150 / 0.12) inset;
}

.transcript[data-display-mode="bubbles"] .utterance.latest-final {
  border-left: 4px solid #d7dde5;
  background: #1b2027;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08) inset;
}

.transcript[data-latest-style="blue"][data-display-mode="bubbles"] .utterance.latest-final {
  border-left-color: #8ab8ff;
  background: #182133;
  box-shadow: 0 0 0 1px rgb(138 184 255 / 0.14) inset;
}

.transcript[data-display-mode="bubbles"] .utterance.older-final {
  border-left: 4px solid #6d7680;
  background: #15191e;
}

.transcript[data-display-mode="bubbles"] .utterance-meta {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  text-align: left;
}

.transcript[data-display-mode="bubbles"] .utterance-text {
  grid-column: 2;
}

.transcript[data-display-mode="bubbles"] .utterance-name {
  max-width: 100%;
}

.transcript[data-display-mode="chat"] {
  gap: 12px;
}

.transcript[data-display-mode="chat"] .utterance {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  padding: 0;
}

.transcript[data-display-mode="chat"] .utterance::before {
  grid-row: 1 / span 2;
  align-self: end;
}

.transcript[data-display-mode="chat"] .utterance.own {
  align-self: end;
}

.transcript[data-display-mode="chat"] .utterance-meta,
.transcript[data-display-mode="chat"] .utterance-text {
  grid-column: 2;
}

.transcript[data-display-mode="chat"] .utterance-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin: 0 2px 3px;
  text-align: left;
}

.transcript[data-display-mode="chat"] .utterance-text {
  width: fit-content;
  max-width: min(560px, 100%);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 6px;
  padding: 10px 12px;
  background: #20262d;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset;
}

.transcript[data-display-mode="chat"] .utterance.own .utterance-text {
  border-color: rgb(88 192 150 / 0.35);
  border-radius: 18px 18px 6px 18px;
  background: #15382d;
}

.transcript[data-display-mode="chat"] .utterance.live .utterance-text {
  border-color: rgb(88 192 150 / 0.55);
  background: #173c31;
  box-shadow: 0 0 0 1px rgb(88 192 150 / 0.12) inset;
}

.transcript[data-display-mode="chat"] .utterance.latest-final .utterance-text {
  border-color: rgb(215 221 229 / 0.28);
  background: #222830;
}

.transcript[data-latest-style="blue"][data-display-mode="chat"] .utterance.latest-final .utterance-text {
  border-color: rgb(138 184 255 / 0.38);
  background: #1c2638;
}

.transcript[data-latest-style="blue"] .utterance.latest-final .utterance-state,
.transcript[data-latest-style="blue"] .utterance.latest-final .utterance-time {
  color: #9ec4ff;
}

.transcript[data-display-mode="chat"] .utterance.older-final .utterance-text {
  border-color: #303741;
  background: #1a1f25;
}

.transcript[data-motion-mode="fade"] .utterance.is-new {
  animation: rowFade 180ms ease-out both;
}

.transcript[data-motion-mode="fade"] .utterance.is-new .utterance-text {
  animation: textFade 180ms ease-out both;
}

.transcript[data-motion-mode="pop"] .utterance.is-new .utterance-text {
  animation: textPop 180ms ease-out both;
  transform-origin: left center;
}

.transcript[data-motion-mode="slide"] .utterance.is-new {
  animation: rowSlide 200ms ease-out both;
}

.transcript[data-motion-mode="slide"] .utterance.is-new .utterance-text {
  animation: textFade 160ms ease-out both;
}

.utterance-text-delta {
  display: inline-block;
  border-radius: 4px;
  transform-origin: left center;
}

.utterance-text-delta.corrected {
  background: rgb(255 211 126 / 0.16);
  box-shadow: 0 0 0 1px rgb(255 211 126 / 0.18);
}

.transcript[data-motion-mode="fade"] .utterance-text-delta {
  animation: textFade 180ms ease-out both;
}

.transcript[data-motion-mode="type"] .utterance-text-delta {
  animation: textReveal 260ms steps(18, end) both;
}

.transcript[data-motion-mode="pop"] .utterance-text-delta {
  animation: textPop 180ms ease-out both;
}

.transcript[data-motion-mode="slide"] .utterance-text-delta {
  animation: textDeltaSlide 180ms ease-out both;
}

.utterance.settling {
  animation: none;
}

.utterance.settling .utterance-state {
  animation: finalLabelSettle 260ms ease-out both;
}

.transcript[data-motion-mode="none"] .utterance,
.transcript[data-motion-mode="none"] .utterance.draft .utterance-state::before,
.transcript[data-motion-mode="none"] .utterance-text,
.transcript[data-motion-mode="none"] .utterance-text-delta {
  animation: none;
}

.avatar-color-0::before {
  background: #85d3ff;
}

.avatar-color-1::before {
  background: #f4a3b4;
}

.avatar-color-2::before {
  background: #b99cff;
}

.avatar-color-3::before {
  background: #8de6c1;
}

.avatar-color-4::before {
  background: #ffd37e;
}

.avatar-color-5::before {
  background: #9db4ff;
}

.avatar-color-6::before {
  background: #f4b183;
}

.avatar-color-7::before {
  background: #a7e07f;
}

@keyframes livePulse {
  0% {
    box-shadow: 0 0 0 0 rgb(88 192 150 / 0.5);
  }

  70% {
    box-shadow: 0 0 0 7px rgb(88 192 150 / 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgb(88 192 150 / 0);
  }
}

@keyframes rowFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes rowSlide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes textFade {
  from {
    opacity: 0.45;
  }

  to {
    opacity: 1;
  }
}

@keyframes textPop {
  from {
    opacity: 0.55;
    transform: scale(0.985);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes textReveal {
  from {
    clip-path: inset(0 100% 0 0);
  }

  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes textDeltaSlide {
  from {
    opacity: 0.55;
    transform: translateY(0.18em);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes finalLabelSettle {
  0% {
    opacity: 0.62;
  }

  100% {
    opacity: 1;
  }
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 20px;
  overflow-y: auto;
}

.side-panel section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.event-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.empty {
  color: #7f8a95;
}

.chat-form {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

@media (max-width: 860px) {
  .shell {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .toolbar {
    flex: none;
    max-height: 48dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
  }

  .toolbar-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .settings-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border-color: #333b45;
    background: var(--panel-soft);
    color: #eef2f5;
  }

  .join-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 12px;
    gap: 10px;
  }

  .join-form[data-mobile-collapsed="true"] {
    display: none;
  }

  .room-grid {
    flex: 1;
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px 12px 0;
    overflow: hidden;
  }

  .transcript {
    max-height: none;
    padding-right: 0;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .utterance {
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 10px;
  }

  .utterance::before {
    width: 32px;
    height: 32px;
    font-size: 0.82rem;
  }

  .side-panel {
    display: none;
  }

  .chat-form {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 12px -12px 0;
    padding: 10px;
    background: #101316;
  }
}

@media (max-width: 520px) {
  .join-form {
    grid-template-columns: 1fr 1fr;
  }

  .join-form label:first-child,
  .join-form .actions {
    grid-column: 1 / -1;
  }

  .join-form label:nth-child(3),
  .join-form label:nth-child(7) {
    display: none;
  }

  label {
    font-size: 0.78rem;
  }

  input,
  select,
  button {
    min-height: 44px;
  }

  .status {
    font-size: 0.86rem;
  }

  h1 {
    font-size: 1.08rem;
  }

  .transcript[data-display-mode="bubbles"] {
    gap: 8px;
  }

  .transcript[data-display-mode="bubbles"] .utterance {
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 12px;
    padding: 10px;
  }

  .transcript[data-display-mode="lines"] .utterance {
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 3px;
  }

  .transcript[data-display-mode="chat"] {
    gap: 10px;
  }

  .transcript[data-display-mode="chat"] .utterance {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 8px;
  }

  .transcript[data-display-mode="chat"] .utterance::before {
    width: 32px;
    height: 32px;
    font-size: 0.82rem;
  }

  .transcript[data-display-mode="chat"] .utterance-text {
    max-width: 100%;
    padding: 9px 11px;
    border-radius: 16px 16px 16px 6px;
  }

  .transcript[data-display-mode="chat"] .utterance.own .utterance-text {
    border-radius: 16px 16px 6px 16px;
  }

  .utterance-meta {
    font-size: 0.68rem;
  }

  .utterance-state,
  .utterance-time {
    font-size: 0.58rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .utterance.draft .utterance-state::before,
  .utterance.settling,
  .transcript .utterance,
  .transcript .utterance-text,
  .transcript .utterance-text-delta {
    animation: none;
  }
}
