:root {
  --bg: #030713;
  --bg-2: #081426;
  --surface: rgba(10, 23, 43, 0.72);
  --text: #edf8ff;
  --muted: #91a9bd;
  --accent: #67e8f9;
  --accent-2: #f4c978;
  --radius: 18px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --glass-line: rgba(166, 224, 255, 0.16);
  --glass-highlight: rgba(255, 255, 255, 0.065);
  --panel-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="range"] {
  min-height: 44px;
}

button {
  color: inherit;
}

button:not(:disabled),
select:not(:disabled),
input:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

button,
select {
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  background: rgba(10, 27, 48, 0.72);
  color: var(--text);
}

button {
  padding: 0.68rem 0.95rem;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(103, 232, 249, 0.52);
  background: rgba(24, 55, 78, 0.82);
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

select {
  max-width: 100%;
  padding: 0.6rem 2.2rem 0.6rem 0.75rem;
  color-scheme: dark;
}

[hidden],
.hidden {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(18, 49, 77, 0.24), transparent 54%),
    #020611;
  touch-action: none;
}

#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
  touch-action: none;
}

.glass {
  border: 1px solid var(--glass-line);
  background:
    linear-gradient(145deg, var(--glass-highlight), transparent 42%),
    rgba(7, 18, 35, 0.69);
  box-shadow: var(--panel-shadow), inset 0 1px rgba(255, 255, 255, 0.035);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
  backdrop-filter: blur(20px) saturate(135%);
}

.topbar {
  position: fixed;
  z-index: 30;
  top: calc(14px + var(--safe-top));
  right: calc(18px + var(--safe-right));
  left: calc(18px + var(--safe-left));
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.topbar .glass {
  border-radius: 16px;
}

.topbar h1,
.topbar .title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar .gradient-text {
  background: linear-gradient(100deg, #f2fbff, #79e6f5 58%, #f5d08a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#dateReadout {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(103, 232, 249, 0.12);
  border-radius: 999px;
  background: rgba(3, 12, 25, 0.36);
  color: #c7e5f2;
  font-family: var(--display);
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.045em;
  white-space: nowrap;
}

#objectList {
  position: fixed;
  z-index: 20;
  top: calc(92px + var(--safe-top));
  bottom: calc(112px + var(--safe-bottom));
  left: calc(18px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 218px;
  padding: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: var(--radius);
  scrollbar-color: rgba(103, 232, 249, 0.25) transparent;
  scrollbar-width: thin;
}

#objectList::-webkit-scrollbar,
#discoveriesList::-webkit-scrollbar,
#objectFacts::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

#objectList::-webkit-scrollbar-thumb,
#discoveriesList::-webkit-scrollbar-thumb,
#objectFacts::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(103, 232, 249, 0.25);
}

.object-row {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 9px 11px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #b7cada;
  text-align: left;
  white-space: nowrap;
}

.object-row::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  content: "";
  opacity: 0.6;
}

.object-row:hover {
  border-color: rgba(145, 207, 235, 0.13);
  background: rgba(116, 191, 222, 0.07);
  color: #effbff;
}

.object-row.active {
  border-color: rgba(103, 232, 249, 0.34);
  background: linear-gradient(90deg, rgba(56, 202, 224, 0.17), rgba(56, 202, 224, 0.035));
  color: #a8f3ff;
  box-shadow: inset 3px 0 var(--accent);
}

.object-row.active::before {
  opacity: 1;
  box-shadow: 0 0 14px var(--accent);
}

#labels {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}

.label {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid rgba(158, 214, 237, 0.16);
  border-radius: 999px;
  background: rgba(2, 10, 23, 0.56);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  color: #c1d8e6;
  font-size: 0.69rem;
  font-weight: 550;
  letter-spacing: 0.035em;
  line-height: 1;
  white-space: nowrap;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
  user-select: none;
  touch-action: manipulation;
}

.label::before {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.label:hover,
.label.selected {
  border-color: rgba(103, 232, 249, 0.72);
  background: rgba(8, 39, 55, 0.86);
  color: #bdf7ff;
  box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.08), 0 0 24px rgba(103, 232, 249, 0.2);
}

.label.selected::after {
  position: absolute;
  inset: -7px;
  border: 1px solid rgba(103, 232, 249, 0.36);
  border-radius: inherit;
  content: "";
  animation: reticle 2.2s ease-in-out infinite;
  pointer-events: none;
}

.dock {
  position: fixed;
  z-index: 25;
  right: calc(18px + var(--safe-right));
  bottom: calc(18px + var(--safe-bottom));
  left: calc(254px + var(--safe-left));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 68px;
  padding: 10px 12px;
  border-radius: 18px;
}

.dock button,
.dock select {
  min-height: 44px;
}

.dock .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#playPause,
#modeSelect,
#skyView,
#systemView,
#discoveriesBtn,
#soundBtn {
  min-height: 44px;
}

#playPause,
#skyView,
#systemView {
  font-weight: 600;
}

#skyView:not(.hidden),
#systemView.active {
  border-color: rgba(103, 232, 249, 0.42);
  color: #b8f6ff;
}

#speed {
  width: clamp(110px, 13vw, 190px);
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

#speed::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(103, 232, 249, 0.72), rgba(125, 145, 169, 0.25));
}

#speed::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 2px solid #d8fbff;
  border-radius: 50%;
  background: #35bad0;
  box-shadow: 0 0 14px rgba(103, 232, 249, 0.55);
  -webkit-appearance: none;
}

#speed::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(103, 232, 249, 0.45);
}

#speed::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #d8fbff;
  border-radius: 50%;
  background: #35bad0;
}

#detailPanel {
  position: fixed;
  z-index: 35;
  top: calc(92px + var(--safe-top));
  right: calc(18px + var(--safe-right));
  display: flex;
  flex-direction: column;
  width: min(350px, calc(100vw - 36px));
  max-height: calc(100dvh - 200px - var(--safe-top) - var(--safe-bottom));
  padding: 22px;
  overflow: hidden;
  border-radius: 22px;
  animation: panel-in 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#closeDetail {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 44px;
  min-width: 44px;
  padding: 0;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
}

#objectName {
  margin: 0 40px 4px 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  font-weight: 550;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

#objectType {
  margin: 0 0 16px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#objectFacts {
  min-height: 0;
  margin: 0 -5px 16px 0;
  padding: 0 8px 0 0;
  overflow-y: auto;
  color: #bfd0dd;
  font-size: 0.88rem;
  line-height: 1.6;
}

.fact {
  position: relative;
  margin: 0 0 11px;
  padding: 0 0 11px 16px;
  border-bottom: 1px solid rgba(155, 207, 231, 0.09);
}

.fact::before {
  position: absolute;
  top: 0.62em;
  left: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 9px rgba(244, 201, 120, 0.48);
  content: "";
}

.fact:last-child {
  border-bottom: 0;
}

.fact b,
.fact strong {
  color: #f0f8fc;
  font-weight: 600;
}

#focusBtn,
#discoverBtn {
  flex: 1 1 0;
  min-height: 46px;
}

#discoverBtn {
  border-color: rgba(244, 201, 120, 0.42);
  background: linear-gradient(135deg, rgba(244, 201, 120, 0.19), rgba(103, 232, 249, 0.08));
  color: #ffe4ab;
}

#discoverBtn:hover:not(:disabled) {
  border-color: rgba(244, 201, 120, 0.75);
  background: rgba(244, 201, 120, 0.2);
}

#discoveriesPanel {
  position: fixed;
  z-index: 45;
  top: calc(86px + var(--safe-top));
  right: calc(18px + var(--safe-right));
  bottom: calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 36px));
  padding: 22px;
  overflow: hidden;
  border-radius: 22px;
  animation: panel-in 280ms ease-out;
}

#discoveriesPanel h2,
#discoveriesPanel .title {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 550;
}

#discoveriesList {
  min-height: 0;
  margin: 14px -6px 14px 0;
  padding-right: 8px;
  overflow-y: auto;
}

#discoveriesList > * {
  margin-bottom: 9px;
  padding: 13px 14px;
  border: 1px solid rgba(151, 211, 236, 0.11);
  border-radius: 13px;
  background: rgba(96, 170, 203, 0.045);
  color: #c5d8e4;
  font-size: 0.84rem;
  line-height: 1.5;
}

#discoveriesList h3,
#discoveriesList strong {
  color: #f2fbff;
  font-family: var(--display);
}

/* Sky owns the time and location controls; the system camera dock is not part of this view. */
#observatory.mode-sky #time-dock {
  display: none;
}

#resetDiscoveries {
  min-height: 44px;
  border-color: rgba(255, 137, 151, 0.2);
  color: #f1b7bf;
}

#toast {
  position: fixed;
  z-index: 100;
  top: calc(88px + var(--safe-top));
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 13px 18px;
  border: 1px solid rgba(103, 232, 249, 0.38);
  border-radius: 999px;
  background: rgba(5, 25, 40, 0.9);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.42), 0 0 25px rgba(103, 232, 249, 0.1);
  color: #dffbff;
  font-size: 0.86rem;
  text-align: center;
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  animation: toast-in 300ms cubic-bezier(0.2, 0.85, 0.25, 1);
  pointer-events: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right))
    calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 30%, rgba(24, 87, 111, 0.28), transparent 45%),
    rgba(1, 5, 14, 0.64);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  place-items: center;
}

.overlay > .panel {
  position: relative;
  width: min(570px, 100%);
  padding: clamp(28px, 5vw, 52px);
  overflow: hidden;
  border: 1px solid rgba(157, 224, 246, 0.2);
  border-radius: 28px;
  background:
    radial-gradient(circle at 85% 0%, rgba(244, 201, 120, 0.1), transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.065), transparent 45%),
    rgba(5, 16, 32, 0.87);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.overlay > .panel::before {
  position: absolute;
  top: 0;
  left: 20%;
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  content: "";
}

.overlay .title {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: clamp(2rem, 6vw, 3.8rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 1;
}

.overlay p {
  max-width: 42ch;
  margin: 0 auto 24px;
  color: #a9c0d0;
  line-height: 1.65;
}

#enter {
  min-width: 190px;
  min-height: 52px;
  padding: 0.85rem 1.8rem;
  border-color: rgba(103, 232, 249, 0.65);
  border-radius: 999px;
  background: linear-gradient(110deg, #b7f5fc, #63d8e9);
  box-shadow: 0 8px 32px rgba(61, 202, 224, 0.22);
  color: #03202a;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.02em;
}

#enter:hover:not(:disabled) {
  background: linear-gradient(110deg, #d8fbff, #83e6f2);
  box-shadow: 0 10px 40px rgba(61, 202, 224, 0.34);
  color: #03202a;
}

#skyCanvas {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
}

#skyPlace,
#skyDate,
#backSystem {
  position: relative;
  z-index: 40;
  min-height: 44px;
}

#skyDate {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  background: rgba(7, 18, 35, 0.67);
  color: #bdd6e5;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
}

#backSystem {
  border-color: rgba(103, 232, 249, 0.35);
  color: #baf5fc;
}

.muted {
  color: var(--muted);
}

.badge,
.chip {
  border-color: rgba(103, 232, 249, 0.18);
  background: rgba(103, 232, 249, 0.065);
  color: #bceaf2;
}

.progress {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(137, 179, 199, 0.13);
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #36b9ce, #9cf2fc, #f4c978);
  box-shadow: 0 0 12px rgba(103, 232, 249, 0.35);
  transition: width 400ms ease;
}

@keyframes reticle {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.96);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.06);
  }
}

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

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@media (max-width: 900px) {
  .topbar {
    gap: 8px;
  }

  #objectList {
    width: 188px;
  }

  .dock {
    left: calc(218px + var(--safe-left));
    flex-wrap: wrap;
  }

  #detailPanel {
    width: min(325px, calc(100vw - 36px));
  }
}

@media (max-width: 700px) {
  .topbar {
    top: calc(8px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    left: calc(8px + var(--safe-left));
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 8px 10px;
    border-radius: 15px;
  }

  .brand,
  .status,
  .brand > div {
    min-width: 0;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 1.25rem;
  }

  .brand strong {
    font-size: 0.88rem;
    letter-spacing: 0.11em;
    white-space: nowrap;
  }

  .brand span:not(.brand-mark) {
    font-size: 0.62rem;
  }

  .topbar h1,
  .topbar .title {
    font-size: 1rem;
  }

  .status {
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    margin-left: 0;
  }

  #dateReadout {
    min-width: 0;
    min-height: 30px;
    padding: 0.25rem 0.5rem;
    overflow: hidden;
    font-size: 0.62rem;
    text-overflow: ellipsis;
  }

  .badge,
  .chip {
    flex-shrink: 0;
    font-size: 0.58rem;
  }

  #objectList {
    top: auto;
    right: calc(8px + var(--safe-right));
    bottom: calc(124px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    flex-direction: row;
    gap: 6px;
    width: auto;
    max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    min-width: 0;
    height: 52px;
    padding: 4px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 15px;
    scroll-padding: 6px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .object-row {
    justify-content: center;
    width: auto;
    min-width: max-content;
    min-height: 42px;
    padding: 6px 12px;
    scroll-snap-align: center;
    font-size: 0.78rem;
  }

  .object-row small {
    display: none;
  }

  .object-row.active {
    box-shadow: inset 0 -2px var(--accent);
  }

  .dock {
    right: calc(8px + var(--safe-right));
    bottom: calc(8px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    width: auto;
    max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    min-width: 0;
    min-height: 0;
    padding: 7px;
    overflow: hidden;
  }

  .dock > * {
    width: 100%;
    min-width: 0;
  }

  .dock button,
  .dock select {
    padding: 0 4px;
    overflow: hidden;
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #playPause {
    grid-column: span 1;
  }

  #modeSelect {
    grid-column: span 3;
  }

  #focusButton {
    grid-column: span 2;
  }

  .speed-group {
    grid-column: span 2;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
  }

  .speed-group label {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: 0.58rem;
    text-overflow: ellipsis;
  }

  #speed {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
  }

  #discoverButton,
  #soundBtn {
    grid-column: span 1;
  }

  #discoveriesButton {
    grid-column: span 2;
  }

  #detailPanel {
    top: auto;
    right: calc(8px + var(--safe-right));
    bottom: calc(184px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    width: auto;
    max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    min-width: 0;
    max-height: min(30dvh, 230px);
    border-radius: 18px;
    animation-name: sheet-in;
  }

  .detail-header {
    padding: 8px 12px 7px;
  }

  .detail-header h2 {
    font-size: 1.2rem;
  }

  .detail-body {
    min-height: 0;
    padding: 10px 12px 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .detail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 10px 0;
  }

  .detail-stats > div {
    min-width: 0;
    padding: 7px 9px;
  }

  .detail-stats dd {
    overflow-wrap: anywhere;
    font-size: 0.78rem;
  }

  .fact {
    font-size: 0.78rem;
    line-height: 1.5;
  }

  #discoveriesPanel {
    top: auto;
    right: calc(8px + var(--safe-right));
    bottom: calc(124px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    width: auto;
    max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    min-width: 0;
    max-height: min(52dvh, 380px);
    border-radius: 18px;
  }

  .discovery-body {
    min-height: 0;
    overflow-y: auto;
  }

  #skyBar {
    top: calc(100px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    left: calc(8px + var(--safe-left));
    flex-wrap: wrap;
    gap: 6px;
    width: auto;
    max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    min-width: 0;
    padding: 6px;
  }

  #skyBar > * {
    min-width: 0;
  }

  #skyPlace {
    flex: 1 1 110px;
    width: auto;
    padding: 0 24px 0 8px;
    font-size: 0.75rem;
  }

  #backSystem {
    padding: 0 8px;
    font-size: 0.75rem;
  }

  .sky-hint {
    top: calc(154px + var(--safe-top));
    right: 12px;
    left: 12px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px 12px;
    width: auto;
    max-width: calc(100vw - 24px);
    font-size: 0.65rem;
  }

  #skyCredit {
    right: calc(12px + var(--safe-right));
    bottom: calc(184px + var(--safe-bottom));
    left: calc(12px + var(--safe-left));
    max-width: calc(100vw - 24px - var(--safe-left) - var(--safe-right));
    font-size: 0.62rem;
    line-height: 1.4;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .overlay {
    inset: 12px;
    width: auto;
    max-width: calc(100vw - 24px);
    border-radius: 22px;
  }

  .overlay-inner {
    max-width: 100%;
    max-height: calc(100dvh - 24px);
    padding: 24px 20px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .overlay h2 {
    font-size: 2.2rem;
    overflow-wrap: anywhere;
  }

  .overlay-features {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 20px 0;
    text-align: left;
  }

  .overlay .fine-print {
    margin-top: 16px;
    font-size: 0.68rem;
  }

  .overlay a {
    overflow-wrap: anywhere;
  }

  #toast {
    top: calc(100px + var(--safe-top));
    width: calc(100vw - 32px - var(--safe-left) - var(--safe-right));
    max-width: 420px;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 380px) {
  .brand strong {
    font-size: 0.8rem;
  }

  .status {
    gap: 4px;
  }

  #dateReadout {
    font-size: 0.58rem;
  }

  .dock {
    gap: 4px;
    padding: 6px;
  }

  .dock button,
  .dock select {
    font-size: 0.62rem;
  }

  #objectList {
    bottom: calc(122px + var(--safe-bottom));
  }

  #detailPanel {
    bottom: calc(182px + var(--safe-bottom));
  }
}

/* Keep navigator guidance as normal horizontal helper text at every breakpoint. */
#navigator .navigator-hint.muted {
  position: static;
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: auto;
  flex: 0 0 auto;
  writing-mode: horizontal-tb;
  white-space: normal;
  overflow-wrap: normal;
  line-height: 1.35;
  margin: 8px 0 0;
  padding: 0;
}

/* Empty helper overlays and hidden panels must not render as glass boxes. */
#flightHint:empty,
#toast:empty,
.navigator-hint:empty {
  display: none !important;
}

[hidden] {
  display: none !important;
}

/* Compact phone layout: contained overlays and two explicit dock rows. */
@media (max-width: 480px) {
  .topbar {
    top: max(8px, var(--safe-top));
    right: max(10px, var(--safe-right));
    left: max(10px, var(--safe-left));
    width: auto;
    min-width: 0;
    min-height: 52px;
    gap: 6px;
    padding: 6px;
    border-radius: 15px;
  }

  .brand {
    flex: 1 1 auto;
    gap: 7px;
    overflow: hidden;
  }

  .brand-mark {
    flex: 0 0 30px;
  }

  .brand > div,
  .status,
  .status > span {
    min-width: 0;
  }

  .brand h1 {
    font-size: 0.92rem;
  }

  .brand p {
    margin-top: 4px;
    font-size: 0.49rem;
    letter-spacing: 0.13em;
  }

  .status {
    flex: 0 1 104px;
    gap: 4px;
    overflow: hidden;
    font-size: 0.59rem;
  }

  .status > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .icon-button {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  #labels {
    position: fixed;
    inset: 0;
    overflow: hidden;
  }

  .label {
    max-width: calc(100vw - 24px - var(--safe-left) - var(--safe-right));
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .label.label-top,
  .label.label-upper {
    visibility: hidden;
  }

  .navigator {
    top: calc(max(8px, var(--safe-top)) + 66px);
    right: max(10px, var(--safe-right));
    left: max(10px, var(--safe-left));
    width: auto;
    height: min(520px, calc(100dvh - 168px));
    min-height: 0;
    max-height: calc(100dvh - 168px - var(--safe-top) - var(--safe-bottom));
    padding: 12px;
    overflow: hidden;
    border-radius: 16px;
  }

  .navigator .object-list {
    min-height: 0;
    padding-right: 4px;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .navigator .object-row {
    min-width: 0;
    grid-template-columns: 18px minmax(0, 1fr) 30px;
    gap: 6px;
    padding: 7px;
  }

  .navigator .object-row strong,
  .navigator .object-row small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .navigator .navigator-hint.muted {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    line-height: 1.4;
    white-space: normal;
  }

  .dock {
    right: max(10px, var(--safe-right));
    bottom: max(10px, var(--safe-bottom));
    left: max(10px, var(--safe-left));
    width: auto;
    min-width: 0;
    max-width: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 9px;
    overflow: hidden;
    border-radius: 16px;
  }

  .camera-controls,
  .time-controls {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0;
    gap: 6px;
  }

  .camera-controls {
    grid-template-columns: minmax(0, 1fr) 74px 44px;
  }

  .time-controls {
    grid-template-columns: minmax(0, 1fr) 88px 44px;
  }

  .camera-controls label,
  .time-controls label,
  .camera-controls output,
  .time-controls output {
    min-width: 0;
    font-size: 0.69rem;
    line-height: 1;
    text-align: left;
    white-space: nowrap;
  }

  .time-controls output {
    text-align: center;
  }

  .dock select,
  .dock button,
  .dock input[type="range"] {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
  }

  .dock select {
    padding: 0.45rem 1.45rem 0.45rem 0.6rem;
    text-overflow: ellipsis;
  }

  .dock .icon-button {
    padding: 0;
  }

  .fact-card {
    right: max(10px, var(--safe-right));
    bottom: calc(max(10px, var(--safe-bottom)) + 123px);
    left: max(10px, var(--safe-left));
    width: auto;
    max-height: min(360px, calc(100dvh - 218px));
  }

  .toast {
    right: 12px;
    bottom: calc(max(10px, var(--safe-bottom)) + 123px);
    left: 12px;
    width: auto;
    max-width: none;
  }

  .free-hint {
    right: 12px;
    bottom: calc(max(10px, var(--safe-bottom)) + 123px);
    left: 12px;
    width: auto;
    max-width: none;
    text-align: center;
  }
}

@media (max-width: 350px) {
  .status {
    display: none;
  }

  .camera-controls {
    grid-template-columns: minmax(0, 1fr) 68px 44px;
  }

  .time-controls {
    grid-template-columns: minmax(0, 1fr) 82px 44px;
  }
}
