:root {
  color-scheme: light;
  --navy: #071f3b;
  --ink: #20364d;
  --muted: #607287;
  --teal: #0a8585;
  --teal-dark: #086b6d;
  --teal-soft: #edf9f8;
  --line: #dbe3e9;
  --paper: #ffffff;
  --background: #f5f7f9;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  line-height: 1.5;
}

button, textarea, input, select { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--navy);
  font-size: 21px;
  font-weight: 760;
  text-decoration: none;
}

.brandmark {
  display: grid;
  width: 34px;
  height: 39px;
  place-items: center;
  color: white;
  border-radius: 6px;
  background: linear-gradient(145deg, #0aa7a4, #087c80);
  box-shadow: 0 5px 14px rgba(7, 128, 131, .2);
  font-size: 25px;
  font-weight: 400;
}

.page-name {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
}

.local-badge {
  justify-self: end;
  color: #3c5268;
  font-size: 14px;
}

main {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
  padding: 38px 0 55px;
}

.hero { max-width: 900px; }

.eyebrow, .step-label {
  margin: 0 0 7px;
  color: var(--teal);
  letter-spacing: .14em;
  font-size: 11px;
  font-weight: 800;
}

.hero h1 {
  margin: 0 0 12px;
  color: var(--navy);
  letter-spacing: -.04em;
  font-size: clamp(31px, 4vw, 49px);
  line-height: 1.08;
}

.hero > p:last-child {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.privacy-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  align-items: center;
  max-width: 900px;
  margin: 22px 0 22px;
  padding: 13px 16px;
  border: 1px solid #b9dfdc;
  border-radius: 12px;
  background: var(--teal-soft);
  color: #315c65;
}

.privacy-note > span { color: var(--teal); font-size: 26px; }
.privacy-note strong { color: #153e49; font-size: 13px; }
.privacy-note p { margin: 2px 0 0; font-size: 12px; }

.report-workspace {
  display: grid;
  grid-template-columns: minmax(520px, 1.08fr) minmax(460px, .92fr);
  gap: 28px;
  align-items: start;
}

.editor-panel, .report-paper {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 10px 32px rgba(14, 42, 65, .07);
}

.editor-panel { overflow: hidden; }

.panel-heading, .preview-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
}

.panel-heading { padding: 18px 20px 15px; }
.panel-heading h2, .preview-heading h2 { margin: 0; color: var(--navy); font-size: 21px; }

.pathway-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .9fr);
  gap: 16px;
  align-items: center;
  margin: 0 20px 15px;
  padding: 15px;
  border: 1px solid #a9d7d3;
  border-radius: 11px;
  background: var(--teal-soft);
}

.pathway-panel strong { display: block; margin-top: 5px; color: #123f49; font-size: 13px; }
.pathway-panel p { margin: 3px 0 0; color: #537079; font-size: 11px; }
.pathway-badge { padding: 3px 6px; border-radius: 5px; color: white; background: var(--teal); letter-spacing: .1em; font-size: 8px; font-weight: 850; }
.pathway-actions { display: grid; gap: 7px; }
.pathway-actions select { width: 100%; min-width: 0; border: 1px solid #9ccbc8; border-radius: 8px; padding: 9px 32px 9px 10px; color: #214b54; background: white; font-size: 11px; }
.pathway-actions button { color: white; border-color: var(--teal); background: var(--teal); }
.pathway-actions button:hover { color: white; background: var(--teal-dark); }

button {
  cursor: pointer;
  border: 1px solid #cbd7df;
  border-radius: 8px;
  padding: 9px 12px;
  color: #35506b;
  background: white;
  font-size: 12px;
  font-weight: 760;
  transition: .16s ease;
}

button:hover { color: var(--teal-dark); border-color: #87c8c5; transform: translateY(-1px); }
.ghost { color: #657588; background: #f3f6f8; }
.pdf { color: #96323b; border-color: #e2bec2; background: #fffafa; }
.word { color: #245f9c; border-color: #bdd0e3; background: #f8fbff; }
button:disabled { cursor: wait; opacity: .6; transform: none; }

button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .report-paper:focus-visible {
  outline: 3px solid rgba(10, 133, 133, .25);
  outline-offset: 3px;
}

.section-list { display: grid; gap: 13px; padding: 0 20px 5px; }

.report-section-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
}

.section-card-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 11px;
}

.section-number {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  font-size: 10px;
  font-weight: 850;
}

.section-title-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 3px 2px;
  color: var(--navy);
  background: transparent;
  font-size: 14px;
  font-weight: 800;
}

.section-title-input:hover, .section-title-input:focus { border-bottom-color: #9bcfcd; outline: 0; }

.quick-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 10px; }
.quick-row select {
  min-width: 0;
  border: 1px solid #c9d6de;
  border-radius: 8px;
  padding: 8px 31px 8px 10px;
  color: #35506b;
  background: white;
  font-size: 11px;
}
.quick-insert { padding: 8px 12px; color: var(--teal-dark); border-color: #9bcfcd; }
.multi-quick-row { grid-template-columns: 1fr; }
.multi-quick-options { display: flex; flex-wrap: wrap; gap: 7px; }
.multi-quick-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid #c9d6de;
  border-radius: 8px;
  color: #35506b;
  background: white;
  cursor: pointer;
  font-size: 11px;
}
.multi-quick-option:hover { border-color: #8bc8c4; background: #f5fbfa; }
.multi-quick-option:has(input:checked) { color: var(--teal-dark); border-color: var(--teal); background: var(--teal-soft); }
.multi-quick-option input { width: 14px; height: 14px; margin: 0; accent-color: var(--teal); }
.multi-quick-row .quick-insert { justify-self: start; }

.section-textarea {
  display: block;
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border: 1px solid #cfd9e0;
  border-radius: 9px;
  padding: 12px;
  color: #18324c;
  background: white;
  font-size: 12px;
  line-height: 1.58;
}

.section-textarea:focus, .quick-row select:focus { border-color: var(--teal); outline: 3px solid rgba(10, 133, 133, .12); }

.editor-footer {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 12px 20px 17px;
  color: var(--muted);
  font-size: 11px;
}

.preview-panel {
  position: sticky;
  top: 98px;
  min-width: 0;
}

.preview-heading { margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.report-paper {
  height: clamp(620px, calc(100vh - 190px), 820px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 48px 42px 58px;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
}

.report-paper::before {
  display: block;
  margin-bottom: 21px;
  content: "Rapport d’urgence";
  font-size: 17px;
  font-weight: 700;
}

.report-paper h3 {
  margin: 18px 0 4px;
  color: #111;
  font-size: 11px;
  line-height: 1.45;
}

.report-paper p {
  margin: 0;
  white-space: pre-wrap;
  color: #111;
  font-size: 11px;
  line-height: 1.48;
}

.report-paper p.inline-section { margin-top: 13px; }
.report-paper p + p:not(.inline-section) { margin-top: 2px; }
.report-paper .blank-line { height: 8px; margin: 0; }
.report-paper .empty-section { color: #98a3ae; font-style: italic; }

.medical-note {
  margin: 20px 0 0;
  color: #68788a;
  font-size: 11px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 28px;
  color: #708094;
  font-size: 12px;
}

footer div { display: flex; gap: 18px; }
footer a { color: var(--teal-dark); font-weight: 750; }

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100% - 40px));
  padding: 11px 14px;
  border-radius: 9px;
  color: white;
  background: #0b6467;
  box-shadow: 0 8px 24px rgba(7, 31, 59, .18);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .18s ease;
}

#toast.visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

@media (max-width: 1100px) {
  .report-workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .report-paper { height: min(76vh, 820px); min-height: 560px; }
}

@media (max-width: 700px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 66px; padding: 0 16px; }
  .local-badge { display: none; }
  .brand { font-size: 18px; }
  .page-name { font-size: 11px; }
  main, footer { width: min(100% - 28px, 1500px); }
  main { padding-top: 27px; }
  .hero h1 { font-size: 33px; }
  .panel-heading, .preview-heading { align-items: flex-start; flex-direction: column; }
  .pathway-panel { grid-template-columns: 1fr; margin-right: 14px; margin-left: 14px; }
  .actions { width: 100%; justify-content: stretch; }
  .actions button { flex: 1 1 calc(50% - 6px); }
  .section-list { padding-right: 14px; padding-left: 14px; }
  .quick-row { grid-template-columns: 1fr; }
  .quick-insert { width: 100%; }
  .editor-footer { padding-left: 14px; padding-right: 14px; }
  .report-paper { height: 70vh; min-height: 500px; padding: 40px 22px 48px; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media print {
  body { background: white; }
  .topbar, .hero, .privacy-note, .editor-panel, .preview-heading, .medical-note, footer, #toast { display: none !important; }
  main { width: 100%; padding: 0; }
  .report-workspace { display: block; }
  .preview-panel { position: static; }
  .report-paper {
    height: auto;
    min-height: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    padding: 10mm;
    box-shadow: none;
  }
}
