/* Drafting-table palette: cool tracing paper, graphite ink, one highlighter for the side being drawn. */
:root {
  --paper: #f2f3f0;
  --sheet: #ffffff;
  --ink: #22262b;
  --pencil: #656b72;
  --rule: #d5d8d2;
  --blue: #1d4f91;
  --start: #2e7d4f;
  --stop: #c2412d;
  --marker: #f5c518;
  --marker-soft: #fdf3c4;
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--ink); color: #fff;
}
header h1 {
  margin: 0; font-size: 22px; font-weight: 650; font-stretch: 78%; letter-spacing: 0.005em;
}
#who { margin-left: auto; font-size: 14px; color: #c9cdd1; }
#who .link { color: #fff; }

main { padding: 20px 24px 48px; max-width: 1600px; margin: 0 auto; }
h2 { font-size: 20px; font-weight: 650; font-stretch: 85%; margin: 0 0 14px; }
h3 { font-size: 16px; font-weight: 600; margin: 0; }

.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 22px; margin-bottom: 20px; }
.card.narrow { max-width: 420px; margin: 48px auto; }

label { display: block; font-size: 13px; color: var(--pencil); margin-bottom: 12px; }
input, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 6px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; font-size: 14px; }
#coordinate-input { margin-top: 12px; font-size: 13px; }
#coordinate-input summary { color: var(--blue); cursor: pointer; padding: 6px 0; font-weight: 600; }
#coordinate-input label { margin: 8px 0 4px; }
#apply-coordinates { margin-top: 10px; }
.coordinate-preview { padding: 8px 0; margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.coordinate-preview dt { font-weight: 600; margin-top: 6px; }
.coordinate-preview dd { margin: 0; font-variant-numeric: tabular-nums; }
button, .button {
  display: inline-block; font: inherit; font-size: 14px; font-weight: 600; padding: 10px 18px; border-radius: 6px;
  border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; text-decoration: none;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.secondary, .button.secondary { background: #fff; color: var(--blue); }
button.link { background: none; border: none; padding: 0; font-weight: 500; color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted, .hint { color: var(--pencil); }
.hint { font-size: 13.5px; margin: 6px 0 0; }
.msg { font-size: 14px; color: var(--blue); min-height: 1em; margin: 10px 0 0; }
.bad { color: var(--stop) !important; }
ul.plain { list-style: none; margin: 0; padding: 0; }

.pill { font-size: 13px; padding: 4px 12px; border-radius: 999px; }
.pill.on { background: #2f5d43; color: #e3f4e9; }
.pill.on::before, .pill.off::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.pill.on::before { background: #7ee2a4; }
.pill.off { background: #4a3f2a; color: #f6e7c4; }
.pill.off::before { background: var(--marker); }

/* ---------- workbench: steps beside a large map ---------- */
.workbench {
  display: grid; grid-template-columns: 380px 1fr;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
}
.panel { padding: 20px 22px; border-right: 1px solid var(--rule); }
.map-workspace { min-width: 0; background: var(--paper); }
.map-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px; background: var(--sheet); }
.map-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.map-buttons button { min-height: 44px; }
.map-buttons button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.arrow-start { color: var(--start); font-size: 20px; line-height: 1; }
.arrow-stop { color: var(--stop); font-size: 20px; line-height: 1; }
.map-buttons button[aria-pressed="true"] span { color: #fff; }
.map-distance { display: flex; flex-direction: column; }
.map-distance strong { font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.map-distance span { font-size: 11px; color: var(--pencil); }
.map-instruction { margin: 0; padding: 9px 12px; border-top: 1px solid var(--rule); font-size: 13px; }
#map { min-height: 560px; height: calc(100vh - 250px); max-height: 780px; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step { position: relative; padding: 0 0 22px 40px; counter-increment: step; }
.step::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--rule); color: var(--pencil); background: var(--sheet);
}
.step:not(:last-child)::after {
  content: ""; position: absolute; left: 12.5px; top: 28px; bottom: 2px; width: 1.5px; background: var(--rule);
}
.step h3 { color: var(--pencil); margin-bottom: 4px; }
.step.current h3 { color: var(--ink); }
.step.current::before { border-color: var(--ink); color: #fff; background: var(--ink); }
.step.done::before { content: "✓"; border-color: var(--start); background: var(--start); color: #fff; }
.step.done h3 { color: var(--ink); }

.search { position: relative; margin-top: 8px; }
.search input { margin: 0; }
.suggestions {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 8px 24px rgba(34, 38, 43, 0.14);
}
.suggestions li { padding: 8px 10px; border-radius: 4px; cursor: pointer; display: flex; flex-direction: column; }
.suggestions li span { font-size: 13px; color: var(--pencil); }
.suggestions li:hover, .suggestions li.active { background: var(--paper); }

.ends { margin: 10px 0 0; display: grid; gap: 6px; }
.ends div { display: grid; grid-template-columns: 70px 1fr; align-items: baseline; font-size: 14px; }
.ends dt { font-weight: 600; }
.ends dd { margin: 0; color: var(--pencil); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--rule); }
.dot.start { background: var(--start); }
.dot.stop { background: var(--stop); }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.side {
  padding: 0; background: #fff; color: var(--ink); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden;
  display: flex; flex-direction: column; text-align: left; font-weight: 600;
}
.side img { display: block; width: 100%; aspect-ratio: 40 / 26; object-fit: cover; background: var(--paper); }
.side span { padding: 7px 9px; font-size: 13px; }
.side:hover { border-color: var(--pencil); }
.side.chosen { border-color: #c99a00; box-shadow: 0 0 0 3px var(--marker); }
.side.chosen span { background: var(--marker); }

/* ---------- results ---------- */
.results { margin-top: 32px; }
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.toggle { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--ink); cursor: pointer; }
.toggle input { width: auto; margin: 0; }

.job { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 20px; margin-bottom: 14px; }
.job.running { border-color: #c99a00; }
.job { scroll-margin-top: 20px; }
.job.submitted { border-color: var(--blue); }
#results-msg { margin: 0 0 16px; }
.job-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.meta { margin: 2px 0 0; font-size: 13px; color: var(--pencil); }
.job-body:not(:empty) { margin-top: 12px; }
.badge { font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--paper); color: var(--pencil); white-space: nowrap; }
.badge.done { background: #e4f2e9; color: var(--start); }
.badge.running { background: var(--marker-soft); color: #7a5c00; }
.badge.failed { background: #f8e4e0; color: var(--stop); }
.badge.review { background: var(--marker-soft); color: #7a5c00; }
.badge.collecting { background: #e7edf7; color: var(--blue); }
.job.review { border-color: #c99a00; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 18px; }
.photo-card { min-width: 0; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.photo-zoom { display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: var(--paper); cursor: zoom-in; }
.photo-zoom img { display: block; width: 100%; height: 220px; object-fit: contain; }
.photo-card.excluded .photo-zoom { opacity: 0.4; }
.photo-card .hint { padding: 0 12px; font-size: 12px; }
.photo-choice { display: flex; align-items: center; gap: 8px; padding: 12px; margin: 0; min-height: 44px; color: var(--ink); cursor: pointer; }
.photo-choice input { width: 18px; height: 18px; margin: 0; }
.photo-review-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 18px; }

.progress { list-style: none; display: flex; margin: 0; padding: 0; gap: 4px; }
.progress li { flex: 1; padding-top: 8px; font-size: 13px; color: var(--pencil); border-top: 4px solid var(--rule); }
.progress li.done { border-color: var(--start); color: var(--ink); }
.progress li.current { border-color: var(--marker); color: var(--ink); font-weight: 600; }

.strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; align-items: start;
  width: 100%; padding: 0; background: none; border: none; cursor: zoom-in;
}
.strip img {
  display: block; width: 100%; max-height: 320px; object-fit: contain; object-position: left top;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--paper);
}
.strip:hover img { border-color: var(--pencil); }

.actions { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; margin-top: 12px; font-size: 14px; }
.actions a { color: var(--blue); text-underline-offset: 2px; }
.empty { padding: 28px; text-align: center; color: var(--pencil); background: var(--sheet); border: 1px dashed var(--rule); border-radius: 8px; }
details summary { cursor: pointer; font-size: 13px; color: var(--pencil); margin-top: 6px; }
pre.error { white-space: pre-wrap; font-size: 12px; background: #f8e4e0; color: var(--stop); padding: 8px; border-radius: 6px; }
#pending-users li { padding: 8px 0; }
#pending-users span { flex: 1; }

/* ---------- full-size viewer ---------- */
#viewer, #photo-viewer {
  width: min(96vw, 1800px); max-width: none; height: 92vh; padding: 0; border: none; border-radius: 8px;
  background: var(--sheet); color: var(--ink);
}
#viewer::backdrop, #photo-viewer::backdrop { background: rgba(34, 38, 43, 0.72); }
#viewer[open], #photo-viewer[open] { display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.viewer-bar strong { margin-right: auto; }
.tabs { display: flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.tabs button { border: none; border-radius: 0; background: #fff; color: var(--ink); font-weight: 500; padding: 8px 14px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.viewer-body { flex: 1; overflow: auto; display: grid; place-items: center; padding: 16px; background: var(--paper); }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }

@media (max-width: 960px) {
  main { padding: 12px; }
  .workbench { grid-template-columns: 1fr; }
  .panel, .steps { display: contents; }
  .step { padding: 18px 18px 18px 54px; }
  .step::before { left: 16px; top: 18px; }
  .step:not(:last-child)::after { left: 28.5px; top: 48px; }
  .step[data-step="find"] { order: 1; }
  .step[data-step="find"]::after { display: none; }
  .map-workspace { order: 2; border-block: 1px solid var(--rule); }
  .step[data-step="ends"] { order: 3; }
  .step[data-step="side"] { order: 4; }
  .step[data-step="send"] { order: 5; }
  #map { min-height: 420px; height: 60vh; }
}
