:root {
  --bg: rgba(12, 16, 24, 0.74);
  --bg-strong: rgba(10, 13, 20, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --text: #e8edf4;
  --muted: #9aa6b6;
  --gold: #e3b45c;
  --jade: #46b89f;
  --red: #d2584c;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0e14; color: var(--text); font-family: var(--font); }
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; outline: none; }
#labels { position: fixed; inset: 0; pointer-events: none; }
.zh { font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", var(--font); }
button { font-family: inherit; }

/* chargement */
#loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 60%, #1c2233 0%, #0a0d13 70%); transition: opacity .8s ease; }
#loader.done { opacity: 0; pointer-events: none; }
.loader-box { width: min(440px, 86vw); text-align: center; }
.loader-title { font-size: 44px; font-weight: 700; letter-spacing: .5px; }
.loader-title .zh { color: var(--gold); margin-left: 8px; font-weight: 600; }
.loader-sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.loader-bar { margin: 28px 0 12px; height: 6px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; }
#loader-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width .25s ease; }
#loader-step { color: var(--muted); font-size: 13px; min-height: 18px; }

/* panneaux */
.panel { position: fixed; z-index: 10; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.hidden { display: none !important; }

#brand { position: fixed; top: 16px; left: 18px; z-index: 10; pointer-events: none; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.brand-title { font-size: 26px; font-weight: 700; }
.brand-title .zh { color: var(--gold); margin-left: 6px; }
.brand-sub { color: #d5dce6; font-size: 13px; margin-top: 2px; opacity: .9; }

/* lieux */
#places { top: 84px; left: 16px; width: 290px; max-height: calc(100vh - 220px); display: flex; flex-direction: column; }
.panel-head { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-weight: 600; font-size: 14px; }
.panel-head .ico { color: var(--gold); }
.panel-head .chev { margin-left: auto; transition: transform .2s; color: var(--muted); }
#places.collapsed .panel-body { display: none; }
#places:not(.collapsed) .chev { transform: rotate(180deg); }
.panel-body { padding: 0 10px 12px; overflow: auto; }
#places-search { width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); font-size: 13px; outline: none; margin-bottom: 8px; }
#places-search:focus { border-color: rgba(227,180,92,.6); }
.place-group { margin: 10px 4px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.place-item { display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text);
  padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.place-item:hover, .place-item.active { background: rgba(255,255,255,.08); }
.place-item .zh { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

/* fiche */
#card { top: 16px; right: 16px; width: 360px; max-height: calc(100vh - 150px); overflow: auto; padding: 18px 18px 16px; }
#card-kicker { color: var(--gold); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
#card-title { margin: 6px 26px 2px 0; font-size: 21px; line-height: 1.25; }
#card-zh { color: #c9d2de; font-size: 16px; margin-bottom: 10px; }
#card-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 13px; }
#card-facts dt { color: var(--muted); }
#card-facts dd { margin: 0; }
#card-text { font-size: 14px; line-height: 1.55; color: #dfe5ee; margin: 10px 0 4px; }
#card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
#card-actions button, #card-actions a { border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); padding: 7px 12px;
  border-radius: 9px; font-size: 13px; cursor: pointer; text-decoration: none; }
#card-actions button:hover, #card-actions a:hover { background: rgba(255,255,255,.12); }
.icon-btn { position: absolute; top: 10px; right: 10px; border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.08); }

/* réglages */
.round-btn { position: fixed; z-index: 11; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font-size: 20px; cursor: pointer; backdrop-filter: blur(12px); display: grid; place-items: center; }
.round-btn:hover { background: var(--bg-strong); }
#settings-btn { top: 16px; right: 16px; }
body.card-open #settings-btn { right: 390px; }
#settings { top: 66px; right: 16px; width: 320px; padding: 14px 16px; }
body.card-open #settings { right: 390px; }
.set-title { font-weight: 700; margin-bottom: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 13.5px; border-top: 1px solid rgba(255,255,255,.05); }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--jade); }
.set-row input[type=range] { width: 100%; accent-color: var(--gold); }
.range-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin-left: 6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 9px; font-size: 12.5px; cursor: pointer; }
.seg button.on { background: rgba(70,184,159,.25); color: var(--text); }
.set-foot { margin-top: 10px; font-size: 11px; color: var(--muted); }

/* temps */
#timebar { left: 50%; transform: translateX(-50%); bottom: 18px; width: min(760px, calc(100vw - 32px)); display: flex; align-items: center; gap: 14px; padding: 10px 16px; }
#play-btn { position: static; width: 38px; height: 38px; font-size: 15px; flex: 0 0 auto; }
.time-main { flex: 1; min-width: 0; }
.time-read { display: flex; align-items: baseline; gap: 10px; }
#time-clock { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
#time-phase { color: var(--gold); font-size: 13px; }
.slider-wrap { position: relative; height: 34px; }
#time-track { position: absolute; left: 0; right: 0; top: 11px; height: 8px; border-radius: 6px; background: linear-gradient(90deg, #0d1426, #1b2a4a 20%, #e59a6a 26%, #9cc3e0 34%, #bcd6ea 50%, #9cc3e0 66%, #ef9460 78%, #283a66 84%, #0d1426); opacity: .9; }
#time-slider { position: absolute; left: 0; right: 0; top: 4px; width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; height: 22px; }
#time-slider::-webkit-slider-runnable-track { background: transparent; height: 22px; }
#time-slider::-moz-range-track { background: transparent; height: 22px; }
#time-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; background: #fff; border: 3px solid var(--gold); box-shadow: 0 0 10px rgba(227,180,92,.7); cursor: grab; }
#time-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--gold); cursor: grab; }
.time-ticks { position: absolute; left: 0; right: 0; top: 22px; display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); pointer-events: none; }
.time-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }
#sun-info { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
#speed-sel { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line); border-radius: 7px; font-size: 12px; padding: 3px 6px; }
#speed-sel option { background: #1a1f2b; }

/* boussole, aide, fps */
#compass { position: fixed; right: 20px; bottom: 30px; z-index: 10; width: 46px; height: 46px; border-radius: 50%; background: var(--bg);
  border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(12px); }
#compass-needle { font-weight: 800; font-size: 13px; color: var(--red); transition: transform .08s linear; }
#compass-needle::after { content: ''; position: absolute; }
#help { position: fixed; left: 50%; transform: translateX(-50%); bottom: 106px; z-index: 9; font-size: 12.5px; color: #dfe6ef; background: rgba(10,13,20,.55);
  padding: 7px 12px; border-radius: 20px; transition: opacity 1.2s; pointer-events: none; }
#help.fade { opacity: 0; }
#fps { position: fixed; left: 16px; bottom: 16px; z-index: 10; font: 12px/1.3 ui-monospace, Consolas, monospace; color: #cfe; background: rgba(0,0,0,.45); padding: 5px 8px; border-radius: 8px; white-space: pre; }
#attrib { position: fixed; right: 76px; bottom: 8px; z-index: 9; font-size: 10.5px; color: rgba(255,255,255,.65); text-shadow: 0 1px 3px #000; }

/* étiquettes 3D */
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer; white-space: nowrap; text-align: center;
  transition: opacity .25s; will-change: transform, opacity; }
.lbl-box { display: inline-flex; flex-direction: column; align-items: center; background: rgba(12,16,24,.72); border: 1px solid rgba(227,180,92,.45);
  border-radius: 9px; padding: 3px 9px 4px; backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.lbl-fr { font-size: 12.5px; font-weight: 600; color: #fff; }
.lbl-zh { font-size: 11px; color: var(--gold); margin-top: 1px; }
.lbl-stem { width: 1px; height: 18px; margin: 0 auto; background: linear-gradient(rgba(227,180,92,.8), rgba(227,180,92,0)); }
.lbl:hover .lbl-box { border-color: var(--gold); background: rgba(20,26,38,.9); }
.lbl.small .lbl-fr { font-size: 11px; }
.lbl.small .lbl-zh { display: none; }

@media (max-width: 900px) {
  #compass { bottom: 118px; right: 16px; }
}
@media (max-width: 720px) {
  #places { width: calc(100vw - 32px); }
  #card { width: calc(100vw - 32px); top: auto; bottom: 120px; max-height: 45vh; }
  body.card-open #settings-btn, body.card-open #settings { right: 16px; }
  #help { display: none; }
}
