:root {
  color-scheme: dark;
  --bg: #202124;
  --panel: #2d2f31;
  --line: #5f6368;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #8ab4f8;
  --join: #1a73e8;
  --leave: #ea4335;
  --speaking: #34a853;
  --danger: #f28b82;
  --btn: #3c4043;
  --you: #1a73e8;
  --them: #3c4043;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }
.status, .call-status { min-height: 1.3em; color: var(--muted); font-size: 13px; }
.status.error, .call-status.error { color: var(--danger); }
.kicker { letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-size: 11px; margin: 0 0 8px; }
h1 { margin: 0 0 8px; font-size: 32px; font-weight: 500; }
h2 { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
h3 { margin: 16px 0 8px; font-size: 12px; color: var(--muted); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.lede, .hint { color: var(--muted); line-height: 1.5; margin: 0 0 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input, textarea, button { font: inherit; color: var(--text); }
input, textarea {
  background: #1f1f1f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
button { border: 0; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.lobby {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.lobby-card {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.35);
}
.lobby-actions { margin-top: 8px; }
.lobby-actions button,
.composer button {
  background: var(--join);
  color: white;
  border-radius: 24px;
  padding: 10px 18px;
  font-weight: 600;
}
.ghost, #logout {
  background: var(--btn);
  color: var(--text);
  border-radius: 24px;
  padding: 10px 16px;
}

.meeting {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
}
.meeting-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #17181a;
}
.meeting-title { display: flex; gap: 10px; align-items: baseline; }
.meeting-title span, .meeting-meta { color: var(--muted); font-size: 13px; }
#user-chip { display: flex; gap: 8px; align-items: center; font-size: 13px; }
#logout { padding: 6px 12px; font-size: 13px; }

.people {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: #232428;
  border-bottom: 1px solid #3c4043;
}
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #2d2f31;
}
.person.speaking { border-color: var(--speaking); }
.person.muted .avatar { opacity: 0.5; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: #5f6368;
  color: white;
  flex: none;
}
#tile-assistant .avatar { background: var(--join); }
.person-copy { display: flex; flex-direction: column; line-height: 1.2; }
.person-copy span { color: var(--muted); font-size: 12px; }
.people-join {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#remote-audio { position: absolute; width: 0; height: 0; opacity: 0; }

.meeting-body {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}
.meeting-body.with-side { grid-template-columns: 1fr 340px; }
.conversation {
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 8px;
}
.conversation.hidden { display: none; }
.side-panel {
  background: var(--panel);
  border-left: 1px solid #3c4043;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side-tabs { display: flex; border-bottom: 1px solid #3c4043; }
.side-tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 650;
}
.side-tab.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.side-pane { display: none; flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.side-pane.on { display: block; }

.transcript {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 220px;
}
.transcript-hint { margin: 0 0 8px; font-size: 13px; }
.transcript .hint { margin: auto; padding: 24px 0; text-align: center; }
.turn {
  max-width: 76%;
  padding: 8px 12px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 14px;
}
.turn strong { display: block; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 2px; opacity: 0.8; }
.turn-user { align-self: flex-end; background: var(--you); }
.turn-assistant, .turn-agent { align-self: flex-start; background: var(--them); }
.turn-tool {
  max-width: min(92%, 520px);
  width: 100%;
  padding: 0;
  align-self: flex-start;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 13px;
}
.tool-card {
  border: 1px solid #5f6368;
  border-radius: 10px;
  overflow: hidden;
  background: #2d2f31;
}
.turn-tool.running .tool-card { border-color: #8ab4f8; }
.turn-tool.error .tool-card { border-color: var(--danger); }
.tool-toggle {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  background: #2d2f31;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.tool-toggle:hover { background: #35373a; }
.tool-spinner {
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid #5f6368;
  border-top-color: #8ab4f8;
  animation: tool-spin 0.8s linear infinite;
  flex: none;
}
@keyframes tool-spin { to { transform: rotate(360deg); } }
.tool-icon { flex: none; }
.tool-icon.done { color: #34a853; }
.tool-icon.error { color: var(--danger); }
.tool-copy {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
}
.tool-verb, .tool-summary { color: var(--muted); }
.tool-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.tool-chevron {
  flex: none;
  color: var(--muted);
  stroke-width: 2;
  transition: transform 150ms;
}
.tool-card.open .tool-chevron { transform: rotate(180deg); }
.tool-details {
  border-top: 1px solid #3c4043;
  background: #1f1f1f;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-details[hidden] { display: none; }
.tool-details h4 {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.tool-details pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.turn.live span::after { content: " ▍"; color: var(--accent); }
.log {
  background: #1f1f1f;
  border: 1px solid #3c4043;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
  font-size: 13px;
  min-height: 72px;
  max-height: 140px;
  white-space: pre-wrap;
}
.chat-log { min-height: 200px; max-height: 42vh; }
.composer { display: flex; gap: 8px; margin: 12px 0; }
.composer input, .composer textarea { flex: 1; }
#memory-list, #call-list { list-style: none; padding: 0; margin: 8px 0 0; }
#memory-list li, #call-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #3c4043;
  font-size: 13px;
}
#call-list li { display: block; white-space: pre-wrap; color: var(--muted); }
#memory-list button { padding: 6px 10px; font-size: 12px; background: var(--btn); color: var(--text); border-radius: 16px; }

.call-status { text-align: center; margin: 0; padding: 4px 12px 0; }

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 18px;
  background: #17181a;
}
.control {
  min-width: 72px;
  background: var(--btn);
  color: var(--text);
  border-radius: 24px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 650;
}
.control.on { background: #5f6368; }
.control.off { background: var(--leave); }
.join, .leave {
  min-width: 108px;
  border-radius: 24px;
  padding: 12px 18px;
  font-weight: 700;
  color: white;
}
.join { background: var(--join); }
.leave { background: var(--leave); }

@media (max-width: 800px) {
  .meeting-body.with-side { grid-template-columns: 1fr; }
  .side-panel { border-left: 0; border-top: 1px solid #3c4043; max-height: 40vh; }
  .people { flex-wrap: wrap; }
  .turn { max-width: 88%; }
}
