:root {
  --papier:#f6f3e8; --ligne:#cfc9b0; --encre:#10231f; --craie:#e8efe9;
  --depart:#ffb703; --fin:#ff8fb1; --scene:#7be0b0; --fil:#10231f;
  --serif:"Literata",Georgia,serif;
  --sans:"Schibsted Grotesk","Helvetica Neue",Arial,sans-serif;
}
* { box-sizing:border-box; }
html, body { height:100%; }
body { display:flex; flex-direction:column; height:100vh; margin:0; background:var(--encre); color:var(--encre); font:500 15px/1.4 var(--sans); }
button { font:700 14px var(--sans); color:var(--encre); cursor:pointer; }
:focus-visible { outline:3px solid #6c8bff; outline-offset:2px; }
[hidden] { display:none !important; }

.haut { display:flex; align-items:center; gap:10px; padding:8px 14px; color:var(--craie); }
.marque { font:700 20px var(--serif); margin-right:8px; }
.onglets { display:flex; align-items:center; gap:6px; min-width:0; overflow-x:auto; }
.onglet { border:2px solid var(--craie); background:transparent; color:var(--craie); border-radius:6px; padding:4px 12px; white-space:nowrap; max-width:24ch; overflow:hidden; text-overflow:ellipsis; flex:none; }
.onglet[aria-selected="true"] { background:var(--depart); color:var(--encre); border-color:var(--depart); }
.nouvelle { width:32px; height:32px; border:2px solid var(--craie); border-radius:6px; background:transparent; color:var(--craie); font-size:20px; line-height:1; flex:none; }
.etat { margin-left:auto; font-size:13px; opacity:.7; min-width:90px; text-align:right; }

.tabs { display:flex; gap:0; padding:0 14px; }
.tabs button { border:2px solid var(--craie); border-bottom:0; border-radius:8px 8px 0 0; background:transparent; color:var(--craie); padding:6px 18px; margin-right:4px; }
.tabs button[aria-selected="true"] { background:var(--papier); color:var(--encre); }

.btn { border:2px solid var(--encre); border-radius:6px; padding:5px 12px; background:var(--craie); box-shadow:2px 2px 0 var(--encre); transition:transform .08s, box-shadow .08s; }
.btn:hover { transform:translate(2px,2px); box-shadow:0 0 0 var(--encre); }
.btn-scene { background:var(--scene); }
.btn-danger { background:var(--fin); }
.btn.confirme { background:#ff4d4d; color:#fff; }

.app { display:grid; grid-template-columns:1fr 340px; flex:1; min-height:0; background:var(--papier); }
.ardoise-wrap { display:flex; flex-direction:column; min-width:0; min-height:0; }
.barre { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:12px 16px; border-bottom:2px solid var(--ligne); background:var(--papier); }
.titre { flex:1 1 220px; min-width:0; border:0; background:transparent; font:700 26px/1.15 var(--serif); color:var(--encre); padding:0; }
.titre::placeholder { color:#8a8a72; }
.zone { flex:1; min-height:0; display:flex; }
.ardoise { position:relative; flex:1; min-width:0; overflow:hidden; background:
  radial-gradient(circle, var(--ligne) 1.2px, transparent 1.4px) 0 0/28px 28px, var(--papier); }
#svg { display:block; width:100%; height:100%; touch-action:none; cursor:grab; }
#svg.panne { cursor:grabbing; }
.zoom { position:absolute; right:10px; bottom:10px; display:flex; flex-direction:column; gap:6px; }
.zoom button { width:32px; height:32px; border:2px solid var(--encre); border-radius:6px; background:var(--craie); box-shadow:2px 2px 0 var(--encre); font-size:18px; line-height:1; }
.trames { display:flex; flex-direction:column; align-items:stretch; gap:8px; width:84px; padding:10px 8px; border-left:2px solid var(--ligne); background:var(--papier); overflow-y:auto; }
.trame { --tc:#6b7770; border:2px solid var(--tc); border-radius:6px; background:#fff; color:var(--encre); padding:6px 4px; box-shadow:3px 0 0 var(--tc) inset, 2px 2px 0 var(--tc); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.trame[aria-pressed="true"] { background:var(--tc); color:#fff; box-shadow:2px 2px 0 var(--encre); }
.vide-trames { text-align:center; opacity:.5; }

.noeud { cursor:grab; }
.noeud.tire { cursor:grabbing; }
.noeud .corps { fill:var(--tf,#fff); stroke:var(--ts,var(--encre)); stroke-width:2.5; }
.noeud.depart .corps { fill:#fff3cf; stroke:var(--encre); }
.noeud.att, .fil.att { opacity:.25; }
.noeud.choisi .corps { stroke:#3b5bff; stroke-width:4; }
.noeud .ombre { fill:var(--encre); }
.texte-fo { pointer-events:none; overflow:hidden; }
.carte { width:100%; height:100%; overflow:hidden; }
.noeud .nom { font:700 15px/1.25 var(--sans); color:var(--encre); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.noeud .extrait { margin-top:3px; font:400 12px/1.25 var(--serif); color:#4b5a54; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical; overflow-wrap:anywhere; }
.noeud .badge { font:700 10px var(--sans); letter-spacing:.06em; }
.noeud .port { fill:var(--scene); stroke:var(--encre); stroke-width:2.5; cursor:crosshair; }
.noeud .port:hover { fill:var(--depart); }
.noeud .suppr { opacity:0; cursor:pointer; fill:var(--encre); stroke:var(--papier); stroke-width:2; transition:opacity .1s; }
.noeud .suppr-x { fill:var(--papier); font:700 12px var(--sans); text-anchor:middle; dominant-baseline:central; pointer-events:none; opacity:0; }
.noeud:hover .suppr, .noeud:hover .suppr-x { opacity:1; }
.fil { fill:none; stroke:var(--fil); stroke-width:2.5; }
.fil.att { stroke-opacity:1; }
.fil-temp { stroke-dasharray:6 5; }

.alertes { list-style:none; margin:0; padding:8px 16px; min-height:36px; border-top:2px solid var(--ligne); background:var(--papier); font-size:13px; display:flex; flex-wrap:wrap; gap:6px 14px; }
.alertes li::before { content:"⚠ "; color:#c2410c; }
.alertes li.ok::before { content:"✓ "; color:#15803d; }

.panneau { min-width:0; border-left:2px solid var(--encre); background:var(--craie); padding:16px; overflow:auto; display:flex; flex-direction:column; gap:12px; }
.panneau h2 { margin:0; font:700 18px var(--serif); }
.panneau label { display:flex; flex-direction:column; gap:4px; font-size:13px; font-weight:700; }
.panneau input[type=text], .panneau textarea { border:2px solid var(--encre); border-radius:6px; padding:6px 8px; font:400 15px var(--serif); background:#fff; color:var(--encre); width:100%; }
.panneau textarea { min-height:180px; resize:vertical; line-height:1.5; }
.panneau .case { flex-direction:row; align-items:center; gap:8px; }
.vide { color:#4b5a54; font-style:italic; }
.choix { display:flex; flex-direction:column; gap:8px; margin:0; padding:0; list-style:none; }
.choix li { display:grid; grid-template-columns:1fr auto; gap:4px 6px; align-items:center; }
.choix .vers { grid-column:1/-1; font-size:12px; color:#4b5a54; }
.recap { display:flex; flex-direction:column; gap:6px; margin:0; padding:0; list-style:none; }
.recap-scene { --tc:#6b7770; display:flex; flex-direction:column; align-items:flex-start; gap:2px; width:100%; text-align:left; border:2px solid var(--tc); border-radius:6px; background:#fff; padding:5px 8px; min-width:0; }
.recap-scene strong, .recap-scene span { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.recap-scene span { font:400 12px var(--serif); color:#4b5a54; }
.mini { border:2px solid var(--encre); border-radius:6px; background:var(--fin); padding:2px 8px; }

.lire { flex:1; min-height:0; display:flex; flex-direction:column; background:var(--papier); }
.poids { font-size:13px; color:#4b5a54; }
#cadre { flex:1; width:100%; border:0; background:#fff; }

@media (max-width:820px) {
  .app { grid-template-columns:1fr; grid-template-rows:60vh auto; overflow:auto; }
  .panneau { min-width:0; border-left:0; border-top:2px solid var(--encre); }
}
