/* FOV Planner — dark-first, system fonts, mobile-first single column. */

:root {
  --bg: #0b0e14;
  --panel: #141a26;
  --panel-2: #1c2433;
  --line: #2a3343;
  --text: #e6ebf2;
  --muted: #9aa7ba;
  --accent: #6db3f2;
  --good: #57d18a;
  --warn: #f2b84b;
  --bad: #f2785c;
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Phone: panes are transparent wrappers — children flow in DOM order. */
.pane { display: contents; }

/* iPad landscape / desktop: two columns. LEFT = selections (camera/target/find);
 * RIGHT = the diagram + targeting + cards + verdict. Neither column is sticky —
 * the whole layout scrolls as ONE page so the two sides move together (a sticky
 * column made them scroll out of sync, which felt awkward on iPad). */
@media (min-width: 900px) {
  main {
    max-width: 1180px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
    gap: 22px;
    align-items: start;
  }
  .pane {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
  }
  .pane-side { grid-column: 1; }
  .pane-main { grid-column: 2; }
}

/* Title bar */
.titlebar {
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.titlebar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.4px;
}
.ver {
  position: absolute;
  right: 14px;
  bottom: 12px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
/* The author display rules below beat the UA `[hidden]{display:none}` (equal
   specificity, author wins), so the hidden attribute would be ignored on
   .field / .custom-panel etc. Restore it globally. */
[hidden] { display: none !important; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 40px 0 14px;
  height: 48px;            /* >= 44px tap target */
  font-size: 16px;
  line-height: 48px;
  width: 100%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%239aa7ba' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Number/text inputs that sit directly in a .field (focal length, etc.) */
.field > input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
  width: 100%;
}
.field > input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Camera picker + Add button */
.cam-add-row { display: flex; gap: 8px; }
.cam-add-row select { flex: 1; min-width: 0; }
.cam-add-row button {
  flex: 0 0 auto;
  min-width: 72px;
  height: 48px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.cam-add-row button[disabled] { opacity: 0.55; cursor: default; }

/* Find object by name */
.find-row { display: flex; gap: 8px; }
.find-row input {
  flex: 1;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
  min-width: 0;
}
.find-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.find-row button {
  flex: 0 0 auto;
  min-width: 84px;
  height: 48px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.find-row button[disabled] { opacity: 0.55; }
.find-status { margin: 6px 2px 0; font-size: 12px; color: var(--muted); line-height: 1.45; min-height: 1em; }

/* Custom-target editor */
.custom-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.size-row { display: flex; gap: 10px; }
.size-row .img-field { flex: 1; }

/* Selected-camera readout */
.cam-info { display: flex; flex-direction: column; gap: 8px; }
.cam-info .cam { cursor: default; }

/* Advanced (optics) disclosure */
.advanced {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 14px;
}
.advanced > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 0;
  list-style: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before { content: "▸ "; }
.advanced[open] > summary::before { content: "▾ "; }
.adv-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 12px; }

/* "Add a real sky photo" disclosure wraps the image panel. The panel keeps its
   own card chrome, so drop the doubled border/padding the .image-panel adds. */
.image-disclosure { padding: 4px 14px; }
.image-disclosure .image-panel {
  border: none;
  background: transparent;
  padding: 4px 0 12px;
}

/* Camera legend / toggles */
.legend { display: flex; flex-direction: column; gap: 8px; }
.cam {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 48px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cam.off { opacity: 0.42; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 6px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
}
.cam.off .swatch { background: transparent !important; }
.cam-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.cam-name { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cam-fov { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Per-camera focal-length editor on each compare chip */
.cam-focal { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.cam-focal > span { font-size: 12px; color: var(--muted); }
.cam-focal input {
  width: 78px;
  height: 34px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.cam-focal input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cam-focal .locked-val {
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.cam-focal .lock { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bg);
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 7px;
  font-weight: 700;
}

/* Remove (×) button on an active-camera chip */
.cam-remove {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cam-remove:hover, .cam-remove:active { color: var(--bad); border-color: var(--bad); }
/* Active-camera chips aren't clickable toggles anymore */
.cam-info .cam { cursor: default; }

/* Diagram */
.diagram-wrap {
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
.diagram-stage { position: relative; }
/* transform-origin MUST be top-left: the zoom pan math (zoomAtPoint) assumes the
   element scales from (0,0). Without this, CSS defaults to center (50% 50%) and
   zooming drifts toward the bottom-right. */
#diagram { width: 100%; height: auto; display: block; border-radius: 8px; touch-action: none; transform-origin: 0 0; }

/* On-screen zoom buttons, stacked top-right over the diagram */
.zoom-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zoom-controls button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(20, 26, 38, 0.82);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(6px);
}
.zoom-controls button:active { background: var(--line); }
#zoomFitBtn { font-size: 13px; font-weight: 600; }

.caption {
  margin: 6px 2px 2px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* Targeting block: frame-center coords + position angle */
.targeting {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.targ-readout {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-variant-numeric: tabular-nums;
}
.targ-center { font-size: 18px; font-weight: 600; }
.targ-pa { font-size: 18px; font-weight: 600; color: var(--accent); }
.pa-row { display: flex; align-items: center; gap: 10px; }
.pa-row input[type="range"] { flex: 1; height: 28px; accent-color: var(--accent); min-width: 0; }
.pa-row input[type="number"] {
  flex: 0 0 auto;
  width: 78px;
  height: 40px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.pa-row input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pa-reset {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pa-reset:active { background: var(--line); }

/* Object image panel */
.image-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.img-head {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.img-hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.img-field { display: flex; flex-direction: column; gap: 6px; }
.img-field > span { font-size: 13px; color: var(--muted); }
.img-field input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
  width: 100%;
}
.img-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.img-btns { display: flex; gap: 10px; }
.img-btn {
  flex: 1;
  min-height: 48px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.img-btn:active { background: var(--line); }
.img-btn.danger { color: var(--bad); border-color: var(--bad); }
.img-btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.img-btn[disabled] { opacity: 0.55; }

/* Survey fetch box */
.img-fetch {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}
.img-fetch select {
  height: 48px; line-height: 48px;
  background: var(--panel);
}

.img-sublabel { font-size: 13px; color: var(--muted); }

/* Brightness slider */
.bright-row { display: flex; align-items: center; gap: 12px; }
.bright-row input[type="range"] {
  flex: 1;
  height: 28px;
  accent-color: var(--accent);
}
.bright-val {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 14px;
}

/* Framing nudge pad: 3x3 grid of arrow buttons */
.img-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 220px;
}
.nudge {
  min-height: 48px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nudge:active { background: var(--line); }
.nudge.center { color: var(--accent); }

/* Metric cards */
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.card .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.card .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Sampling card spans full width because it carries a per-camera list. */
.card.sampling { grid-column: 1 / -1; }
.samp-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.samp-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.samp-row .sname { color: var(--muted); }
.samp-row .sval { font-weight: 600; }

/* Verdict */
.verdict {
  margin: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.45;
}
.verdict.good { border-left-color: var(--good); }
.verdict.some { border-left-color: var(--warn); }
.verdict.bad  { border-left-color: var(--bad); }
.verdict-head { margin: 0; }
.verdict-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.verdict-row { display: flex; align-items: center; gap: 10px; }
.verdict-row .swatch { width: 16px; height: 16px; border-radius: 5px; }
.verdict-txt { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* "What's here?" reverse-lookup (SIMBAD) */
.whats-here { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.whats-here button {
  flex: 0 0 auto; height: 40px; padding: 0 14px;
  background: var(--accent); color: var(--bg); border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.whats-here button[disabled] { opacity: 0.55; cursor: default; }
.wh-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.wh-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 10px; background: var(--panel-2); border-radius: 8px; font-size: 14px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.wh-item:hover, .wh-item:active { background: var(--line); }
.wh-item strong { color: var(--text); }
.wh-type { color: var(--muted); font-size: 12px; }
.wh-dist { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
