/* Image Geotagger. Survey-map palette: slate ink, sage contour lines, flagging-tape pink for the pin. */

:root {
  --paper: #eef2ee;
  --panel: #ffffff;
  --ink: #17242e;
  --muted: #56676f;
  --line: #d3ddd5;
  --contour: #b6c8b8;
  --flag: #d41c68;
  --flag-ink: #ffffff;
  --water: #2a6a8e;
  --ok: #1d7448;
  --warn: #a8571a;
  --field: #f6f8f6;
  --shadow: 0 1px 0 rgba(23, 36, 46, 0.06), 0 8px 24px -12px rgba(23, 36, 46, 0.18);
  --font: "Archivo", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111b22;
    --panel: #17242d;
    --ink: #e3ebe6;
    --muted: #94a6ad;
    --line: #2a3b44;
    --contour: #2b4048;
    --flag: #ff4f95;
    --flag-ink: #1a0a12;
    --water: #73b6db;
    --ok: #4cc58b;
    --warn: #f0a060;
    --field: #1d2c36;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111b22; --panel: #17242d; --ink: #e3ebe6; --muted: #94a6ad; --line: #2a3b44; --contour: #2b4048;
  --flag: #ff4f95; --flag-ink: #1a0a12; --water: #73b6db; --ok: #4cc58b; --warn: #f0a060; --field: #1d2c36;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-variation-settings: "wdth" 100;
}
a { color: var(--water); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--flag); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 6px; z-index: 2000; }
.skip:focus { top: 12px; }

/* ---------- masthead ---------- */
.masthead { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.contours { position: absolute; inset: 0; width: 100%; height: 100%; stroke: var(--contour); }
.masthead-inner { position: relative; max-width: 1360px; margin: 0 auto; padding: 28px 24px 30px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; font-weight: 700; font-variation-settings: "wdth" 112; letter-spacing: 0.01em; }
.flag { width: 20px; height: 26px; color: var(--ink); }
.flag-cloth { fill: var(--flag); }
.masthead h1 {
  margin: 0 0 10px;
  max-width: 16ch;
  font-size: clamp(2rem, 4.6vw, 3.5rem);
  line-height: 1.02;
  font-weight: 800;
  font-variation-settings: "wdth" 125;
  letter-spacing: -0.015em;
}
.lede { margin: 0; max-width: 60ch; color: var(--muted); font-size: 1.05rem; }

/* ---------- workspace ---------- */
.workspace {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 24px 8px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 390px;
  grid-template-areas: "tray rail" "map rail";
  align-items: start;
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.tray { grid-area: tray; padding: 16px; }
.mapbox { grid-area: map; position: relative; padding: 0; overflow: hidden; }
.rail { grid-area: rail; padding: 18px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: hidden auto; }

h2 { margin: 0; font-size: 1.05rem; font-weight: 700; font-variation-settings: "wdth" 110; }

/* tray */
.tray-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.counts { margin: 0; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.meter { height: 3px; background: var(--line); border-radius: 2px; margin: 10px 0 14px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.3s ease; }

.drop {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 132px;
  padding: 20px;
  text-align: center;
  border: 1.5px dashed var(--contour);
  border-radius: 10px;
  background: var(--field);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--flag); outline-offset: 2px; }
.drop.over, .drop:hover { border-color: var(--flag); }
.drop.compact { min-height: 64px; }
.drop.compact .drop-sub { display: none; }
.drop-main { font-weight: 600; font-size: 1.02rem; }
.drop-main u { text-decoration-color: var(--flag); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.drop-sub { color: var(--muted); font-size: 0.88rem; }

.tray-tools { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0 4px; }
.link { background: none; border: 0; padding: 2px 0; color: var(--water); cursor: pointer; font-size: 0.9rem; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link.danger { color: var(--warn); }
.link:disabled { color: var(--muted); cursor: default; }

.grid { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid:empty { display: none; }
.card { position: relative; }
.card-btn {
  display: block;
  width: 100%;
  padding: 0;
  text-align: left;
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
}
.card-btn[aria-pressed="true"] { border-color: var(--flag); box-shadow: 0 0 0 1px var(--flag); }
.card-thumb { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line); }
.card-thumb.pending { display: grid; place-items: center; color: var(--muted); font-size: 0.8rem; }
.card-body { display: block; padding: 7px 9px 8px; }
.card-name { display: block; font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-status { display: block; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-status.tagged { color: var(--ok); }
.card-status.error { color: var(--warn); white-space: normal; }
.card-check {
  position: absolute; top: 7px; left: 7px;
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.92); border: 1.5px solid rgba(23, 36, 46, 0.35);
  pointer-events: none;
}
.card-btn[aria-pressed="true"] .card-check { background: var(--flag); border-color: var(--flag); }
.card-check svg { width: 13px; height: 13px; stroke: var(--flag-ink); opacity: 0; }
.card-btn[aria-pressed="true"] .card-check svg { opacity: 1; }
.card-flag { position: absolute; top: 7px; right: 7px; width: 16px; height: 21px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.card-remove {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(23, 36, 46, 0.78); color: #fff;
  font-size: 15px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 0.15s;
}
.card:hover .card-remove, .card-remove:focus-visible { opacity: 1; }
.card:hover .card-flag { opacity: 0; }
@media (hover: none) { .card-remove { opacity: 1; } .card-flag { display: none; } }

/* map */
.search { position: absolute; z-index: 600; top: 12px; left: 12px; right: 12px; display: flex; gap: 8px; max-width: 520px; }
.search input {
  flex: 1; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.results {
  position: absolute; z-index: 600; top: 58px; left: 12px; right: 12px; max-width: 520px;
  list-style: none; margin: 0; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow);
}
.results button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: none; cursor: pointer; font-size: 0.9rem; }
.results button:hover, .results button:focus-visible { background: var(--field); }
.results .muted { padding: 8px 10px; color: var(--muted); font-size: 0.9rem; }
.map { height: clamp(360px, 58vh, 620px); background: var(--field); }
.map-hint { position: absolute; z-index: 500; left: 12px; bottom: 10px; margin: 0; padding: 4px 9px; border-radius: 6px; background: var(--panel); color: var(--muted); font-size: 0.8rem; box-shadow: var(--shadow); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }
.pin { background: none; border: 0; }
.pin svg { width: 34px; height: 44px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
:root:not([data-theme="light"]) .leaflet-tile-pane { transition: filter 0.2s; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: brightness(0.82) contrast(1.05) saturate(0.85); }
}

/* rail */
.readout { padding: 2px 0 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.readout-empty { margin: 0; color: var(--muted); }
.readout-coords {
  display: grid;
  font-size: clamp(1.5rem, 2.4vw, 1.9rem);
  line-height: 1.08;
  font-weight: 700;
  font-variation-settings: "wdth" 125;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.readout-coords span::after { content: attr(data-hemi); color: var(--flag); margin-left: 0.25em; }
.readout-place { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; min-height: 1.35em; }
.readout.flash .readout-coords { animation: flash 0.5s ease; }
@keyframes flash { from { color: var(--flag); } to { color: inherit; } }

.group { border: 0; margin: 18px 0 0; padding: 0; min-width: 0; }
.group legend { padding: 0; margin-bottom: 8px; font-weight: 700; font-variation-settings: "wdth" 110; }
.group label { display: block; font-size: 0.84rem; color: var(--muted); margin-bottom: 9px; }
.group input:not([type="checkbox"]):not([type="range"]), .group select, .group textarea {
  display: block; width: 100%;
  margin-top: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  font-size: 0.94rem;
}
.group textarea { resize: vertical; min-height: 58px; }
.group input::placeholder, .group textarea::placeholder { color: var(--muted); opacity: 0.7; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }
.row3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 0 8px; }
.row3 input { font-variant-numeric: tabular-nums; }
.presets, .preset-save { display: flex; gap: 8px; align-items: center; }
.presets select { margin-top: 0 !important; }
.preset-save { margin-top: 8px; }
.preset-save input { margin-top: 0 !important; }
.note { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); }
.check { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; font-size: 0.92rem !important; }
.check input { width: 16px; height: 16px; accent-color: var(--flag); }
.range output { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }
.range input { width: 100%; accent-color: var(--flag); margin-top: 4px; }
.range.off { opacity: 0.5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper);
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--flag); border-color: var(--flag); color: var(--flag-ink); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.wide { width: 100%; margin-top: 16px; padding: 12px; font-size: 1rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(1.07); }
.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed; z-index: 3000; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px; border-radius: 9px;
  background: var(--ink); color: var(--paper);
  font-size: 0.92rem; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--warn); color: #fff; }

/* ---------- guide ---------- */
.guide {
  max-width: 1360px; margin: 0 auto; padding: 40px 24px 24px;
  display: grid; gap: 36px; grid-template-columns: repeat(3, minmax(0, 1fr));
}
.guide h2 { font-size: 1.3rem; font-variation-settings: "wdth" 118; margin-bottom: 12px; }
.guide p { max-width: 62ch; }
.steps { margin: 0 0 12px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 40px; }
.steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: -1px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--flag); color: var(--flag);
  font-weight: 700; font-size: 0.85rem;
}
.fields { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.fields th, .fields td { text-align: left; padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.fields thead th { color: var(--muted); font-weight: 600; }
.fields tbody th { font-weight: 600; white-space: nowrap; padding-right: 16px; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 2px; color: var(--muted); }

.foot { max-width: 1360px; margin: 0 auto; padding: 18px 24px 36px; color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; border-top: 1px solid var(--line); }
.foot p { margin: 0; }


/* ---------- mode tabs ---------- */
.modes { max-width: 1360px; margin: 0 auto; padding: 18px 24px 0; }
.modes-inner { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); box-shadow: var(--shadow); }
.modes button {
  border: 0; background: none; color: var(--muted);
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-variation-settings: "wdth" 108;
}
.modes button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.modes button:not([aria-selected="true"]):hover { color: var(--ink); }

/* service area */
.pool-tools { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: -4px; }
.place-status { min-height: 1.2em; }
#cam-opts.off, #cam-same-wrap.off { opacity: 0.45; pointer-events: none; }
.card-reroll {
  position: absolute; top: 6px; right: 38px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(23, 36, 46, 0.78); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 0.15s;
}
.card:hover .card-reroll, .card-reroll:focus-visible { opacity: 1; }
@media (hover: none) { .card-reroll { opacity: 1; } }
.card-num {
  position: absolute; left: 34px; top: 8px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--flag); color: var(--flag-ink); font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.card.flash .card-btn { animation: cardflash 0.9s ease; }
@keyframes cardflash { 0%, 60% { box-shadow: 0 0 0 4px var(--flag); } 100% { box-shadow: none; } }
.dot-label { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; font: 600 12px/1.3 var(--font); box-shadow: var(--shadow); padding: 4px 7px; }
.dot-label::before { display: none; }
.leaflet-tooltip.dot-num { background: none; border: 0; box-shadow: none; color: #fff; font: 700 10px/1 var(--font); padding: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; }
  .guide { grid-template-columns: 1fr 1fr; }
  .faq { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tray" "map" "rail"; padding: 16px; }
  .rail { position: static; max-height: none; }
  .masthead-inner { padding: 22px 16px 24px; }
  .modes { padding: 14px 16px 0; }
  .guide { grid-template-columns: 1fr; padding: 32px 16px 16px; }
  .foot { padding: 18px 16px 32px; }
  .map { height: 380px; }
}
@media (max-width: 420px) {
  .row3 { grid-template-columns: 1fr 1fr; }
  .row3 label:last-child { grid-column: 1 / -1; }
  .downloads { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
