/* Layout: full-screen map, thin top bar, floating buttons, bottom tab bar, one bottom sheet for every panel.
   Field palette: spruce panels, bone text, blaze orange for the one thing that matters. */
:root {
  --panel: #1d2a22;
  --panel-2: #26362c;
  --line: #3a4d40;
  --text: #ece6d6;
  --muted: #a9b3a3;
  --blaze: #ff6a13;
  --blaze-ink: #1d1206;
  --ok: #7cc47f;
  --warn: #f2c14e;
  --bad: #ef5d4a;
  --font-ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-label: 'Barlow Semi Condensed', 'Arial Narrow', system-ui, sans-serif;
  --tabbar-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--panel); color: var(--text); font: 15px/1.45 var(--font-ui); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; background: #2b3a30; }

.topbar {
  position: fixed; inset: 0 0 auto; z-index: 900;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(14px, env(safe-area-inset-right, 0px)) 8px max(14px, env(safe-area-inset-left, 0px));
  background: linear-gradient(to bottom, rgba(18, 27, 21, .92), rgba(18, 27, 21, 0));
  pointer-events: none;
}
.brand { font: 700 18px/1 var(--font-label); letter-spacing: .02em; display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 2px #000; }
.brand-mark { width: 14px; height: 14px; background: var(--blaze); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.coords { font: 500 13px/1 var(--font-label); color: var(--text); background: rgba(18, 27, 21, .8); padding: 8px 10px; border-radius: 6px; border: 0; font-variant-numeric: tabular-nums; pointer-events: auto; cursor: pointer; white-space: nowrap; min-height: 32px; }
.crosshair { position: fixed; z-index: 450; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; pointer-events: none; opacity: .7; }
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: #1d1206; box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
.crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
.crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.legend img, .legend .sw { width: 18px; height: 18px; flex: none; border-radius: 3px; border: 1px solid var(--line); }
.results { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.results button { text-align: left; }
.file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.fab-stack { position: fixed; z-index: 900; right: max(12px, env(safe-area-inset-right, 0px)); top: calc(env(safe-area-inset-top, 0px) + 56px); display: flex; flex-direction: column; gap: 10px; }
.fab { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.fab svg { width: 22px; height: 22px; stroke: var(--text); stroke-width: 2; fill: none; stroke-linecap: round; }
.fab svg circle[r="4"] { fill: var(--text); stroke: none; }
.fab.active { background: var(--blaze); border-color: var(--blaze); }
.fab.active svg { stroke: var(--blaze-ink); }
.fab.active svg circle[r="4"] { fill: var(--blaze-ink); }

.tabbar {
  position: fixed; inset: auto 0 0; z-index: 1000; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 4px max(6px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 4px) max(6px, env(safe-area-inset-left, 0px));
}
.tab { background: none; border: 0; padding: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font: 600 12px/1 var(--font-label); letter-spacing: .03em; cursor: pointer; min-height: 52px; }
.tab svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--blaze); }

.sheet {
  position: fixed; z-index: 950; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  max-height: min(62vh, calc(100dvh - var(--tabbar-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 56px)); background: var(--panel); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
  transform: translateY(110%); transition: transform .22s ease; display: flex; flex-direction: column;
  box-shadow: 0 -6px 24px rgba(0,0,0,.45);
}
.sheet.open { transform: none; }
.sheet.tall { max-height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 56px); }
.sheet-head { position: relative; flex: none; height: 30px; }
.sheet-grip { display: block; width: 100%; height: 30px; background: none; border: 0; padding: 0; cursor: pointer; }
.sheet-grip span { display: block; width: 40px; height: 5px; background: var(--line); border-radius: 3px; margin: 10px auto 0; }
.sheet-close { position: absolute; top: 4px; right: max(8px, env(safe-area-inset-right, 0px)); width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--panel-2); display: grid; place-items: center; cursor: pointer; z-index: 1; }
.sheet-close svg { width: 20px; height: 20px; stroke: var(--text); stroke-width: 2.2; fill: none; stroke-linecap: round; }
.sheet-grip:focus-visible, .sheet-close:focus-visible { outline: 2px solid var(--blaze); outline-offset: -2px; }
.btn:disabled { opacity: .6; cursor: default; }
.sheet-body { overflow-y: auto; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 18px max(16px, env(safe-area-inset-left, 0px)); -webkit-overflow-scrolling: touch; }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }

h2 { font: 700 20px/1.15 var(--font-label); margin: 2px 48px 10px 0; letter-spacing: .01em; text-wrap: balance; }
h3 { font: 700 13px/1.2 var(--font-label); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--blaze); }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 10px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--blaze); border-color: var(--blaze); color: var(--blaze-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:focus-visible, .tab:focus-visible, .fab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blaze); outline-offset: 2px; }

.choice { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer; }
.choice input { accent-color: var(--blaze); width: 18px; height: 18px; }
.choice .grow { flex: 1; min-width: 0; }
.choice .src { font-size: 12px; color: var(--muted); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); font: 600 13px/1.4 var(--font-label); letter-spacing: .03em; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.flag { border-left: 4px solid var(--warn); background: rgba(242, 193, 78, .1); padding: 10px 12px; border-radius: 0 8px 8px 0; margin: 10px 0; font-size: 14px; }
.flag.bad { border-color: var(--bad); background: rgba(239, 93, 74, .12); }
.flag.ok { border-color: var(--ok); background: rgba(124, 196, 127, .1); }

.card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .card .title { font-weight: 600; }

table.hours { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
table.hours th { text-align: left; color: var(--muted); font: 600 12px/1 var(--font-label); text-transform: uppercase; letter-spacing: .06em; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.hours td { padding: 7px 4px; border-bottom: 1px solid rgba(58, 77, 64, .5); }
.arrow { display: inline-block; width: 16px; text-align: center; color: var(--blaze); }
.table-wrap { overflow-x: auto; }

label.field { display: flex; flex-direction: column; gap: 4px; font: 600 13px/1.2 var(--font-label); color: var(--muted); letter-spacing: .03em; }
input[type=text], input[type=number], input[type=date], select, textarea {
  font: 15px var(--font-ui); color: var(--text); background: #142019; border: 1px solid var(--line); border-radius: 8px; padding: 10px; width: 100%; min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font: 600 12px/1.5 var(--font-label); letter-spacing: .03em; background: var(--line); color: var(--text); }
.pill.ok { background: rgba(124,196,127,.2); color: var(--ok); }
.pill.warn { background: rgba(242,193,78,.2); color: var(--warn); }
.pill.used { background: rgba(169,179,163,.15); color: var(--muted); }
.icons { display: flex; flex-wrap: wrap; gap: 6px; }
.icons button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font-size: 20px; cursor: pointer; }
.icons button[aria-pressed=true] { border-color: var(--blaze); box-shadow: 0 0 0 2px var(--blaze) inset; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--blaze); width: 0; transition: width .2s; }

.tool-banner, .track-hud {
  position: fixed; z-index: 960; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 52px);
  background: var(--panel); border: 1px solid var(--blaze); border-radius: 12px; padding: 8px 10px 8px 14px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.45); max-width: calc(100% - 120px); font-weight: 600;
}
.track-hud { top: auto; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: pulse 1.2s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

.toast { position: fixed; z-index: 1100; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px); background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: calc(100% - 32px); text-align: center; }

/* Map markers */
.wp-icon { font-size: 22px; line-height: 30px; text-align: center; width: 30px; height: 30px; border-radius: 50%; background: var(--panel); border: 2px solid var(--blaze); box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #3fa9f5; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(63,169,245,.25); }
.measure-label { background: var(--panel); color: var(--text); border: 1px solid var(--blaze); border-radius: 6px; padding: 2px 6px; font: 600 12px var(--font-label); white-space: nowrap; }
.leaflet-container { font: 13px var(--font-ui); background: #2b3a30; }
.leaflet-control-attribution { font-size: 10px; background: rgba(29,42,34,.8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bottom { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
.leaflet-control-scale-line { background: rgba(29,42,34,.8); color: var(--text); border-color: var(--text); }
.leaflet-top.leaflet-left { top: calc(env(safe-area-inset-top, 0px) + 44px); }
.leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--line); }
