:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17201c;
  --muted: #65736d;
  --line: #d8ddd6;
  --accent: #0f7b6c;
  --accent-dark: #075b50;
  --warn: #a35c00;
  --danger: #ad2932;
}

* {
  box-sizing: border-box;
}

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

button,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}

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

.brand strong {
  font-size: 20px;
  letter-spacing: 0;
}

#status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfa;
  white-space: nowrap;
}

#status[data-state="ready"] {
  color: var(--accent-dark);
  border-color: rgba(15, 123, 108, 0.35);
  background: rgba(15, 123, 108, 0.08);
}

#status[data-state="error"] {
  color: var(--danger);
  border-color: rgba(173, 41, 50, 0.35);
  background: rgba(173, 41, 50, 0.08);
}

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

select,
button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

select {
  min-width: 104px;
  padding: 0 10px;
}

button {
  padding: 0 14px;
  cursor: pointer;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.ghost {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  padding-top: 20px;
}

.conversation,
.side {
  min-height: calc(100vh - 132px);
}

.conversation {
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.conversation:empty::before {
  content: "开始后，转写和回复会显示在这里。";
  display: block;
  color: var(--muted);
}

.message {
  max-width: 760px;
  margin: 0 0 14px;
}

.message span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.message p {
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.65;
  background: #eef3ef;
  white-space: pre-wrap;
}

.message.assistant {
  margin-left: auto;
}

.message.assistant p {
  background: #e9f2f8;
}

.side {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.hint,
.logs {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hint {
  padding: 16px;
}

.hint h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.hint p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.logs {
  overflow: auto;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #3e4a45;
}

.logs:empty::before {
  content: "连接事件会显示在这里。";
  color: var(--muted);
  font-family: inherit;
}

.log-row {
  padding: 7px 0;
  border-bottom: 1px solid #edf0eb;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 680px);
    padding: 12px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 12px;
  }

  .controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .controls select,
  .controls button {
    flex: 1 1 120px;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .conversation,
  .side {
    min-height: auto;
  }

  .conversation {
    min-height: 55vh;
  }

  .logs {
    max-height: 220px;
  }
}
