/* Layout: one screen. The photo view on top, a compact controls card in the middle, and the
   eye cross-section with its explanation at the bottom. Light, monochrome, after Garde's
   Maurten Fuel Planner: grey page, white cards, black selected states, mono labels. */
:root {
  --page: #ebebeb;
  --card: #ffffff;
  --well: #f1f1f1;
  --chip: #e3e3e3;
  --ink: #0b0b0b;
  --ink-2: #8a8a8a;
  --muted: #6c6c6c;
  --grid: #d6d6d6;
  --line: #e4e4e4;
  --ok: #1fa34a;
  --warn: #e2612b;

  --font-sans: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r-card: 18px;
  --r-ctl: 6px;
  --row: 24px;
  color-scheme: light;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* Scrollbars: thin grey pill on a transparent track, inset so it clears the card corners */
* { scrollbar-width: thin; scrollbar-color: var(--grid) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; margin: 10px 0; }
::-webkit-scrollbar-thumb { background: var(--grid); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-2); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
button, input, select { font: inherit; color: inherit; }

/* Mono label: the system's LABEL SMALL */
.label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.app {
  height: 100%;
  box-sizing: border-box;
  padding: 10px 12px 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

/* Top bar */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 6px;
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand h1 {
  margin: 0;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.top-controls { display: flex; gap: 8px; align-items: center; }
.cam-link {
  padding: 8px 14px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--card);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}

/* Segmented control: grey track, black selected pill */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--chip);
}
.seg button {
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.seg button[aria-checked="true"] { background: var(--ink); color: var(--card); }

/* Stage */
.stage {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(200px, 1.25fr) auto minmax(230px, 1fr);
  gap: 10px;
}
.card { background: var(--card); border-radius: var(--r-card); min-width: 0; min-height: 0; }

/* Photo view */
.view { position: relative; overflow: hidden; background: #111111; }
.view canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: var(--r-ctl);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  backdrop-filter: blur(8px);
}
.tag:empty { display: none; }
.tag.good::before, .tag.warn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.tag.warn::before { background: var(--warn); }
.compare {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border: 0;
  border-radius: var(--r-ctl);
  padding: 8px 12px;
  background: var(--card);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.compare[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.hint, .credit {
  position: absolute;
  left: 12px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.hint { bottom: 26px; }
.credit { bottom: 12px; opacity: 0.75; }
.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  pointer-events: none;
}

/* Controls card */
.controls { padding: 12px 16px 14px; display: grid; gap: 10px; }
.presets-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.presets-row > .label { flex: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: var(--row);
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover { background: #d6d6d6; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--card); }

.control-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }
.group { display: grid; align-content: start; gap: 5px; min-width: 0; }
.group > h2 {
  margin: 0 0 2px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

/* Slider: black fill with the label inside the bar, value in a grey box */
.slider {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.9em;
  gap: 4px;
  height: var(--row);
}
.slider.has-toggle { grid-template-columns: auto minmax(0, 1fr) 4.9em; }
.slider > input[type="range"], .slider > label { grid-row: 1; grid-column: 1; }
.slider.has-toggle > input[type="range"], .slider.has-toggle > label { grid-column: 2; }
.slider > label {
  z-index: 1;
  align-self: center;
  padding-left: 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  mix-blend-mode: difference;
  pointer-events: none;
  white-space: nowrap;
}
.slider > .switch { grid-row: 1; grid-column: 1; }
.slider > output {
  grid-row: 1;
  grid-column: -2 / -1;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  border-radius: var(--r-ctl);
  background: var(--well);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  height: var(--row);
  margin: 0;
  border-radius: var(--r-ctl);
  background: linear-gradient(to right, var(--ink) var(--p, 50%), var(--chip) var(--p, 50%));
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--ink);
}
input[type="range"]::-moz-range-thumb {
  width: 3px;
  height: 16px;
  border: 0;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--ink);
}
input[type="range"]::-moz-range-track { background: transparent; }

/* Toggle switch */
.switch {
  -webkit-appearance: none;
  appearance: none;
  align-self: center;
  width: 32px;
  height: 18px;
  margin: 0 2px 0 0;
  border-radius: 999px;
  background: #c9c9c9;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s;
}
.switch:checked { background: var(--ink); }
.switch:checked::before { transform: translateX(14px); }

select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  height: var(--row);
  padding: 0 26px 0 9px;
  border: 0;
  border-radius: var(--r-ctl);
  background: var(--well) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0h8L4 5z' fill='%230b0b0b'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.linkish {
  border: 0;
  padding: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cross-section card */
.cross { display: grid; grid-template-columns: minmax(0, 1fr) 300px; overflow: hidden; }
.cross-main { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.card-head { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px 0; min-width: 0; }
.card-note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diagram-wrap { position: relative; min-height: 0; }
.diagram-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.explain-col {
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  padding: 12px 16px 14px;
  display: grid;
  align-content: start;
  gap: 8px;
}
.explain-col h2 { margin: 0; }
.psf { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; }
.psf canvas { width: 64px; height: 64px; border-radius: var(--r-ctl); background: var(--well); }
.psf-text { display: grid; gap: 3px; min-width: 0; }
.psf-val { font-family: var(--font-mono); font-size: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; border-top: 1.5px solid var(--ink); }
.legend i.dash { border-top: 1.5px dashed var(--ink-2); }
.explain { display: grid; gap: 6px; font-size: 13.5px; line-height: 1.4; color: #3a3a3a; }
.explain p { margin: 0; }
.explain p:last-child { color: var(--ink); font-weight: 500; }
.fineprint { margin: 4px 0 0; font-size: 11px; line-height: 1.4; color: var(--muted); }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Narrower windows: two control columns, let the page scroll. */
@media (max-width: 960px), (max-height: 620px) {
  html, body { height: auto; }
  .app { height: auto; }
  .stage { grid-template-rows: auto auto auto; }
  .view { height: min(50vh, 56vw); min-height: 220px; }
  .cross { height: 360px; }
}
@media (max-width: 960px) {
  .control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; }
  .control-grid { grid-template-columns: minmax(0, 1fr); }
  .cross { grid-template-columns: minmax(0, 1fr); height: auto; }
  .diagram-wrap { height: 340px; }
  .explain-col { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .card-note { white-space: normal; }
  .hint, #hud-blur { display: none; }
  .credit { bottom: 52px; }
}
