:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #030712;
  color: #f8fafc;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(circle at 50% 25%, #102447 0%, #050b18 45%, #02040a 100%);
}

button {
  font: inherit;
}

.sky3d-app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  isolation: isolate;
}

.sky3d-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.top-bar {
  position: absolute;
  z-index: 4;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.top-bar h1,
.top-bar p {
  margin: 0;
}

.top-bar h1 {
  margin-top: 2px;
  font-size: clamp(19px, 5vw, 28px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.eyebrow {
  color: #7dd3fc;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  border: 1px solid rgb(148 163 184 / 35%);
  border-radius: 14px;
  place-items: center;
  color: #f8fafc;
  background: rgb(3 7 18 / 78%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 30%);
  pointer-events: auto;
}

.view-controls {
  position: absolute;
  z-index: 4;
  top: max(68px, calc(env(safe-area-inset-top) + 68px));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 7px;
}

.control-button {
  min-width: 72px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgb(148 163 184 / 35%);
  border-radius: 13px;
  color: #e2e8f0;
  background: rgb(3 7 18 / 78%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 25%);
}

.control-button:active {
  transform: translateY(1px);
  background: rgb(15 31 55 / 94%);
}

.observer-panel {
  position: absolute;
  z-index: 4;
  top: max(76px, calc(env(safe-area-inset-top) + 76px));
  left: max(12px, env(safe-area-inset-left));
  max-width: min(250px, calc(100% - 112px));
  padding: 10px 12px;
  border: 1px solid rgb(148 163 184 / 28%);
  border-radius: 14px;
  background: rgb(3 7 18 / 78%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 24%);
}

.layers-panel {
  position: absolute;
  z-index: 4;
  top: 190px;
  left: max(12px, env(safe-area-inset-left));
  display: grid;
  gap: 6px;
  min-width: 150px;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid rgb(148 163 184 / 24%);
  border-radius: 14px;
  color: #cbd5e1;
  background: rgb(3 7 18 / 72%);
  font-size: 11px;
}

.layers-panel legend {
  padding: 0 5px;
  color: #7dd3fc;
  font-weight: 700;
}

.layers-panel label {
  display: flex;
  gap: 7px;
  align-items: center;
}

.time-panel {
  position: absolute;
  z-index: 4;
  top: 126px;
  right: max(12px, env(safe-area-inset-right));
  width: min(218px, calc(100% - 188px));
  padding: 9px 10px;
  border: 1px solid rgb(148 163 184 / 24%);
  border-radius: 14px;
  color: #e2e8f0;
  background: rgb(3 7 18 / 72%);
  font-size: 10px;
}

.time-panel > div:not(.time-actions) {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.time-panel span {
  color: #7dd3fc;
  font-weight: 700;
}

.time-panel time {
  white-space: nowrap;
}

.time-panel .drawer-heading small {
  margin-left: 5px;
  padding: 2px 5px;
  border: 1px solid rgb(52 211 153 / 42%);
  border-radius: 999px;
  color: #6ee7b7;
  font-size: 8px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

.time-panel .drawer-heading small[data-mode="selected"] {
  border-color: rgb(251 191 36 / 40%);
  color: #fde68a;
}

.time-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 7px;
}

.time-actions button {
  min-width: 0;
  min-height: 28px;
  padding: 0 3px;
  border: 1px solid rgb(125 211 252 / 28%);
  border-radius: 7px;
  color: #dbeafe;
  background: rgb(14 34 59 / 88%);
  font-size: 9px;
}

.terrain-panel {
  position: absolute;
  z-index: 4;
  top: 228px;
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  gap: 2px;
  width: min(218px, calc(100% - 188px));
  padding: 9px 10px;
  border: 1px solid rgb(52 211 153 / 28%);
  border-radius: 14px;
  color: #d1fae5;
  background: rgb(3 18 16 / 78%);
  font-size: 10px;
}

.terrain-panel span,
.terrain-panel small {
  overflow: hidden;
  color: #94a3b8;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terrain-panel[data-state="error"] {
  border-color: rgb(251 113 133 / 45%);
  color: #fecdd3;
}

.horizon-panel {
  position: absolute;
  z-index: 4;
  top: 310px;
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  gap: 5px;
  width: min(218px, calc(100% - 188px));
  padding: 9px 10px;
  border: 1px solid rgb(245 158 11 / 32%);
  border-radius: 14px;
  color: #fef3c7;
  background: rgb(24 13 3 / 80%);
  font-size: 10px;
}

.horizon-panel span,
.horizon-panel small {
  color: #cbd5e1;
}

.horizon-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.horizon-panel select,
.horizon-panel input[type="number"] {
  min-width: 0;
  max-width: 112px;
  color: #f8fafc;
  border: 1px solid rgb(245 158 11 / 28%);
  border-radius: 6px;
  background: #111827;
}

.horizon-panel[data-state="error"] {
  border-color: rgb(251 113 133 / 45%);
  color: #fecdd3;
}

.observer-panel p,
.observer-panel strong {
  display: block;
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.observer-panel p {
  color: #94a3b8;
  font-size: 10px;
}

.observer-panel strong {
  margin-top: 3px;
  font-size: 12px;
}

.observer-actions,
.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.compact-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgb(125 211 252 / 35%);
  border-radius: 10px;
  color: #dbeafe;
  background: rgb(14 34 59 / 88%);
}

.compact-button.primary {
  color: #03111e;
  background: #7dd3fc;
}

.location-dialog {
  width: min(420px, calc(100% - 32px));
  border: 1px solid rgb(125 211 252 / 28%);
  border-radius: 20px;
  color: #f8fafc;
  background: #07101f;
  box-shadow: 0 24px 80px rgb(0 0 0 / 65%);
}

.sources-dialog {
  width: min(680px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 18px;
  border: 1px solid rgb(125 211 252 / 28%);
  border-radius: 20px;
  color: #f8fafc;
  background: #07101f;
  box-shadow: 0 24px 80px rgb(0 0 0 / 65%);
}

.sources-dialog::backdrop {
  background: rgb(0 0 0 / 72%);
}

.sources-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.sources-heading p,
.sources-heading h2 {
  margin: 0;
}

.sources-heading p {
  color: #7dd3fc;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.sources-heading h2 {
  margin-top: 3px;
  font-size: 21px;
}

.sources-dialog ul {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.sources-dialog li {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgb(148 163 184 / 18%);
  border-radius: 11px;
  background: rgb(2 6 23 / 58%);
}

.sources-dialog li span,
.sources-offline {
  color: #94a3b8;
  font-size: 12px;
}

.license-list details {
  margin-top: 8px;
  border-top: 1px solid rgb(148 163 184 / 18%);
  padding-top: 8px;
}

.license-list summary {
  cursor: pointer;
  color: #bae6fd;
  font-size: 12px;
}

.license-list pre {
  overflow: auto;
  max-height: 210px;
  padding: 10px;
  border-radius: 9px;
  white-space: pre-wrap;
  color: #cbd5e1;
  background: #020617;
  font: 10px/1.4 ui-monospace, monospace;
}

.location-dialog::backdrop {
  background: rgb(0 0 0 / 68%);
}

.location-dialog h2 {
  margin: 0;
  font-size: 20px;
}

.location-dialog p {
  margin: 8px 0 16px;
  color: #94a3b8;
  font-size: 13px;
}

.location-dialog label {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  color: #cbd5e1;
  font-size: 12px;
}

.location-dialog input {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #f8fafc;
  background: #020617;
}

.location-dialog .form-error {
  margin-bottom: 0;
  color: #fb7185;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.status-panel,
.diagnostics {
  position: absolute;
  z-index: 3;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  border: 1px solid rgb(125 211 252 / 22%);
  border-radius: 18px;
  background: rgb(5 12 27 / 88%);
  box-shadow: 0 16px 48px rgb(0 0 0 / 35%);
  backdrop-filter: blur(16px);
}

.object-card {
  position: absolute;
  z-index: 6;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(104px, calc(env(safe-area-inset-bottom) + 104px));
  width: min(360px, calc(100% - 24px));
  max-height: min(420px, calc(100% - 140px));
  overflow: auto;
  padding: 16px;
  border: 1px solid rgb(253 224 71 / 42%);
  border-radius: 18px;
  color: #f8fafc;
  background: rgb(5 12 27 / 94%);
  box-shadow: 0 20px 60px rgb(0 0 0 / 52%);
  backdrop-filter: blur(16px);
}

.object-card[hidden] {
  display: none;
}

.object-card p,
.object-card h2,
.object-card dl,
.object-card dd {
  margin: 0;
}

.object-card p {
  color: #fde047;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.object-card h2 {
  margin: 3px 32px 11px 0;
  font-size: 20px;
}

.object-card dl > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  border-top: 1px solid rgb(148 163 184 / 14%);
  font-size: 12px;
}

.object-card dt,
.object-card small {
  color: #94a3b8;
}

.object-card dd {
  text-align: right;
}

.object-card small {
  display: block;
  margin-top: 11px;
  line-height: 1.35;
}

.object-card-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 34px;
  height: 34px;
  border: 0;
  color: #e2e8f0;
  background: transparent;
  font-size: 24px;
}

.status-panel {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 14px 16px;
}

.status-panel p {
  margin: 4px 0 0;
  color: #aebdd2;
  font-size: 13px;
}

.recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.recovery-actions[hidden] {
  display: none;
}

.loader {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 3px solid rgb(125 211 252 / 22%);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.status-panel[data-state="ready"] .loader {
  border-color: #34d399;
  animation: none;
}

.status-panel[data-state="error"] .loader {
  border-color: #fb7185;
  animation: none;
}

.diagnostics {
  max-width: 380px;
  padding: 16px;
}

.diagnostics h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.diagnostics dl,
.diagnostics dd {
  margin: 0;
}

.diagnostics dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px solid rgb(148 163 184 / 15%);
  font-size: 12px;
}

.diagnostics dt {
  color: #94a3b8;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 720px) {
  .status-panel {
    right: auto;
    width: min(430px, calc(100% - 24px));
  }
}

@media (max-height: 480px) {
  .observer-panel {
    top: max(58px, calc(env(safe-area-inset-top) + 58px));
  }

  .observer-panel p {
    display: none;
  }

  .view-controls {
    top: max(58px, calc(env(safe-area-inset-top) + 58px));
  }

  .layers-panel {
    top: auto;
    bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px));
    grid-template-columns: repeat(2, auto);
  }

  .time-panel {
    top: 58px;
    right: 96px;
  }

  .terrain-panel {
    top: 130px;
    right: 12px;
  }

  .horizon-panel {
    top: 205px;
    right: 12px;
    width: 218px;
  }
}

/* Compact mobile control shell: one drawer at a time over the scene. */
[hidden] {
  display: none !important;
}

.top-bar {
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  left: max(8px, env(safe-area-inset-left));
  align-items: center;
}

.top-bar h1 {
  margin: 0;
  padding: 7px 10px;
  border: 1px solid rgb(148 163 184 / 22%);
  border-radius: 12px;
  background: rgb(3 7 18 / 70%);
  font-size: 16px;
  line-height: 1;
  backdrop-filter: blur(10px);
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.observer-chip {
  position: absolute;
  z-index: 4;
  top: max(56px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  display: flex;
  max-width: calc(100% - 24px);
  transform: translateX(-50%);
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  overflow: hidden;
  border: 1px solid rgb(148 163 184 / 20%);
  border-radius: 999px;
  color: #cbd5e1;
  background: rgb(3 7 18 / 66%);
  box-shadow: 0 6px 18px rgb(0 0 0 / 22%);
  font-size: 9px;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.observer-chip span,
.observer-chip b,
.observer-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.observer-chip span {
  color: #7dd3fc;
}

.observer-chip strong {
  font-size: 9px;
}

.observer-chip b,
.observer-chip i {
  flex: 0 0 auto;
}

.observer-chip b {
  color: #f8fafc;
}

.observer-chip i {
  color: #64748b;
  font-style: normal;
}

.compass-button {
  position: absolute;
  z-index: 7;
  top: max(12px, env(safe-area-inset-top));
  right: max(64px, calc(env(safe-area-inset-right) + 64px));
  display: grid;
  min-width: 68px;
  min-height: 38px;
  padding: 4px 9px;
  border: 1px solid rgb(148 163 184 / 35%);
  border-radius: 12px;
  place-items: center;
  gap: 1px;
  color: #dbeafe;
  background: rgb(3 7 18 / 86%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 30%);
  font-size: 9px;
}

.compass-button span {
  color: #7dd3fc;
  font-size: 17px;
  line-height: 1;
}

.compass-button b {
  font: inherit;
}

.compass-button[data-state="on"] {
  border-color: rgb(125 211 252 / 70%);
  color: #fff;
  background: rgb(30 64 104 / 92%);
}

.compass-button[data-state="starting"] {
  color: #fde68a;
}

.compass-button[data-state="error"] {
  border-color: rgb(251 113 133 / 55%);
  color: #fecdd3;
}

.control-toolbar {
  position: absolute;
  z-index: 7;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  left: max(8px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid rgb(148 163 184 / 25%);
  border-radius: 15px;
  background: rgb(3 7 18 / 86%);
  box-shadow: 0 12px 36px rgb(0 0 0 / 38%);
  backdrop-filter: blur(14px);
}

.control-toolbar button {
  display: grid;
  min-width: 0;
  min-height: 46px;
  padding: 4px 2px;
  border: 0;
  border-radius: 10px;
  place-items: center;
  align-content: center;
  gap: 1px;
  color: #dbeafe;
  background: transparent;
  font-size: 8px;
  line-height: 1.1;
}

.control-toolbar button span {
  color: #7dd3fc;
  font-size: 16px;
  line-height: 1;
}

.control-toolbar button b {
  overflow: hidden;
  font: inherit;
  text-overflow: ellipsis;
}

.control-toolbar button[aria-pressed="true"] {
  background: rgb(30 64 104 / 75%);
}

.control-toolbar button[aria-expanded="true"],
.control-toolbar button:active {
  background: rgb(30 64 104 / 75%);
}

.control-drawer,
.layers-panel,
.time-panel,
.terrain-panel,
.horizon-panel {
  position: absolute;
  z-index: 6;
  top: auto;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(68px, calc(env(safe-area-inset-bottom) + 68px));
  left: max(8px, env(safe-area-inset-left));
  display: grid;
  width: auto;
  min-width: 0;
  max-height: calc(100% - max(142px, calc(env(safe-area-inset-top) + 142px)));
  gap: 8px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgb(125 211 252 / 30%);
  border-radius: 16px;
  color: #e2e8f0;
  background: rgb(4 11 24 / 94%);
  box-shadow: 0 18px 54px rgb(0 0 0 / 48%);
  font-size: 12px;
  overscroll-behavior: contain;
  backdrop-filter: blur(16px);
}

.drawer-heading {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #bae6fd;
  font-size: 14px;
}

.drawer-heading button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgb(148 163 184 / 22%);
  border-radius: 9px;
  color: #e2e8f0;
  background: rgb(15 23 42 / 85%);
  font-size: 20px;
}

.layers-panel label,
.terrain-panel label,
.horizon-panel label {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 8px;
}

.range-row {
  display: grid !important;
  grid-template-columns: auto minmax(80px, 1fr) auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.settings-grid button,
.location-actions button {
  min-height: 44px;
  border: 1px solid rgb(125 211 252 / 28%);
  border-radius: 11px;
  color: #dbeafe;
  background: rgb(14 34 59 / 88%);
}

.location-panel p {
  margin: 0;
  color: #94a3b8;
}

.location-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.status-panel {
  z-index: 5;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 72px));
  left: max(8px, env(safe-area-inset-left));
  padding: 10px 12px;
  border-radius: 14px;
}

.status-panel.status-dismissed {
  display: none;
}

.object-card {
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 72px));
}

@media (min-width: 600px) {
  .control-toolbar {
    left: 50%;
    width: min(520px, calc(100% - 16px));
    transform: translateX(-50%);
  }

  .control-drawer,
  .layers-panel,
  .time-panel,
  .terrain-panel,
  .horizon-panel {
    right: max(12px, env(safe-area-inset-right));
    left: auto;
    width: min(430px, calc(100% - 24px));
  }
}

@media (max-height: 480px) {
  .observer-chip {
    top: max(8px, env(safe-area-inset-top));
    max-width: calc(100% - 250px);
  }

  .control-toolbar {
    right: 8px;
    bottom: max(6px, env(safe-area-inset-bottom));
    left: 8px;
    width: auto;
    transform: none;
  }

  .control-toolbar button {
    min-height: 42px;
  }

  .control-drawer,
  .layers-panel,
  .time-panel,
  .terrain-panel,
  .horizon-panel {
    top: max(54px, calc(env(safe-area-inset-top) + 54px));
    right: 8px;
    bottom: max(62px, calc(env(safe-area-inset-bottom) + 62px));
    left: auto;
    width: min(430px, calc(100% - 16px));
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loader {
    animation-duration: 1800ms;
  }
}
