:root {
  --bg: #02030a;
  --panel: rgba(10, 14, 28, 0.62);
  --panel-strong: rgba(10, 14, 28, 0.86);
  --border: rgba(150, 180, 255, 0.16);
  --border-strong: rgba(150, 180, 255, 0.32);
  --text: #e8ecf8;
  --muted: #9aa6c4;
  --faint: #6b7695;
  --accent: #7fb4ff;
  --accent-2: #ffc46b;
  --good: #7de3a5;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
kbd { display: inline-block; min-width: 1.5em; padding: 1px 5px; margin: 0 1px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; font-size: 11px; font-family: var(--font); color: var(--muted); text-align: center; background: rgba(255,255,255,0.04); }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; outline: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }

.hud { position: fixed; z-index: 5; transition: opacity .5s ease, transform .5s ease; }
.hud.hidden { opacity: 0; pointer-events: none; transform: translateY(-6px); }

/* ---------- Étiquettes ---------- */
.lbl3d { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; white-space: nowrap; pointer-events: auto; cursor: pointer; will-change: transform; user-select: none; }
.lbl3d .dot { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; flex: none; transform: translateX(-3.5px); box-shadow: 0 0 6px currentColor; opacity: .9; }
.lbl3d .txt { font-size: 12px; font-weight: 500; letter-spacing: .01em; color: #dfe6fb; text-shadow: 0 0 4px #000, 0 0 8px #000; transform: translateX(-3px); opacity: .92; }
.lbl3d.t-planet .txt { font-size: 13px; font-weight: 600; }
.lbl3d.t-star .txt, .lbl3d.t-sun .txt { color: #ffe4b0; }
.lbl3d.t-moon .txt { font-size: 11px; color: #c8d0e6; }
.lbl3d.t-spacecraft .txt, .lbl3d.t-satellite .txt { font-size: 11px; color: #bfe9ff; }
.lbl3d.t-nebula .txt { color: #ffc2d6; font-style: italic; }
.lbl3d.t-cluster .txt { color: #d9e4ff; font-style: italic; }
.lbl3d.t-galaxy .txt { color: #e7d9ff; font-weight: 600; }
.lbl3d.t-region .txt { color: #9fb5e8; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; font-weight: 500; }
.lbl3d.t-region .dot { display: none; }
.lbl3d.t-arm .txt { color: rgba(170, 195, 255, .55); font-size: 13px; letter-spacing: .25em; text-transform: uppercase; font-style: normal; font-weight: 300; }
.lbl3d.t-arm .dot { display: none; }
.lbl3d.t-arm { pointer-events: none; }
.lbl3d.here .txt { color: #ffd98a; font-weight: 700; font-size: 13px; }
.lbl3d.here .dot { width: 10px; height: 10px; }
.lbl3d.selected .dot { box-shadow: 0 0 0 3px rgba(127,180,255,.35), 0 0 10px currentColor; }
.lbl3d.selected .txt { color: #fff; }
.lbl3d:hover .txt { color: #fff; }
.sel-ring { position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 1.5px solid rgba(127,180,255,.9); border-radius: 50%; pointer-events: none; will-change: transform; box-shadow: 0 0 12px rgba(127,180,255,.5); display: none; }
.sel-ring::before, .sel-ring::after { content: ""; position: absolute; background: rgba(127,180,255,.9); }
.sel-ring::before { left: 50%; top: -7px; width: 1.5px; height: 6px; }
.sel-ring::after { left: 50%; bottom: -7px; width: 1.5px; height: 6px; }

/* ---------- Intro ---------- */
.intro { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 60%, rgba(8, 12, 30, 0.35), rgba(2, 3, 10, 0.92) 70%); transition: opacity 1.2s ease; }
.intro.gone { opacity: 0; pointer-events: none; }
.intro-card { max-width: 620px; padding: 38px 40px 30px; text-align: center; }
.intro-kicker { font-family: var(--font-display); letter-spacing: .32em; text-transform: uppercase; font-size: 12px; color: var(--accent); }
.intro h1 { font-family: var(--font-display); font-size: clamp(44px, 9vw, 84px); font-weight: 600; margin: 8px 0 12px; letter-spacing: -.02em; background: linear-gradient(180deg, #fff 30%, #a9c3ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.intro-lead { color: var(--muted); font-size: 16px; line-height: 1.6; margin: 0 auto 26px; max-width: 520px; }
.intro-progress { height: 3px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; max-width: 360px; margin: 0 auto; }
#introBar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #c9a8ff); transition: width .3s ease; }
.intro-status { color: var(--faint); font-size: 12px; margin: 10px 0 24px; min-height: 16px; }
.intro-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-primary, .btn-secondary { border: 1px solid var(--border-strong); border-radius: 999px; padding: 12px 22px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .2s; }
.btn-primary { background: linear-gradient(135deg, #5b8dff, #8f6bff); color: white; border-color: transparent; box-shadow: 0 8px 30px rgba(91, 141, 255, .35); }
.btn-secondary { background: rgba(255,255,255,0.05); color: var(--text); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .35; cursor: default; box-shadow: none; }
.btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 10px 36px rgba(91, 141, 255, .5); }
.btn-secondary:not(:disabled):hover { background: rgba(255,255,255,0.1); }
.intro-hint { margin-top: 26px; color: var(--faint); font-size: 12px; line-height: 1.9; }

/* ---------- Barre supérieure ---------- */
#topbar { top: 14px; left: 14px; right: 14px; display: flex; align-items: center; gap: 14px; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.brand { padding: 8px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); min-width: 170px; }
.brand-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--accent); margin-top: 1px; }
.search { position: relative; flex: 1; max-width: 460px; }
.search input { width: 100%; padding: 11px 14px 11px 38px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); color: var(--text); font-size: 13.5px; outline: none; transition: border-color .2s; }
.search input:focus { border-color: var(--accent); }
.search input::placeholder { color: var(--faint); }
.search-ico { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 60vh; overflow-y: auto; border-radius: var(--radius); background: var(--panel-strong); border: 1px solid var(--border); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); display: none; padding: 6px; }
.search-results.open { display: block; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.sr-item.active, .sr-item:hover { background: rgba(127, 180, 255, 0.14); }
.sr-ico { width: 22px; text-align: center; opacity: .85; }
.sr-name { flex: 1; font-weight: 500; }
.sr-name mark { background: none; color: var(--accent); }
.sr-type { font-size: 11.5px; color: var(--faint); }
.quicknav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.quicknav button { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: all .15s; }
.quicknav button:hover { border-color: var(--border-strong); background: rgba(40, 55, 95, .7); }
.quicknav button.accent { border-color: rgba(255, 196, 107, .45); color: #ffe2b0; }
.quicknav .qi { font-size: 13px; opacity: .9; }

/* ---------- Échelle ---------- */
#scalebar { left: 14px; top: 50%; transform: translateY(-50%); display: flex; gap: 14px; align-items: stretch; pointer-events: none; }
#scalebar.hidden { transform: translateY(-50%) translateX(-8px); }
.scale-track { position: relative; width: 2px; height: 300px; background: linear-gradient(180deg, rgba(200,170,255,.5), rgba(127,180,255,.5), rgba(125,227,165,.5)); border-radius: 2px; margin-left: 6px; }
.scale-mark { position: absolute; left: -3px; top: calc(var(--p) * 100%); width: 8px; height: 1px; background: rgba(255,255,255,.35); }
.scale-mark span { position: absolute; left: 14px; top: -7px; font-size: 10.5px; color: var(--faint); white-space: nowrap; letter-spacing: .02em; }
.scale-cursor { position: absolute; left: -6px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(127,180,255,.25), 0 0 14px rgba(127,180,255,.9); transform: translateY(-50%); transition: top .15s linear; }
.scale-readout { margin-left: 104px; align-self: center; padding: 10px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); min-width: 150px; }
.scale-readout .lbl { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin-top: 6px; }
.scale-readout .lbl:first-child { margin-top: 0; }
.scale-readout .val { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.scale-readout .val.small { font-size: 13px; font-weight: 500; color: var(--muted); }

/* ---------- Temps ---------- */
#timebar { bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
#timebar.hidden { transform: translateX(-50%) translateY(8px); }
.time-date { min-width: 205px; }
.time-date .date { font-family: var(--font-display); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.time-date .rate { font-size: 12px; color: var(--accent-2); margin-top: 1px; }
.time-buttons { display: flex; gap: 6px; align-items: center; }
.time-buttons button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--text); cursor: pointer; font-size: 14px; transition: all .15s; }
.time-buttons button.big { width: 44px; height: 44px; border-radius: 50%; font-size: 16px; background: rgba(127, 180, 255, 0.16); border-color: rgba(127,180,255,.4); }
.time-buttons button.txt { width: auto; padding: 0 12px; font-size: 12px; font-weight: 600; }
.time-buttons button:hover { background: rgba(127,180,255,.2); border-color: var(--border-strong); }
#rateSlider { width: 150px; accent-color: var(--accent); }

/* ---------- Calques ---------- */
#layers { left: 14px; bottom: 16px; padding: 10px 14px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: flex; flex-direction: column; gap: 5px; width: 236px; max-height: calc(100vh - 120px); overflow-y: auto; }
#layers.collapsed > :not(.panel-head) { display: none; }
#layers.collapsed { padding-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; background: none; border: none; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 0; cursor: pointer; margin-bottom: 3px; }
.panel-head:hover { color: var(--text); }
.panel-head .chev { transition: transform .2s; font-size: 12px; }
#layers.collapsed .panel-head .chev { transform: rotate(180deg); }
.panel-title { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 3px; }
#layers label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); cursor: pointer; user-select: none; }
#layers label kbd { margin-left: auto; }
#layers input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; }
.panel-sep { height: 1px; background: var(--border); margin: 5px 0; }
.sat-status { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; text-align: left; padding: 2px 0; display: flex; gap: 6px; align-items: center; }
.linkbtn:hover { text-decoration: underline; }
#layersToggle { left: 14px; bottom: 16px; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 17px; cursor: pointer; display: none; }

/* ---------- Panneau d'informations ---------- */
.info { position: fixed; z-index: 6; top: 76px; right: 14px; bottom: 90px; width: 380px; max-width: calc(100vw - 28px); border-radius: 18px; background: var(--panel-strong); border: 1px solid var(--border); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); transform: translateX(calc(100% + 30px)); transition: transform .45s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; overflow: hidden; }
.info.open { transform: none; }
.info-close { position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: rgba(255,255,255,.05); color: var(--text); font-size: 18px; cursor: pointer; z-index: 2; }
#infoContent { overflow-y: auto; padding: 20px 20px 24px; flex: 1; scrollbar-width: thin; scrollbar-color: rgba(127,180,255,.3) transparent; }
.i-type { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); }
.i-name { font-family: var(--font-display); font-size: 28px; font-weight: 600; margin: 4px 0 2px; line-height: 1.1; padding-right: 30px; }
.i-alt { font-size: 12.5px; color: var(--faint); margin-bottom: 10px; }
.i-desc { color: #c9d2ea; line-height: 1.6; font-size: 13.5px; margin: 10px 0 12px; }
.i-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.i-actions button { padding: 7px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: rgba(127,180,255,.1); color: var(--text); cursor: pointer; font-size: 12px; font-weight: 500; }
.i-actions button:hover { background: rgba(127,180,255,.22); }
.i-actions button.on { background: rgba(255,196,107,.18); border-color: rgba(255,196,107,.5); }
.lod { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: 11.5px; color: var(--muted); }
.lod-bars { display: flex; gap: 4px; }
.lod-bars i { width: 22px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); }
.lod-bars i.on { background: linear-gradient(90deg, var(--accent), #b59cff); }
.lod-hint { font-size: 11.5px; color: var(--faint); font-style: italic; margin: 2px 0 8px; }
.i-section { margin-top: 16px; animation: fadeIn .6s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.i-section h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent-2); margin: 0 0 8px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.i-section h3::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.i-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.i-grid > div { background: rgba(12, 17, 34, .92); padding: 7px 10px; }
.i-grid .k { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.i-grid .v { font-size: 13px; font-weight: 500; margin-top: 1px; font-variant-numeric: tabular-nums; }
.i-grid .v.live { color: var(--good); }
.i-grid .full { grid-column: 1 / -1; }
.i-list { margin: 0; padding-left: 18px; color: #c9d2ea; line-height: 1.6; font-size: 13px; }
.i-list li { margin-bottom: 3px; }
.i-p { color: #c9d2ea; line-height: 1.6; font-size: 13px; margin: 0 0 6px; }
.comp { display: flex; flex-direction: column; gap: 5px; }
.comp-row { display: grid; grid-template-columns: 110px 1fr 56px; gap: 8px; align-items: center; font-size: 12px; }
.comp-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.comp-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #b59cff); }
.comp-row .pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.04); font-size: 12px; cursor: pointer; color: var(--text); }
.chip:hover { border-color: var(--accent); background: rgba(127,180,255,.12); }
.layers-diagram { display: flex; flex-direction: column; gap: 3px; }
.layer-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.layer-sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.note { font-size: 11.5px; color: var(--faint); margin-top: 8px; line-height: 1.5; }

/* ---------- Infobulle ---------- */
.tooltip { position: fixed; z-index: 8; pointer-events: none; padding: 6px 10px; border-radius: 9px; background: var(--panel-strong); border: 1px solid var(--border); font-size: 12px; opacity: 0; transition: opacity .15s; white-space: nowrap; }
.tooltip.show { opacity: 1; }
.tooltip .tt-type { color: var(--faint); font-size: 11px; }

/* ---------- Sous-titres ---------- */
.caption { position: fixed; z-index: 7; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); width: min(680px, calc(100vw - 28px)); padding: 16px 20px 14px; border-radius: 18px; background: var(--panel-strong); border: 1px solid var(--border); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); opacity: 0; pointer-events: none; transition: all .5s ease; }
.caption.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.caption-step { font-size: 11px; color: var(--accent); letter-spacing: .14em; text-transform: uppercase; }
.caption-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin: 3px 0 6px; }
.caption-text { color: #c9d2ea; font-size: 13.5px; line-height: 1.6; }
.caption-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.caption-actions button { padding: 7px 13px; border-radius: 9px; border: 1px solid var(--border-strong); background: rgba(255,255,255,.05); color: var(--text); cursor: pointer; font-size: 12px; }
.caption-actions button:hover { background: rgba(127,180,255,.18); }
#captionStop { margin-right: auto; color: var(--muted); }

/* ---------- Modales ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: rgba(2,3,10,.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal.open { display: flex; }
.modal-card { position: relative; width: min(720px, calc(100vw - 32px)); max-height: 86vh; overflow-y: auto; padding: 26px 28px; border-radius: 20px; background: var(--panel-strong); border: 1px solid var(--border); }
.modal-card h2 { font-family: var(--font-display); margin: 0 0 16px; font-weight: 600; }
.modal-close { position: absolute; top: 14px; right: 16px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: rgba(255,255,255,.05); color: var(--text); font-size: 18px; cursor: pointer; }
.help-grid { display: grid; grid-template-columns: minmax(180px, auto) 1fr; gap: 8px 18px; font-size: 13px; color: #c9d2ea; }
.help-grid b { color: var(--accent-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; margin-top: 6px; display: inline-block; }
.help-note { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin-top: 18px; }
.credits { padding-left: 18px; line-height: 1.65; color: #c9d2ea; font-size: 13px; }
.credits li { margin-bottom: 6px; }
.credits code { font-size: 12px; color: var(--accent); }

.toast { position: fixed; z-index: 50; left: 50%; top: 80px; transform: translate(-50%, -10px); padding: 9px 16px; border-radius: 12px; background: var(--panel-strong); border: 1px solid var(--border); font-size: 13px; opacity: 0; transition: all .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .quicknav button span:not(.qi) { display: none; }
  .quicknav button.accent span:not(.qi) { display: inline; }
  #scalebar .scale-mark span { display: none; }
  .scale-readout { margin-left: 16px; }
}
@media (max-width: 760px) {
  #topbar { flex-wrap: wrap; top: 10px; left: 10px; right: 10px; gap: 8px; }
  .brand { display: none; }
  .search { order: 2; flex-basis: 100%; max-width: none; }
  .quicknav { margin-left: 0; width: 100%; justify-content: space-between; }
  .quicknav button.accent span:not(.qi) { display: none; }
  #scalebar { display: none; }
  #timebar { left: 10px; right: 10px; transform: none; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 8px 10px; bottom: 10px; }
  #timebar.hidden { transform: translateY(8px); }
  .time-date { min-width: 0; text-align: center; flex-basis: 100%; }
  #rateSlider { display: none; }
  #layers { display: none; bottom: 130px; left: 10px; }
  #layers.mobile-open { display: flex; }
  #layersToggle { display: block; bottom: 130px; left: 10px; }
  #layersToggle.hidden { display: none; }
  .info { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-width: none; height: 55vh; border-radius: 18px 18px 0 0; transform: translateY(105%); }
  .caption { bottom: 128px; }
}
