:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #111318;
  --muted: #5f6672;
  --line: #d7dde3;
  --blue: #255fc7;
  --green: #1f7a4d;
  --red: #b43333;
  --amber: #946200;
  --shadow: 0 8px 24px rgba(28, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  border: 1px solid #1f2937;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: #0f172a;
}

button:disabled,
.button-link.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
  padding: 9px 10px;
  resize: vertical;
  width: 100%;
}

textarea {
  min-height: 70px;
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #111318;
  color: #fff;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 18px;
}

.topbar h1 {
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0 0 4px;
}

.endpoint {
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin: 0;
}

.connection {
  align-items: center;
  display: inline-flex;
  font-size: 13px;
  gap: 8px;
  min-width: 120px;
  justify-content: flex-end;
}

.dot {
  background: var(--amber);
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.notice {
  background: #fff7e6;
  border-bottom: 1px solid #e2bd77;
  color: #5d3b00;
  font-size: 14px;
  padding: 9px 18px;
}

.dot.ok {
  background: var(--green);
}

.dot.bad {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: 0;
}

.rooms {
  background: #e9eef2;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 16px;
}

.create-form,
.stacked-form,
.join-form {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(78px, 0.45fr) minmax(150px, 1fr);
}

.room-list-wrap {
  min-height: 0;
}

.section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.room-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 430px);
  min-height: 100px;
  overflow: auto;
}

.room-list button {
  align-items: stretch;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  display: grid;
  gap: 5px;
  justify-content: stretch;
  min-height: 74px;
  padding: 10px;
  text-align: left;
  white-space: normal;
}

.room-list button.active {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.room-title {
  font-size: 14px;
  font-weight: 750;
}

.room-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.room {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.room-header {
  align-items: start;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 92px;
  padding: 16px 18px;
}

.room-header h2 {
  font-size: 21px;
  line-height: 1.24;
  margin: 3px 0 6px;
  max-width: 76ch;
}

.code {
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 800;
}

.meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px 12px;
}

.meta span {
  white-space: nowrap;
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.room-actions button {
  background: #fff;
  color: #1f2937;
}

.room-actions button:hover {
  background: #edf2f7;
}

.room-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  min-height: 0;
}

.transcript {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding: 18px;
}

.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid #94a3b8;
  border-radius: 6px;
  box-shadow: var(--shadow);
  max-width: 860px;
  padding: 12px 14px;
}

.message.participant {
  border-left-color: var(--blue);
}

.message.moderator {
  border-left-color: var(--green);
}

.message.system {
  border-left-color: var(--amber);
  box-shadow: none;
}

.message-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 6px;
}

.author {
  font-weight: 800;
}

.stamp {
  color: var(--muted);
  font-size: 12px;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-state {
  align-self: center;
  color: var(--muted);
  justify-self: center;
  padding: 24px;
  text-align: center;
}

.side-panel {
  background: #fdfdfc;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-auto-rows: max-content;
  overflow: auto;
  padding: 16px;
}

.turn-box {
  background: #eef6f0;
  border: 1px solid #b8d8c2;
  border-radius: 6px;
  color: #16412b;
  font-weight: 800;
  min-height: 44px;
  padding: 10px 12px;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.join-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

@media (max-width: 920px) {
  .workspace,
  .room-body {
    grid-template-columns: 1fr;
  }

  .rooms,
  .side-panel {
    border-left: 0;
    border-right: 0;
  }

  .room-list {
    max-height: 240px;
  }
}

@media (max-width: 640px) {
  .topbar,
  .room-header {
    align-items: stretch;
    flex-direction: column;
  }

  .connection,
  .room-actions {
    justify-content: flex-start;
  }

  .form-row,
  .join-form {
    grid-template-columns: 1fr;
  }
}
