:root { --side-w: max(280px, 33.333vw); --bg: #0a0a0a; --panel: #141414; --line: #262626; --txt: #ededed; --muted: #8f8f8f; --accent: #00c4b3; --dot: #ffd200;
        --font: "Inter", system-ui, "Segoe UI", sans-serif; }
html, body { margin: 0; height: 100%; background: #000; font-family: var(--font); color: var(--txt); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }
#app { display: flex; height: 100%; }
[hidden] { display: none !important; }

/* ---- volet ---- */
#side { position: relative; flex: none; width: var(--side-w); overflow: hidden; background: var(--bg);
        border-right: 1px solid var(--line); transition: width .25s ease; z-index: 30; }
#side.dragging { transition: none; }
body.collapsed #side { width: 0; border-right: 0; }
#side-inner { width: var(--side-w); height: 100%; display: flex; flex-direction: column; }
#side-head { padding: 10px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
#search { position: relative; }
#q { box-sizing: border-box; width: 100%; padding: 9px 12px; border-radius: 4px; border: 1px solid var(--line);
     background: var(--panel); color: var(--txt); font-size: 14px; outline: none; }
#q:focus { border-color: var(--accent); }
#results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
           max-height: 55vh; overflow-y: auto; background: #1a1a1a; border: 1px solid var(--line);
           border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 50; }
#results li { padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
#results li small { color: var(--muted); white-space: nowrap; }
#results li.active, #results li:hover { background: #262626; }
#results li.none, #results li.count { cursor: default; color: var(--muted); font-size: 12.5px; }
#results li.none:hover, #results li.count:hover { background: none; }
#level-row { display: flex; align-items: center; gap: 8px; }
#level-row label { font-size: 13px; color: var(--muted); }
#levels { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel);
          color: var(--txt); font-size: 14px; outline: none; cursor: pointer; }
#levels:focus { border-color: var(--accent); }

/* ---- plan ---- */
#plan { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--panel); border-top: 1px solid var(--line);
        cursor: grab; touch-action: none; user-select: none; }
#plan.panning { cursor: grabbing; }
#plan-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; --inv: 1; }
#plan-img { display: block; max-width: none; pointer-events: none; }
#plan-lines { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#plan-lines line { stroke: rgba(255,255,255,.35); stroke-width: 2px; vector-effect: non-scaling-stroke; }
#plan-dots { position: absolute; left: 0; top: 0; }
.dot { position: absolute; width: 13px; height: 13px; box-sizing: border-box; border-radius: 50%; background: var(--dot);
       border: 2px solid #111; transform: translate(-50%, -50%) scale(var(--inv)); cursor: pointer; }
.dot:hover { background: #fff; box-shadow: 0 0 0 4px rgba(255,210,0,.45); z-index: 3; }
.dot.flat { border-radius: 2px; }
.dot.current { background: #2d8cff; border-color: #fff; z-index: 2; }
#me { position: absolute; width: 0; height: 0; transform: scale(var(--inv)); pointer-events: none; z-index: 1; }
#me svg { position: absolute; left: -40px; top: -40px; width: 80px; height: 80px; overflow: visible; }
#me path { fill: rgba(45,140,255,.45); stroke: rgba(45,140,255,.9); stroke-width: 1; }
#me .me-dot { display: none; }
#me.ghost .me-dot { display: block; fill: #9a9a9a; stroke: #fff; stroke-width: 2; }
#me.ghost path { fill: rgba(150,150,150,.45); stroke: rgba(190,190,190,.9); }
#plan-tools { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
#plan-tools button { width: 34px; height: 34px; border-radius: 4px; border: 1px solid var(--line); background: rgba(10,10,10,.92);
                     color: var(--txt); font-size: 18px; line-height: 1; cursor: pointer; }
#plan-tools button:hover { border-color: var(--accent); }
#tip { position: absolute; z-index: 6; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,.85); color: #fff;
       font-size: 12.5px; white-space: nowrap; pointer-events: none; transform: translate(-50%, -100%); }
#plan-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
            padding: 2em; color: var(--muted); pointer-events: none; }
#splitter { position: absolute; top: 0; right: 0; width: 6px; height: 100%; cursor: col-resize; z-index: 8; }
#splitter:hover, #side.dragging #splitter { background: rgba(0,196,179,.5); }

/* ---- visionneuse ---- */
#stage { position: relative; flex: 1; min-width: 0; }
#viewer { position: absolute; inset: 0; }
#topbar { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 40; display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; pointer-events: none; }
/* bouton Masquer le plan : en bas à gauche du plan (ou de la photo quand le plan est masqué) */
.plan-toggle { position: absolute; left: 10px; bottom: 10px; z-index: 6; padding: 8px 12px; border-radius: 4px; border: 1px solid var(--line); background: rgba(10,10,10,.92); color: var(--txt); font-size: 14px; cursor: pointer; }
.plan-toggle:hover { border-color: var(--accent); }
#toggle-open { display: none; z-index: 41; bottom: 54px; background: rgba(0,0,0,.65); border: 0; color: #fff; }
body.collapsed #toggle-open { display: block; }
/* niveau + photo active : simple texte sur la photo, volet ouvert ou fermé */
#where { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 16px; min-width: 0; pointer-events: none; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 10px rgba(0,0,0,.7); }
#where span { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#where-level { opacity: .85; }
#where-name { font-weight: 600; }
#where-year { pointer-events: auto; cursor: pointer; padding: 0; border: 0; background: transparent; color: #fff; font-size: 15px; font-family: inherit; text-shadow: inherit; opacity: .85; }
#where-year option { background: #222; color: #fff; text-shadow: none; }
#warn { display: none; position: absolute; top: 56px; left: 10px; z-index: 35; max-width: min(520px, 60%);
        background: rgba(120,20,20,.92); color: #fff; font-size: 13px; padding: 8px 12px; border-radius: 4px; }
#warn ul { margin: 6px 0 0; padding-left: 18px; } #warn a { color: #fff; margin-left: 8px; }
#error { position: absolute; inset: var(--bar-h, 0px) 0 0 0; display: none; align-items: center; justify-content: center;
         color: #fff; text-align: center; padding: 2em; z-index: 100; background: #111; white-space: pre-line; }

/* ---- accueil : liste des sites ---- */
#home { max-width: 760px; margin: 0 auto; padding: 48px 20px; box-sizing: border-box; }
#home h1 { font-size: 32px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 20px; }
#home-q { box-sizing: border-box; width: 100%; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel);
          color: var(--txt); font-size: 16px; outline: none; }
#home-q:focus { border-color: var(--accent); }
#home-count { margin: 12px 2px; color: var(--muted); font-size: 13.5px; }
#home-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.gare-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line);
             color: var(--txt); text-decoration: none; }
.gare-card:hover, .gare-card:focus { border-color: var(--accent); outline: none; }
.gare-name { font-size: 17px; font-weight: 600; } .gare-card small { color: var(--muted); }


/* photo classique 2D : affichée à la place du panorama, dans la même zone */
#photo2d { position: absolute; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; }
#photo2d[hidden] { display: none; }
#photo2d-img { max-width: 100%; max-height: 100%; object-fit: contain; }
#photo2d-close { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 10px 18px; border-radius: 4px; border: 1px solid rgba(255,255,255,.35);
                 background: rgba(0,0,0,.7); color: #fff; font-size: 14px; cursor: pointer; }
#photo2d-close:hover { background: rgba(0,0,0,.9); }
body.flat-open .psv-navbar { display: none !important; }
#photo2d { overflow: hidden; touch-action: none; }
#photo2d-img { cursor: grab; user-select: none; -webkit-user-drag: none; transform-origin: center center; }
#photo2d.dragging #photo2d-img { cursor: grabbing; }
#photo2d-zoom { position: absolute; right: 16px; bottom: 22px; display: flex; flex-direction: column; gap: 6px; }
#photo2d-zoom button { width: 38px; height: 38px; border-radius: 6px; border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.7); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
#photo2d-zoom button:hover { background: rgba(0,0,0,.9); }

/* ---- filtre sur les années (jauge à deux bornes) */
#year-row { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 2px; font-size: 13px; color: var(--txt); }
#year-row[hidden] { display: none; }
#yr-min, #yr-max { position: absolute; top: 24px; transform: translateX(-50%); font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; pointer-events: none; }
#yr-min.apart { transform: translateX(-100%); margin-left: -4px; }
#yr-max.apart { transform: none; margin-left: 4px; }
#yr-box { position: relative; flex: 1; height: 42px; min-width: 60px; margin: 0 14px; }
#yr-track { position: absolute; left: 8px; right: 8px; top: 9px; height: 4px; border-radius: 2px; background: var(--line, #444); }
#yr-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; }
#yr-box input[type=range] { position: absolute; left: 0; top: 0; width: 100%; height: 22px; margin: 0; padding: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
#yr-box input[type=range]::-webkit-slider-runnable-track { background: transparent; border: 0; height: 22px; }
#yr-box input[type=range]::-moz-range-track { background: transparent; border: 0; }
#yr-box input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; background: var(--accent); border: 2px solid #111; cursor: pointer; }
#yr-box input[type=range]::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #111; cursor: pointer; }
#yr-reset { flex: 0 0 auto; width: 28px; height: 28px; padding: 0; border-radius: 6px; border: 1px solid var(--line, #444); background: none; color: var(--txt); font-size: 16px; line-height: 1; cursor: pointer; }
#yr-reset:disabled { opacity: .35; cursor: default; }
.dot.faded { opacity: .4; }

/* ---- logo et nom du site */
#brand { display: flex; align-items: center; gap: 10px; min-height: 40px; }
#brand-name { font-size: 18px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.gare-card .gare-head { display: flex; align-items: center; gap: 12px; }
.gare-card .gare-logo { height: 40px; width: 40px; object-fit: contain; flex: 0 0 auto; }

/* photos 2D dans les photos 360° */
#flat-marks { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.flat-mark { box-sizing: border-box; position: absolute; left: 0; top: 0; width: calc(var(--sq, 26px) * var(--k, 1)); height: calc(var(--sq, 26px) * var(--k, 1)); padding: 0; border-radius: 3px; background: var(--dot); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.5); cursor: pointer; pointer-events: auto; }
.flat-mark:hover { background: #fff3a0; }
body.flat-open #flat-marks { display: none; }
#adm-range { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; border: calc(2px * var(--inv)) solid rgba(80,220,120,.55); background: rgba(80,220,120,.10); }
#adm-range[hidden] { display: none; }

#home-msg { margin: 6px 2px 0; color: var(--muted); font-size: 14px; } #home-msg a { color: var(--accent); }
#brand { min-height: 0; }
#brand-logo { height: 36px; max-width: 80px; object-fit: contain; flex: none; } #brand-logo[hidden] { display: none; }
input[type=checkbox], input[type=range] { accent-color: var(--accent); }
