:root { color-scheme: light; }
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f7fa;
  color: #1a1a1a;
  margin: 0;
  padding: 20px;
  line-height: 1.5;
}
.container { max-width: 1280px; margin: 0 auto; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  color: #1F3864;
  display: flex;
  align-items: center;
  gap: 10px;
}
.subtitle { color: #5a6478; font-size: 13px; margin-bottom: 20px; }

.card {
  background: white;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 16px;
  border: 1px solid #e4e8ef;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1F3864;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) { .setup-grid { grid-template-columns: 1fr; } }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #5a6478;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
input[type=text], input[type=date] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d7e0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}
input[type=text]:focus, input[type=date]:focus {
  outline: none;
  border-color: #1F3864;
  box-shadow: 0 0 0 2px rgba(31,56,100,0.1);
}

.record-panel {
  background: linear-gradient(135deg, #1F3864 0%, #2a4a82 100%);
  color: white;
  border: none;
}
.record-panel h2 { color: rgba(255,255,255,0.85); }
.record-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
button {
  padding: 11px 18px;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-record {
  background: #d63333;
  color: white;
  font-size: 15px;
  padding: 12px 22px;
}
.btn-record:hover:not(:disabled) { background: #b82828; }
.btn-record.recording { background: white; color: #d63333; }
.btn-record.recording::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #d63333;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.btn-speaker {
  background: #ED7D31;
  color: white;
}
.btn-speaker:hover:not(:disabled) { background: #d66a20; }
.btn-secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.25); }
.btn-action {
  background: #1F3864;
  color: white;
}
.btn-action:hover:not(:disabled) { background: #15294a; }
.btn-ghost {
  background: white;
  color: #1F3864;
  border: 1px solid #d1d7e0;
}
.btn-ghost:hover:not(:disabled) { background: #f5f7fa; }
.btn-danger {
  background: white;
  color: #d63333;
  border: 1px solid #f1c0c0;
}
.btn-danger:hover:not(:disabled) { background: #fff5f5; }

.current-speaker-display {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.15);
  border-radius: 7px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.current-speaker-display strong {
  background: white;
  color: #1F3864;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 13px;
}
.voice-meter {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.status-msg {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  background: rgba(255,255,255,0.15);
}
.status-msg.warn { background: rgba(255, 200, 0, 0.25); }
.status-msg.error { background: rgba(214, 51, 51, 0.4); }

.transcript-area {
  max-height: 520px;
  overflow-y: auto;
  padding: 4px 2px;
}
.transcript-empty {
  text-align: center;
  color: #9ca3af;
  padding: 40px 20px;
  font-size: 14px;
}
.utterance {
  margin-bottom: 14px;
  padding-left: 12px;
  border-left: 3px solid #e4e8ef;
}
.utterance.unknown {
  border-left-color: #ED7D31;
  background: #fff7ef;
  padding: 8px 12px;
  border-radius: 4px;
}
.utterance-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.speaker-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}
.speaker-chip.unknown {
  background: #ED7D31;
  cursor: pointer;
}
.speaker-chip.unknown::after { content: " — click to name"; font-weight: 400; opacity: 0.85; }
.timestamp {
  font-size: 11px;
  color: #9ca3af;
}
.utterance-text {
  font-size: 14px;
  color: #1a1a1a;
}
.utterance-text.interim {
  color: #6b7280;
  font-style: italic;
}

.speakers-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.speaker-pill {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.speaker-pill .count {
  background: rgba(255,255,255,0.3);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
}
.no-speakers { color: #9ca3af; font-size: 13px; }

.export-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.history-list { list-style: none; padding: 0; margin: 0; }
.history-item {
  padding: 10px 12px;
  border: 1px solid #e4e8ef;
  border-radius: 7px;
  margin-bottom: 8px;
  cursor: pointer;
  background: white;
  transition: background 0.15s, border-color 0.15s;
}
.history-item:hover { background: #f5f7fa; border-color: #d1d7e0; }
.history-item.active { border-color: #1F3864; background: #eef2f9; }
.history-item .h-title { font-weight: 600; font-size: 13px; color: #1F3864; }
.history-item .h-meta { font-size: 11px; color: #5a6478; margin-top: 2px; display: flex; justify-content: space-between; }
.history-item .h-status {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.h-status.active { background: #fff5d4; color: #997300; }
.h-status.ended { background: #e6efe6; color: #2d5a2d; }
.history-empty { color: #9ca3af; font-size: 13px; }
.history-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.history-actions button { padding: 4px 10px; font-size: 11px; }

.unknown-banner {
  margin-top: 12px;
  padding: 12px 14px;
  background: #ED7D31;
  color: white;
  border-radius: 7px;
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.unknown-banner.show { display: flex; }
.unknown-banner button {
  background: white;
  color: #ED7D31;
  padding: 6px 14px;
  font-size: 13px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white;
  border-radius: 10px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.modal h3 { margin: 0 0 14px; color: #1F3864; font-size: 16px; }
.modal p { margin: 0 0 12px; font-size: 13px; color: #5a6478; }
.modal input { width: 100%; margin-bottom: 14px; }
.modal-suggestions { margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.modal-suggestion {
  background: #eef2f9;
  border: 1px solid #d1d7e0;
  border-radius: 14px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 12px;
  color: #1F3864;
}
.modal-suggestion:hover { background: #d8e1f0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.confidence-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}
.confidence-dot.match { background: #548235; }
.confidence-dot.unsure { background: #ED7D31; }
.confidence-dot.new { background: #d63333; }
