:root {
  color-scheme: dark;
  --ink: #e8eefc;
  --muted: #93a3c4;
  --panel: rgba(8, 12, 24, 0.72);
  --edge: rgba(140, 170, 220, 0.25);
  --accent: #7fb4ff;
  --warn: #ffb457;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: #05070f;
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}
.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  padding: max(8px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom));
}
.sky { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: auto; }
.sky-canvas { position: absolute; inset: 0; display: block; }
.sky-labels { position: absolute; inset: 0; pointer-events: none; }
.sky-label {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font-size: 11.5px; letter-spacing: .02em; color: rgba(214, 228, 255, .9);
  text-shadow: 0 0 4px #000, 0 1px 2px #000;
}
.sky-label.cardinal {
  font-size: 14px; font-weight: 700; color: var(--warn);
  text-shadow: 0 0 6px rgba(0,0,0,.9);
}
.sky-label.star { color: rgba(226, 236, 255, .78); }
.labels-off .sky-label.star { display: none; }

.topbar, .readout, .controls, .bottombar, .offline { position: relative; z-index: 2; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.place {
  display: flex; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--edge);
  border-radius: 14px; padding: 6px 10px; backdrop-filter: blur(10px);
  max-width: 70vw;
}
.place .sub { font-size: 11.5px; color: var(--muted); }
#location-label { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58vw; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #667; flex: 0 0 auto; }
.dot.live { background: #57e08a; box-shadow: 0 0 8px #57e08a; }
.dot.fallback { background: var(--warn); }
.top-actions { display: flex; gap: 6px; }

button, input, dialog { pointer-events: auto; }
button { font: inherit; color: inherit; cursor: pointer; }
button.ghost {
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  min-width: 44px; min-height: 44px; padding: 0 10px; backdrop-filter: blur(10px);
}
button.ghost[aria-pressed="false"] { color: var(--muted); }
button.pill {
  background: var(--panel); border: 1px solid var(--edge); border-radius: 999px;
  min-height: 44px; padding: 0 16px; backdrop-filter: blur(10px); font-weight: 600;
}
button.pill.primary { background: rgba(70, 120, 210, .85); border-color: rgba(150, 190, 255, .55); }
button.pill.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
button:disabled { opacity: .5; }

.readout {
  margin: 8px 0 0; text-align: center; text-shadow: 0 1px 3px #000;
}
.readout-main { font-size: clamp(17px, 5vw, 22px); font-weight: 700; letter-spacing: .01em; }
.readout-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.reticle {
  position: absolute; left: 50%; top: 50%; width: 18px; height: 18px;
  transform: translate(-50%, -50%); z-index: 1; pointer-events: none;
  border: 1px solid rgba(160, 200, 255, .35); border-radius: 50%;
}
.reticle::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 2px; height: 2px;
  transform: translate(-50%, -50%); background: rgba(200, 225, 255, .8); border-radius: 50%;
}

.controls {
  display: flex; gap: 8px; justify-content: center; margin-top: 6px; flex-wrap: wrap;
}
.bottombar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 8px;
}
.compass {
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  padding: 6px 10px; font-variant-numeric: tabular-nums; font-size: 13px;
  min-width: 78px; text-align: center; backdrop-filter: blur(10px);
}
.zoom { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.zoom { flex: 1 1 auto; min-width: 0; }
.zoom input { width: 100%; max-width: 9rem; accent-color: var(--accent); }
.offline { position: fixed; left: 0; right: 0; bottom: max(2px, env(safe-area-inset-bottom)); margin: 0; font-size: 12px; color: var(--warn); min-height: 0; text-align: center; pointer-events: none; }

dialog {
  border: 1px solid var(--edge); border-radius: 16px; background: #0b1120;
  color: var(--ink); padding: 18px; max-width: min(28rem, 92vw); width: 100%;
}
dialog::backdrop { background: rgba(2, 4, 10, .6); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog p { color: var(--muted); font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field.row > span { display: inline; margin: 0; }
.field small { display: block; flex-basis: 100%; color: var(--muted); font-size: 11.5px; }
dialog input[type="number"] {
  width: 100%; margin-bottom: 6px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--edge); background: #060a14; color: var(--ink); font: inherit;
}
dialog input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
dialog button { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--edge); background: #16203a; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.note { font-size: 12px; min-height: 1em; }
body.manual .reticle { border-color: rgba(255, 180, 87, .5); }
