:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1d2522;
  --muted: #66716c;
  --line: #d8ded8;
  --accent: #16745b;
  --accent-strong: #0d5f49;
  --danger: #b23939;
  --focus: #e5f3ed;
  --shadow: 0 10px 30px rgba(39, 50, 45, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

button.danger {
  border-color: #e3b9b9;
  color: var(--danger);
}

.icon-btn {
  width: 42px;
  font-size: 20px;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

#statusText {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.top-actions,
.button-row,
.toggle-row,
.meters,
.panel-head,
.channel-actions,
.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(260px, 0.9fr);
  grid-template-rows: minmax(280px, 1fr) minmax(220px, 0.8fr);
  gap: 16px;
  min-height: calc(100vh - 108px);
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.connection-panel {
  align-self: start;
}

.chat-panel,
.event-panel,
.channel-panel,
.client-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.form-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

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

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

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.audio-controls {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.audio-controls button {
  flex: 1;
}

.toggle-row {
  justify-content: space-between;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.toggle-row input {
  width: auto;
}

.meters {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.channel-actions {
  justify-content: flex-end;
  min-width: 0;
}

.small-input {
  width: min(160px, 50%);
}

.id-input {
  width: 96px;
}

.list {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  min-height: 0;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcfa;
}

.list-main {
  min-width: 0;
}

.list-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.list-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.move-btn {
  min-width: 58px;
}

.speaking {
  border-color: #71a78a;
  background: #eef8f2;
}

.chat-log,
.event-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  padding: 10px;
}

.chat-log {
  margin: 12px 0 10px;
}

.event-log {
  margin-top: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.chat-line,
.event-line {
  overflow-wrap: anywhere;
  padding: 4px 0;
}

.chat-form input {
  flex: 1;
}

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

  .workspace {
    grid-template-rows: auto;
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .danger {
    flex: 1;
  }

  .panel-head,
  .channel-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .small-input,
  .id-input {
    width: 100%;
  }
}
