/* Chase — chase-crew companion, themed to match Competition Tools (GitHub-dark
   palette, #1f6feb accent). Map is the artwork; the pilot is the now-playing bar;
   targets are a list. */
:root {
  --bg:      #0d1117;
  --panel:   #161b22;        /* sheet surface            */
  --elev:    #1c2330;        /* cards / rows             */
  --elev-2:  #232c3a;        /* hover / pressed          */
  --text:    #e6edf3;
  --text-2:  #9fb4c8;        /* muted                    */
  --text-3:  #6e7b8a;        /* dim / units              */
  --line:    #30363d;
  --accent:  #1f6feb;        /* Competition Tools blue    */
  --accent-h: #388bfd;
  --accent-ink: #ffffff;
  --self:    #2b83ff;        /* my-location dot (blue) */
  --edge:    #0d1117;        /* marker outline on the map */
  --radius:  14px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  overflow: hidden; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
#map { position: absolute; inset: 0; z-index: 0; background: #090c10; }

.top-scrim {
  position: absolute; z-index: 400; top: 0; left: 0; right: 0; height: 130px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .5), transparent);
  pointer-events: none;
}

/* ============================== top controls ============================== */
#top {
  position: absolute; z-index: 500;
  top: calc(12px + var(--safe-t)); left: 12px; right: 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.chips { display: flex; gap: 8px; overflow: hidden; }
.chip {
  border: 0; cursor: pointer; white-space: nowrap;
  font-family: var(--font); font-weight: 600; font-size: 13px;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(22, 27, 34, .8); color: var(--text-2);
  border: 1px solid var(--line); backdrop-filter: blur(14px);
}
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.round {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  background: rgba(22, 27, 34, .8); color: var(--text);
  border: 1px solid var(--line); backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.round svg { width: 21px; height: 21px; }
.round:active { background: var(--elev-2); }
.tools { display: flex; flex-direction: column; gap: 8px; }
.round.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.hint-banner {
  position: absolute; z-index: 500; left: 50%; transform: translateX(-50%);
  top: calc(64px + var(--safe-t));
  background: var(--accent); color: #fff;
  font-weight: 600; font-size: 13px; padding: 7px 14px; border-radius: 999px;
  box-shadow: var(--shadow); white-space: nowrap;
}
.hint-banner[hidden] { display: none; }

/* ================================ scrim ================================ */
#scrim {
  position: absolute; inset: 0; z-index: 900; background: rgba(0, 0, 0, .55);
  opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s;
}
#scrim.show { opacity: 1; visibility: visible; }

/* ============================== bottom sheet ============================== */
.sheet {
  position: absolute; z-index: 1000; left: 0; right: 0; bottom: 0;
  height: min(80vh, 600px);
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; box-shadow: 0 -8px 36px rgba(0, 0, 0, .55);
  transform: translateY(calc(min(80vh, 600px) - var(--peek-h, 84px)));
  transition: transform .34s cubic-bezier(.32, .72, 0, 1); will-change: transform;
}
.sheet.expanded { transform: translateY(0); }
.peek {
  display: block; width: 100%; border: 0; cursor: pointer; text-align: left;
  background: transparent; color: inherit; padding: 0 16px; height: var(--peek-h, 84px);
}
.grip { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--elev-2); margin: 8px auto 0; }
.peek-row { display: flex; align-items: center; gap: 12px; height: 64px; }
.peek-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--text-3); transition: background .3s; }
.peek-dot.live { background: var(--accent); }
.peek-dot.stale { background: #d8973c; }
.peek-main { flex: 1; min-width: 0; }
.peek-name { display: block; font-weight: 700; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-sub { display: block; font-weight: 500; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.peek-stat { display: flex; align-items: baseline; gap: 11px; font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; }
.peek-stat i { font-style: normal; font-weight: 600; font-size: 11px; color: var(--text-3); margin-left: 2px; }
.peek-chev { width: 22px; height: 22px; color: var(--text-3); flex: none; transition: transform .34s ease; }
.sheet.expanded .peek-chev { transform: rotate(180deg); }
.sheet-body {
  height: calc(min(80vh, 600px) - var(--peek-h, 84px));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(24px + var(--safe-b));
}

/* telemetry */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 4px; margin: 6px 0 18px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .sv { font-weight: 700; font-size: 21px; letter-spacing: -.02em; line-height: 1; }
.stat .sv.up { color: var(--accent-h); }
.stat .sv.down { color: #d8973c; }
.stat .sl { font-weight: 500; font-size: 11px; color: var(--text-3); }
.stat .sl i { font-style: normal; }

/* nav row */
.navrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-decoration: none; color: inherit; background: var(--elev); border: 1px solid rgba(31, 111, 235, .4); border-radius: var(--radius); padding: 13px 15px; margin-bottom: 18px; }
.navrow[hidden] { display: none; }
.navrow .eyebrow { display: block; font-weight: 600; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-h); }
.navrow-name { display: block; font-weight: 700; font-size: 15px; margin-top: 2px; }
.navrow-go { font-weight: 700; font-size: 13px; color: var(--accent-h); white-space: nowrap; }

/* section heads */
.sec-head { display: flex; align-items: center; gap: 9px; margin: 6px 2px 10px; }
.sec-head h2 { font-weight: 700; font-size: 18px; letter-spacing: -.01em; margin: 0; }
.count { font-weight: 700; font-size: 12px; color: var(--text-2); background: var(--elev-2); border-radius: 999px; padding: 2px 9px; }

/* target list */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 13px; width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; color: inherit; padding: 9px 8px; border-radius: 10px; }
.row:active { background: var(--elev); }
.row .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; border: 2px solid rgba(255, 255, 255, .22); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: block; font-weight: 500; font-size: 13px; color: var(--text-2); margin-top: 1px; }
.row-dir { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; color: var(--text-2); text-decoration: none; }
.row-dir:active { background: var(--elev-2); color: var(--text); }
.row-dir svg { width: 20px; height: 20px; }
.empty { color: var(--text-3); font-size: 14px; font-weight: 500; padding: 4px 8px 14px; }
.empty.in-card { padding: 2px; margin: 0; }

/* landing + parcel card */
.card { background: var(--elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; margin-bottom: 8px; }
.card .land-title { font-weight: 700; font-size: 16px; }
.card .land-sub { font-weight: 500; font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.card .pdl { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.card .pdl > div { display: flex; justify-content: space-between; gap: 14px; font-size: 14px; }
.card .pdl dt { color: var(--text-3); font-weight: 500; }
.card .pdl dd { color: var(--text); font-weight: 600; margin: 0; text-align: right; }
.btn-accent { display: block; text-align: center; text-decoration: none; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; padding: 12px; border-radius: 999px; }
.btn-accent:active { background: var(--accent-h); }

/* ================================ overlay ================================ */
.overlay { position: absolute; inset: 0; z-index: 2000; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); }
.overlay[hidden], .overlay.hidden { display: none; }
.boot { width: 100%; max-width: 340px; margin: 0 auto; min-height: 100%; padding: 28px 24px calc(28px + var(--safe-b)); display: flex; flex-direction: column; justify-content: center; text-align: center; }
.boot .mark { width: 60px; height: 60px; border-radius: 14px; object-fit: cover; }
.boot h1 { font-weight: 800; font-size: 34px; letter-spacing: -.02em; margin: 16px 0 4px; }
.boot .lede { color: var(--text-2); font-size: 15px; margin: 0 0 28px; }
#pilot-input, #set-id { width: 100%; font-family: var(--font); font-weight: 600; font-size: 17px; text-align: center; letter-spacing: .04em; padding: 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--elev); color: var(--text); }
#pilot-input::placeholder, #set-id::placeholder { color: var(--text-3); letter-spacing: 0; text-transform: none; font-weight: 500; }
#pilot-input:focus, #set-id:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 111, 235, .25); }
.cta { width: 100%; margin-top: 12px; border: 0; cursor: pointer; font-family: var(--font); font-weight: 700; font-size: 16px; padding: 15px; border-radius: 999px; color: #fff; background: var(--accent); }
.cta:active { background: var(--accent-h); }
.err { color: #ff7b72; min-height: 1.1em; margin: 12px 0 0; font-size: 13.5px; font-weight: 500; }
.hint { color: var(--text-3); font-size: 12.5px; margin: 10px 0 0; line-height: 1.5; }

/* settings sheet */
.set-card { text-align: left; }
.set-h { font-weight: 800; font-size: 26px; letter-spacing: -.01em; margin: 0 0 18px; text-align: center; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0; }
.set-row .field { margin: 0; }
.seg2 { display: flex; gap: 4px; background: var(--elev); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg2 button { border: 0; background: transparent; cursor: pointer; color: var(--text-2); font-family: var(--font); font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 7px; }
.seg2 button.on { background: var(--accent); color: #fff; }
#set-magnote { margin-top: 4px; }
#set-share { width: 100%; font-family: var(--font); font-weight: 600; font-size: 16px; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--elev); color: var(--text); letter-spacing: .04em; }
#set-share:focus { outline: none; border-color: var(--accent); }
#set-share::placeholder { text-transform: none; letter-spacing: 0; color: var(--text-3); font-weight: 500; }
#set-crew { width: 100%; font-family: var(--font); font-weight: 600; font-size: 16px; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--elev); color: var(--text); }
#set-crew:focus { outline: none; border-color: var(--accent); }
.dim-id { color: var(--text-3); font-weight: 500; font-size: 11px; letter-spacing: 0; text-transform: none; }

/* report-wind FAB */
.fab {
  position: absolute; z-index: 800; right: 14px;
  bottom: calc(var(--peek-h, 84px) + 16px + var(--safe-b));
  display: flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-family: var(--font); font-weight: 700; font-size: 14px;
  padding: 11px 16px 11px 13px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.fab svg { width: 20px; height: 20px; }
.fab:active { background: var(--accent-h); }
.fab[hidden] { display: none; }

/* wind report form */
.seg2.wide { width: 100%; margin-bottom: 6px; }
.seg2.wide button { flex: 1; padding: 9px; font-size: 14px; }
.compass { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; margin: 8px 0 4px; }
.compass button { border: 1px solid var(--line); background: var(--elev); color: var(--text-2); border-radius: 7px; padding: 7px 0; font-family: var(--font); font-weight: 700; font-size: 10.5px; cursor: pointer; }
.compass button:active { background: var(--accent); color: #fff; border-color: var(--accent); }
#wind-dir, #wind-spd, #wind-note { width: 100%; font-family: var(--font); font-weight: 600; font-size: 17px; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--elev); color: var(--text); }
#wind-dir { text-align: center; letter-spacing: .1em; }
#wind-dir:focus, #wind-spd:focus, #wind-note:focus { outline: none; border-color: var(--accent); }
.wind-actions { display: flex; gap: 10px; margin-top: 8px; }
.wind-actions .cta, .wind-actions .ghost { margin-top: 0; flex: 1; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--text); font-family: var(--font); font-weight: 700; font-size: 16px; padding: 15px; border-radius: 999px; cursor: pointer; }
.ghost:active { background: var(--elev); }
.wind-row { display: flex; align-items: baseline; gap: 8px; padding: 9px 2px; border-top: 1px solid var(--line); font-size: 14px; }
.wind-row b { font-weight: 700; }
.wind-row .age { margin-left: auto; color: var(--text-3); font-size: 12.5px; white-space: nowrap; }

/* ================================ markers ================================ */
.mk svg { display: block; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .55)); }
.dotpin { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--edge); box-shadow: 0 2px 6px rgba(0, 0, 0, .45); font-weight: 800; font-size: 12px; line-height: 1; }
.pilot { transition: transform .4s ease; }
@media (prefers-reduced-motion: reduce) { .pilot { transition: none; } }
.self { display: grid; place-items: center; }
.self i { width: 15px; height: 15px; border-radius: 50%; background: var(--self); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 1px 4px rgba(0, 0, 0, .5); }

/* ================================ popups ================================ */
.leaflet-popup-content-wrapper { background: var(--elev); color: var(--text); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--elev); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 13px 15px; font-family: var(--font); min-width: 190px; }
.pop-eyebrow { font-weight: 700; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.leaflet-popup-content h3 { font-weight: 700; font-size: 16px; margin: 0 0 9px; }
.leaflet-popup-content p { margin: 0 0 9px; font-size: 13px; color: var(--text-2); }
.pop-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.pop-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; padding: 4px 9px; border-radius: 7px; background: var(--elev-2); color: var(--text); }
.pop-sw { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .55); }
a.dir-btn { display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; padding: 10px; border-radius: 9px; }
a.dir-btn:active { background: var(--accent-h); }
.leaflet-popup-close-button { width: 34px !important; height: 34px !important; font: 700 24px/32px var(--font) !important; color: var(--text-2) !important; padding: 0 !important; right: 2px; top: 2px; text-align: center; }
.leaflet-popup-close-button:hover { color: var(--text) !important; background: var(--elev-2); border-radius: 9px; }
.pop-eyebrow, .leaflet-popup-content h3 { padding-right: 26px; }
.leaflet-popup-content .pdl { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 11px; }
.leaflet-popup-content .pdl > div { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; }
.leaflet-popup-content .pdl dt { color: var(--text-3); font-weight: 500; }
.leaflet-popup-content .pdl dd { color: var(--text); font-weight: 600; margin: 0; text-align: right; }

.leaflet-bar a { background: rgba(22, 27, 34, .85) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-top.leaflet-left { margin-top: 66px; }
.leaflet-control-attribution { background: rgba(13, 17, 23, .7) !important; color: var(--text-3) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-3) !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .sheet, .peek-chev { transition: none; } }
