:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666;
  --border: #d9d9d9;
  --panel: #f6f7f9;
  --accent: #2b6cb0;
  --accent-fg: #ffffff;
  --pass: #2f855a;
  --fail: #c53030;
  --warn: #b7791f;
  --warn-bg: #fefcbf;
  --err-bg: #fed7d7;
  --listening: #3182ce;
  --speaking: #805ad5;
  --awaiting: #dd6b20;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --fg: #e8e8e8;
    --muted: #a0a0a0;
    --border: #333;
    --panel: #202329;
    --accent: #4299e1;
    --panel-alt: #262a31;
    --warn-bg: #4a3f14;
    --err-bg: #4a1f1f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
}

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}
#app-header h1 { font-size: 1.15rem; margin: 0; }

.status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.status.listening { background: var(--listening); color: #fff; border-color: transparent; }
.status.speaking { background: var(--speaking); color: #fff; border-color: transparent; }
.status.translating { background: var(--accent); color: #fff; border-color: transparent; }
.status.awaiting_response { background: var(--awaiting); color: #fff; border-color: transparent; }
.status.error { background: var(--fail); color: #fff; border-color: transparent; }

#banners:empty { display: none; }
.banner {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.banner.warn { background: var(--warn-bg); color: var(--fg); }
.banner.error { background: var(--err-bg); color: var(--fg); }

#tab-bar {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
}
.tab.active { color: var(--fg); background: var(--panel); border-color: var(--border); font-weight: 600; }

#app-main { padding: 1rem; max-width: 860px; margin: 0 auto; }

button.primary {
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 8px; padding: 0.6rem 1rem;
  font-size: 0.95rem; cursor: pointer;
}
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.speak-btn {
  display: block; width: 100%; padding: 2rem; font-size: 1.3rem; font-weight: 700;
  border-radius: 16px; border: none; cursor: pointer; user-select: none;
  background: var(--accent); color: #fff; touch-action: none;
}
.speak-btn.held { background: var(--listening); transform: scale(0.99); }

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }
.field select, .field input[type="text"], .field textarea {
  width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--fg); font-size: 0.95rem;
}
.field input[type="range"] { width: 100%; }
.rowline { display: flex; align-items: center; gap: 0.75rem; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }

.transcript { max-height: 55vh; overflow-y: auto; }
.turn { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; background: var(--bg); }
.turn .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.turn .line { margin: 0.15rem 0 0.5rem; }
.turn .line:last-child { margin-bottom: 0; }

.case-list { list-style: none; padding: 0; margin: 0; }
.case-item {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.4rem; cursor: pointer; background: var(--bg);
}
.case-item:hover { border-color: var(--accent); }
.case-item .meta { flex: 1; min-width: 0; }
.case-item .cid { font-weight: 600; font-size: 0.85rem; }
.case-item .prev { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge { font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 999px; }
.badge.untested { background: var(--panel); color: var(--muted); border: 1px solid var(--border); }
.badge.pass { background: var(--pass); color: #fff; }
.badge.fail { background: var(--fail); color: #fff; }

.progress-track { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.2s; }

.btn-pass { background: var(--pass); color: #fff; border: none; border-radius: 8px; padding: 0.6rem 1.2rem; font-size: 1rem; cursor: pointer; }
.btn-fail { background: var(--fail); color: #fff; border: none; border-radius: 8px; padding: 0.6rem 1.2rem; font-size: 1rem; cursor: pointer; }

.muted { color: var(--muted); font-size: 0.85rem; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.summary-grid .cell { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; text-align: center; }
.summary-grid .num { font-size: 1.6rem; font-weight: 700; }
.summary-grid .lab { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
