:root {
  --focus: #196b86;
  --panel-width: min(54vw, 860px);
}

html { background: #eef4f7; }

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a, button { -webkit-tap-highlight-color: transparent; }

a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.immersive header .nav {
  min-height: 84px;
}

.immersive nav a {
  position: relative;
  padding: 7px 0;
}

.immersive nav a::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 1px;
  left: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .24s ease;
}

.immersive nav a:hover::after,
.immersive nav a:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

.world-label {
  min-height: 42px;
  border-radius: 999px;
  font-size: 13px;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

.world-label:hover { transform: translate(-50%, -3px); }

#reading-panel {
  width: var(--panel-width);
  scrollbar-width: thin;
  scrollbar-color: #87aab9 transparent;
  animation: panel-enter .38s cubic-bezier(.2,.8,.2,1) both;
}

#reading-panel::after {
  content: '';
  position: fixed;
  inset: 84px var(--panel-width) 0 0;
  pointer-events: none;
}

#panel-content {
  width: min(100%, 760px);
  margin-inline: auto;
}

#panel-content .prose p,
#panel-content .data-card p {
  max-width: 68ch;
}

#panel-content .paper {
  border-radius: 8px;
  padding-inline: 12px;
}

#panel-content .paper h3 a {
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.panel-top {
  min-height: 61px;
}

#close-panel {
  min-width: 74px;
  min-height: 40px;
}

.scene-tools button,
.travel-controls button,
#return-world {
  min-height: 42px;
}

.scene-tools button { backdrop-filter: blur(12px); }

@keyframes panel-enter {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 900px) {
  .immersive header { overflow: hidden; }

  .immersive header .nav {
    min-height: 112px;
  }

  .immersive nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .immersive nav::-webkit-scrollbar { display: none; }
  .immersive nav a { flex: 0 0 auto; min-height: 38px; }

  #reading-panel {
    width: 100%;
    top: 188px;
    border-radius: 22px 22px 0 0;
  }

  #panel-content { width: 100%; }
  .panel-top { min-height: 56px; }
}

@media (max-width: 560px) {
  .scene-tools { gap: 6px; }
  .scene-tools button { padding-inline: 10px; }
  .world-label { min-height: 38px; font-size: 12px; }
  #reading-panel { padding-inline: 18px; }
  #reading-panel .paper { grid-template-columns: 42px 1fr 18px; }
  #reading-panel .paper h3 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
