:root {
  color-scheme: dark;
  --ink: #050505;
  --paper: #f0eee8;
  --muted: #9d9b95;
  --faint: #5d5c58;
  --line: rgba(240, 238, 232, .18);
  --new: #d9ecf5;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--ink);
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--paper);
  font-family: var(--sans);
}

button,
a { color: inherit; }

button { font: inherit; }

.observatory {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 48%, rgba(255,255,255,.018), transparent 37%),
    #050505;
}

#sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
}

.instrument {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
}

.instrument--top {
  top: max(24px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.series,
.readout-label,
.readout-value,
.connection,
.utc-clock,
.stat span,
.stat strong,
.record p,
.record dl {
  margin: 0;
}

.series {
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .22em;
}

.identity h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(23px, 2.7vw, 39px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -.035em;
  text-transform: none;
}

.stream-readout {
  width: min(290px, 46vw);
  padding-top: 2px;
  text-align: right;
}

.readout-label {
  margin-bottom: 7px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 700;
}

.readout-value {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  color: var(--paper);
  font-size: 8px;
}

.connection-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 rgba(240,238,232,0);
  transition: background .25s ease, box-shadow .25s ease;
}

.connection-dot.is-live {
  background: var(--paper);
  box-shadow: 0 0 10px rgba(240,238,232,.55);
}

.observation-controls {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  pointer-events: auto;
}

.control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.control-label {
  color: var(--faint);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .13em;
}

.control-button {
  min-width: 28px;
  padding: 2px 0 3px;
  border: 0;
  border-bottom: 1px solid rgba(240, 238, 232, .28);
  border-radius: 0;
  background: transparent;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .1em;
  text-align: center;
  cursor: pointer;
}

.control-button:hover,
.control-button:focus-visible {
  border-bottom-color: var(--paper);
  outline: none;
}

.source-menu {
  position: absolute;
  z-index: 12;
  top: calc(100% + 10px);
  right: 0;
  width: 188px;
  max-height: min(420px, calc(100dvh - 150px));
  overflow-y: auto;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 5, .96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .35);
  text-align: left;
}

.source-option {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  text-align: left;
  cursor: pointer;
}

.source-option span {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: .12em;
}

.source-option small {
  overflow: hidden;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-option:hover,
.source-option:focus-visible,
.source-option.is-active {
  color: var(--paper);
  outline: none;
}

.source-option.is-active span { color: var(--paper); }

.instrument--bottom {
  right: max(24px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  left: max(24px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(3, auto) 1fr;
  align-items: end;
  gap: clamp(20px, 4vw, 54px);
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.stat {
  min-width: 72px;
}

.stat span {
  display: block;
  margin-bottom: 5px;
  color: var(--faint);
  font-size: 8px;
}

.stat strong {
  display: block;
  color: var(--paper);
  font-size: 10px;
  font-weight: 500;
}

.utc-clock {
  justify-self: end;
  color: var(--muted);
  font-size: 9px;
}

.record {
  position: absolute;
  z-index: 6;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(88px, calc(72px + env(safe-area-inset-bottom)));
  width: min(520px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.record.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.record-index {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
}

.record-title {
  max-width: 430px;
  overflow-wrap: anywhere;
  color: var(--paper);
  font-family: var(--serif);
  font-size: clamp(20px, 3vw, 34px);
  line-height: 1.02;
  letter-spacing: -.025em;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 15px !important;
  font-family: var(--mono);
}

.record-meta div {
  display: flex;
  gap: 7px;
}

.record-meta dt,
.record-meta dd {
  margin: 0;
  font-size: 8px;
  letter-spacing: .12em;
}

.record-meta dt { color: var(--faint); }
.record-meta dd { color: var(--muted); }

.record-hint {
  margin-top: 11px !important;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.intro {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  width: min(520px, calc(100vw - 48px));
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px));
  pointer-events: none;
  transition: opacity .8s ease, transform .8s ease;
  text-align: center;
}

.intro.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.intro p {
  margin: 0;
  color: rgba(240,238,232,.76);
  font-family: var(--serif);
  font-size: clamp(16px, 2.2vw, 25px);
  line-height: 1.4;
  letter-spacing: -.01em;
}

.boot {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: #050505;
  transition: opacity .9s ease, visibility .9s ease;
}

.boot.is-done {
  opacity: 0;
  visibility: hidden;
}

.boot-mark {
  position: relative;
  width: 54px;
  height: 54px;
  margin-bottom: 8px;
  border: 1px solid rgba(240,238,232,.16);
  border-radius: 50%;
}

.boot-mark::before,
.boot-mark::after {
  content: "";
  position: absolute;
  background: rgba(240,238,232,.2);
}

.boot-mark::before {
  top: 50%;
  left: -11px;
  width: 74px;
  height: 1px;
}

.boot-mark::after {
  top: -11px;
  left: 50%;
  width: 1px;
  height: 74px;
}

.boot-mark span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 14px rgba(240,238,232,.85);
  transform: translate(-50%, -50%);
  animation: pulse 1.6s ease-in-out infinite;
}

.boot-title,
.boot-status {
  margin: 0;
  font-family: var(--mono);
  letter-spacing: .16em;
}

.boot-title {
  color: var(--paper);
  font-size: 10px;
}

.boot-status {
  color: var(--faint);
  font-size: 8px;
}

.fallback {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: max(86px, calc(76px + env(safe-area-inset-bottom)));
  margin: 0;
  padding: 7px 9px;
  background: rgba(5,5,5,.8);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: .1em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.noscript {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #050505;
  color: var(--paper);
  font: 12px/1.6 var(--mono);
  text-align: center;
}

@keyframes pulse {
  0%, 100% { opacity: .35; transform: translate(-50%, -50%) scale(.75); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
}

@media (max-width: 700px) {
  .observatory { min-height: 460px; }

  .instrument--top {
    top: max(18px, env(safe-area-inset-top));
    left: max(18px, env(safe-area-inset-left));
    right: max(18px, env(safe-area-inset-right));
  }

  .series { margin-bottom: 8px; font-size: 7px; }
  .identity h1 { font-size: 23px; }
  .stream-readout { width: 48vw; }
  .readout-value { font-size: 7px; }
  .connection { margin-top: 7px; font-size: 7px; }
  .observation-controls { gap: 9px; margin-top: 9px; }
  .control { gap: 4px; }
  .control-label { font-size: 6px; }
  .control-button { min-width: 23px; font-size: 7px; }
  .source-menu { width: 166px; top: calc(100% + 8px); }
  .source-option { grid-template-columns: 30px 1fr; padding: 7px 3px; }
  .source-option span { font-size: 7px; }
  .source-option small { font-size: 8px; }

  .instrument--bottom {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    left: max(18px, env(safe-area-inset-left));
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .stat { min-width: 0; }
  .stat span { font-size: 7px; }
  .stat strong { font-size: 8px; }
  .utc-clock { display: none; }

  .record {
    left: max(18px, env(safe-area-inset-left));
    bottom: max(79px, calc(68px + env(safe-area-inset-bottom)));
    width: calc(100vw - 36px);
    grid-template-columns: 38px 1fr;
    gap: 12px;
  }

  .record-title { font-size: 23px; }
  .record-meta { gap: 8px 15px; }
  .record-meta dt,
  .record-meta dd { font-size: 7px; }

  .fallback {
    bottom: max(78px, calc(70px + env(safe-area-inset-bottom)));
    max-width: calc(100vw - 36px);
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .identity h1 { font-size: 21px; }
  .series { margin-bottom: 5px; }
  .record { bottom: 68px; }
  .record-title { font-size: 21px; }
  .record-meta { margin-top: 9px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-mark span { animation: none; }
  .boot,
  .intro,
  .record { transition-duration: .01ms; }
}
