/* lecteur.css — habillage du lecteur de sismogramme (charte des sites ksr-infra). */
/* Mise en page : poste d'analyste — tracés à gauche (pleine largeur utile), réglages à droite,
   lectures en afficheurs sombres sous les tracés. Charte reprise des sites ksr-infra (fondation). */
:root {
  --bg: #f3f8fb; --paper: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #dbe5ed;
  --blue: #0369a1; --blue-ink: #075985; --cyan: #0891b2; --teal: #0f766e; --good: #15803d; --bad: #b91c1c;
  --soft: #f0f9ff; --soft-line: #bae6fd; --chip: #e0f2fe; --input: #f8fafc; --input-line: #cbd5e1;
  --panel: #0f172a; --panel-ink: #e2e8f0; --panel-muted: #94a3b8; --panel-value: #67e8f9;
  --trace: #0f172a; --grid: #edf2f7; --grid-strong: #d5e0ea;
  --pick-p: #d9480f; --pick-s: #1d4ed8; --amp: #a16207; --phase: #0891b2; --vrai: #15803d; --sature: #dc2626;
  --warn-bg: #fffbeb; --warn-ink: #854d0e; --ok-bg: #f0fdf4; --ko-bg: #fef2f2;
  --shadow: 0 12px 32px #0c4a6e12;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #06131f; --paper: #0b1d2c; --ink: #e2edf5; --muted: #8ba3b6; --line: #1c3346;
    --blue: #38bdf8; --blue-ink: #bae6fd; --cyan: #22d3ee; --teal: #2dd4bf; --good: #4ade80; --bad: #f87171;
    --soft: #0d2436; --soft-line: #1e4a66; --chip: #0f3049; --input: #0a1824; --input-line: #24435b;
    --panel: #020c15; --panel-ink: #dbe7f0; --panel-muted: #7f97aa; --panel-value: #67e8f9;
    --trace: #e2edf5; --grid: #10263a; --grid-strong: #1d3a52;
    --pick-p: #fb923c; --pick-s: #60a5fa; --amp: #fbbf24; --phase: #22d3ee; --vrai: #4ade80; --sature: #f87171;
    --warn-bg: #2a2110; --warn-ink: #fcd34d; --ok-bg: #0f2a1c; --ko-bg: #2c1416;
    --shadow: 0 12px 32px #00000040;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #06131f; --paper: #0b1d2c; --ink: #e2edf5; --muted: #8ba3b6; --line: #1c3346;
  --blue: #38bdf8; --blue-ink: #bae6fd; --cyan: #22d3ee; --teal: #2dd4bf; --good: #4ade80; --bad: #f87171;
  --soft: #0d2436; --soft-line: #1e4a66; --chip: #0f3049; --input: #0a1824; --input-line: #24435b;
  --panel: #020c15; --panel-ink: #dbe7f0; --panel-muted: #7f97aa; --panel-value: #67e8f9;
  --trace: #e2edf5; --grid: #10263a; --grid-strong: #1d3a52;
  --pick-p: #fb923c; --pick-s: #60a5fa; --amp: #fbbf24; --phase: #22d3ee; --vrai: #4ade80; --sature: #f87171;
  --warn-bg: #2a2110; --warn-ink: #fcd34d; --ok-bg: #0f2a1c; --ko-bg: #2c1416;
  --shadow: 0 12px 32px #00000040;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.5; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--soft-line); outline-offset: 2px; }

.topbar { position: sticky; z-index: 20; top: env(safe-area-inset-top, 0px); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px max(16px, calc((100% - 1280px) / 2)); background: color-mix(in srgb, var(--paper) 93%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #0369a1, #0891b2); color: #fff; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); }
.mode-switch { display: flex; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.mode-switch button { padding: 8px 13px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 800; cursor: pointer; }
.mode-switch button[aria-pressed="true"] { background: var(--blue); color: var(--paper); }

main { max-width: 1280px; margin: 0 auto; padding-inline: 16px; padding-block: 22px 56px; }
.banniere { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px 24px; margin-bottom: 18px; }
.banniere .eyebrow { margin: 0 0 4px; color: var(--cyan); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.banniere h1 { margin: 0; font-size: clamp(28px, 4.2vw, 40px); line-height: 1.08; text-wrap: balance; }
.banniere p.chapeau { max-width: 62ch; margin: 8px 0 0; color: var(--muted); }
.live-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid var(--soft-line); border-radius: 999px; background: var(--soft); color: var(--blue-ink); font-size: 12px; font-weight: 800; white-space: nowrap; }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 25%, transparent); }
.live-badge.calcul i { background: var(--amp); }

.poste { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.colonne { display: grid; gap: 16px; min-width: 0; }
.carte { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.carte > h2 { margin: 0 0 12px; font-size: 17px; }
.carte > h2 small { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }

/* Barre d'outils du lecteur */
.outils { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.outils .groupe { display: flex; flex-wrap: wrap; gap: 5px; }
.outil { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid var(--input-line); border-radius: 10px; background: var(--paper); font-size: 13.5px; font-weight: 800; cursor: pointer; }
.outil:hover { border-color: var(--cyan); }
.outil[aria-pressed="true"] { border-color: currentColor; background: var(--soft); }
.outil .pastille { width: 10px; height: 10px; border-radius: 3px; }
.outil.p { color: var(--pick-p); } .outil.p .pastille { background: var(--pick-p); }
.outil.s { color: var(--pick-s); } .outil.s .pastille { background: var(--pick-s); }
.outil.a { color: var(--amp); } .outil.a .pastille { background: var(--amp); border-radius: 50%; }
.outil.neutre { color: var(--ink); }
.outil kbd { padding: 0 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font: 11px var(--mono); }
.curseur-lecture { margin-left: auto; color: var(--muted); font: 12.5px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.voie { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 8px; color: var(--muted); font-size: 12.5px; }
.voie b { color: var(--ink); font-family: var(--mono); font-weight: 700; }
.cadre-traces { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
#traces { display: block; width: 100%; height: 400px; touch-action: pan-y; cursor: crosshair; }
#traces.glisse { cursor: grabbing; }
#apercu { display: block; width: 100%; height: 50px; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); cursor: pointer; touch-action: none; }
.aide { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.aide strong { color: var(--ink); }

/* Afficheurs (repris des bancs de fondation) */
.afficheurs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.afficheur { display: flex; flex-direction: column; min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--panel); color: var(--panel-ink); font-variant-numeric: tabular-nums; }
.afficheur span { font-size: 11px; color: var(--panel-muted); }
.afficheur strong { font-size: 18px; line-height: 1.3; color: var(--panel-value); font-family: var(--mono); overflow-wrap: anywhere; }
.afficheur small { font-size: 11px; color: var(--panel-muted); }
.afficheur.vide strong { color: var(--panel-muted); }
.etapes { margin-top: 12px; }
.etape { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.etape:last-child { border-bottom: 0; }
.etape > span { color: var(--cyan); font-size: 11px; font-weight: 900; padding-top: 2px; }
.etape h4 { margin: 0; font-size: 14px; }
.etape p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.etape .formule { margin-top: 4px; overflow-x: auto; color: var(--ink); font-family: "Cambria Math", Cambria, serif; font-size: 15.5px; white-space: nowrap; }

/* Réglages */
.champ { display: grid; gap: 5px; margin-bottom: 12px; }
.champ > label, .champ > .etiquette { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 800; }
.champ output { color: var(--ink); font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--blue); }
select, input[type="number"], input[type="text"] { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--input-line); border-radius: 10px; background: var(--input); }
.segments { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--input-line); border-radius: 11px; background: var(--input); }
.segments button { flex: 1; min-width: 0; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 13px; font-weight: 800; cursor: pointer; }
.segments button[aria-pressed="true"] { background: var(--paper); color: var(--blue-ink); box-shadow: 0 1px 3px #0f172a26; }
.segments button:disabled { opacity: .45; cursor: not-allowed; }
.duo-champs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.case { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.separateur { height: 1px; margin: 16px 0 14px; background: var(--line); }
.sous-titre { margin: 0 0 10px; color: var(--blue-ink); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.bouton { padding: 9px 14px; border-radius: 11px; font-weight: 800; cursor: pointer; }
.bouton.primaire { border: 1px solid var(--blue); background: var(--blue); color: var(--paper); }
.bouton.secondaire { border: 1px solid var(--soft-line); background: var(--chip); color: var(--blue-ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.verite { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--soft); border: 1px solid var(--soft-line); font-size: 13px; }
.verite b { font-family: var(--mono); font-weight: 700; }
.enonce { margin: 0 0 12px; font-size: 14.5px; }
.numero { display: inline-block; margin-bottom: 8px; padding: 2px 9px; border-radius: 999px; background: var(--chip); color: var(--blue-ink); font: 700 12px var(--mono); }
.polarites { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Hodogramme */
.hodo-cadre { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 14px; align-items: center; }
#hodo { display: block; width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.hodo-texte p { margin: 0 0 6px; font-size: 13.5px; color: var(--muted); }
.hodo-texte strong { color: var(--ink); }

/* Corrigé */
.resultats { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.resultats th { padding: 8px 6px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
.resultats td { padding: 8px 5px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
.resultats td.n { text-align: right; white-space: nowrap; font-family: var(--mono); }
.resultats tr.ok td:first-child { box-shadow: inset 3px 0 0 var(--good); }
.resultats tr.ko td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.resultats tr.ko { background: var(--ko-bg); }
.verdict { font-weight: 900; white-space: nowrap; }
.verdict.ok { color: var(--good); } .verdict.ko { color: var(--bad); }
.score { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--ok-bg); color: var(--good); font-weight: 900; }
.table-defile { overflow-x: auto; }

/* Repères */
.reperes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.reperes li { min-width: 0; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); font-size: 13.5px; }
.reperes li strong { display: block; margin-bottom: 3px; color: var(--blue-ink); font-size: 15px; }
.modele { margin: 14px 0 0; padding: 12px 14px; border-left: 4px solid #fcd34d; border-radius: 0 10px 10px 0; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 50; max-width: calc(100% - 32px); transform: translate(-50%, 140%); padding: 10px 16px; border-radius: 11px; background: var(--panel); color: var(--panel-ink); font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Banc réseau */
.mode-banc { display: flex; }
.mode-banc button { flex: 1; }
.filtre-court { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 800; }
.filtre-court select { width: auto; padding: 6px 8px; }
.r-traces { display: grid; gap: 8px; }
.r-station .voie { margin: 0 0 3px; }
.r-canvas { display: block; width: 100%; height: 152px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); touch-action: pan-y; cursor: crosshair; }
.r-canvas.glisse { cursor: grabbing; }
#r-carte { display: block; width: 100%; aspect-ratio: 1 / 1; max-width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#r-carte.deplacable { touch-action: none; cursor: grab; }
#r-wadati { display: block; width: 100%; height: 220px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.notes-loc { display: grid; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--muted); }
.notes-loc b { color: var(--ink); }
#r-residus td.ecart { color: var(--bad); font-weight: 800; }

/* Banc sismomètre */
#s-scene { display: block; width: 100%; height: 270px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#s-courbes { display: block; width: 100%; height: 190px; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#s-reponse { display: block; width: 100%; height: 280px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.legende { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
.legende i { display: inline-block; width: 18px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.legende i.tirets { height: 0; border-top: 3px dashed; border-radius: 0; }
.prereglages { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.prereglages button { padding: 6px 10px; border: 1px solid var(--input-line); border-radius: 9px; background: var(--paper); font-size: 12.5px; font-weight: 800; cursor: pointer; }
.prereglages button:hover { border-color: var(--cyan); }
.afficheurs.deux { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.experiences { display: grid; gap: 8px; margin: 0; padding-left: 20px; font-size: 13.5px; }

/* Banc spectre de réponse */
.segments.compact { display: inline-flex; }
.segments.compact button { flex: 0 0 auto; white-space: nowrap; padding-inline: 12px; }
#sp-table { display: block; width: 100%; height: 260px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#sp-accelero { display: block; width: 100%; height: 110px; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#sp-spectre { display: block; width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }

/* Banc sismicité */
#sc-catalogue { display: block; width: 100%; height: 290px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: crosshair; }
#sc-stepp { display: block; width: 100%; height: 300px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.table-completude { margin-bottom: 12px; }
.table-completude input { width: 100%; padding: 6px 8px; border: 1px solid var(--input-line); border-radius: 8px; background: var(--input); font-family: var(--mono); }
#sc-fmd { display: block; width: 100%; height: 320px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }

/* Banc géodésie */
#ge-carte { display: block; width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); touch-action: pan-y; }
#ge-profil { display: block; width: 100%; height: 380px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#ge-moment { display: block; width: 100%; height: 200px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#ge-recurrence { display: block; width: 100%; height: 320px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }

/* Banc aléa */
#al-carte { display: block; width: 100%; height: 400px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: crosshair; touch-action: pan-y; }
#al-courbe { display: block; width: 100%; height: 360px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#al-uhs { display: block; width: 100%; height: 330px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#al-desag { display: block; width: 100%; height: 330px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#al-tornade { display: block; width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
#al-imts { flex-wrap: wrap; }

/* Banc profil */
#p-section { display: block; width: 100%; height: 580px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: crosshair; }

@media (max-width: 1100px) {
  .poste { grid-template-columns: minmax(0, 1fr); }
  .reperes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .afficheurs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #traces { height: 330px; }
  #p-section { height: 480px; }
  #al-carte { height: 290px; }
  #ge-carte { height: 300px; }
  #ge-profil, #ge-recurrence { height: 300px; }
  #al-courbe, #al-uhs, #al-desag { height: 300px; }
  #s-scene { height: 250px; }
  .hodo-cadre { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .curseur-lecture { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .topbar nav.mode-switch { width: 100%; flex-wrap: wrap; }
  .topbar nav.mode-switch button { flex: 1 1 auto; padding: 7px 8px; }
}
@media (max-width: 480px) {
  .reperes { grid-template-columns: minmax(0, 1fr); }
  .brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
