:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5c6773;
  --line: #d8dee6;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --danger: #b42318;
  --focus: #8b5cf6;
  --caption-bg: #eef8f6;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent-strong);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 44px;
  padding: 0.62rem 0.9rem;
  cursor: pointer;
}

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

button.secondary,
#leaveButton {
  background: #fff;
  color: var(--accent-strong);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.app-header h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-pill {
  flex: 0 0 auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: #f9fafb;
  color: var(--muted);
}

.status-pill.connected {
  border-color: #99d5ca;
  color: var(--accent-strong);
  background: #e8f7f4;
}

.status-pill.error {
  border-color: #fecdca;
  color: var(--danger);
  background: #fff1f0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem) 2rem;
}

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.08rem;
}

.setup-panel,
.log-panel {
  grid-column: 1;
}

.call-panel,
.captions-panel {
  grid-column: 2;
}

.join-form {
  display: grid;
  gap: 0.8rem;
}

label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
}

.compact-label {
  align-items: center;
  grid-template-columns: auto minmax(8rem, 12rem);
  color: var(--text);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  color: var(--text);
}

.consent-line {
  grid-template-columns: auto 1fr;
  align-items: start;
  color: var(--text);
}

.consent-line input {
  width: 1.25rem;
  min-height: 1.25rem;
  margin-top: 0.15rem;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.participants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
}

.participant {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  background: #fbfcfd;
}

.participant strong {
  display: block;
  overflow-wrap: anywhere;
}

.participant span {
  color: var(--muted);
  font-size: 0.92rem;
}

.captions {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.caption {
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
  background: var(--caption-bg);
}

.caption .meta {
  display: flex;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.caption p {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.caption.partial {
  border-left-color: #64748b;
  background: #f3f6fa;
}

.log-list {
  max-height: 14rem;
  overflow: auto;
  margin: 0;
  padding-left: 1.2rem;
}

.log-list li {
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .setup-panel,
  .log-panel,
  .call-panel,
  .captions-panel {
    grid-column: 1;
  }

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

  .button-row,
  .button-row button {
    width: 100%;
  }
}
