:root {
  color-scheme: light;
  --canvas: #f5f6f4;
  --surface: #ffffff;
  --surface-muted: #eef1ed;
  --ink: #17201b;
  --muted: #68716b;
  --line: #dce1dc;
  --green: #16794c;
  --green-strong: #0f5c39;
  --blue: #2463a8;
  --danger: #b13a34;
  --shadow: 0 8px 24px rgba(23, 32, 27, 0.07);
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.topbar {
  height: 72px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.connection-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.state-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ba39e; }
.connection-state[data-state="connecting"] .state-dot { background: #c98722; }
.connection-state[data-state="connected"] .state-dot { background: var(--green); }
.connection-state[data-state="error"] .state-dot { background: var(--danger); }

.workspace {
  height: calc(100dvh - 72px);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 320px;
}

.controls, .event-pane {
  min-height: 0;
  background: var(--surface);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.controls { border-right: 1px solid var(--line); }
.event-pane { border-left: 1px solid var(--line); }

.control-section { padding: 22px; border-bottom: 1px solid var(--line); }
.control-section h2, .pane-heading h2 { margin: 0; font-size: 14px; }
.control-section label { display: block; margin: 18px 0 7px; color: var(--muted); font-size: 12px; }

input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(22, 121, 76, 0.12); }

.command-row { display: grid; grid-template-columns: 1fr 40px; gap: 8px; margin-top: 12px; }
button { border: 0; border-radius: 5px; min-height: 40px; }
button svg { width: 17px; height: 17px; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--green);
  color: white;
  font-weight: 650;
}
.primary:hover:not(:disabled) { background: var(--green-strong); }
.secondary { background: #28332d; color: white; }
.icon-button { width: 40px; padding: 0; display: inline-grid; place-items: center; }
.quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.mic-control { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.mic-button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  color: var(--ink);
  flex: none;
}
.mic-button[data-active="true"] { background: var(--green); color: white; }
.mic-control strong, .mic-control span { display: block; }
.mic-control strong { font-size: 13px; }
.mic-control span { margin-top: 4px; color: var(--muted); font-size: 11px; }

.level-track { height: 4px; margin-top: 14px; background: var(--surface-muted); overflow: hidden; }
.level-fill { width: 0; height: 100%; background: var(--green); transition: width 80ms linear; }

.session-meta { padding: 18px 22px; }
.session-meta div { display: grid; grid-template-columns: 58px 1fr; gap: 8px; margin-bottom: 10px; }
.session-meta span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.session-meta code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }

.conversation-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.pane-heading { min-height: 68px; padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.pane-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

.conversation {
  height: 100%;
  min-height: 0;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scrollbar-gutter: stable;
}
.empty-state { height: 100%; min-height: 260px; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.empty-state svg { width: 30px; height: 30px; }

.message { max-width: 76%; margin-bottom: 20px; }
.message[data-role="user"] { margin-left: auto; }
.message-meta { margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.message[data-role="user"] .message-meta { text-align: right; }
.message-body { padding: 11px 13px; border-radius: 6px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.message[data-role="assistant"] .message-body { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.message[data-role="user"] .message-body { background: #dfece4; color: #123c28; }

.live-transcript { padding: 12px 14px; margin-top: 4px; border: 1px solid var(--line); background: #fbfcfb; }
.live-transcript span { color: var(--green); font-size: 11px; }
.live-transcript p { margin: 4px 0 0; line-height: 1.5; }
.conversation-end { height: 1px; }

.resume-follow-button {
  position: absolute;
  right: 24px;
  bottom: 20px;
  min-height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #cbd5ce;
  background: var(--surface);
  color: var(--green-strong);
  box-shadow: 0 5px 16px rgba(23, 32, 27, 0.14);
  font-size: 12px;
  font-weight: 650;
  z-index: 2;
}
.resume-follow-button:hover { border-color: var(--green); background: #f7faf8; }
.resume-follow-button[hidden] { display: none; }

.events { padding: 16px; min-height: 220px; }
.event-empty { color: var(--muted); font-size: 12px; padding: 18px 4px; }
.event-item { border-left: 3px solid var(--blue); padding: 10px 11px; margin-bottom: 12px; background: #f5f8fb; }
.event-item strong { display: block; color: var(--blue); font-size: 12px; }
.event-item pre { margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

.activity-log { border-top: 1px solid var(--line); padding: 16px; }
.activity-log h3 { margin: 0 0 10px; font-size: 12px; }
.log-line { padding: 6px 0; color: var(--muted); font-size: 11px; border-bottom: 1px solid #edf0ed; }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: 250px 1fr; }
  .event-pane { display: none; }
}

@media (max-width: 720px) {
  .topbar { height: 64px; padding: 0 16px; }
  .workspace {
    height: calc(100dvh - 64px);
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 42%) minmax(0, 58%);
  }
  .controls { border-right: 0; border-bottom: 1px solid var(--line); }
  .message { max-width: 90%; }
  .conversation { padding: 18px 16px; }
  .resume-follow-button { right: 16px; bottom: 14px; }
}
