:root {
  --sigma-good:    #60c080;
  --sigma-warn:    #d0a060;
  --sigma-bad:     #d06060;
  --sigma-unknown: #707070;
}
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
#view { display: block; cursor: grab;
        touch-action: none; user-select: none; -webkit-user-select: none;
        overscroll-behavior: none; }
#view:active { cursor: grabbing; }
#hud { position: fixed; top: 8px; left: 10px; color: #fff;
       font: 12px monospace; text-shadow: 0 0 3px #000; pointer-events: none; }
#map-wrap { position: fixed; inset: 0; background: #000; display: none; }
#map-wrap.show { display: block; }
#map { width: 100%; height: 100%; }
.btn { padding: 6px 10px; background: rgba(0,0,0,0.5);
       color: #fff; border: 1px solid #fff; font: 12px monospace; cursor: pointer;
       text-decoration: none; }
.top-right-fixed { position: fixed; top: 8px; right: 8px; display: flex; gap: 4px;
                   align-items: center; z-index: 1000; }
.top-right-fixed[hidden] { display: none; }
#menu-dropdown { position: fixed; top: 38px; right: 8px; z-index: 2400;
                 background: rgba(0,0,0,0.9); color: #fff; border: 1px solid #fff;
                 font: 12px monospace; min-width: 160px;
                 display: flex; flex-direction: column; }
#menu-dropdown[hidden] { display: none; }
.menu-item { padding: 6px 10px; background: transparent; border: none;
             color: #fff; font: inherit; text-align: left; cursor: pointer; }
.menu-item:hover { background: rgba(255,255,255,0.15); }
.menu-item[hidden] { display: none; }
label.menu-item { display: flex; align-items: center; gap: 6px; }
.session-widget { display: inline-flex; gap: 6px; align-items: center;
                  padding: 4px 8px; background: rgba(0,0,0,0.7);
                  border: 1px solid rgba(255,255,255,0.4); color: #fff;
                  font: 12px monospace; position: relative; }
.session-widget[hidden] { display: none; }
.session-widget-counter { white-space: nowrap; }
.session-widget-problems { white-space: nowrap; color: var(--sigma-bad); cursor: pointer;
                           border: 0; background: transparent; font: inherit;
                           padding: 0 4px; }
.session-widget-problems[hidden] { display: none; }
.session-widget-problems:hover { color: #ff8080; }
.session-widget-dropdown { position: absolute; top: 100%; right: 0;
                           margin-top: 4px; min-width: 320px; max-width: 480px;
                           max-height: 320px; overflow-y: auto;
                           background: rgba(0,0,0,0.92); color: #fff;
                           border: 1px solid rgba(255,255,255,0.4);
                           padding: 6px 8px; font: 11px monospace; z-index: 1100; }
.session-widget-dropdown[hidden] { display: none; }
.deficient-axes-list { list-style: none; margin: 0; padding: 0; }
.deficient-axes-list li { padding: 2px 0; }
.deficient-axes-list .axes { color: var(--sigma-warn); }
.sigma { font-size: 10px; margin-left: 0.4em; opacity: 0.85; }
.sigma-good    { color: var(--sigma-good); }
.sigma-warn    { color: var(--sigma-warn); }
.sigma-bad     { color: var(--sigma-bad); }
.sigma-unknown { color: var(--sigma-unknown); font-style: italic; }
.sigma[hidden] { display: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: rgba(0,0,0,0.5); }
.settings-row { display: flex; flex-direction: column; gap: 4px; }
.settings-row input[type="range"] { width: 100%; accent-color: #fff; }
.settings-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.settings-check input { margin: 0; }
.tool.active { background: rgba(255,255,255,0.25); }
.settings-inline { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.settings-inline select, .settings-inline input[type="datetime-local"] {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid #888;
  font: 12px monospace; padding: 1px 3px;
}
.settings-inline input[type="range"] { flex: 1; accent-color: #fff; }
.settings-inline input[type="number"] {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid #888;
  font: 12px monospace; padding: 1px 3px; width: 9em;
}
.settings-row.station-pos { gap: 4px 8px; flex-direction: row; flex-wrap: wrap; align-items: center; }
.captured-at-est { font: 11px monospace; color: #aaa; }
.inconsistency-detail { display: inline-block; font: 11px monospace; color: #d97706; vertical-align: top; }
.inconsistency-detail > summary { cursor: pointer; user-select: none; }
.inconsistency-detail[open] > summary { color: #b45309; }
.inconsistency-detail .reasons { margin: 4px 0 4px 16px; padding: 0; list-style: disc; color: #ccc; }
.inconsistency-detail .reasons li { margin: 2px 0; line-height: 1.4; }
.inconsistency-detail .bound-sources { margin: 2px 0 4px 16px; padding: 0; list-style: '↳ '; color: #999; }
.inconsistency-detail .bound-sources li { margin: 1px 0; line-height: 1.4; }
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.settings-group > summary { cursor: pointer; user-select: none; color: #ccc; }
.settings-group[open] > summary { color: #fff; }
#view.tool-poi { cursor: crosshair; }
.station-popup .leaflet-popup-content { margin: 8px 10px; font: 12px monospace; }
.station-popup .name { display: block; font-weight: bold; margin-bottom: 6px; color: #000; }
.station-popup .go { display: block; padding: 4px 8px; background: #1a73e8;
                     color: #fff; text-decoration: none; cursor: pointer;
                     border: none; font: 12px monospace; text-align: left; }
.station-popup .go + .go { margin-top: 4px; }
.station-popup .go:hover { background: #155bbd; }
.popup-alt { color: #000; margin-bottom: 4px; }
.popup-dates { color: #555; margin-bottom: 4px; line-height: 1.3; }
.popup-lock-row { display: block; color: #000; margin-bottom: 2px; cursor: pointer; }
.popup-lock-row input { margin-right: 4px; vertical-align: middle; }
.popup-lock-row + .go, .popup-lock-row + a.go { margin-top: 6px; }
.uncertainty-circle { fill-opacity: 0.12; stroke-width: 1.5; stroke-dasharray: 4 3; }
.uncertainty-circle.sigma-good { stroke: var(--sigma-good); fill: var(--sigma-good); }
.uncertainty-circle.sigma-warn { stroke: var(--sigma-warn); fill: var(--sigma-warn); }
.uncertainty-circle.sigma-bad  { stroke: var(--sigma-bad);  fill: var(--sigma-bad);  }
.poi-anchor-marker { color: #5080ff; filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)); }
.leaflet-marker-icon.leaflet-interactive.cp-marker { background: transparent; border: none; cursor: pointer; }
.cp-marker .cp-marker-dot { fill: #ff5050; stroke: rgba(0,0,0,0.6); stroke-width: 1; }
.cp-marker.observed .cp-marker-dot { fill: #50d050; }
.marker-lock-ring, .marker-lock-alt { stroke: rgba(0,0,0,0.85); fill: none; }
/* Hitbox is the apex circle plus the wedge polygon fills; gaps between
   wedges (and the rest of the 80px icon box) keep pointer-events: none
   so clicks there fall through to the map. The apex and wedges each
   re-enable pointer events for themselves and bubble their events up
   to the marker container, where Leaflet dispatches them. Three classes
   are required to out-specific Leaflet's own
   `.leaflet-marker-icon.leaflet-interactive { pointer-events: auto }`
   rule — equal specificity isn't enough because Vite injects Leaflet's
   bundled CSS after our static `styles.css` link, so the later rule wins
   on ties. Adding `.leaflet-interactive` (which Leaflet adds to every
   interactive marker container) makes us strictly more specific. */
.leaflet-marker-icon.leaflet-interactive.station-frustum-icon { background: transparent; border: none; pointer-events: none; }
/* Move-mode: the marker follows the cursor until commit (click) or cancel
   (right-click). Override per-marker cursors so the whole map reads as one
   targeting surface, including over other markers the cursor passes. */
.leaflet-container.move-mode-active,
.leaflet-container.move-mode-active .leaflet-marker-icon { cursor: crosshair; }
.station-frustum-wedges polygon {
  fill: #a050ff; fill-opacity: 0.45;
  stroke: rgba(0,0,0,0.6); stroke-width: 0.6; stroke-linejoin: round;
  pointer-events: auto; cursor: pointer;
}
/* Hide the inner icon-cones on the previewed station so they don't overlap
   the large preview cones drawn on the map for the same station. */
.station-frustum-icon.previewed .station-frustum-wedges { display: none; }
.station-frustum-apex {
  fill: #a050ff; stroke: rgba(0,0,0,0.85); stroke-width: 0.6;
  pointer-events: auto; cursor: pointer;
}
.leaflet-container.move-mode-active .station-frustum-apex { cursor: crosshair; }
.leaflet-container.move-mode-active .station-frustum-wedges polygon { cursor: crosshair; }
#map.photo-drop-active { box-shadow: inset 0 0 0 4px #5080ff; }
.poi-anchor-marker.selected { color: #ffff66; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6);
         display: flex; align-items: center; justify-content: center; z-index: 2000; }
.modal[hidden] { display: none; }
.modal-panel { background: rgba(0,0,0,0.85); color: #fff; border: 1px solid #fff;
               padding: 16px; min-width: 320px; font: 12px monospace;
               display: flex; flex-direction: column; gap: 12px; }
.modal-panel .modal-header { display: flex; align-items: center; justify-content: space-between;
                             font-weight: bold; }
.modal-panel .modal-header .btn { padding: 2px 6px; }
/* .modal-panel has display: flex, so [hidden] needs an explicit override. */
.modal-panel[hidden] { display: none; }
.modal-panel.floating { position: fixed; top: 56px; right: 8px; z-index: 1500;
                        max-height: calc(100vh - 72px); overflow-y: auto; }
.modal-panel.floating .modal-header { cursor: grab; user-select: none; }
.modal-panel.floating .modal-header.dragging { cursor: grabbing; }
.modal-field { display: flex; flex-direction: column; gap: 4px; }
.modal-field input[type="text"],
.modal-field input[type="datetime-local"],
.modal-field input[type="number"],
.modal-field textarea {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid #888;
  font: 12px monospace; padding: 4px 6px;
}
.modal-field textarea { resize: vertical; }
.modal-error { color: #ff8080; font: 12px monospace; }
.drop-zone { border: 1px dashed #888; padding: 16px; text-align: center;
             cursor: pointer; min-height: 60px; color: #aaa; }
.drop-zone.over { border-color: #fff; background: rgba(255,255,255,0.08); color: #fff; }
#start-station-photos-preview { display: flex; flex-direction: column; gap: 4px;
                                 max-height: 160px; overflow-y: auto; }
.photo-thumb { display: flex; justify-content: space-between; align-items: center; gap: 8px;
               padding: 2px 4px; background: rgba(255,255,255,0.06); }
.photo-thumb .remove { padding: 0 6px; background: transparent; border: none;
                       color: #fff; cursor: pointer; font: 14px monospace; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
#solve-modal .modal-panel { width: 480px; }
/* Slider rows in the solve modal lay out as [label / slider+readout],
   with the readout right-aligned in a fixed-width column so values
   don't jitter as the slider moves. */
.solve-slider-row { display: grid; grid-template-columns: 1fr auto;
                    column-gap: 8px; row-gap: 4px; align-items: center; }
.solve-slider-row > label { grid-column: 1 / -1; }
.solve-slider-row input[type="range"] { width: 100%; accent-color: #fff; }
.solve-slider-readout { font: 12px monospace; color: #ddd; min-width: 5ch;
                        text-align: right; }
#solve-progress { display: flex; flex-direction: column; gap: 6px; }
#solve-progress[hidden] { display: none; }
#solve-status { font: 12px monospace; color: #ddd; }
#solve-loss-chart { width: 100%; height: 160px; background: rgba(255,255,255,0.04);
                    border: 1px solid #333; display: block; box-sizing: border-box; }
#params-panel { position: fixed; top: 44px; right: 8px; z-index: 1000;
                background: rgba(0,0,0,0.7); color: #fff; font: 12px monospace;
                border: 1px solid #fff; min-width: 260px; max-width: 320px;
                padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
#params-panel[hidden] { display: none; }
.params-panel-header { display: flex; align-items: center; justify-content: space-between;
                       gap: 8px; }
.params-panel-title { font-weight: bold; }
.params-toggle { padding: 0 6px; line-height: 1; }
#params-panel-body { display: flex; flex-direction: column; gap: 8px; }
#params-panel.collapsed > #params-panel-body { display: none; }
.params-section { display: flex; flex-direction: column; gap: 6px; }
.params-section + .params-section { border-top: 1px solid rgba(255,255,255,0.2); padding-top: 8px; }
.params-section[hidden] { display: none; }
.params-section-header { font-weight: bold; }
.photo-hud-row { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.photo-hud-row > span { flex: 0 0 90px; }
.photo-hud-row input[type="number"],
.photo-hud-row input[type="text"] {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid #888;
  font: 12px monospace; padding: 1px 3px;
}
.photo-hud-row .lock-check { display: flex; align-items: center; gap: 4px;
                              cursor: pointer; flex: 0 0 auto; }
.photo-hud-row .lock-check input { margin: 0; }

/* Auto-locked checkbox affordance: fade the row and remove the
   pointer-cursor so the disabled+checked state reads as "computer says
   no" rather than greyed-out-and-broken. */
.settings-check:has(input:disabled),
.popup-lock-row:has(input:disabled),
.photo-hud-row .lock-check:has(input:disabled) { cursor: default; opacity: 0.55; }
#photo-hud-opacity { flex: 1; accent-color: #fff; }
.btn.danger { color: #ff8080; border-color: #ff8080; }
.btn.danger:hover { background: rgba(255,80,80,0.2); }
.btn.loading { color: transparent; position: relative; cursor: wait; }
.btn.loading::after { content: ''; position: absolute; inset: 0; margin: auto;
                      width: 12px; height: 12px;
                      border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
                      border-radius: 50%; animation: btn-spin 0.7s linear infinite; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
.index-cp-popup .leaflet-popup-content { margin: 8px 10px; font: 12px monospace; }
.index-cp-popup .name { display: block; font-weight: bold; margin-bottom: 6px; color: #000; }
.index-cp-popup .go { display: inline-block; padding: 4px 8px; background: #1a73e8;
                     color: #fff; text-decoration: none; cursor: pointer;
                     border: none; font: 12px monospace; }
.index-cp-popup .go + .go { margin-left: 6px; }
.index-cp-popup .go:hover { background: #155bbd; }
#context-menu { position: fixed; background: rgba(0,0,0,0.9); color: #fff;
                border: 1px solid #fff; font: 12px monospace; z-index: 2500;
                min-width: 160px; display: flex; flex-direction: column; }
#context-menu[hidden] { display: none; }
#context-menu button { padding: 6px 10px; background: transparent; border: none;
                       color: #fff; font: inherit; text-align: left; cursor: pointer; }
#context-menu button:hover { background: rgba(255,255,255,0.15); }
#context-menu .header { padding: 6px 10px; color: #aaa; font: inherit;
                        border-bottom: 1px solid rgba(255,255,255,0.2);
                        text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
#context-menu .info { padding: 4px 10px; color: #777; font: inherit;
                      line-height: 1.3;
                      border-bottom: 1px solid rgba(255,255,255,0.2); }
#context-menu fieldset.radio-group { margin: 6px 8px; padding: 4px 8px 6px 8px;
                                     border: 1px solid rgba(255,255,255,0.3);
                                     font: inherit; display: flex;
                                     flex-direction: column; gap: 2px; }
#context-menu fieldset.radio-group legend { padding: 0 4px; color: #aaa;
                                            font: inherit; }
#context-menu fieldset.radio-group label { display: flex; align-items: center;
                                           gap: 6px; cursor: pointer;
                                           padding: 2px 0; }
#context-menu fieldset.radio-group label:has(input:disabled) { cursor: default;
                                                               color: #888; }
/* Custom-painted radios: native disabled+checked renders a near-invisible
   dot on a dark page, so we draw our own ring + dot for full contrast. */
#context-menu fieldset.radio-group input[type=radio] {
  appearance: none; -webkit-appearance: none;
  width: 12px; height: 12px; margin: 0; padding: 0;
  border: 1.5px solid #fff; border-radius: 50%;
  background: transparent; cursor: pointer; position: relative;
  flex-shrink: 0;
}
#context-menu fieldset.radio-group input[type=radio]:checked::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff; transform: translate(-50%, -50%);
}
#context-menu fieldset.radio-group input[type=radio]:disabled {
  cursor: default; border-color: #888;
}
#context-menu fieldset.radio-group input[type=radio]:disabled:checked::before {
  background: #aaa;
}
.cp-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px;
           overflow-y: auto; border: 1px solid #444; padding: 4px; }
.cp-list .empty { color: #888; padding: 8px; text-align: center; }
.cp-row { display: flex; justify-content: space-between; align-items: center; gap: 8px;
          padding: 4px 6px; cursor: pointer; background: rgba(255,255,255,0.04); }
.cp-row:hover { background: rgba(255,255,255,0.15); }
.cp-row .desc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-row .meta { color: #aaa; font-size: 10px; }
.cp-row .meta.unlocated { color: #ffb060; }
#save-error { position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
              background: rgba(180,40,40,0.92); color: #fff; padding: 8px 12px;
              border: 1px solid #fff; font: 12px monospace; z-index: 1500;
              display: flex; align-items: center; gap: 10px; max-width: 80vw; }
#save-error[hidden] { display: none; }
#save-error .btn { background: rgba(0,0,0,0.3); }

#time-filter { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
               background: rgba(0,0,0,0.75); color: #fff; padding: 8px 12px;
               border: 1px solid #fff; font: 12px monospace; z-index: 1000;
               display: flex; flex-direction: column; gap: 6px; min-width: 320px;
               max-width: calc(100vw - 32px); }
#time-filter[hidden] { display: none; }
.time-filter-row { display: flex; gap: 8px; align-items: center; }
.time-filter-row label { display: flex; align-items: center; gap: 4px; flex: 1; }
.time-filter-row input[type="date"] { flex: 1; min-width: 0; }
/* Two stacked range inputs share one drawn track. Both --start-pct and
   --end-pct are set from JS in paint(). The container draws the gray
   rail and the highlighted selection between the two thumbs; the
   native tracks are made invisible so they don't fight the composite. */
.time-filter-slider { position: relative; height: 24px; }
.time-filter-slider::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%); height: 4px; border-radius: 2px;
  background: linear-gradient(to right,
    rgba(255,255,255,0.25) 0%,
    rgba(255,255,255,0.25) var(--start-pct, 0%),
    #fff var(--start-pct, 0%),
    #fff var(--end-pct, 100%),
    rgba(255,255,255,0.25) var(--end-pct, 100%),
    rgba(255,255,255,0.25) 100%);
  pointer-events: none;
}
.time-filter-slider input[type="range"] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  background: transparent; pointer-events: none;
  -webkit-appearance: none; appearance: none;
}
.time-filter-slider input[type="range"]::-webkit-slider-runnable-track {
  background: transparent; border: none; height: 4px;
}
.time-filter-slider input[type="range"]::-moz-range-track {
  background: transparent; border: none; height: 4px;
}
.time-filter-slider input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto; -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 1px solid rgba(0,0,0,0.6); margin-top: -5px; cursor: pointer;
}
.time-filter-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 1px solid rgba(0,0,0,0.6); cursor: pointer;
}
.time-filter-year { text-align: center; opacity: 0.75; }

.sundial-row { display: flex; align-items: center; gap: 8px; }
.sundial-row-label { flex: 0 0 60px; opacity: 0.75; }
.sundial-row-value { flex: 1; font: 12px monospace; opacity: 0.9;
                     white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.picking { background: rgba(255,221,68,0.25); color: #ffdd44;
               border-color: #ffdd44; }
.sundial-candidates { list-style: none; margin: 6px 0 0; padding: 0;
                      display: flex; flex-direction: column; gap: 2px; }
.sundial-candidates .muted { opacity: 0.6; font-size: 11px; }

#constraint-multiselect-hud { position: fixed; top: 12px; left: 50%;
                              transform: translateX(-50%);
                              background: rgba(0,0,0,0.75); color: #fff;
                              padding: 6px 12px; border: 1px solid #fff;
                              font: 12px monospace; z-index: 1000;
                              display: flex; align-items: center; gap: 10px; }
#constraint-multiselect-hud[hidden] { display: none; }

/* Touch devices: scale chrome up so labels stay readable and buttons are
   reachable with a fingertip. Roughly 2× the desktop sizing. */
@media (pointer: coarse) {
  /* Below the button row (which may wrap to two lines on narrow screens). */
  #hud { font-size: 14px; top: auto; bottom: 14px; left: 14px; }
  .btn { font-size: 16px; padding: 8px 12px; }
  #top-right { top: 12px; right: 12px; gap: 6px; flex-wrap: wrap;
               justify-content: flex-end; max-width: calc(100vw - 24px); }
  #params-panel { font-size: 16px; top: 64px; right: 12px;
                  padding: 12px 16px; gap: 12px; min-width: 300px; }
  #menu-dropdown { font-size: 18px; top: 56px; right: 12px; min-width: 220px; }
  .menu-item { padding: 10px 14px; }
  .settings-row { gap: 8px; }
  .settings-check { gap: 12px; }
  .settings-inline { gap: 12px; }
  .settings-inline select, .settings-inline input[type="datetime-local"] {
    font-size: 18px; padding: 4px 8px;
  }
  .modal-panel { font-size: 18px; padding: 24px; gap: 18px; min-width: 360px; }
  .modal-panel .modal-header .btn { padding: 6px 12px; }
  .modal-field input[type="text"],
  .modal-field input[type="datetime-local"],
  .modal-field input[type="number"] { font-size: 18px; padding: 8px 12px; }
  .modal-actions { gap: 12px; }
  .drop-zone { padding: 24px; min-height: 100px; }
  .photo-thumb .remove { font-size: 22px; padding: 0 10px; }
  #context-menu { font-size: 20px; min-width: 240px; }
  #context-menu button { padding: 12px 18px; }
  .cp-list { max-height: 60vh; padding: 8px; gap: 4px; }
  .cp-row { padding: 8px 12px; gap: 12px; }
  .cp-row .meta { font-size: 16px; }
  .station-popup .leaflet-popup-content,
  .index-cp-popup .leaflet-popup-content { font-size: 18px; margin: 12px 14px; }
  .station-popup .go,
  .index-cp-popup .go { font-size: 18px; padding: 8px 14px; }
  #save-error { font-size: 18px; padding: 14px 20px; }
}
