/* ============================================================
   Conny — design tokens
   Signature motif: a waveform — an audio/speech trace (what the
   app transcribes) and a neuro trace like ICP/EEG (the clinical
   domain) at once. Clinical-calm teal warmed by a soft apricot
   accent for pediatric care.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper: #FBFCFC;
  --surface: #FFFFFF;
  --ink: #142B31;
  --ink-soft: #55696E;
  --ink-faint: #5A6B6F;
  --teal: #1F5D63;
  --teal-deep: #14434A;
  --teal-wash: #EAF2F1;
  --amber: #E3A857;
  --amber-wash: #FBF1E1;
  --line: #E1E8E7;
  --danger: #B95744;
  --danger-wash: #FBEEEA;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20,43,49,0.04), 0 4px 16px rgba(20,43,49,0.05);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --rail-w: 68px;
  --list-w: 300px;
}

* { box-sizing: border-box; }

html, body {
  font-family: var(--font-body);
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; letter-spacing: -0.01em; margin: 0 0 0.9rem; color: var(--teal-deep); }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; margin: 1.6rem 0 0.5rem; color: var(--teal-deep); }
h3, h4 { font-family: var(--font-body); font-weight: 600; font-size: 0.92rem; color: var(--ink); margin: 1rem 0 0.4rem; }

input, select, textarea {
  display: block; width: 100%; margin: 0.4rem 0;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body); font-size: 0.92rem; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-wash);
}

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: auto; margin: 0.35rem 0.35rem 0.35rem 0;
  padding: 0.55rem 1rem;
  font-family: var(--font-body); font-size: 0.88rem; font-weight: 500;
  color: var(--surface); background: var(--teal);
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: var(--teal-deep); }
button:active { transform: translateY(1px); }
button:disabled { background: var(--line); color: var(--ink-faint); cursor: not-allowed; }
button.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); padding: 0.35rem 0.7rem; font-size: 0.82rem; }
button.btn-ghost:hover { background: var(--teal-wash); color: var(--teal-deep); border-color: var(--teal-wash); }
button.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid var(--line); padding: 0.35rem 0.7rem; font-size: 0.82rem; }
button.btn-danger-ghost:hover { background: var(--danger-wash); border-color: var(--danger-wash); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin: 0.9rem 0; }
.hint { color: var(--ink-faint); font-size: 0.85rem; margin: 0.3rem 0 0.8rem; }
.readonly-box { background: var(--teal-wash); padding: 1rem; white-space: pre-wrap; max-height: 240px; overflow-y: auto; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft); line-height: 1.6; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; margin: 0.85rem 0; }
details summary { cursor: pointer; font-weight: 500; color: var(--teal-deep); font-size: 0.88rem; }
details[open] summary { margin-bottom: 0.65rem; }
a { color: var(--teal); }
::selection { background: var(--amber-wash); color: var(--teal-deep); }

/* ============================================================
   App shell — icon rail + session list + main pane, Heidi-style
   ============================================================ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.rail {
  width: var(--rail-w); flex-shrink: 0;
  background: var(--teal-deep); color: white;
  display: flex; flex-direction: column; align-items: center;
  padding: 0.9rem 0; gap: 0.3rem;
}
.rail .rail-logo { margin-bottom: 0.6rem; }
.rail-btn {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  background: transparent; color: rgba(255,255,255,0.65);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin: 0; padding: 0; border: none;
  flex-direction: column; gap: 2px;
}
a.rail-btn { text-decoration: none; }
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn span { font-size: 0.56rem; font-weight: 500; }
.rail-btn:hover { background: rgba(255,255,255,0.08); color: white; }
.rail-btn.active { background: rgba(255,255,255,0.14); color: white; }
.rail-spacer { flex: 1; }
.rail-btn.logout { color: rgba(255,255,255,0.4); }

.list-pane {
  width: var(--list-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.list-pane-header { padding: 1rem 1rem 0.6rem; border-bottom: 1px solid var(--line); }
.list-pane-header h1 { font-size: 1.05rem; margin: 0 0 0.6rem; }
.session-list { flex: 1; overflow-y: auto; padding: 0.5rem; }

.session-row {
  padding: 0.65rem 0.7rem; border-radius: var(--radius-sm);
  cursor: pointer; margin-bottom: 0.25rem;
  border: 1px solid transparent;
}
.session-row:hover { background: var(--teal-wash); }
.session-row.active { background: var(--teal-wash); border-color: var(--teal); }
.session-row .session-name { font-weight: 500; font-size: 0.88rem; color: var(--ink); }
.session-row .session-meta { font-size: 0.76rem; color: var(--ink-faint); margin-top: 0.15rem; }
.session-row .session-tag { display: inline-block; font-size: 0.7rem; color: var(--teal-deep); background: var(--teal-wash); padding: 0.1rem 0.4rem; border-radius: 6px; margin-top: 0.25rem; }

.main-pane { flex: 1; overflow-y: auto; padding: 1.75rem 2rem; }
.main-pane-inner { max-width: 980px; }
.pane-narrow { max-width: 740px; }
.main-pane.wide .main-pane-inner { max-width: 100%; }

/* Sub-nav within a pane (e.g. Verwaltung's sub-sections) — quiet pills */
.subtabs { display: flex; flex-wrap: wrap; gap: 0.2rem; background: var(--teal-wash); padding: 0.3rem; border-radius: var(--radius); margin-bottom: 1.3rem; }
.subtab-btn { flex: 1 1 auto; background: transparent; color: var(--ink-soft); padding: 0.45rem 0.6rem; font-size: 0.8rem; font-weight: 500; border-radius: var(--radius-sm); box-shadow: none; }
.subtab-btn:hover { background: rgba(255,255,255,0.6); color: var(--teal-deep); }
.subtab-btn.active { background: var(--surface); color: var(--teal-deep); box-shadow: var(--shadow); }

.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.7rem 0.85rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 0.35rem; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.result-row:hover { border-color: var(--teal); background: var(--teal-wash); }
.result-row .row-main { flex: 1; min-width: 0; }
.result-row .row-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.result-row .row-actions button { margin: 0; }

/* Step flow for new-recording within the main pane */
.step { display: flex; gap: 0.9rem; align-items: flex-start; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: none; }
.step-num { flex-shrink: 0; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--teal-wash); color: var(--teal-deep); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 0.8rem; font-weight: 500; }
.step-body { flex: 1; min-width: 0; }
.step-body h2 { margin: 0 0 0.5rem; font-size: 1rem; }

/* Progress indicator for the transcription pipeline */
.progress-track { background: var(--teal-wash); border-radius: 999px; height: 6px; overflow: hidden; margin: 0.6rem 0; }
.progress-fill { background: var(--teal); height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.progress-label { font-size: 0.82rem; color: var(--ink-soft); display: flex; align-items: center; gap: 0.4rem; }
.progress-label .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .progress-label .dot { animation: none; } }

#startBtn.recording { background: var(--danger); }
#startBtn.recording::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: white; animation: pulse 1.1s ease-in-out infinite; }

/* Login page (unauthenticated) keeps the old centered-card look */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }

@media (max-width: 900px) {
  :root { --list-w: 260px; }
}
@media (max-width: 640px) {
  .app-shell { flex-direction: column; height: auto; }
  .rail { width: 100%; flex-direction: row; overflow-x: auto; padding: 0.5rem; }
  .rail-spacer { display: none; }
  .list-pane { width: 100%; max-height: 40vh; }
  .main-pane { padding: 1.1rem; }
}


/* ============================================================
   2026-10-01 — Getrennte Tabs: Patient:innen / Aufnahme / Berichte
   ============================================================ */
label.field { display: block; margin: 0.9rem 0 0; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
label.field + input, label.field + select, label.field + textarea { margin-top: 0.25rem; }
.muted { font-weight: 400; color: var(--ink-faint); }
.form-error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin: 0.4rem 0; }
.warn-text { color: var(--danger); font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; margin: 0.3rem 0 0.8rem; cursor: pointer; }
.check-row input { width: auto; display: inline-block; margin: 0; }

/* Rückmeldung nach Aktionen (z.B. Patient:in angelegt) — sitzt oben, direkt im Blick */
.flash { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.6rem;
  background: var(--teal-wash); border: 1px solid var(--teal); color: var(--teal-deep);
  border-radius: var(--radius); padding: 0.7rem 1rem; margin: 0.4rem 0 0.9rem; font-size: 0.9rem; }
.flash-error { background: var(--danger-wash); border-color: var(--danger); color: var(--danger); }
.flash-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.flash-actions button { margin: 0; }

.patients-grid { display: grid; grid-template-columns: minmax(250px, 320px) 1fr; gap: 1rem; align-items: start; }
.patients-grid .card { margin: 0; }
.patients-grid h2 { margin-top: 0; }
.count-chip { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; background: var(--teal-wash); color: var(--teal-deep); border-radius: 999px; padding: 0.05rem 0.5rem; vertical-align: middle; }
.count-chip:empty { display: none; }
.patient-list { margin-top: 0.4rem; max-height: calc(100vh - 17rem); min-height: 6rem; overflow-y: auto; }
.patient-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0.75rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 0.35rem; background: var(--surface); }
.patient-row:hover { border-color: var(--teal); }
.patient-row.just-created { background: var(--amber-wash); border-color: var(--amber); }
.patient-row .row-main { flex: 1; min-width: 0; }
.patient-row .row-actions { display: flex; gap: 0.3rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
input[type=radio], input[type=checkbox] { display: inline-block; width: auto; min-height: 0; margin-right: 0.4rem; }
#main-pane, .patient-row { min-width: 0; max-width: 100%; }
@media (max-width: 480px) { .patient-row { flex-wrap: wrap; } }
.patient-row .row-actions button { margin: 0; }
.patient-name { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
button.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.stepper { list-style: none; display: flex; gap: 0.4rem; padding: 0; margin: 0 0 1rem; counter-reset: st; }
.stepper li { flex: 1; counter-increment: st; font-size: 0.8rem; color: var(--ink-faint); padding: 0.45rem 0.6rem;
  border-bottom: 3px solid var(--line); display: flex; align-items: center; gap: 0.4rem; }
.stepper li::before { content: counter(st); font-family: var(--font-mono); width: 1.4rem; height: 1.4rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; background: var(--line); color: var(--ink-soft); font-size: 0.72rem; flex-shrink: 0; }
.stepper li.active { color: var(--teal-deep); font-weight: 600; border-bottom-color: var(--teal); }
.stepper li.active::before { background: var(--teal); color: white; }
.stepper li.done { color: var(--teal); border-bottom-color: var(--teal-wash); }
.stepper li.done::before { content: "✓"; background: var(--teal-wash); color: var(--teal-deep); }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.6rem; }
button.chip { background: var(--teal-wash); color: var(--teal-deep); border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.8rem; font-size: 0.82rem; margin: 0; }
button.chip:hover { background: var(--surface); border-color: var(--teal); }

.patient-banner { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  background: var(--teal-wash); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin-bottom: 0.9rem; }
.patient-banner-name { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--teal-deep); overflow-wrap: anywhere; }
.patient-banner button { margin: 0; }
.rec-timer { font-family: var(--font-mono); font-size: 1rem; color: var(--danger); font-weight: 500; }
.finish-bar { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.9rem 0 0.2rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.finish-bar button { margin: 0; }

.session-row { outline-offset: -2px; }
.session-row:focus-visible, .result-row:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--teal); }
.session-row .session-tag.pending { background: var(--amber-wash); color: #8a5a12; }
.rail-btn.recording { color: white; }
.rail-btn.recording::after { content: ""; position: absolute; width: 9px; height: 9px; border-radius: 50%; background: #ff6b57; margin: -26px -26px 0 0; animation: pulse 1.1s ease-in-out infinite; }
.rail-btn.busy { color: white; }
.rail-btn { position: relative; }
.rail-btn.busy::before { content: ""; position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: pulse 1.1s ease-in-out infinite; }
.rail-btn.recording::after { top: 7px; right: 8px; margin: 0; }

.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 50; max-width: 360px; background: var(--teal-deep); color: white;
  padding: 0.8rem 1rem; border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,0.25); font-size: 0.88rem; display: none; }
button.toast-action { background: var(--amber); color: var(--teal-deep); margin: 0 0 0 0.4rem; padding: 0.25rem 0.7rem; font-weight: 600; }

@media (max-width: 800px) {
  .patients-grid { grid-template-columns: 1fr; }
  .patient-list { max-height: none; }
  .stepper li { font-size: 0.72rem; padding: 0.35rem 0.3rem; }
}
@media (prefers-reduced-motion: reduce) { .rail-btn.recording::after, .rail-btn.busy::before { animation: none; } }


/* ---- Nachbesserungen nach UX-Test 2026-10-01 ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
input, select { min-height: 40px; }
button:not(.rail-btn):not(.subtab-btn) { min-height: 38px; }
@media (pointer: coarse) { input, select, button:not(.rail-btn):not(.subtab-btn) { min-height: 46px; } .rail-btn { width: 52px; height: 52px; } }
.patient-row .row-actions button { min-height: 40px; padding: 0.4rem 0.85rem; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.rail-btn:focus-visible { outline: 3px solid #fff; outline-offset: -4px; }

/* Aufnahme: laufende Aufnahme unübersehbar, Stopp als große Hauptaktion */
#startBtn.recording, #startBtn.recording:disabled { background: var(--danger); color: #fff; opacity: 1; }
#stopBtn:not(:disabled) { background: var(--danger); color: #fff; border: none; padding: 0.7rem 1.4rem; font-size: 1rem; font-weight: 600; min-height: 46px; }
#stopBtn:not(:disabled):hover { background: #8f3f30; }

.danger-zone { background: transparent; border: 1px dashed var(--line); padding: 0.4rem 0.8rem; }
.danger-zone summary { color: var(--ink-soft); font-weight: 400; }
.report-actions { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); padding: 0.6rem 0 0.4rem; margin-top: 0.8rem; z-index: 5; }
.report-actions input { margin-top: 0; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.field-row input { width: 100%; box-sizing: border-box; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

details#report-inputs { margin: 0.8rem 0; }
details#report-inputs > summary { cursor: pointer; font-weight: 600; }

.patient-row.editing { align-items: flex-start; background: var(--amber-wash); border-color: var(--amber); }
.pe-field { display: flex; flex-direction: column; font-size: .8rem; gap: .15rem; }
.pe-field input, .pe-field select { margin: 0; }

/* ---- Seitenleiste mit mehr Einträgen (2026-10-16): Beschriftung umbrechen, Leiste bei Bedarf scrollen ---- */
.rail { overflow-y: auto; }
.rail-btn { width: calc(var(--rail-w) - 4px); height: auto; min-height: 46px; padding: 4px 0; flex-shrink: 0; }
.rail-btn span { text-align: center; line-height: 1.1; white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
@media (pointer: coarse) { .rail-btn { width: calc(var(--rail-w) - 4px); height: auto; min-height: 52px; } }
@media (max-width: 800px) { .rail { overflow-y: hidden; } .rail-btn { min-width: 52px; } }
.tpl-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.stepper li.clickable { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
