/* Spotr. A field instrument, not a holiday planner: hard edges, black and white, one safety-orange accent,
   survey-style triangle markers. The map does the talking; the chrome stays out of the way. */
@font-face { font-family: "Plex"; src: url("/static/vendor/plex-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("/static/vendor/plex-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("/static/vendor/plex-600.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "PlexC"; src: url("/static/vendor/plexc-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "PlexC"; src: url("/static/vendor/plexc-600.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }
:root {
  --ink: #0f1112; --ink-2: #5a6065; --paper: #e4e6e7; --panel: #fbfbfb; --line: #c6cacd; --line-2: #8d9398;
  --accent: #e2531f; --accent-ink: #ffffff; --done: #0f1112; --bad: #b42318; --focus: #e2531f;
  --edge: 0 0 0 1px rgba(15, 17, 18, .55), 0 3px 0 rgba(15, 17, 18, .12);
  --r: 2px;
  --font: "Plex", "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --cond: "PlexC", "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eceeef; --ink-2: #9aa1a6; --paper: #0c0e0f; --panel: #16191b; --line: #2c3134; --line-2: #4b5257;
    --accent: #ff6a33; --accent-ink: #0c0e0f; --done: #eceeef; --bad: #ff8a7a; --focus: #ff6a33;
    --edge: 0 0 0 1px rgba(255, 255, 255, .14), 0 3px 0 rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #eceeef; --ink-2: #9aa1a6; --paper: #0c0e0f; --panel: #16191b; --line: #2c3134; --line-2: #4b5257;
  --accent: #ff6a33; --accent-ink: #0c0e0f; --done: #eceeef; --bad: #ff8a7a; --focus: #ff6a33;
  --edge: 0 0 0 1px rgba(255, 255, 255, .14), 0 3px 0 rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.45 var(--font); color: var(--ink); background: var(--paper); -webkit-tap-highlight-color: transparent; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h2, h3, .cond { font-family: var(--cond); }

#map { position: fixed; inset: 0; background: #1b1f21; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10.5px; background: color-mix(in srgb, var(--panel) 85%, transparent) !important; color: var(--ink-2); }
.leaflet-control-attribution a { color: inherit; }
.leaflet-bottom.leaflet-right { margin-bottom: calc(env(safe-area-inset-bottom) + 76px); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { border-radius: var(--r); background: var(--panel); color: var(--ink); box-shadow: var(--edge); }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 14px;
  border-radius: var(--r); border: 1px solid var(--line-2); background: var(--panel); font-weight: 500; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn.wide { width: 100%; }
.icon-btn { width: 42px; height: 42px; border-radius: var(--r); border: 0; background: var(--panel); box-shadow: var(--edge);
  font-size: 20px; line-height: 1; cursor: pointer; flex: none; }

/* ---------------------------------------------------------------- top bar */
.hud { position: fixed; z-index: 500; top: calc(env(safe-area-inset-top) + 10px); left: 10px; right: 10px;
  display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
.hud > * { pointer-events: auto; }
.log { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; cursor: pointer;
  background: var(--panel); border-radius: var(--r); box-shadow: var(--edge); padding: 8px 12px 8px 8px; min-width: 180px; }
.log .mark, .brand .mark { width: 26px; height: 26px; grid-row: span 2; flex: none; background: url("/static/icon-192.png") center/cover; border-radius: var(--r); }
.log-text { display: flex; align-items: baseline; gap: 10px; line-height: 1.1; }
.log-text b { font-family: var(--cond); font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.log-text span { font-size: 13px; color: var(--ink-2); }
.bar { grid-column: 2; height: 2px; background: var(--line); margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.search { position: relative; flex: 1; max-width: 400px; margin-left: auto; }
.search input { width: 100%; height: 42px; border: 0; border-radius: var(--r); padding: 0 12px; background: var(--panel); box-shadow: var(--edge); }
.results { position: absolute; top: 48px; left: 0; right: 0; background: var(--panel); border-radius: var(--r); box-shadow: var(--edge); overflow: hidden; }
.results button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; }
.results button:first-child { border-top: 0; }
.results button:hover, .results button:focus-visible { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.results small { display: block; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .none { padding: 12px; color: var(--ink-2); font-size: 14px; }
@media (max-width: 640px) {
  .hud { flex-wrap: wrap; }
  .log { flex: 1; min-width: 0; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
}

/* ---------------------------------------------------------------- bottom bar */
.dock { position: fixed; z-index: 500; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 10px);
  display: flex; background: var(--panel); border-radius: var(--r); box-shadow: var(--edge); overflow: hidden; }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 66px; height: 54px;
  border: 0; border-right: 1px solid var(--line); background: transparent; font-size: 11.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.tool:hover { color: var(--ink); }
.tool.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.tool.add { background: var(--accent); color: var(--accent-ink); min-width: 74px; border-right: 0; font-weight: 600; }
.tool.add .plus { font-size: 22px; line-height: 20px; font-weight: 400; }
.ic { width: 20px; height: 20px; display: block; background: currentColor; -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; }
.ic-locate { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 1v5M12 18v5M1 12h5M18 12h5'/%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3C/svg%3E"); }
.ic-layers { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='miter'%3E%3Cpath d='M12 3 2 8l10 5 10-5-10-5Z'/%3E%3Cpath d='m2 13 10 5 10-5'/%3E%3C/svg%3E"); }
.ic-list { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13'/%3E%3Cpath d='M3 5h2v2H3zM3 11h2v2H3zM3 17h2v2H3z' fill='black'/%3E%3C/svg%3E"); }

.placing { position: fixed; z-index: 600; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 66px);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 20px);
  background: var(--ink); color: var(--panel); padding: 5px 5px 5px 12px; border-radius: var(--r); font-weight: 500; }
.placing .btn { background: var(--panel); color: var(--ink); border: 0; }
.placing .btn.ghost { background: transparent; color: var(--panel); }
body.placing-mode #map { cursor: crosshair; }
@media (max-width: 640px) { .placing { top: calc(env(safe-area-inset-top) + 112px); } }

/* ---------------------------------------------------------------- markers: survey triangles */
.qpin { background: none; border: 0; }
.qpin .m { position: relative; width: 28px; height: 26px; transition: transform .12s ease; transform-origin: 50% 70%; }
.qpin svg { display: block; width: 28px; height: 26px; overflow: visible; }
.qpin.sel .m { transform: scale(1.35); }
.qpin.ghost .m { opacity: .6; }
.me-dot { width: 14px; height: 14px; border-radius: 50%; background: #2f7fe0; box-shadow: 0 0 0 2px #fff, 0 0 0 7px rgba(47, 127, 224, .25); }

/* ---------------------------------------------------------------- side panel (laptop) / sheet (phone) */
.panel { position: fixed; z-index: 700; background: var(--panel); box-shadow: var(--edge); display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 721px) {
  .panel { top: 10px; left: 10px; bottom: 10px; width: 390px; border-radius: var(--r); }
  body.panel-open .hud { left: 410px; }
}
@media (max-width: 720px) {
  .panel { left: 0; right: 0; bottom: 0; height: 76vh; max-height: 76vh; border-radius: var(--r) var(--r) 0 0; padding-bottom: env(safe-area-inset-bottom);
    border-top: 2px solid var(--ink); }
  .panel.short { height: auto; }
}
.p-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px 6px 16px; flex: none; }
.p-head h2 { margin: 0; font-size: 24px; line-height: 1.1; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; letter-spacing: .005em; }
.p-head .x { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: var(--r); background: none; font-size: 15px; cursor: pointer; flex: none; }
.p-body { overflow-y: auto; padding: 0 16px 18px; flex: 1; -webkit-overflow-scrolling: touch; }

.meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; font-size: 13.5px; color: var(--ink-2); }
.coords { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 6px 6px 10px; margin-bottom: 12px; }
.coords span { flex: 1; font-size: 14px; letter-spacing: .02em; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: var(--r); font-size: 13.5px; font-weight: 500;
  background: transparent; color: var(--ink); border: 1px solid var(--line); }
.chip .dot { width: 9px; height: 9px; background: var(--c); }
button.chip { cursor: pointer; }
button.chip.off { color: var(--ink-2); }
button.chip.off .dot { opacity: .3; }
button.chip:not(.off) { border-color: var(--ink); }

.status { margin: 0 0 14px; padding: 12px; border-radius: var(--r); border: 1px solid var(--line); }
.status.done { border-color: var(--ink); border-left-width: 4px; }
.status h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.status p { margin: 3px 0; }
.stars { letter-spacing: 3px; }
.muted { color: var(--ink-2); }
.small { font-size: 13.5px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 14px; }
.sec { font-size: 15px; font-weight: 600; margin: 16px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 16px; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.photos .ph { aspect-ratio: 1; border-radius: 0; overflow: hidden; border: 0; padding: 0; background: var(--line); cursor: zoom-in; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph.up { display: grid; place-items: center; font-size: 12px; color: var(--ink-2); cursor: default; }
.photos label.addph { aspect-ratio: 1; border: 1px dashed var(--line-2); display: grid; place-items: center; text-align: center;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer; padding: 6px; }
.photos label.addph b { display: block; font-size: 20px; color: var(--ink); font-weight: 400; }
.photos label.addph:hover { border-color: var(--ink); color: var(--ink); }

/* list */
.filters { padding: 2px 16px 10px; display: grid; gap: 8px; flex: none; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-2); border-radius: var(--r); }
.seg button { border: 0; border-right: 1px solid var(--line-2); background: none; height: 34px; font-weight: 500; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--panel); }
.seg button.on .muted { color: inherit; opacity: .7; }
.chips { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip { flex: none; }
.row2 { display: flex; gap: 6px; }
.row2 input, .row2 select, .field input, .field select, .field textarea {
  height: 40px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 10px; background: var(--panel); min-width: 0; }
.row2 input { flex: 1; }
.items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.items li button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 2px;
  border-bottom: 1px solid var(--line); cursor: pointer; }
.items li button:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.items .badge { width: 18px; height: 16px; flex: none; }
.items .tx { flex: 1; min-width: 0; }
.items .tx b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.items .tx span { font-size: 12.5px; color: var(--ink-2); }
.items .dist { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.empty { padding: 28px 8px; text-align: center; color: var(--ink-2); }
.p-foot { padding: 10px 16px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex: none; }

/* ---------------------------------------------------------------- dialogs */
.modal-bg { position: fixed; inset: 0; z-index: 900; background: rgba(5, 6, 7, .62); display: grid; place-items: center; padding: 14px; }
.modal { width: min(450px, 100%); max-height: calc(100vh - 28px); overflow-y: auto; background: var(--panel); border-radius: var(--r);
  border-top: 3px solid var(--ink); padding: 18px; }
.modal h3 { margin: 0 0 14px; font-size: 21px; font-weight: 600; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13.5px; font-weight: 600; }
.field textarea { height: auto; min-height: 92px; padding: 9px 10px; resize: vertical; }
.pick { display: flex; flex-wrap: wrap; gap: 5px; }
.rate { display: flex; gap: 4px; }
.rate button { width: 40px; height: 34px; border: 1px solid var(--line-2); border-radius: var(--r); background: none; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.rate button.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.m-foot { display: flex; gap: 6px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.catrow { display: grid; grid-template-columns: 1fr 50px 36px; gap: 6px; align-items: center; margin-bottom: 6px; }
.catrow input { height: 38px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 8px; background: var(--panel); min-width: 0; }
.catrow input[type=color] { padding: 2px; }
.catrow .del { border: 0; background: none; font-size: 18px; color: var(--ink-2); cursor: pointer; }
.menu { position: fixed; z-index: 800; top: calc(env(safe-area-inset-top) + 58px); right: 10px; background: var(--panel); border-radius: var(--r);
  box-shadow: var(--edge); padding: 4px; min-width: 230px; }
.menu button, .menu a { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none;
  cursor: pointer; text-decoration: none; color: var(--ink); font-size: 14.5px; }
.menu button:hover, .menu a:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }

/* photo viewer */
.lb { position: fixed; inset: 0; z-index: 1000; background: #050607; display: flex; flex-direction: column; color: #fff; touch-action: pan-y; }
.lb-top { display: flex; align-items: center; gap: 6px; padding: calc(env(safe-area-inset-top) + 8px) 8px 8px 14px; border-bottom: 1px solid #222; }
.lb-top .n { flex: 1; font-size: 13.5px; opacity: .8; }
.lb-top .btn { background: transparent; color: #fff; border-color: #444; }
.lb-img { flex: 1; display: grid; place-items: center; min-height: 0; padding: 8px; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 60px; border: 1px solid #444; border-radius: var(--r);
  background: rgba(0, 0, 0, .4); color: #fff; font-size: 24px; cursor: pointer; }
.lb-nav.prev { left: 10px; } .lb-nav.next { right: 10px; }
@media (hover: none) { .lb-nav { display: none; } }

.toast { position: fixed; z-index: 1100; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 80px);
  background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: var(--r); max-width: calc(100% - 28px); font-size: 14.5px; }
body.panel-open .toast { bottom: auto; top: calc(env(safe-area-inset-top) + 66px); }
@media (min-width: 721px) { body.panel-open .toast { left: calc(50% + 200px); } }

/* ---------------------------------------------------------------- login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--paper); }
.login-card { width: min(340px, 100%); background: var(--panel); border-radius: var(--r); border-top: 3px solid var(--ink); padding: 22px; display: grid; gap: 6px; }
.login-card .brand { display: flex; align-items: center; gap: 10px; font-family: var(--cond); font-size: 24px; font-weight: 600; margin-bottom: 12px; }
.login-card label { font-size: 13.5px; font-weight: 600; }
.login-card input { height: 44px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 10px; background: var(--panel); margin-bottom: 8px; }
.login-card .err { color: var(--bad); margin: 0 0 4px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
