:root {
  --bg0: #04060b; --bg1: #0b1120; --bg2: #121a2e;
  --panel: rgba(13, 19, 33, 0.86); --panel-solid: #0e1524;
  --line: rgba(255, 255, 255, 0.085); --line2: rgba(255, 255, 255, 0.16);
  --text: #e9edf6; --muted: #9aa6bd; --dim: #6c7891;
  --accent: #7cc4ff; --accent2: #ffd166; --good: #6ee7a8; --warn: #ffb347; --bad: #ff7b8a; --violet: #c79bff;
  --leftW: 330px; --rightW: 410px; --topH: 54px;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg0); color: var(--text); font: 14px/1.5 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
b { font-weight: 650; }
i { font-style: italic; }
::selection { background: rgba(124, 196, 255, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); background-clip: content-box; border: 2px solid transparent; }

#app { position: fixed; inset: 0; display: grid; grid-template-columns: var(--leftW) minmax(0, 1fr) 0px; grid-template-rows: var(--topH) minmax(0, 1fr); transition: grid-template-columns .45s cubic-bezier(.2,.8,.2,1); }
#app.has-fiche { grid-template-columns: var(--leftW) minmax(0, 1fr) var(--rightW); }
#app.left-collapsed { grid-template-columns: 0px minmax(0, 1fr) 0px; }
#app.left-collapsed.has-fiche { grid-template-columns: 0px minmax(0, 1fr) var(--rightW); }

/* ---------- barre du haut ---------- */
#top { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding: 0 16px; background: linear-gradient(180deg, #0c1322, #090e1a); border-bottom: 1px solid var(--line); z-index: 20; }
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand .logo { width: 22px; height: 22px; align-self: center; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd9c9, #d58a86 55%, #7a3f64); box-shadow: 0 0 0 1px rgba(255,255,255,.15), 0 0 18px rgba(213,138,134,.35); }
.brand b { font-family: var(--serif); font-size: 17px; letter-spacing: .2px; }
.brand small { color: var(--dim); font-size: 12px; }
#crumbs { flex: 1; display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; min-width: 0; }
#crumbs .crumb { background: none; border: 0; color: var(--muted); padding: 4px 8px; border-radius: 8px; font-size: 13px; }
#crumbs .crumb:hover { background: rgba(255,255,255,.07); color: var(--text); }
#crumbs .crumb.last { color: var(--text); font-weight: 600; }
#crumbs .sep { color: var(--dim); }
.seg { display: inline-flex; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; padding: 5px 12px; border-radius: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: rgba(124,196,255,.17); color: #fff; box-shadow: inset 0 0 0 1px rgba(124,196,255,.35); }
.top-actions { display: flex; gap: 8px; }
.btn { background: rgba(255,255,255,.06); border: 1px solid var(--line); padding: 6px 12px; border-radius: 10px; font-size: 13px; color: var(--text); transition: background .15s, border-color .15s; }
.btn:hover { background: rgba(255,255,255,.11); border-color: var(--line2); }
.btn.primary { background: rgba(124,196,255,.16); border-color: rgba(124,196,255,.4); }
.btn.primary:hover { background: rgba(124,196,255,.25); }
.btn.small { padding: 3px 9px; font-size: 12px; border-radius: 8px; }
.btn.on { background: rgba(124,196,255,.22); border-color: rgba(124,196,255,.5); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(255,255,255,.07); color: var(--text); }

/* ---------- panneau gauche ---------- */
#left { background: var(--panel-solid); border-right: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; z-index: 10; min-width: 0; }
#app.left-collapsed #left { border-right: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 6px 8px 0; gap: 2px; flex: 0 0 auto; }
.tabs button { flex: 1; background: none; border: 0; padding: 8px 4px 9px; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: #fff; border-bottom-color: var(--accent); }
.panes { flex: 1; overflow-y: auto; overflow-x: hidden; }
.pane { display: none; padding: 14px 14px 40px; }
.pane.on { display: block; }
.card { background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 13px; margin-bottom: 12px; }
.card h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h4 .tag { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--dim); font-size: 11.5px; }
.card p.hint { margin: 6px 0 0; color: var(--dim); font-size: 12px; line-height: 1.4; }
.row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.row > label { flex: 0 0 auto; color: var(--muted); font-size: 12.5px; min-width: 0; }
.row .val { flex: 0 0 auto; width: 44px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-size: 12px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; }
.btnrow .btn { flex: 1 1 auto; text-align: center; }

input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 20px; background: transparent; margin: 0; cursor: pointer; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--p), rgba(255,255,255,.14) var(--p)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.14); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -6px; box-shadow: 0 0 0 3px rgba(124,196,255,.3), 0 2px 8px rgba(0,0,0,.5); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(124,196,255,.3); }
input[type=range]:disabled { opacity: .35; cursor: not-allowed; }

.switch { position: relative; width: 36px; height: 20px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: rgba(255,255,255,.14); border-radius: 20px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; font-size: 13px; }
.switchrow .lab small { display: block; color: var(--dim); font-size: 11.5px; line-height: 1.3; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); cursor: pointer; transition: .15s; line-height: 1.5; }
.chip:hover { border-color: var(--line2); color: var(--text); }
.chip.on { color: #fff; border-color: var(--cc, var(--accent)); background: color-mix(in srgb, var(--cc, var(--accent)) 22%, transparent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cc, var(--accent)); flex: 0 0 auto; }

/* granularité (principale) */
.gran { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.gran button { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 8px 2px 7px; color: var(--muted); font-size: 11.5px; line-height: 1.2; text-align: center; }
.gran button b { display: block; font-size: 15px; color: var(--dim); margin-bottom: 2px; font-weight: 600; }
.gran button:hover { color: var(--text); border-color: var(--line2); }
.gran button.on { background: rgba(124,196,255,.17); color: #fff; border-color: rgba(124,196,255,.5); }
.gran button.on b { color: var(--accent); }

/* arbre */
.search { position: relative; margin-bottom: 10px; }
.search input { width: 100%; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 11px; color: var(--text); padding: 9px 12px 9px 34px; font-size: 13.5px; outline: none; }
.search input:focus { border-color: rgba(124,196,255,.55); background: rgba(255,255,255,.08); }
.search svg { width: 16px; height: 16px; }
.tree { font-size: 13px; }
.trow { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 8px; cursor: pointer; user-select: none; min-height: 26px; }
.trow:hover { background: rgba(255,255,255,.07); }
.trow.sel { background: rgba(124,196,255,.16); box-shadow: inset 0 0 0 1px rgba(124,196,255,.4); }
.trow .caret { width: 14px; flex: 0 0 14px; color: var(--dim); font-size: 10px; text-align: center; transition: transform .15s; }
.trow .caret.open { transform: rotate(90deg); }
.trow .dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 3px; }
.trow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .cnt { color: var(--dim); font-size: 11px; }
.trow .approx { color: var(--warn); font-size: 11px; }
.tkids { margin-left: 13px; border-left: 1px solid var(--line); padding-left: 4px; }
.tkids.closed { display: none; }

/* lignes systèmes */
.sysrow { display: grid; grid-template-columns: 22px 1fr 84px; align-items: center; gap: 8px; padding: 5px 0; }
.sysrow .nm { font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.sysrow .nm i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.sysrow .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eye { width: 22px; height: 22px; border-radius: 7px; background: rgba(255,255,255,.06); border: 1px solid var(--line); display: grid; place-items: center; padding: 0; }
.eye svg { width: 14px; height: 14px; opacity: .9; }
.eye.off { opacity: .45; }
.eye.off svg { opacity: .5; }

/* ---------- scène ---------- */
#center { position: relative; min-width: 0; display: flex; overflow: hidden; }
#stage { container-type: inline-size; position: relative; flex: 1 1 100%; min-width: 0; background: radial-gradient(120% 90% at 50% 38%, #16213a 0%, #0a1020 48%, #04060b 100%); overflow: hidden; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; padding: 2px 8px; font-size: 11.5px; border-radius: 999px; background: rgba(8,12,22,.66); border: 1px solid rgba(255,255,255,.12); color: #dfe6f5; white-space: nowrap; backdrop-filter: blur(4px); will-change: transform; }
.lbl.strong { background: rgba(255,209,102,.92); color: #1b1608; border-color: rgba(255,255,255,.4); font-weight: 650; box-shadow: 0 4px 16px rgba(0,0,0,.45); }
#tip { position: absolute; pointer-events: none; z-index: 30; background: rgba(8,12,22,.94); border: 1px solid var(--line2); border-radius: 10px; padding: 7px 11px; font-size: 12.5px; max-width: 280px; box-shadow: 0 10px 30px rgba(0,0,0,.5); opacity: 0; transform: translate(14px, 14px); transition: opacity .12s; }
#tip.show { opacity: 1; }
#tip b { display: block; font-size: 13px; }
#tip small { color: var(--muted); display: block; margin-top: 1px; font-size: 11.5px; }

#hud { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; z-index: 12; }
.hudbox { background: var(--panel); backdrop-filter: blur(14px); border: 1px solid var(--line2); border-radius: 16px; padding: 6px; display: flex; gap: 3px; align-items: center; box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.hudbox .lbl3 { padding: 0 6px 0 10px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .09em; white-space: nowrap; }
.hudbox .lbl2 { padding: 0 8px 0 10px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .09em; white-space: nowrap; }
.hudbox button { background: none; border: 0; padding: 7px 14px; border-radius: 11px; font-size: 13px; color: var(--muted); white-space: nowrap; transition: .2s; }
.hudbox button:hover { color: #fff; background: rgba(255,255,255,.07); }
.hudbox button.on { background: rgba(124,196,255,.2); color: #fff; box-shadow: inset 0 0 0 1px rgba(124,196,255,.45); }
.hudbox button .n { opacity: .55; margin-right: 6px; font-variant-numeric: tabular-nums; }
#viewbtns { position: absolute; right: 14px; top: 14px; z-index: 12; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#viewbtns .hudbox { padding: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 460px; flex-wrap: nowrap; }
#viewbtns .hudbox button { padding: 5px 9px; font-size: 12px; }
#sidehint { position: absolute; left: 14px; bottom: 18px; z-index: 11; color: var(--dim); font-size: 12px; line-height: 1.45; max-width: 330px; pointer-events: none; }
#sidehint kbd { background: rgba(255,255,255,.1); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font: 11px var(--sans); color: var(--muted); }
#legend { position: absolute; left: 14px; top: 14px; z-index: 11; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; padding: 8px 12px; font-size: 12px; display: none; backdrop-filter: blur(10px); }
#legend.show { display: block; }
#legend .li { display: flex; align-items: center; gap: 8px; margin: 2px 0; color: var(--muted); }
#legend svg { width: 34px; height: 12px; flex: 0 0 34px; }
#toast { position: absolute; bottom: 82px; left: 50%; transform: translateX(-50%); z-index: 40; background: rgba(8,12,22,.95); border: 1px solid var(--line2); padding: 8px 16px; border-radius: 999px; font-size: 13px; opacity: 0; transition: opacity .25s; pointer-events: none; }
#toast.show { opacity: 1; }

/* carte de parcours */
#tourcard { position: absolute; left: 14px; bottom: 76px; width: min(430px, calc(100% - 28px)); z-index: 15; background: rgba(10,15,28,.94); border: 1px solid rgba(255,209,102,.4); border-radius: 16px; padding: 14px 16px 12px; box-shadow: 0 18px 50px rgba(0,0,0,.6); backdrop-filter: blur(12px); display: none; }
#tourcard.show { display: block; animation: rise .35s cubic-bezier(.2,.8,.2,1); }
#tourcard .tt { font-family: var(--serif); font-size: 16px; margin: 0 0 6px; color: #fff; }
#tourcard .tx { color: #cdd5e6; font-size: 13.5px; line-height: 1.55; max-height: 34vh; overflow: auto; }
#tourcard .tx b { color: #fff; }
#tourcard .tnav { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
#tourcard .dots { flex: 1; display: flex; gap: 5px; align-items: center; }
#tourcard .dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.18); cursor: pointer; }
#tourcard .dots i.on { background: var(--accent2); transform: scale(1.25); }
#tourcard .dots i.done { background: rgba(255,209,102,.5); }
#tourcard .small { color: var(--dim); font-size: 11.5px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- fiche ---------- */
#right { background: var(--panel-solid); border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; z-index: 10; min-width: 0; }
#fiche { padding: 18px 20px 60px; width: var(--rightW); }
#fiche .close { float: right; margin: -4px -8px 0 0; }
#fiche .crumbs { font-size: 11.5px; color: var(--dim); margin-bottom: 4px; display: flex; flex-wrap: wrap; gap: 3px 4px; }
#fiche .crumbs a { color: var(--muted); cursor: pointer; text-decoration: none; }
#fiche .crumbs a:hover { color: var(--accent); }
#fiche h1 { font-family: var(--serif); font-size: 25px; line-height: 1.15; margin: 4px 0 2px; font-weight: 600; letter-spacing: -.1px; }
#fiche .en { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; font-style: italic; }
#fiche .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--muted); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.badge.warn { color: var(--warn); border-color: rgba(255,179,71,.35); background: rgba(255,179,71,.09); }
.badge.high { color: var(--good); border-color: rgba(110,231,168,.35); background: rgba(110,231,168,.08); }
.badge.med { color: var(--warn); border-color: rgba(255,179,71,.3); }
.badge.low { color: var(--bad); border-color: rgba(255,123,138,.35); background: rgba(255,123,138,.09); }
#fiche .actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; }
#fiche section { margin: 0 0 17px; }
#fiche h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin: 0 0 5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
#fiche h3 .ico { width: 15px; height: 15px; opacity: .85; }
#fiche p { margin: 0; color: #d7deec; line-height: 1.62; font-size: 14px; }
#fiche p b { color: #fff; }
#fiche .mnemo { background: linear-gradient(135deg, rgba(255,209,102,.13), rgba(255,209,102,.04)); border: 1px solid rgba(255,209,102,.32); border-radius: 12px; padding: 11px 13px; }
#fiche .mnemo h3 { color: var(--accent2); }
#fiche .proj { background: rgba(124,196,255,.07); border: 1px solid rgba(124,196,255,.3); border-radius: 12px; padding: 11px 13px; }
#fiche .caution { font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--warn); padding-left: 10px; }
.cons { display: flex; flex-direction: column; gap: 5px; }
.con { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid var(--line); cursor: pointer; transition: .15s; }
.con:hover { background: rgba(255,255,255,.09); border-color: var(--line2); }
.con.active { border-color: var(--accent2); background: rgba(255,209,102,.1); }
.con .ic { width: 22px; height: 12px; }
.con .who { font-size: 13px; line-height: 1.25; }
.con .who small { display: block; color: var(--dim); font-size: 11px; }
.con .cf { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.con .cf.low { color: var(--bad); border-color: rgba(255,123,138,.4); }
.con .cf.med { color: var(--warn); border-color: rgba(255,179,71,.35); }
.subh { color: var(--muted); font-size: 12px; margin: 9px 0 5px; display: flex; align-items: center; gap: 8px; }
.subh::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; font-size: 12.5px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 500; }
.edgebox { background: rgba(255,255,255,.04); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }

/* graphe */
#graph { position: relative; flex: 0 0 0; width: 0; overflow: hidden; background: radial-gradient(120% 90% at 50% 30%, #121b30, #070b15 70%); border-left: 1px solid var(--line); display: none; }
#app.mode-graph #stage { display: none; }
#app.mode-graph #graph { display: block; flex: 1 1 100%; width: auto; border-left: 0; }
#app.mode-split #stage { flex: 1 1 52%; }
#app.mode-split #graph { display: block; flex: 1 1 48%; width: auto; }
#graph svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#graph .gtools { position: absolute; left: 12px; top: 12px; z-index: 5; display: flex; flex-direction: column; gap: 8px; max-width: 70%; }
#graph .gnote { position: absolute; right: 14px; bottom: 12px; color: var(--dim); font-size: 12px; max-width: 340px; text-align: right; pointer-events: none; }
.gnode { cursor: pointer; }
.gnode rect { transition: opacity .2s, stroke-width .2s; }
.gnode text { pointer-events: none; font: 11.5px var(--sans); fill: #eef2fb; }
.gedge { fill: none; transition: opacity .2s, stroke-width .2s; cursor: pointer; }

/* menus / modales */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(2,4,9,.66); display: none; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.modal.show { display: flex; }
.mbox { width: min(760px, calc(100vw - 40px)); max-height: calc(100vh - 60px); overflow: auto; background: var(--panel-solid); border: 1px solid var(--line2); border-radius: 18px; padding: 22px 26px; box-shadow: 0 30px 90px rgba(0,0,0,.7); }
.mbox h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 4px; font-weight: 600; }
.mbox h3 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); }
.mbox p, .mbox li { color: #cfd7e8; font-size: 14px; line-height: 1.6; }
.mbox ul { padding-left: 20px; margin: 4px 0; }
.mbox .sub { color: var(--muted); margin: 0 0 12px; font-size: 13.5px; }
.tourlist { display: grid; gap: 10px; margin-top: 12px; }
.tourlist button { text-align: left; background: rgba(255,255,255,.045); border: 1px solid var(--line); border-radius: 14px; padding: 12px 15px; transition: .15s; }
.tourlist button:hover { background: rgba(255,255,255,.09); border-color: var(--line2); transform: translateY(-1px); }
.tourlist b { display: block; font-size: 15px; margin-bottom: 2px; font-family: var(--serif); font-weight: 600; }
.tourlist small { color: var(--muted); font-size: 12.5px; }
.tourlist .meta { color: var(--dim); font-size: 11.5px; margin-top: 3px; display: block; }
.viewitem { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; margin: 5px 0; }
.viewitem span { flex: 1; }
.viewitem small { color: var(--dim); }
.mbox input[type=text] { background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--text); padding: 7px 11px; border-radius: 9px; outline: none; flex: 1; font-size: 13.5px; }
.mbox input[type=text]:focus { border-color: rgba(124,196,255,.55); }
.mclose { position: sticky; top: 0; float: right; }
.footnote { color: var(--dim); font-size: 12px; margin-top: 14px; line-height: 1.5; }
.legend-row { display: flex; align-items: center; gap: 10px; margin: 3px 0; font-size: 13px; color: var(--muted); }

@media (max-width: 1100px) {
  :root { --leftW: 290px; --rightW: 360px; }
  .brand small { display: none; }
  #fiche { width: var(--rightW); }
}
@media (max-width: 860px) {
  #app { grid-template-columns: 0 minmax(0, 1fr) 0; }
  #app.has-fiche { grid-template-columns: 0 minmax(0, 1fr) min(var(--rightW), 100vw); }
  #left { position: fixed; left: 0; top: var(--topH); bottom: 0; width: var(--leftW); transform: translateX(-102%); transition: transform .3s; }
  #app:not(.left-collapsed) #left { transform: none; }
  #crumbs { display: none; }
}

/* ---------- écran de chargement ---------- */
#loading { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, #16213a, #04060b); color: var(--muted); font-size: 14px; transition: opacity .8s ease; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .msg { text-align: center; max-width: 520px; line-height: 1.6; padding: 0 20px; }
#loading .spin { display: block; width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent); animation: spin 1s linear infinite; }
#loading.err .spin { display: none; }
#loading.err .msg { color: #ffb4bd; }
@keyframes spin { to { transform: rotate(360deg); } }

@container (max-width: 1280px) { #sidehint { display: none; } }
#sidehint { max-width: 300px; }

@container (max-width: 780px) {
  .hudbox .lbl2 { display: none; }
  .hudbox button { padding: 7px 10px; }
  .hudbox button .n { display: none; }
  #viewbtns .hudbox { flex-wrap: wrap; max-width: 230px; }
  #toast { max-width: 86%; text-align: center; border-radius: 16px; }
}
@container (max-width: 470px) { .hudbox button { padding: 6px 7px; font-size: 12px; } #hud { max-width: calc(100% - 12px); } }

@container (max-width: 560px) { #viewbtns .hudbox .lbl3 { display: none; } }
#viewbtns .hudbox.lblbox { flex-wrap: nowrap; max-width: none; }

/* ---------- historique : précédent / suivant ---------- */
.histnav { display: flex; gap: 2px; }
.btn.hbtn { width: 34px; height: 32px; padding: 0; font-size: 18px; line-height: 1; border-radius: 10px; color: var(--text); }
.btn:disabled, .btn.hbtn:disabled { opacity: .3; cursor: default; pointer-events: none; }
.histbar { display: none; position: sticky; top: 0; z-index: 6; gap: 8px; align-items: center; padding: 8px 14px; background: var(--panel-solid); border-bottom: 1px solid var(--line); }
.histbar.show { display: flex; }
.histbar .btn { max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.histbar .btn:first-child { background: rgba(124,196,255,.14); border-color: rgba(124,196,255,.38); }
.histbar .btn.ghost:last-child { margin-left: auto; }
@media (max-width: 860px) {
  #top { gap: 8px; padding: 0 8px; }
  .brand b, .brand small { display: none; }
  .seg button { padding: 5px 9px; }
  .top-actions { gap: 6px; }
  .top-actions .btn { padding: 6px 10px; }
}
@media (max-width: 640px) {
  .brand { display: none; }
  .top-actions .tl { display: none; }
  .seg button { padding: 5px 7px; font-size: 12px; }
}
.seg.lang button { padding: 5px 9px; font-weight: 650; letter-spacing: .05em; font-size: 12px; }
@media (max-width: 640px) { .seg.lang { display: inline-flex; } .seg.lang button { padding: 5px 6px; } }
#fiche .mnemo .story { margin: 10px 0 0; padding-top: 9px; border-top: 1px dashed rgba(255,209,102,.3); font-size: 13.5px; color: #e9e2cf; }
#fiche .mnemo .story b { color: var(--accent2); }
#fiche .mnemo h3 + .story { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- placement explicite de la grille (le panneau gauche est « fixed » en dessous de 860 px :
   sans cela la scène et la fiche glissaient d'une colonne) ---------- */
#left { grid-column: 1; grid-row: 2; }
#center { grid-column: 2; grid-row: 2; }
#right { grid-column: 3; grid-row: 2; }
/* écran étroit : la fiche devient un volet en bas, la scène 3D reste visible au-dessus */
@media (max-width: 700px) {
  #app, #app.has-fiche, #app.left-collapsed, #app.left-collapsed.has-fiche { grid-template-columns: 0 minmax(0, 1fr) 0; grid-template-rows: var(--topH) minmax(0, 1fr) 0; }
  #app.has-fiche, #app.left-collapsed.has-fiche { grid-template-rows: var(--topH) minmax(0, 42vh) minmax(0, 1fr); }
  #right { grid-column: 1 / -1; grid-row: 3; border-left: 0; border-top: 1px solid var(--line2); }
  #fiche { width: 100%; box-sizing: border-box; }
}
@container (max-width: 560px) { #legend.show { display: none; } }

/* opacité des structures estompées */
.ctxrow { margin-top: 10px; }
.ctxlab { color: var(--muted); font-size: 12.5px; }
.ctxrow .row { margin: 3px 0 0; }
