:root {
  color-scheme: dark;
  --ink: #f5f7ff;
  --muted: #8d96aa;
  --line: rgba(255, 255, 255, .12);
  --panel: rgba(6, 9, 18, .78);
  --accent: #82b8ff;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #02040b;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  background: radial-gradient(circle at 50% 100%, #101a31 0, #03050c 42%, #010208 100%);
}

.navigator {
  position: relative;
  z-index: 10;
  max-height: 270px;
  padding: 10px 14px 11px;
  background: linear-gradient(180deg, rgba(8, 12, 23, .98), rgba(3, 6, 13, .94));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 35px rgba(0, 0, 0, .42);
  overflow: hidden;
  transition: max-height .34s ease, padding .34s ease, border-color .34s ease;
}

.app.nav-collapsed .navigator { max-height: 0; padding-top: 0; padding-bottom: 0; border-color: transparent; }

.navigator-toggle { display: flex; align-items: center; justify-content: center; color: #aab4c8; background: rgba(8, 12, 23, .82); border: 1px solid rgba(255, 255, 255, .14); cursor: pointer; backdrop-filter: blur(12px); transition: color .18s ease, border-color .18s ease, background .18s ease, opacity .2s ease, transform .2s ease; }
.navigator-toggle:hover { color: white; border-color: rgba(130, 184, 255, .55); background: rgba(35, 65, 105, .72); }
.close-navigator { position: absolute; top: 8px; right: 9px; z-index: 2; width: 28px; height: 28px; border-radius: 50%; font-size: 19px; line-height: 1; }
.open-navigator { position: absolute; top: 14px; right: 15px; z-index: 8; gap: 7px; height: 36px; padding: 0 12px; border-radius: 8px; opacity: 0; pointer-events: none; transform: translateY(-6px); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.app.nav-collapsed .open-navigator { opacity: 1; pointer-events: auto; transform: translateY(0); }
.planet-symbol { width: 14px; height: 14px; border: 1.5px solid currentColor; border-radius: 50%; box-shadow: inset -3px -1px 0 rgba(130, 184, 255, .25); }

.body-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(64px, 1fr));
  gap: 5px 7px;
  max-width: 1040px;
  margin: 0 auto;
}

.body-button {
  min-width: 0;
  height: 43px;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  color: #9ca5b8;
  background: rgba(255, 255, 255, .025);
  border: 1px solid rgba(255, 255, 255, .075);
  border-radius: 7px;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease, transform .18s ease;
}

.body-button:hover,
.body-button:focus-visible {
  color: white;
  border-color: rgba(130, 184, 255, .5);
  background: rgba(130, 184, 255, .09);
  outline: none;
  transform: translateY(-1px);
}

.body-button.active {
  color: white;
  border-color: rgba(130, 184, 255, .72);
  background: linear-gradient(100deg, rgba(47, 105, 175, .3), rgba(255, 255, 255, .045));
  box-shadow: inset 0 0 18px rgba(80, 150, 240, .09), 0 0 18px rgba(42, 115, 214, .08);
}

.body-button img {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 50%;
  filter: saturate(.92) contrast(1.05);
}

.sail-thumbnail { position: relative; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; background: radial-gradient(circle, rgba(79, 139, 214, .28), rgba(9, 14, 27, .1) 65%); }
.sail-thumbnail::before { content: ""; position: absolute; left: 7px; top: 7px; width: 17px; height: 17px; background: linear-gradient(135deg, #f7f1cf, #83a9d5); clip-path: polygon(0 0, 100% 50%, 0 100%); filter: drop-shadow(0 0 4px #8ec4ff); }
.sail-thumbnail::after { content: ""; position: absolute; left: 5px; top: 15px; width: 22px; height: 1px; background: #dbeaff; transform: rotate(-14deg); }
.monolith-thumbnail, .par-thumbnail { position: relative; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; background: radial-gradient(circle, rgba(95, 119, 154, .22), rgba(5, 8, 15, .15) 67%); }
.monolith-thumbnail::before { content: ""; position: absolute; left: 12px; top: 5px; width: 8px; height: 22px; border-radius: 1px; background: linear-gradient(110deg, #020204 30%, #657083 48%, #050508 60%); box-shadow: 0 0 5px rgba(190, 215, 255, .25); transform: perspective(20px) rotateY(-12deg); }
.par-thumbnail::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d5964a, #653019 65%, #160b09); box-shadow: inset 0 0 0 2px #d6ad68; }
.par-thumbnail::after { content: ""; position: absolute; left: 5px; right: 5px; top: 14px; height: 4px; border: 1px solid #f0c06c; border-radius: 50%; transform: rotate(-18deg); }

.body-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .035em;
}

.viewport { position: relative; min-height: 0; overflow: hidden; }

.top-actions { position: absolute; top: 14px; right: 10px; z-index: 12; display: flex; align-items: center; gap: 5px; }
.top-action { height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 8px; color: #aeb8ca; background: rgba(7, 11, 21, .8); border: 1px solid rgba(255, 255, 255, .13); border-radius: 8px; cursor: pointer; box-shadow: 0 7px 24px rgba(0, 0, 0, .3); backdrop-filter: blur(13px); font-size: 9.5px; font-weight: 680; letter-spacing: .025em; transition: color .18s ease, border-color .18s ease, background .18s ease; }
.top-action:hover, .top-action:focus-visible { color: white; border-color: rgba(130, 184, 255, .5); background: rgba(35, 65, 105, .68); outline: none; }
.top-action.active { color: #e1edff; border-color: rgba(130, 184, 255, .43); background: rgba(70, 126, 198, .2); }
.top-action.icon-only { width: 38px; padding: 0; justify-content: center; }
.top-action .sail-thumbnail, .top-action .monolith-thumbnail, .top-action .par-thumbnail { width: 20px; height: 20px; }
.top-action .sail-thumbnail::before { left: 4px; top: 4px; width: 11px; height: 11px; }
.top-action .sail-thumbnail::after { left: 3px; top: 9px; width: 14px; }
.top-action .monolith-thumbnail::before { left: 7px; top: 2px; width: 6px; height: 16px; }
.top-action .par-thumbnail::before { inset: 4px; }
.top-action .par-thumbnail::after { left: 2px; right: 2px; top: 8px; height: 3px; }
.fullscreen-symbol { position: relative; width: 16px; height: 16px; background: linear-gradient(#b9c6db, #b9c6db) left top / 6px 1px no-repeat, linear-gradient(#b9c6db, #b9c6db) left top / 1px 6px no-repeat, linear-gradient(#b9c6db, #b9c6db) right top / 6px 1px no-repeat, linear-gradient(#b9c6db, #b9c6db) right top / 1px 6px no-repeat, linear-gradient(#b9c6db, #b9c6db) left bottom / 6px 1px no-repeat, linear-gradient(#b9c6db, #b9c6db) left bottom / 1px 6px no-repeat, linear-gradient(#b9c6db, #b9c6db) right bottom / 6px 1px no-repeat, linear-gradient(#b9c6db, #b9c6db) right bottom / 1px 6px no-repeat; }
.fullscreen-symbol.exit { transform: scale(.8); box-shadow: 0 0 0 1px #b9c6db; background: none; }
.vr-symbol { position: relative; width: 19px; height: 11px; border: 1.5px solid currentColor; border-radius: 4px 4px 7px 7px; }
.vr-symbol::before { content: ""; position: absolute; left: 50%; top: -1.5px; width: 1px; height: 8px; background: currentColor; transform: translateX(-50%); }
.vr-symbol::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: -4px; height: 5px; border-left: 1px solid currentColor; border-right: 1px solid currentColor; transform: skewX(-22deg); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(0, 2, 8, .72); backdrop-filter: blur(12px); }
.modal-backdrop[hidden] { display: none; }
.vr-modal { position: relative; width: min(430px, 100%); padding: 34px 34px 28px; text-align: center; background: linear-gradient(155deg, rgba(18, 27, 45, .98), rgba(5, 9, 18, .98)); border: 1px solid rgba(137, 184, 246, .3); border-radius: 16px; box-shadow: 0 25px 90px rgba(0, 0, 0, .72), inset 0 0 50px rgba(71, 131, 211, .045); }
.modal-close { position: absolute; top: 10px; right: 11px; width: 30px; height: 30px; color: #8f9bb0; background: transparent; border: 0; border-radius: 50%; cursor: pointer; font-size: 21px; }
.modal-close:hover { color: white; background: rgba(255, 255, 255, .07); }
.modal-vr-symbol { display: inline-block; width: 39px; height: 23px; color: #91bfff; filter: drop-shadow(0 0 10px rgba(86, 155, 246, .45)); }
.modal-vr-symbol::before { height: 18px; }
.modal-vr-symbol::after { left: 7px; right: 7px; bottom: -7px; height: 8px; }
.modal-kicker { margin: 22px 0 3px; color: #7eacf0; font-size: 9px; font-weight: 800; letter-spacing: .23em; }
.vr-modal h2 { margin: 0; font-size: 27px; font-weight: 560; }
.vr-modal > p:not(.modal-kicker):not(.vr-status) { margin: 12px auto 0; max-width: 330px; color: #a4aec0; font-size: 13px; line-height: 1.55; }
.vr-status { min-height: 18px; margin: 18px 0 0; color: #d6e5fb; font-size: 11px; }
.vr-status.unavailable { color: #e0a896; }
.modal-actions { display: flex; justify-content: center; gap: 9px; margin-top: 22px; }
.modal-button { min-width: 118px; height: 38px; border-radius: 7px; cursor: pointer; font-size: 12px; }
.modal-button.secondary { color: #b0b9c9; background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .12); }
.modal-button.primary { color: #07101e; background: #91bfff; border: 1px solid #b6d5ff; font-weight: 750; }
.modal-button.primary:disabled { color: #697386; background: #242b38; border-color: #363f50; cursor: not-allowed; }

#renderCanvas, #detailCanvas, #parDetailCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  opacity: 0;
  transition: opacity 2s ease;
  outline: none;
}

#renderCanvas.ready { opacity: 1; }
#detailCanvas, #parDetailCanvas { opacity: 0; pointer-events: none; background: white; }
.app.scene-two #renderCanvas { opacity: 0; pointer-events: none; }
.app.scene-two #detailCanvas { opacity: 1; pointer-events: auto; }
.app.scene-three #renderCanvas { opacity: 0; pointer-events: none; }
.app.scene-three #parDetailCanvas { opacity: 1; pointer-events: auto; }
.app.scene-two .vignette, .app.scene-two .selection, .app.scene-two .help, .app.scene-two .top-actions,
.app.scene-three .vignette, .app.scene-three .selection, .app.scene-three .help, .app.scene-three .top-actions { opacity: 0; pointer-events: none; }

.detail-actions { position: absolute; top: 16px; right: 16px; z-index: 14; opacity: 0; pointer-events: none; transition: opacity .35s ease .7s; }
.app.scene-two .detail-actions-sail, .app.scene-three .detail-actions-par { opacity: 1; pointer-events: auto; }
.return-button { height: 40px; padding: 0 16px; color: #253247; background: rgba(255, 255, 255, .88); border: 1px solid rgba(20, 38, 65, .2); border-radius: 9px; box-shadow: 0 8px 28px rgba(35, 55, 80, .16); cursor: pointer; font-weight: 700; }
.return-button:hover { background: white; border-color: rgba(32, 82, 145, .42); }

.memory-monitor { position: absolute; left: 16px; bottom: 14px; z-index: 20; display: grid; grid-template-columns: auto; gap: 2px; min-width: 285px; padding: 9px 12px; color: #aeb9ca; background: rgba(4, 8, 16, .75); border: 1px solid rgba(255, 255, 255, .12); border-radius: 9px; box-shadow: 0 8px 30px rgba(0, 0, 0, .32); backdrop-filter: blur(12px); font: 10px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; transition: color .4s, background .4s, border-color .4s; }
.memory-title { color: #82b8ff; font-size: 8px; font-weight: 800; letter-spacing: .18em; }
.app.scene-two .memory-monitor, .app.scene-three .memory-monitor { color: #37465b; background: rgba(255, 255, 255, .86); border-color: rgba(34, 58, 88, .18); box-shadow: 0 8px 30px rgba(45, 65, 90, .12); }
.app.scene-two .memory-title, .app.scene-three .memory-title { color: #2867a8; }
.vignette, .selection, .help, .top-actions { transition: opacity .35s ease; }

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 130px rgba(0, 0, 0, .72);
}

.selection {
  position: absolute;
  top: 22px;
  left: 24px;
  display: grid;
  gap: 1px;
  padding-left: 13px;
  border-left: 2px solid var(--accent);
  text-shadow: 0 2px 8px #000;
  pointer-events: none;
}

.selection-kicker {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .22em;
}

.selection strong { font-size: clamp(22px, 3vw, 34px); font-weight: 530; letter-spacing: -.02em; }
.selection > span:last-child { color: var(--muted); font-size: 11px; }

.controls {
  position: absolute;
  right: 22px;
  bottom: 30px;
  display: flex;
  align-items: center;
  gap: 13px;
  width: auto;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  backdrop-filter: blur(16px);
}

.control-button {
  height: 38px;
  color: #b8c0d0;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 7px;
  cursor: pointer;
}

.control-button:hover { color: white; border-color: rgba(255, 255, 255, .28); }
.icon-button { width: 42px; flex: 0 0 42px; font-size: 14px; font-weight: 750; }
.toggle { display: flex; align-items: center; gap: 8px; padding: 0 13px; font-size: 12px; }
.toggle.active { color: #dceaff; border-color: rgba(130, 184, 255, .43); background: rgba(86, 151, 235, .13); }

.orbit-symbol {
  width: 15px;
  height: 8px;
  border: 1px solid currentColor;
  border-radius: 50%;
  transform: rotate(-18deg);
}

.help {
  position: absolute;
  right: 18px;
  bottom: 9px;
  color: rgba(210, 220, 240, .42);
  font-size: 9px;
  pointer-events: none;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  color: #7f899d;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: #02040b;
  transition: opacity .5s ease;
}

.loading.hidden { opacity: 0; pointer-events: none; }
.loading-orbit { width: 42px; height: 18px; border: 1px solid #528ed8; border-radius: 50%; animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .navigator { padding: 7px; overflow-x: auto; }
  .navigator::-webkit-scrollbar { display: none; }
  .body-grid { min-width: 650px; gap: 4px; }
  .body-button { height: 38px; gap: 5px; }
  .body-button img { width: 27px; height: 27px; }
  .body-button span { font-size: 9px; }
  .selection { top: 14px; left: 14px; }
  .controls { right: 13px; bottom: 18px; gap: 8px; }
  .top-actions { top: 8px; right: 8px; gap: 4px; }
  .top-action { padding: 0 7px; }
  .top-action > span:last-child:not(.fullscreen-symbol) { display: none; }
  .help { display: none; }
}
