:root {
  color-scheme: dark;
  font:
    13px -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  /* WoolawayWx brand palette. Burgundy on ink is only 2.2:1, so burgundy is a
     fill behind cream text, never text or thin lines on the dark UI. */
  --burgundy: #a61e22;
  --ink: #1e1f20;
  --cream: #f1eee6;
  --bg: #161718;
  --bar: var(--ink);
  --control: #28292a;
  --control-hover: #323334;
  --control-border: #3a3b3d;
  --hover-border: #6b6862;
  --line: #343537;
  --text: #e2ded5;
  --muted: #9a968e;
  --accent: var(--cream);
  background: var(--bg);
  color: var(--text);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bar {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bar);
  z-index: 2;
  padding: 10px 14px;
  flex-shrink: 0;
}
.top {
  min-height: 62px;
  border-bottom: 1px solid var(--line);
}
.bottom {
  min-height: 54px;
  border-top: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.6px;
  margin-right: 15px;
}
.brand span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cream);
}
.brand small {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px;
}
button,
select,
input {
  font: inherit;
  color: inherit;
}
button,
select,
#site {
  border: 1px solid var(--control-border);
  border-radius: 5px;
  background: var(--control);
  height: 33px;
  padding: 0 10px;
}
button {
  cursor: pointer;
  white-space: nowrap;
}
button:hover,
select:hover,
#site:hover {
  background: var(--control-hover);
  border-color: var(--hover-border);
}
button:focus-visible,
select:focus-visible,
#site:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.spacer {
  flex: 1;
}
.badge {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  white-space: nowrap;
}
.muted {
  color: var(--muted);
}
.active {
  color: var(--cream);
  border-color: var(--burgundy);
  background: var(--burgundy);
}
.site-control #site {
  width: 250px;
  max-width: 100%;
  background: var(--control);
}
.site-control #site:focus {
  outline-offset: 0;
}
#product {
  max-width: 215px;
}
#map {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
}
#radar {
  touch-action: none;
  cursor: grab;
}
#radar:active {
  cursor: grabbing;
}
#labels {
  pointer-events: none;
}
#notice {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(640px, 90%);
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1e1f20ee;
  box-shadow: 0 3px 15px #0003;
  font-size: 12px;
  line-height: 1.5;
}
#notice.error {
  border-color: #825041;
}
#notice button {
  height: 28px;
  padding: 0 10px;
  flex-shrink: 0;
}
.status-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}
.error .status-dot {
  background: #efa079;
}
#notice.hidden {
  display: none;
}
.map-credit {
  position: absolute;
  bottom: 7px;
  right: 12px;
  font-size: 12px;
  color: var(--muted);
  text-shadow: 0 1px 2px #000;
}
#timeline {
  min-width: 45px;
  flex: 1;
  accent-color: var(--accent);
}
#time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 12px;
}
#frameCount,
#elevation {
  white-space: nowrap;
  font-size: 12px;
}
#elevation:empty {
  display: none;
}
.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}
#legendRamp {
  display: block;
  width: 100px;
  height: 7px;
  border-radius: 2px;
}
#coordinates {
  min-width: 115px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
dialog {
  border: 1px solid var(--control-border);
  border-radius: 12px;
  background: var(--bar);
  color: var(--text);
  width: min(450px, calc(100vw - 28px));
  padding: 24px;
  box-shadow: 0 25px 100px #0009;
  max-height: 90dvh;
}
dialog::backdrop {
  background: #0b0b0cb0;
  backdrop-filter: blur(3px);
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}
#settingsForm section > label {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 18px;
  font-weight: 500;
}
h2 {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 0;
}
#settingsForm section:first-of-type h2 {
  margin-top: 0;
}
#settingsForm select {
  width: 100%;
  height: 38px;
}
#settingsForm p {
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 0 16px;
}
#settingsForm input[type="number"] {
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--control-border);
  border-radius: 5px;
  padding: 8px;
}
.check {
  flex-direction: row !important;
  align-items: center;
}
.check input {
  accent-color: var(--burgundy);
}
.archive {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 2px;
}
.archive input {
  font-size: 12px;
  font-weight: 400;
  max-width: 100%;
}
.primary {
  background: var(--burgundy);
  color: var(--cream);
  border: 0;
  font-weight: 650;
  width: 100%;
  margin-top: 4px;
  height: 39px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
/* Tablet and below: compact bars. The source badge shows its short name. */
@media (max-width: 1100px) {
  .optional {
    display: none;
  }
  .badge {
    display: block;
    font-size: 0;
  }
  .badge::after {
    content: attr(data-short);
    font-size: 12px;
  }
  .brand {
    margin-right: 0;
  }
  .bar {
    gap: 6px;
    padding: 9px;
  }
  .site-control #site {
    width: 200px;
  }
  #legendRamp {
    width: 56px;
  }
}

/* Phones: the selectors get their own row; Previous/Next/Center stay, the coordinates go. */
@media (max-width: 700px) {
  .top {
    flex-wrap: wrap;
    gap: 7px;
  }
  .top::after {
    content: "";
    height: 0;
    flex-basis: 100%;
    order: 2;
  }
  .brand {
    font-size: 17px;
    margin-right: auto;
  }
  .brand small,
  .spacer,
  #coordinates,
  #frameCount {
    display: none;
  }
  .badge {
    order: 0;
  }
  .site-control {
    order: 3;
    width: 42%;
  }
  .site-control #site {
    width: 100%;
    max-width: none;
  }
  .top > label:has(#product) {
    order: 4;
    flex: 1 1 0;
    min-width: 0;
  }
  #product {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .top > label:has(#tilt) {
    order: 5;
  }
  #settingsButton,
  #refresh {
    font-size: 17px;
  }
  /* Two rows: transport controls, then time, elevation, legend and map buttons. */
  .bottom {
    flex-wrap: wrap;
    gap: 4px 4px;
    padding: 8px 6px;
  }
  .bottom button {
    padding: 0 8px;
  }
  #timeline {
    flex: 1 1 calc(100% - 215px);
  }
  #time {
    flex: 1 1 auto;
  }
  #legendRamp {
    width: 48px;
  }
}

/* Landscape phones: fold both bars into single compact rows. */
@media (max-height: 500px) and (orientation: landscape) {
  .top {
    flex-wrap: nowrap;
    min-height: 48px;
    padding-block: 6px;
  }
  .top::after {
    display: none;
  }
  .brand span,
  .badge,
  .optional {
    display: none;
  }
  .site-control {
    width: auto;
    order: 0;
  }
  .site-control #site {
    width: 150px;
  }
  .top > label:has(#product) {
    order: 0;
    flex: 0 1 150px;
  }
  .top > label:has(#tilt) {
    order: 0;
  }
  .spacer {
    display: block;
  }
  .bottom {
    flex-wrap: nowrap;
    min-height: 48px;
    padding-block: 6px;
  }
  #timeline {
    flex: 1 1 0;
  }
  #coordinates,
  #frameCount {
    display: none;
  }
  #notice {
    top: 8px;
  }
  dialog {
    max-height: 96dvh;
  }
}

/* Touch targets: at least 44px on coarse pointers. */
@media (pointer: coarse) {
  button,
  select,
  #site {
    min-height: 44px;
    min-width: 44px;
  }
  #notice button {
    height: 44px;
  }
  #settingsForm select,
  #settingsForm input[type="number"] {
    height: 44px;
  }
  #timeline {
    height: 44px;
  }
  .check input {
    width: 24px;
    height: 24px;
  }
  .check {
    min-height: 44px;
  }
}

#reportControls {
  margin-top: 12px;
}
#reportPayload {
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 8px;
  background: var(--bg);
}
