:root {
  --paper: #efe9dc;
  --ink: #2b2824;
  --ink-soft: #5d564c;
  --bronze: #8a6a3b;
  --gold: #c79a4e;
  --card: rgba(250, 246, 237, 0.86);
  --line: rgba(43, 40, 36, 0.16);
  --serif: 'Playfair Display', 'Times New Roman', serif;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.orbit { overflow: hidden; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
body.orbit #gl { cursor: grab; }
#scroll-space { height: 2500vh; pointer-events: none; position: relative; z-index: 1; }

#vignette { position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(20, 12, 4, 0) 52%, rgba(20, 12, 4, 0.3) 100%); }

/* ---------- nhãn bám mô hình ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
#labels > div { position: absolute; left: 0; top: 0; opacity: 0; will-change: transform, opacity; transition: opacity 0.2s linear; }

.plan-label { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 0; white-space: nowrap; margin-top: -11px; }
.plan-label i {
  width: 22px; height: 22px; border-radius: 50%; background: var(--bronze); color: #fff;
  font: 600 11px/22px var(--sans); text-align: center; font-style: normal; flex: none;
  box-shadow: 0 0 0 2px rgba(250, 246, 237, 0.9);
}
.plan-label span {
  font: 600 9.5px/1.25 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink);
  background: rgba(250, 246, 237, 0.78); padding: 1px 5px; border-radius: 2px; text-align: center;
}
.plan-label.minor span { font-weight: 500; font-size: 8.5px; color: var(--ink-soft); background: none; }

.dim { width: 0; height: 0; }
.dim span { position: absolute; left: 0; top: 0; translate: -50% -50%; font: 500 11px/1 var(--sans); letter-spacing: 0.1em; color: var(--ink); background: #e9e3d5; padding: 3px 7px; white-space: nowrap; }
.dim.vert span { rotate: -90deg; }

.callout { display: flex; align-items: flex-start; gap: 10px; color: #fff; text-shadow: 0 1px 10px rgba(30, 20, 8, 0.75); max-width: 250px; }
.callout i { width: 9px; height: 9px; border-radius: 50%; background: #fff; margin: 5px 0 0 -4px; flex: none; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.28); }
.callout div { border-left: 1px solid rgba(255, 255, 255, 0.75); padding-left: 10px; }
.callout b { display: block; font: 600 13px/1.3 var(--sans); }
.callout span { font: 400 12px/1.4 var(--sans); opacity: 0.94; }
.callout.left { flex-direction: row-reverse; margin-left: -250px; width: 250px; text-align: right; }
.callout.left i { margin: 5px -4px 0 0; }
.callout.left div { border-left: 0; border-right: 1px solid rgba(255, 255, 255, 0.75); padding: 0 10px 0 0; }

/* ---------- HUD ---------- */
.hud-top {
  position: fixed; inset: 0 0 auto 0; z-index: 10; pointer-events: none;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 14px 22px;
}
.brand { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px 8px; backdrop-filter: blur(6px); }
.brand span { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft); }
.brand strong { font: 500 19px/1.3 var(--serif); }
.readout {
  font: 500 11px/1.5 var(--sans); letter-spacing: 0.04em; text-align: right; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px 10px;
  display: flex; flex-direction: column; min-width: 232px; font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
}
.bar { position: relative; height: 3px; background: rgba(43, 40, 36, 0.12); margin-top: 6px; border-radius: 2px; overflow: hidden; }
#ro-bar { position: absolute; inset: 0; background: var(--bronze); transform-origin: left; transform: scaleX(0); z-index: 2; }
.bar-built { position: absolute; inset: 0 0 0 0; background: rgba(138, 106, 59, 0.28); }

/* ---------- chú thích chặng ---------- */
.caption { position: fixed; z-index: 8; pointer-events: none; max-width: 430px; visibility: hidden; opacity: 0; }
#cap-plan { visibility: visible; opacity: 1; }
.caption.right { right: clamp(24px, 5vw, 84px); top: 50%; translate: 0 -50%; }
.caption ul { margin: 0 0 12px; padding-left: 18px; color: var(--ink-soft); }
.caption.dark ul { color: #fff; text-shadow: 0 2px 18px rgba(25, 16, 6, 0.75); }
.caption .trio { display: flex; gap: 18px; margin-top: 8px; }
.caption .trio div { flex: 1; font-size: 12.5px; line-height: 1.45; color: #fff; text-shadow: 0 1px 14px rgba(25, 16, 6, 0.85); }
.caption .trio b { display: block; font: 600 15px/1.4 var(--sans); color: #f2d49a; }
#cap-cinema { max-width: 560px; }
.caption.left { left: clamp(24px, 4.5vw, 72px); bottom: 132px; }
#cap-hall { bottom: auto; top: 104px; }
.caption .kicker { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--bronze); margin: 0 0 10px; font-weight: 600; }
.caption h1 { font: 400 clamp(30px, 3.5vw, 50px)/1.14 var(--serif); margin: 0 0 22px; }
.caption h2 { font: 400 clamp(26px, 2.9vw, 42px)/1.16 var(--serif); margin: 0 0 12px; }
.caption p { margin: 0 0 12px; color: var(--ink-soft); }
.caption ol { margin: 0 0 22px; padding-left: 22px; font-size: 16px; line-height: 1.75; }
.caption ol li::marker { color: var(--bronze); font-weight: 600; }
.caption .note { background: rgba(226, 216, 196, 0.72); border: 1px solid rgba(138, 106, 59, 0.35); padding: 14px 18px; color: var(--ink); font-size: 14px; }
.caption .hint { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bronze); margin-top: 18px; }
.caption .hint i { display: inline-block; font-style: normal; animation: bob 1.6s ease-in-out infinite; }
.caption .tagline { font: italic 400 19px/1.4 var(--serif); }
.caption.dark h2, .caption.dark p { color: #fff; text-shadow: 0 2px 22px rgba(25, 16, 6, 0.7), 0 0 2px rgba(25, 16, 6, 0.45); }
.caption.dark .kicker { color: #f2d49a; text-shadow: 0 1px 12px rgba(25, 16, 6, 0.8); }
@keyframes bob { 50% { transform: translateY(5px); } }

/* ---------- thanh chặng ---------- */
#stages {
  position: fixed; z-index: 12; left: 50%; bottom: 18px; translate: -50% 0;
  display: flex; gap: 6px; padding: 6px; max-width: calc(100vw - 24px); overflow-x: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(8px);
}
.stage {
  font-family: var(--sans); border: 0; background: transparent; color: var(--ink); cursor: pointer;
  padding: 6px 10px 7px; border-radius: 8px; text-align: left; display: flex; flex-direction: column; gap: 1px; white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.stage i { font: 500 10px/1.3 var(--sans); letter-spacing: 0.08em; color: var(--ink-soft); font-style: normal; font-variant-numeric: tabular-nums; }
.stage b { font: 600 12px/1.3 var(--sans); }
.stage em { font: 500 9.5px/1 var(--sans); font-style: normal; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.stage:hover:not(:disabled) { background: rgba(138, 106, 59, 0.12); }
.stage.active, .stage.active:hover:not(:disabled) { background: var(--ink); color: #fff; }
.stage.active i { color: #e7cf9f; }
.stage.todo { opacity: 0.45; cursor: not-allowed; }
.stage:focus-visible, #panel button:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }

/* ---------- bảng nghiệm thu ---------- */
#panel {
  position: fixed; z-index: 12; left: 50%; top: 14px; translate: -50% 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; backdrop-filter: blur(8px);
  max-width: min(820px, calc(100vw - 24px));
}
.panel-title { margin: 0 2px 0 4px; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--bronze); font-weight: 600; }
#panel button {
  font: 500 12px/1.3 var(--sans); text-align: left; padding: 6px 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: #fbf8f1; color: var(--ink); white-space: nowrap;
}
#panel button span { font-weight: 600; color: var(--bronze); }
#panel button:disabled { opacity: 0.55; cursor: not-allowed; }
#panel button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
#panel button[aria-pressed="true"] span { color: #e7cf9f; }
#panel label { font-size: 11px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#panel input[type="range"] { width: 110px; accent-color: var(--bronze); }
.panel-help { margin: 0; flex-basis: 100%; text-align: center; font-size: 10.5px; line-height: 1.45; color: var(--ink-soft); display: none; }
body.orbit .panel-help { display: block; }
body.orbit .caption { display: none; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; background: var(--paper); display: grid; place-items: center;
  transition: opacity 0.9s ease, visibility 0.9s; text-align: center;
}
#loader.done { opacity: 0; visibility: hidden; }
#loader strong { display: block; font: 400 28px/1.3 var(--serif); margin-bottom: 8px; }
#loader span { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }

@media (max-width: 1560px) {
  #panel { top: 84px; }
  #cap-hall { top: 148px; }
}
@media (max-width: 820px) {
  .hud-top { padding: 10px 10px; gap: 8px; }
  .brand { padding: 6px 9px; }
  .brand span { display: none; }
  .brand strong { font-size: 13px; }
  .readout { min-width: 0; font-size: 9.5px; padding: 6px 8px 7px; }
  #ro-clip { display: none; }
  #panel { top: 54px; padding: 5px 7px; gap: 6px; width: max-content; }
  .panel-title, #panel label { display: none; }
  body.orbit #panel label { display: flex; }
  #panel button { font-size: 11px; padding: 5px 8px; }
  .caption.right, .caption.left, #cap-hall {
    left: 12px; right: 12px; top: auto; bottom: 86px; translate: none; max-width: none;
  }
  .caption h1 { font-size: 24px; margin-bottom: 6px; }
  .caption h2 { font-size: 22px; margin-bottom: 6px; }
  .caption .kicker { margin-bottom: 4px; font-size: 10px; }
  .caption p { font-size: 13px; margin-bottom: 4px; }
  .caption ol, .caption .note { display: none; }
  .caption .hint { margin-top: 6px; font-size: 10.5px; }
  .caption .tagline { font-size: 15px; }
  .plan-label span, .plan-label.minor, .callout span { display: none; }
  .plan-label i { width: 18px; height: 18px; font-size: 10px; line-height: 18px; }
  .callout { max-width: 150px; }
  .callout.left { margin-left: -150px; width: 150px; }
  #stages { bottom: 10px; }
  .stage { padding: 6px 10px 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .caption .hint i { animation: none; }
}
