/* PadPipe — dashboard shell. The palette is the brand's (see marketing/brand.md):
   warm clay against a cool ink, on paper in the light theme and on deep ink in
   the dark one. Ration the clay — one primary action per view. */
:root {
  --bg:        #0B1A22;
  --bg-2:      #0F2029;
  --panel:     #12262F;
  --panel-2:   #17303B;
  --line:      #23414E;
  --line-soft: #1B3541;
  --txt:       #F2EDE6;
  --txt-2:     #A9BCC5;
  --txt-3:     #718B98;
  --accent:    #E8703F;
  --accent-2:  #D8552F;
  --good:      #34C79A;
  --warn:      #F0B429;
  --bad:       #F0705C;
  --radius:    12px;
  --shadow:    0 10px 30px rgba(0,0,0,.42);
  --topbar-h:  60px;
  --stats-h:   62px;
  --nav-h:     0px;
  --display:   'Fraunces', ui-serif, Georgia, serif;
}
html[data-theme="light"] {
  --bg:#FBF7F2; --bg-2:#F5EDE4; --panel:#FFFDFB; --panel-2:#F5EDE4;
  --line:#E4D7C7; --line-soft:#EFE3D6; --txt:#10242E;
  --txt-2:#3D5866; --txt-3:#6E8592; --shadow:0 8px 24px rgba(28,14,4,.10);
  --good:#0F8A73; --bad:#C2412B; --warn:#B77400;
}

@font-face{font-family:'Jakarta';src:url(/fonts/jakarta-var.woff2) format('woff2');font-weight:200 800;font-style:normal;font-display:swap}
@font-face{font-family:'Fraunces';src:url(/fonts/fraunces-var.woff2) format('woff2');font-weight:100 900;font-style:normal;font-display:swap}

* { box-sizing: border-box; }
/* An id-based `display` (e.g. #view-map) out-ranks `.view[hidden]`, which would
   leave the map painted over every other view. Make hiding unconditional. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 14px/1.45 'Jakarta', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 18px;
  padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  /* Leaflet's own panes sit at z-index 400-700, so every chrome layer that must
     cover the map has to clear that. */
  position: relative; z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.brand-mark { display: grid; place-items: center; color: var(--accent); flex: none; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -.03em; font-variation-settings: 'opsz' 40; }
.brand-sub { font-size: 11px; color: var(--txt-3); }

.views { display: flex; gap: 2px; background: var(--bg-2); padding: 3px; border-radius: 10px; }
.views button {
  background: none; border: 0; padding: 6px 14px; border-radius: 7px;
  color: var(--txt-2); cursor: pointer; font-weight: 500;
}
.views button:hover { color: var(--txt); }
.views button.on { background: var(--panel-2); color: var(--txt); box-shadow: inset 0 0 0 1px var(--line); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search {
  width: 260px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 11px; outline: none;
}
.search:focus { border-color: var(--accent-2); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--txt);
  padding: 7px 13px; border-radius: 9px; cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); background: var(--panel); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 7px 9px; }
.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; justify-content: center; margin-top: 6px; }
.btn.danger { color: var(--bad); border-color: #5A2A22; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pill {
  background: var(--accent-2); color: #fff; border-radius: 20px;
  font-size: 10px; padding: 1px 6px; margin-left: 4px;
}

/* ---------- stats strip ---------- */
.stats {
  height: var(--stats-h); display: flex; align-items: stretch; gap: 0;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stats::-webkit-scrollbar { height: 0; }
.stat {
  padding: 10px 18px; border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; justify-content: center; min-width: 132px;
}
.stat-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--txt-3); white-space: nowrap; }
/* Numbers stay in the sans with tabular figures — the display serif is
   beautiful in a headline and hard to read in a price. */
.stat-v { font-size: 19px; font-weight: 750; letter-spacing: -.03em; margin-top: 1px; white-space: nowrap; font-feature-settings: 'tnum' 1; }
.stat-v small { font-size: 11px; font-weight: 500; color: var(--txt-2); margin-left: 4px; }
.stat-chips { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin-top: 3px; }
.chip {
  font-size: 10.5px; padding: 2px 7px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-2); cursor: pointer;
}
.chip:hover { color: var(--txt); }
.chip .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; }

/* ---------- main / views ---------- */
#main { height: calc(100dvh - var(--topbar-h) - var(--stats-h) - var(--nav-h)); position: relative; }
@supports not (height: 100dvh) { #main { height: calc(100vh - var(--topbar-h) - var(--stats-h) - var(--nav-h)); } }
.view { position: absolute; inset: 0; }

/* ---------- map view ---------- */
#view-map { display: grid; grid-template-columns: 340px 1fr; }
.maplist { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-width:0; }
.maplist-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--txt-2);
}
.mini-select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 7px; font-size: 12px; outline: none;
}
.maplist-body { overflow-y: auto; flex: 1; }

.pcard {
  padding: 11px 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
  display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: start;
}
.pcard:hover, .pcard.hot { background: var(--panel-2); }
.pcard.sel { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.score-badge {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 750; font-size: 16px; color: #06131f; line-height: 1; letter-spacing: -.02em;
  font-feature-settings: 'tnum' 1;
}
.score-badge small { display: block; font-size: 8px; font-weight: 600; opacity: .65; letter-spacing: .04em; }
.pcard-title { font-weight: 570; font-size: 13.5px; line-height: 1.3; }
.pcard-sub { color: var(--txt-3); font-size: 11.5px; margin-top: 2px; }
.pcard-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 5px; font-size: 11.5px; color: var(--txt-2); }
.pcard-meta b { color: var(--txt); font-weight: 600; }
.tag {
  font-size: 10px; padding: 1.5px 6px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-2);
}
.tag.flag { color: var(--bad); border-color: #5A2A22; background: rgba(240,112,92,.09); }

.mapwrap { position: relative; }
#map { position: absolute; inset: 0; background: var(--bg-2); }
.leaflet-container { font: inherit; background: var(--bg-2); }
.map-panel {
  position: absolute; top: 10px; right: 10px; z-index: 500; width: 214px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow); max-height: calc(100% - 20px); overflow-y: auto;
}
.panel-toggle {
  display: none; width: 100%; background: none; border: 0; color: var(--txt-2);
  font-size: 12px; font-weight: 600; padding: 4px 2px; text-align: left; cursor: pointer;
}
.map-panel.collapsed .map-panel-body { display: none; }
.map-panel.collapsed { width: auto; }
.map-panel-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--txt-3); margin-bottom: 6px;
}
.mini-check { display: flex; align-items: center; gap: 7px; font-size: 12px; padding: 3px 0; cursor: pointer; color: var(--txt-2); }
.mini-check:hover { color: var(--txt); }
.mini-check input { accent-color: var(--accent-2); }
.mini-check .swatch { width: 9px; height: 9px; border-radius: 50%; }
.mini-check .n { margin-left: auto; font-size: 10px; color: var(--txt-3); }
.anchor-row { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 0; color: var(--txt-2); }
.anchor-row .x { margin-left: auto; cursor: pointer; color: var(--txt-3); }
.anchor-row .x:hover { color: var(--bad); }

.marker-pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 2px; transform: rotate(45deg);
  border: 2px solid rgba(255,255,255,.85); box-shadow: 0 2px 6px rgba(0,0,0,.5);
  display: grid; place-items: center;
}
.marker-pin span { transform: rotate(-45deg); font-size: 10px; font-weight: 700; color: #04101b; }
.marker-pin.dim { opacity: .45; }
.marker-pin.sel { outline: 3px solid var(--accent); outline-offset: 2px; }
.poi-dot { border-radius: 50%; border: 1.5px solid rgba(255,255,255,.6); }
.anchor-pin {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  border: 2px solid #fff; font-size: 11px; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--txt); border-radius: 10px; }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 10px 12px; font-size: 12.5px; }
.leaflet-bar a { background: var(--panel); color: var(--txt); border-color: var(--line); }

/* ---------- pipeline ---------- */
.board { display: flex; gap: 12px; padding: 14px; height: 100%; overflow-x: auto; align-items: stretch; }
.col {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  width: 268px; min-width: 268px; display: flex; flex-direction: column; overflow: hidden;
}
.col.over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(232,112,63,.22); }
.col-head {
  padding: 9px 11px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 7px;
}
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.col-head .name { font-weight: 600; font-size: 12.5px; }
.col-head .n { margin-left: auto; font-size: 11px; color: var(--txt-3); }
.col-head .sum { font-size: 10.5px; color: var(--txt-3); }
.col-body { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kcard {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; cursor: grab; position: relative;
}
.kcard:hover { border-color: var(--accent); }
.kcard.dragging { opacity: .4; }
.kcard-top { display: flex; gap: 8px; align-items: flex-start; }
.kcard-title { font-size: 12.5px; font-weight: 570; line-height: 1.3; flex: 1; }
.kcard-sub { font-size: 11px; color: var(--txt-3); margin-top: 2px; }
.kcard-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 7px; font-size: 11px; color: var(--txt-2); }
.mini-score {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #06131f; flex-shrink: 0;
}
.kmove {
  display: none; width: 100%; margin-top: 8px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 8px; font-size: 12px;
}
@media (max-width: 820px) { .kmove { display: block; } }
.col-empty { color: var(--txt-3); font-size: 11.5px; text-align: center; padding: 14px 8px; }

/* ---------- table ---------- */
.tablewrap { height: 100%; overflow: auto; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
table.grid th {
  position: sticky; top: 0; background: var(--panel); z-index: 5; text-align: left;
  padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--txt-3); cursor: pointer; white-space: nowrap;
}
table.grid th:hover { color: var(--txt); }
table.grid th .arrow { opacity: .6; font-size: 9px; }
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.grid tr:hover td { background: var(--panel-2); }
table.grid tr { cursor: pointer; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.cell-sel { position: relative; }

/* ---------- compare ---------- */
.comparewrap { height: 100%; overflow: auto; padding: 16px; }
table.cmp { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
table.cmp th, table.cmp td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.cmp th.rowh {
  text-align: left; color: var(--txt-3); font-weight: 500; width: 190px;
  position: sticky; left: 0; background: var(--bg); z-index: 2; font-size: 12px;
}
table.cmp thead th { position: sticky; top: 0; background: var(--bg); z-index: 3; text-align: left; }
table.cmp td.best { color: var(--good); font-weight: 600; }
table.cmp td.worst { color: var(--txt-3); }
.cmp-head { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 200px; }
.empty-state { display: grid; place-items: center; height: 100%; color: var(--txt-3); text-align: center; padding: 40px; }
.empty-state h3 { color: var(--txt-2); font-weight: 600; margin: 0 0 6px; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 94vw;
  background: var(--panel); border-left: 1px solid var(--line); z-index: 4000;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: .4 } to { transform: none; opacity: 1 } }
.drawer-inner { overflow-y: auto; flex: 1; }
.scrim { position: fixed; inset: 0; background: rgba(4,8,14,.5); z-index: 3900; }

.d-head { padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 4; }
.d-head-top { display: flex; gap: 10px; align-items: flex-start; }
.d-title { font-size: 16px; font-weight: 640; letter-spacing: -.01em; line-height: 1.25; }
.d-sub { color: var(--txt-3); font-size: 12px; margin-top: 3px; }
.d-actions { margin-left: auto; display: flex; gap: 6px; }
.d-hero { width: 100%; height: 150px; object-fit: cover; display: block; background: var(--bg-2); }
.d-tabs { display: flex; gap: 2px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 3; }
.d-tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 7px 10px;
  color: var(--txt-3); cursor: pointer; font-size: 12.5px; font-weight: 500;
}
.d-tabs button.on { color: var(--txt); border-bottom-color: var(--accent); }
.d-body { padding: 14px 16px 60px; }
.d-sec { margin-bottom: 20px; }
.d-sec h4 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--txt-3); margin: 0 0 9px; font-weight: 600;
}
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--txt-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv dd.big { font-weight: 650; }
.kv .rule { grid-column: 1/-1; border-top: 1px solid var(--line-soft); margin: 4px 0; }

.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 11px; }
.fld > span { font-size: 11px; color: var(--txt-3); }
.fld input, .fld select, .fld textarea {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; outline: none; width: 100%; resize: vertical;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--accent-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.span2 { grid-column: 1 / -1; }

.scorebars { display: flex; flex-direction: column; gap: 7px; }
.sb { display: grid; grid-template-columns: 92px 1fr 34px; gap: 8px; align-items: center; font-size: 12px; }
.sb .lbl { color: var(--txt-2); }
.sb .bar { height: 7px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.sb .bar i { display: block; height: 100%; border-radius: 4px; }
.sb .val { text-align: right; color: var(--txt-2); font-variant-numeric: tabular-nums; }
.sb .note { grid-column: 2 / -1; font-size: 10.5px; color: var(--txt-3); margin-top: -3px; }

.featgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; padding: 3px 0; color: var(--txt-2); }
.check input { accent-color: var(--accent-2); }
.check.on { color: var(--txt); }

.nearby { display: flex; flex-direction: column; gap: 6px; }
.near-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.near-row .ico { width: 18px; text-align: center; }
.near-row .nm { color: var(--txt-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near-row .dist { color: var(--txt); font-variant-numeric: tabular-nums; font-weight: 550; }
.near-row .mi { color: var(--txt-3); font-size: 11px; width: 52px; text-align: right; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 14px 1fr; gap: 9px; padding-bottom: 12px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: 6px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--txt-3); margin-top: 5px; margin-left: 2px; }
.tl-body { font-size: 12.5px; }
.tl-time { font-size: 10.5px; color: var(--txt-3); margin-top: 1px; }
.tl-del { float: right; color: var(--txt-3); cursor: pointer; font-size: 11px; }
.tl-del:hover { color: var(--bad); }

.checklist { display: flex; flex-direction: column; gap: 1px; }
.checklist label { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 4px 0; cursor: pointer; color: var(--txt-2); }
.checklist label.done { color: var(--txt-3); text-decoration: line-through; }

.stars { display: flex; gap: 3px; font-size: 17px; cursor: pointer; }
.stars span { color: var(--txt-3); }
.stars span.on { color: var(--warn); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(4,8,14,.62); z-index: 5000; display: grid; place-items: center; padding: 20px; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  width: 620px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-box.wide { width: 780px; }
.modal-box.narrow { width: 460px; }
.modal-head { display: flex; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: -.025em; font-variation-settings: 'opsz' 30; }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.row { display: flex; gap: 8px; }
.muted { color: var(--txt-3); font-size: 12px; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 9px; padding: 3px; margin-bottom: 14px; }
.seg button { background: none; border: 0; padding: 5px 13px; border-radius: 7px; color: var(--txt-2); cursor: pointer; font-size: 12.5px; }
.seg button.on { background: var(--panel-2); color: var(--txt); box-shadow: inset 0 0 0 1px var(--line); }
.parse-preview {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; font-size: 12px; color: var(--txt-2);
}
.parse-preview b { color: var(--txt); }

.wrow { display: grid; grid-template-columns: 118px 1fr 42px; gap: 10px; align-items: center; margin-bottom: 9px; }
.wrow label { font-size: 12.5px; color: var(--txt-2); }
.wrow input[type=range] { width: 100%; accent-color: var(--accent-2); }
.wrow .v { text-align: right; font-size: 12px; color: var(--txt-2); font-variant-numeric: tabular-nums; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 6000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 15px; font-size: 12.5px; box-shadow: var(--shadow); animation: pop .16s ease-out;
}
.toast.err { border-color: #6A2A24; color: var(--bad); }
.toast.ok { border-color: #17503F; }
@keyframes pop { from { transform: translateY(6px); opacity: 0 } to { transform: none; opacity: 1 } }

.spinner {
  width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

.mobilenav { display: none; }

@media (max-width: 1100px) {
  #view-map { grid-template-columns: 280px 1fr; }
  .search { width: 160px; }
}

/* ------------------------------------------------------------------ phones */
@media (max-width: 820px) {
  :root { --topbar-h: 54px; --stats-h: 56px; --nav-h: 58px; }

  /* iOS zooms the page whenever a focused input is under 16px. */
  input, select, textarea, .fld input, .fld select, .fld textarea, .search { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.tiny { min-height: 32px; }

  .topbar { gap: 10px; padding: 0 12px; }
  .brand { min-width: 0; gap: 8px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 14px; }
  .views { display: none; }                 /* replaced by the bottom bar */
  .topbar-right { gap: 6px; flex: 1; justify-content: flex-end; }
  .search { width: 100%; max-width: none; flex: 1; min-width: 0; }
  #btnFilters, #btnPriorities, #btnTheme, #btnExport { display: none; }
  #btnAdd { padding: 8px 12px; }
  #btnAdd .add-label { display: none; }

  .stat { min-width: auto; padding: 7px 14px; }
  .stat-v { font-size: 15px; }
  .stat-k { font-size: 9.5px; }
  .stat-chips { flex-wrap: nowrap; }

  /* Map on top, the list underneath — the list is how you actually browse. */
  #view-map { grid-template-columns: 1fr; grid-template-rows: 44dvh minmax(0, 1fr); }
  .maplist { display: flex; border-right: 0; border-top: 1px solid var(--line); order: 2; }
  .mapwrap { order: 1; }
  .map-panel { width: auto; max-width: 74vw; top: 8px; right: 8px; padding: 7px 9px; }
  .panel-toggle { display: block; }
  .map-panel:not(.collapsed) { width: 214px; max-height: calc(100% - 16px); }

  .board { padding: 10px; gap: 10px; scroll-snap-type: x mandatory; }
  .col { width: 84vw; min-width: 84vw; scroll-snap-align: start; }

  .drawer { width: 100vw; max-width: 100vw; border-left: 0; }
  .d-body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .featgrid { grid-template-columns: 1fr; }

  .modal { padding: 0; place-items: end center; }
  .modal-box, .modal-box.wide, .modal-box.narrow {
    width: 100%; max-width: 100%; max-height: 92dvh;
    border-radius: 16px 16px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .row { flex: 1; justify-content: flex-end; }

  table.cmp th.rowh { width: 128px; min-width: 128px; font-size: 11.5px; }
  .cmp-photo { height: 84px; }

  .mobilenav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .mobilenav button {
    flex: 1; background: none; border: 0; color: var(--txt-3); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: 10px; font-weight: 500; padding: 0;
  }
  .mobilenav button.on { color: var(--accent); }
  .mobilenav .mn-i { font-size: 15px; line-height: 1; }
  .sheet-actions { display: flex; flex-direction: column; gap: 8px; }
  .toasts { bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .col { width: 90vw; min-width: 90vw; }
}

/* ---------- cover photos ---------- */
.pthumb, .kthumb {
  position: relative; background: var(--bg-2); overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px;
}
.pthumb { width: 84px; height: 62px; }
.kthumb { width: 100%; height: 92px; margin-bottom: 8px; border-radius: 8px; }
.pthumb img, .kthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pthumb.dragging-photo, .kthumb.dragging-photo, .d-hero-wrap.dragging-photo {
  outline: 2px dashed var(--accent); outline-offset: -3px;
}
.ph-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 9px; letter-spacing: .09em; text-transform: uppercase; color: var(--txt-3);
}
.pthumb img ~ .ph-empty, .kthumb img ~ .ph-empty { display: none; }
.pthumb.noimg img, .kthumb.noimg img { display: none; }
.pthumb.noimg .ph-empty, .kthumb.noimg .ph-empty { display: grid; }
.ph-score {
  position: absolute; left: 4px; bottom: 4px; min-width: 24px; padding: 1px 5px;
  border-radius: 6px; font-size: 11px; font-weight: 700; color: #06131f; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.pcard { grid-template-columns: 84px 1fr; }

.tname { display: inline-flex; align-items: center; gap: 8px; }
.tthumb {
  width: 38px; height: 27px; object-fit: cover; border-radius: 4px;
  border: 1px solid var(--line); background: var(--bg-2); display: block;
}
.tthumb.noimg { display: inline-block; }
.cmp-photo {
  width: 100%; max-width: 240px; height: 120px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); display: block;
}

.d-hero-wrap { position: relative; background: var(--bg-2); min-height: 150px; }
.d-hero-wrap.empty { min-height: 86px; }
.d-hero-wrap .d-hero-hint {
  position: absolute; inset: 0; display: none; place-items: center;
  font-size: 12px; color: var(--txt-3); text-align: center; padding: 10px;
}
.d-hero-wrap.empty .d-hero-hint { display: grid; }
.d-hero-wrap.empty .d-hero { display: none; }


/* ---------- chat ---------- */
.chat {
  position: fixed; right: 0; top: var(--topbar-h); bottom: 0; width: 420px; max-width: 96vw;
  background: var(--panel); border-left: 1px solid var(--line); z-index: 4200;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 620; font-size: 14px; }
.chat-sub { font-size: 11px; color: var(--txt-3); margin-top: 2px; }
.chat-head .btn { margin-left: auto; }
.chat-head .btn + .btn { margin-left: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { font-size: 13.5px; line-height: 1.55; }
.msg.user {
  align-self: flex-end; max-width: 85%; background: var(--accent-2); color: #fff;
  padding: 8px 12px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap;
}
.msg.bot { align-self: stretch; color: var(--txt); }
.msg.bot p { margin: 0 0 9px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin: 0 0 9px; padding-left: 20px; }
.msg.bot li { margin-bottom: 3px; }
.msg.bot strong { color: var(--txt); font-weight: 640; }
.msg.bot code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.msg.err { color: var(--bad); font-size: 12.5px; }
.tool-chip {
  align-self: flex-start; font-size: 11px; color: var(--txt-3);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chat-empty { color: var(--txt-3); font-size: 12.5px; }
.chat-empty b { color: var(--txt-2); display: block; margin-bottom: 8px; font-weight: 600; }
.chat-sugg { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; align-items: flex-start; }
.chat-sugg button {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--txt-2); cursor: pointer;
  border-radius: 9px; padding: 7px 11px; font-size: 12.5px; text-align: left; width: 100%;
}
.chat-sugg button:hover { color: var(--txt); border-color: var(--accent); }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-input textarea {
  flex: 1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; outline: none; resize: none; max-height: 140px; font: inherit;
}
.chat-input textarea:focus { border-color: var(--accent-2); }
.chat-cursor { display: inline-block; width: 7px; height: 14px; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0 } }

@media (max-width: 820px) {
  .chat { top: 0; bottom: var(--nav-h); width: 100vw; max-width: 100vw; border-left: 0; z-index: 4200; }
  .chat-input { padding-bottom: 10px; }
}


/* ---------- sign in ---------- */
.authgate {
  position: fixed; inset: 0; z-index: 9000; background: var(--bg);
  display: grid; place-items: center; padding: 24px;
}
.authbox {
  width: 360px; max-width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 24px; box-shadow: var(--shadow);
}
.auth-brand {
  display: flex; align-items: center; gap: 9px; color: var(--accent);
  font-size: 17px; font-weight: 650; letter-spacing: -.01em; margin-bottom: 4px;
}
.auth-brand span { color: var(--txt); font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: -.03em; font-variation-settings: 'opsz' 40; }
.authbox .muted { margin: 0 0 18px; }
.authbox .btn.block { margin-top: 10px; }
.auth-err {
  background: rgba(240,112,92,.10); border: 1px solid #5A2A22; color: var(--bad);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-top: 4px;
}
.auth-ok {
  background: rgba(52,199,154,.10); border: 1px solid #1B4D3E; color: var(--good);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-top: 4px; line-height: 1.45;
}
.linkish {
  display: block; width: 100%; margin-top: 14px; background: none; border: 0;
  color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; text-align: center;
}
.linkish:hover { color: var(--txt); text-decoration: underline; }


/* ---------- onboarding ---------- */
.onboard { position: fixed; inset: 0; z-index: 9500; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.ob-box {
  width: 640px; max-width: 100%; max-height: 92dvh; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.ob-progress { height: 3px; background: var(--bg-2); }
.ob-progress i { display: block; height: 100%; background: var(--accent); transition: width .25s ease; }
.ob-body { padding: 28px 28px 8px; overflow-y: auto; }
.ob-body h2 { margin: 0 0 6px; font-family: var(--display); font-size: 25px; font-weight: 700; letter-spacing: -.03em; font-variation-settings: 'opsz' 60; }
.ob-body .sub { color: var(--txt-2); font-size: 13.5px; margin: 0 0 20px; line-height: 1.5; }
.ob-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px 20px; }
.ob-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ob-pick {
  display: flex; align-items: center; gap: 9px; text-align: left; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 13px; color: var(--txt-2);
}
.ob-pick:hover { border-color: var(--accent); color: var(--txt); }
.ob-pick.on { border-color: var(--accent); background: rgba(232,112,63,.12); color: var(--txt); }
.ob-pick .tick { margin-left: auto; color: var(--accent); opacity: 0; }
.ob-pick.on .tick { opacity: 1; }
.ob-pick .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ob-pick small { display: block; color: var(--txt-3); font-size: 11px; }
.ob-how { display: flex; flex-direction: column; gap: 14px; }
.ob-card { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.ob-card .ico { font-size: 19px; line-height: 1.2; }
.ob-card h4 { margin: 0 0 3px; font-size: 13.5px; font-weight: 620; }
.ob-card p { margin: 0; font-size: 12.5px; color: var(--txt-2); line-height: 1.55; }
.ob-card code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.ob-seeding { font-size: 12px; color: var(--txt-3); margin-top: 12px; }

@media (max-width: 820px) { .ob-grid { grid-template-columns: 1fr; } .ob-body { padding: 22px 18px 6px; } .ob-foot { padding: 14px 18px 18px; } }

/* ---------- gallery ---------- */
.gallery { display: flex; gap: 6px; padding: 8px 16px 0; overflow-x: auto; }
.gallery img {
  width: 76px; height: 56px; object-fit: cover; border-radius: 7px; cursor: pointer;
  border: 2px solid transparent; flex: none; background: var(--bg-2);
}
.gallery img.on { border-color: var(--accent); }
.gallery-count { font-size: 11px; color: var(--txt-3); padding: 4px 16px 0; }

/* ---------- billing ---------- */
.trial-pill {
  margin-left: 4px; background: rgba(232,112,63,.12); border: 1px solid var(--accent);
  color: var(--accent); border-radius: 20px; padding: 3px 10px; font-size: 11px;
  font-weight: 650; cursor: pointer; white-space: nowrap;
}
.trial-pill:hover { background: var(--accent); color: #fff; }
.trial-pill.warn { background: rgba(240,180,41,.14); border-color: var(--warn); color: var(--warn); }
.trial-pill.warn:hover { background: var(--warn); color: #1a1206; }

.paywall-box { width: 400px; }
.paywall-box h2 {
  font-family: var(--display); font-size: 24px; font-weight: 700;
  letter-spacing: -.03em; margin: 6px 0 6px; font-variation-settings: 'opsz' 60;
}
.pw-list { list-style: none; margin: 14px 0 4px; padding: 0; display: grid; gap: 7px; }
.pw-list li { padding-left: 22px; position: relative; font-size: 13px; color: var(--txt-2); }
.pw-list li::before {
  content: '✓'; position: absolute; left: 0; top: -1px; color: var(--good); font-weight: 700;
}
