:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --error: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
}

header h1 {
  font-size: 1.15rem;
  margin: 0;
}

#auth-status {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Wider than the original 640px: the note now sits beside the
   dictation controls rather than below them, and a clinical note
   needs room to be readable while being edited. */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

#app-view > section:last-child {
  margin-bottom: 0;
}

/* Dictation left, note right. Stacks on narrow screens so the phone
   path (phase A, walking out of a room) stays usable. */
.encounter-layout {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

#dictation-section {
  flex: 1 1 40%;
  min-width: 0;
}

#note-section {
  flex: 1 1 60%;
  min-width: 0;
  position: sticky;
  top: 5rem;
}

h2 {
  font-size: 1.05rem;
  margin-top: 0;
}

h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  margin-right: 0.5rem;
  margin-top: 0.5rem;
  min-height: 44px; /* comfortable tap target for mobile use */
}

button:hover:not(:disabled) {
  background: var(--primary-dark);
}

button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* Phase buttons default to outlined; the active one fills in and stays
   filled for the whole dictation, so the clinician can see at a glance
   what they are recording into. */
#phase-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.phase-btn {
  background: var(--surface);
  color: var(--primary);
  border: 2px solid var(--primary);
  flex: 1 1 auto;
  margin-right: 0;
}

.phase-btn:hover:not(:disabled) {
  background: #eff6ff;
}

.phase-btn.active {
  background: var(--primary);
  color: white;
}

/* Informational, not a second selection: this marks that the dictation
   also filed content into sections this phase wouldn't normally touch.
   Deliberately a different treatment from .active. */
.phase-btn.also-detected {
  border-color: var(--warning);
  box-shadow: inset 0 0 0 2px var(--warning);
}

.phase-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  border-color: #cbd5e1;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

li:last-child {
  border-bottom: none;
}

.roster-patient {
  color: white;
  text-align: center;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  border-bottom: none;
  cursor: pointer;
}

.roster-patient:last-child {
  margin-bottom: 0;
}

/* The currently selected patient, so it's unambiguous which note is
   open in the pane. */
.roster-patient.selected {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

/* Used on the live "Hearing: ..." readout and the final "Matched
   patient: ..." line -- same color as that patient's roster pill
   (assigned inline via JS), so a match is visually tied to the same
   color the clinician already associates with that patient. */
.patient-match-badge {
  display: inline-block;
  color: white;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
}

.patient-choices {
  margin-top: 0.5rem;
}

.patient-choices li {
  border: none;
  padding: 0.25rem 0;
}

textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0.75rem;
  resize: vertical;
}

/* Monospace-ish line height so section headings and one-line-per-system
   exam findings stay visually scannable while editing. */
#note-pane {
  line-height: 1.5;
  min-height: 24rem;
}

.error {
  color: var(--error);
}

.success {
  color: var(--success);
  font-weight: 600;
}

#live-status,
#upload-status,
#send-status,
#note-save-status {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#live-status,
#upload-status {
  display: block;
  margin-top: 0.5rem;
}

#note-save-status {
  font-weight: 400;
}

#live-transcript-container {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

#live-transcript-box {
  white-space: pre-wrap;
  min-height: 2.5rem;
  margin: 0.4rem 0;
}

#live-match-status {
  font-size: 0.9rem;
  min-height: 1.2rem;
  margin: 0;
}

/* Contradiction warnings sit under the note, not inline in it: the
   note text stays exactly what will be sent, and the warning is a
   prompt to the clinician rather than part of the record. */
#note-warnings {
  margin-top: 0.75rem;
}

#note-warnings h4 {
  font-size: 0.9rem;
  color: var(--warning);
  margin: 0.5rem 0 0.25rem;
}

.note-warning {
  border-left: 3px solid var(--warning);
  background: var(--warning-bg);
  padding: 0.5rem 0.75rem;
  margin: 0.4rem 0;
  font-size: 0.9rem;
}

input[type="file"] {
  margin-top: 0.5rem;
}

@media (max-width: 900px) {
  .encounter-layout {
    display: block;
  }
  #note-section {
    position: static;
  }
}

@media (max-width: 480px) {
  main {
    padding: 1rem;
  }
  header {
    padding: 0.75rem 1rem;
  }
  #phase-buttons {
    flex-direction: column;
  }
}
