/* © 2026 Winston Moy. All rights reserved. */
/* Light is the default. js/theme.js sets data-theme="dark" on <html> when the user picks Dark. */
:root {
  color-scheme: light;               /* native controls (file picker, number spinners, scrollbars) follow the theme */
  accent-color: var(--accent);
  --bg: #f6f7f8;
  --fg: #1c2024;
  --muted: #5f6870;
  --line: #d5d9dd;
  --accent: #2563eb;
  --warn: #b42318;
  --warn-bg: #fef3f2;
  --map-bg: #ddd;
  --map-ui-bg: rgba(255, 255, 255, .85);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a1d;
  --fg: #e8eaec;
  --muted: #9aa3ab;
  --line: #333a40;
  --accent: #6ea0ff;
  --warn: #ff8a80;
  --warn-bg: #3a1f1d;
  --map-bg: #1b1f23;
  --map-ui-bg: rgba(23, 26, 29, .85);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* classes that set display (.row, .info) would otherwise defeat the hidden attribute */
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
}

#panel {
  width: 340px;
  flex: none;
  padding: 0 16px 24px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
#stage { flex: 1; min-width: 0; position: relative; }
#map { position: absolute; inset: 0; }
#hm-view { position: absolute; inset: 0; padding: 56px 16px 16px; background: var(--map-bg); }
#hm-canvas { display: block; width: 100%; height: 100%; object-fit: contain; background: transparent; cursor: crosshair; }
#hm-readout { position: absolute; left: 16px; bottom: 16px; padding: 4px 10px; border-radius: 6px; background: var(--map-ui-bg); color: var(--fg); font-variant-numeric: tabular-nums; pointer-events: none; }
#t3-view { position: absolute; inset: 0; background: var(--map-bg); }
#t3-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
#t3-ctl { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--map-ui-bg); color: var(--fg); font-size: 13px; }
#t3-ctl label { display: flex; align-items: center; gap: 6px; }
#t3-hint { position: absolute; left: 16px; bottom: 12px; padding: 3px 9px; border-radius: 6px; background: var(--map-ui-bg); color: var(--muted); font-size: 12px; pointer-events: none; }
#t3-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--fg); pointer-events: none; }
#view-switch { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1100; display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--map-ui-bg); }
#view-switch button { border: 0; border-radius: 0; background: transparent; color: var(--fg); padding: 6px 14px; font: inherit; cursor: pointer; }
#view-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
#view-switch button:disabled { opacity: .45; cursor: default; }

h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.title-row { padding-top: 14px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.theme-btn { padding: 4px 10px; font-size: 12px; color: var(--muted); }
h3 { margin: 14px 0 6px; font-size: 14px; }
h2 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.lede, .hint { color: var(--muted); margin: 4px 0 8px; overflow-wrap: anywhere; }
progress { width: 100%; margin: 8px 0 0; }
input[type="file"] { display: block; width: 100%; margin-top: 4px; font: inherit; }
fieldset.field { border: 0; padding: 0; margin: 8px 0; }
fieldset.field legend { padding: 0; color: var(--fg); }
label.inline { display: block; margin: 4px 0; }
input[type="number"] { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; min-height: 40px; width: 100%; margin-top: 4px; }
.field + .field { margin-top: 8px; }
.row > .field { flex: 1; margin-top: 0; }
.advanced { margin-top: 18px; }
.advanced summary { cursor: pointer; color: var(--muted); }

.row { display: flex; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .field { flex: 1 1 8rem; min-width: 0; }
.row.wrap > button { flex: 1 1 8rem; }
button, select {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px;
  min-height: 40px;                 /* comfortable touch target */
}
button { cursor: pointer; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.field { display: block; }
.field select { display: block; width: 100%; margin-top: 4px; }

.info { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-variant-numeric: tabular-nums; }

.warning { color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: 6px; margin: 8px 0; }

/* Drawing: the map surface must own the drag gesture, or touch would pan/scroll the page instead. */
#map.drawing { cursor: crosshair; touch-action: none; user-select: none; }

.colon { align-self: center; font-weight: 600; }
.row > select { flex: 1; min-width: 0; }

.move-handle {
  width: 32px; height: 32px; margin: -16px 0 0 -16px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
  cursor: move; touch-action: none; user-select: none;
}
.move-handle:active { transform: scale(.94); }
.move-handle svg { width: 20px; height: 20px; pointer-events: none; }
.leaflet-marker-icon.handle-hidden { display: none; }   /* rectangle too small on screen: corners only */

.corner-handle {
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  background: #fff; border: 3px solid var(--accent); border-radius: 50%;
  touch-action: none;
}

@media (max-width: 720px) {
  body { flex-direction: column-reverse; }
  #panel { width: 100%; max-height: 45vh; border-right: 0; border-top: 1px solid var(--line); }
  #stage { min-height: 55vh; }
}

/* ---- Map in dark mode -------------------------------------------------------------------------
 * The OSM tiles are light. Rather than switch tile provider (a different data source and attribution), invert them
 * and rotate hue back so water stays bluish and roads stay light-on-dark. Only the map tile layers are filtered; the
 * selection rectangle, track and handles sit in other panes and keep their colours. */
.leaflet-container { background: var(--map-bg); }
:root[data-theme="dark"] .leaflet-layer.tiles-map { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9); }
:root[data-theme="dark"] .leaflet-layer.tiles-photo { filter: brightness(.8); }   /* photos are never inverted, just dimmed */

.leaflet-control-layers { background: var(--bg); color: var(--fg); border: 1px solid var(--line); box-shadow: none; }
.leaflet-control-layers-toggle { background-color: var(--bg); }
:root[data-theme="dark"] .leaflet-control-layers-toggle { filter: invert(1) brightness(1.4); }   /* the stock icon is dark-on-light */
.leaflet-control-layers label { margin: 2px 0; }

.leaflet-bar a, .leaflet-bar a:hover {
  background-color: var(--bg); color: var(--fg); border-bottom-color: var(--line);
}
.leaflet-bar { border-color: var(--line); }
.leaflet-bar a:hover { background-color: var(--line); }
.leaflet-bar a.leaflet-disabled { background-color: var(--bg); color: var(--muted); }
.leaflet-container .leaflet-control-attribution { background: var(--map-ui-bg); color: var(--muted); }  /* matches Leaflet's own specificity */
.leaflet-container .leaflet-control-attribution a { color: var(--accent); }
.leaflet-control-scale-line { background: var(--map-ui-bg); color: var(--fg); border-color: var(--fg); text-shadow: none; }

/* ---- Panes and the always-visible data strip ------------------------------------------------ */
.data-strip {
  position: sticky; top: 0; z-index: 5;
  margin: 8px -16px 12px; padding: 8px 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.data-strip .strip-line { margin: 0 0 4px; }
.data-strip .info { margin: 6px 0 0; }
.data-strip .row { margin-top: 6px; }
.data-strip .warning { margin: 6px 0 0; }

.pane { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; }
.pane > summary {
  display: flex; align-items: center; gap: 8px; list-style: none;
  padding: 10px 12px; min-height: 44px; cursor: pointer; font-weight: 600; user-select: none;
}
.pane > summary::-webkit-details-marker { display: none; }
.pane > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.pane[open] > summary::after { transform: rotate(-135deg); }
.pane > summary:active { background: var(--line); }
.pane > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
.pane[open] > summary { border-bottom: 1px solid var(--line); }
.pane-body { padding: 4px 12px 12px; }
.pane-body h3:first-child { margin-top: 8px; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; }

/* ---- Route point editing ------------------------------------------------------------------------ */
#map.editing-hit-vertex { cursor: move; }
#map.editing-hit-line { cursor: copy; }
.leaflet-edit-pane { z-index: 450; pointer-events: none; }
#pane-clean .row button { flex: 1; }
#pane-clean input:disabled, #pane-clean button:disabled { opacity: .5; }

/* ---- Editing view ---------------------------------------------------------------------------- */
#main-view[hidden], #edit-view[hidden] { display: none; }
.edit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 14px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 8px; border-bottom: 1px solid var(--line); margin: 0 -16px 8px; padding-left: 16px; padding-right: 16px; }
.edit-title { margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--fg); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; min-width: 84px; }
.segmented { display: flex; margin: 6px 0 10px; }
.segmented button { flex: 1; border-radius: 0; margin-left: -1px; }
.segmented button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 6px 6px 0; }
.segmented button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.help { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.help li { margin: 4px 0; }
.help b { color: var(--fg); }
#edit-view .row button { flex: 1; }

/* Rotate button: circular arrows around a small frame that turns upright in portrait. */
#aspect-swap { display: inline-flex; align-items: center; justify-content: center; padding: 4px 8px; }
#aspect-swap svg { width: 24px; height: 24px; }
#aspect-swap .orient { fill: currentColor; fill-opacity: .2; stroke-width: 1.5; transform-box: fill-box; transform-origin: center; transition: transform .2s; }
#aspect-swap.is-portrait .orient { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { #aspect-swap .orient { transition: none; } }

/* Carve size: the number takes the room, the unit menu is only as wide as its text. */
#carve-size { flex: 1 1 0; width: auto; min-width: 0; }
.row > select#carve-unit { flex: 0 0 auto; width: auto; min-width: 4.5em; }

/* Tabs (route export: PNG layer / vector). */
.tabs { display: flex; gap: 4px; margin: 8px 0; border-bottom: 1px solid var(--border, #d0d7de); }
.tabs [role="tab"] { flex: 1; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; background: transparent; padding: 6px 8px; cursor: pointer; font: inherit; color: inherit; opacity: .7; }
.tabs [role="tab"][aria-selected="true"] { opacity: 1; font-weight: 600; border-color: var(--border, #d0d7de); background: var(--panel, transparent); box-shadow: inset 0 -2px 0 var(--accent, #2563eb); }
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: -2px; }

.osm-group { border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; padding: 4px 10px 6px; }
.osm-group label.inline { display: flex; align-items: flex-start; gap: 8px; }
.osm-group label.inline input { flex: none; margin: .25em 0 0; }
.marker-add { display: flex; gap: 8px; margin: 8px 0 4px; }
.marker-add input { flex: 1 1 auto; min-width: 0; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.marker-add button { flex: none; white-space: nowrap; }
.marker-list { list-style: none; margin: 4px 0 0; padding: 0; }
.marker-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.marker-list button { flex: none; padding: 2px 8px; font-size: 12px; }
.osm-group legend { padding: 0 4px; font-size: 0.9em; color: var(--muted); }
#fb-message, #fb-contact { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
#fb-message { resize: vertical; }
#pane-feedback .field, #pane-feedback .check { display: block; margin: 8px 0; }
#pane-feedback .row { margin-top: 8px; }
#fb-status { margin: 8px 0 0; }
.crash { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.crash span { flex: 1 1 100%; }
#credits { font-size: 0.8em; margin: 16px 0 4px; padding-top: 8px; border-top: 1px solid var(--line); line-height: 1.4; }

.filename { margin-top: 4px; color: var(--muted, inherit); overflow-wrap: anywhere; }
.route-actions > button { flex: 1; }
.region-locked .corner-handle, .region-locked .move-handle { display: none; }
.plain { margin: 4px 0 0; padding-left: 18px; }

/* Collapsible secondary options inside a pane (step 3). A small "on" marker shows when something inside is active. */
details.sub { margin: 8px 0; border-top: 1px solid var(--line); padding-top: 6px; }
details.sub > summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
details.sub > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.info dd.bad { color: var(--warn); }
.sub-on { margin-left: 6px; padding: 0 6px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 11px; }
/* rev ce74e5 */
