/* GeoChat
   Look: utility operations map. Map-paper panels, slate ink, survey-blue actions, and one
   colour per question mode (electric yellow, habitat green, fire red, survey blue) that runs
   through the chips, the answer rule and the results.
   Layout: desktop map over the results table, chat as a full-height column;
   phone (<= 760px) map on top with Chat / Results tabs below. */

:root {
  /* palette */
  --paper:   #eef1ec;   /* panel background, like a topo sheet */
  --sheet:   #ffffff;   /* raised surfaces: composer, menus, table */
  --ink:     #17242f;   /* text, header band */
  --ink-2:   #4a5866;   /* secondary text */
  --ink-3:   #5c6b78;   /* hints, counts — 5.48:1 on white, passes AA */
  --ink-4:   #aeb9c3;   /* light text on dark bands only */
  --rule:    #d6ddd6;   /* lines between areas */
  --rule-2:  #e6ebe5;   /* lighter rows */
  --row-hover:#f4f7fb;  /* hovered list / table row */
  --track:   #c5ced6;   /* toggle track, off */
  --check-mid:#8fb0d8;  /* toggle indeterminate */
  --survey:  #1f5fad;   /* actions and links */
  --survey-d:#174b8a;
  --select:  #e3ecf7;   /* hover / active row */
  --danger:  #a3321f;
  --danger-bg:#fbebe7;

  /* mode colours */
  --m-auto:  #4a5866;
  --m-data:  #8a6d08;   /* high-voltage yellow, darkened for text contrast (4.92:1) */
  --m-data-bg: #e8b520; /* yellow as a fill / dot only, never as text */
  --m-analysis: #1f5fad;
  --m-env:   #2f7350;   /* 5.69:1 on white, passes AA */
  --m-fire:  #c4432a;

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;

  --chat-w: 400px;
  --dock-h: 34vh;
  --dock-head-h: 48px;
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 var(--font);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;                          /* panels scroll, not the page */
  -webkit-font-smoothing: antialiased;
}
button, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 1px solid var(--rule); background: var(--sheet);
  border-radius: var(--r-sm); padding: 5px 10px;
}
button:disabled { opacity: .4; cursor: default; }
button.ghost { background: transparent; }
a { color: var(--survey); }
:focus-visible { outline: 2px solid var(--survey); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

/* ------------------------------------------------------------------ grid */

#app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--chat-w);
  grid-template-rows: minmax(0, 1fr) var(--dock-h);
  grid-template-areas: "map chat" "dock chat";
}
#app.dock-collapsed { grid-template-rows: minmax(0, 1fr) var(--dock-head-h); }
#mapArea { grid-area: map; position: relative; min-width: 0; min-height: 0; }
#viewDiv { position: absolute; inset: 0; }
#chat { grid-area: chat; }
#dock { grid-area: dock; }
#tabs { display: none; }

/* ------------------------------------------------------------------ layers button + panel */

.map-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
  background: var(--sheet); border: 0; border-radius: var(--r-sm);
  box-shadow: 0 1px 2px rgba(23, 36, 47, .3); font-size: 13px; font-weight: 500; color: var(--ink);
}
.map-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.map-btn[aria-expanded="true"], .map-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.map-btn:hover { box-shadow: 0 1px 4px rgba(23, 36, 47, .4); }

/* Layers + Full map: one segmented group, top-right */
.map-actions {
  display: flex; background: var(--sheet); border-radius: var(--r-md);
  box-shadow: 0 1px 3px rgba(23, 36, 47, .28); overflow: hidden;
}
.map-actions .map-btn { height: 40px; padding: 0 13px; border-radius: 0; box-shadow: none; }
.map-actions .map-btn + .map-btn { border-left: 1px solid var(--rule); }
.map-actions .map-btn:hover:not([aria-expanded="true"]):not([aria-pressed="true"]) { background: var(--select); box-shadow: none; }

/* drawing tools: one slim strip */
.esri-sketch { box-shadow: 0 1px 2px rgba(23, 36, 47, .3); border-radius: var(--r-sm); overflow: hidden; }

/* desktop: panel over the top-right of the map, never taller than the map */
#layersPanel {
  grid-area: map; align-self: start; justify-self: end; z-index: 30;
  width: min(290px, calc(100% - 24px)); max-height: min(520px, calc(100% - 80px));
  margin: 63px 15px 0 0;                       /* right under the Layers / Full map group */
  display: flex; flex-direction: column;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  box-shadow: 0 10px 30px rgba(23, 36, 47, .2);
}
#layersPanel[hidden], #layersBackdrop[hidden] { display: none; }
.layers-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 6px 8px 14px; border-bottom: 1px solid var(--rule);
}
.layers-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.layers-count {
  flex: 1; font-size: 11.5px; font-weight: 600; color: var(--survey-d); font-variant-numeric: tabular-nums;
}
.layers-alloff {
  border: 0; background: none; padding: 4px 8px; font-size: 12px; font-weight: 500; color: var(--survey);
}
.layers-alloff:hover:not(:disabled) { background: var(--select); }
.layers-alloff:disabled { color: var(--ink-3); opacity: .6; }
.layers-done {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; background: none; color: var(--ink-2);
}
.layers-done:hover { background: var(--paper); color: var(--ink); }
.layers-done svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.layers-done span { display: none; }
#layerListHost { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 6px; }

/* one collapsible section per category */
.lyr-group + .lyr-group { border-top: 1px solid var(--rule-2); }
.lyr-head-row { display: flex; align-items: center; padding-right: 12px; }
.lyr-head {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 8px 8px 8px 8px; border: 0; background: none; border-radius: 0; text-align: left;
}
.lyr-head:hover .lyr-title { color: var(--survey); }
.lyr-chev { flex: none; display: grid; width: 18px; color: var(--ink-3); }
.lyr-chev svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.lyr-group.open .lyr-chev svg { transform: rotate(90deg); }
.lyr-title {
  flex: 1; min-width: 0; font: 600 11.5px var(--font-cond); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lyr-count {
  flex: none; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-3);
  padding: 1px 7px; border-radius: 999px; background: var(--rule-2);
}
.lyr-count.some { background: var(--select); color: var(--survey-d); }
.lyr-list { padding: 0 0 6px; }
.lyr-list[hidden] { display: none; }

/* one short row per layer: switch, map symbol, name */
.lyr-row {
  display: flex; align-items: center; gap: 9px; min-height: 32px;
  padding: 3px 12px 3px 32px; cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.lyr-row:hover { background: var(--row-hover); }
.lyr-row.on { color: var(--ink); }
.lyr-row:not(.on) .lyr-swatch { opacity: .45; filter: grayscale(.6); }
.lyr-swatch { flex: none; display: grid; width: 18px; height: 18px; }
.lyr-swatch svg { width: 18px; height: 18px; }
.lyr-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* compact switch, built on a real checkbox */
.lyr-check {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 26px; height: 15px; border-radius: 999px; background: var(--track); transition: background .15s;
}
.lyr-check::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(23, 36, 47, .3); transition: transform .15s;
}
.lyr-check:checked { background: var(--survey); }
.lyr-check:checked::after { transform: translateX(11px); }
.lyr-check:indeterminate { background: var(--check-mid); }
.lyr-check:indeterminate::after { transform: translateX(5.5px); }
.lyr-check:focus-visible { outline: 2px solid var(--survey); outline-offset: 2px; }
.lyr-row .lyr-check { order: 3; }                 /* switch on the right, aligned with the section toggles */
#layersBackdrop { position: fixed; inset: 0; z-index: 40; background: rgba(23, 36, 47, .35); }

/* ------------------------------------------------------------------ drawing tools */
.sketch-host { display: none; }          /* Sketch runs headless; the toolbar below is the UI */

/* Vertical rail on the map's left edge, under the search bar */
.draw-rail { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.draw-toggle { display: none; }                       /* phones only */
.draw-bar {
  display: flex; flex-direction: column; gap: 2px; padding: 4px;
  background: var(--sheet); border-radius: var(--r-md);
  box-shadow: 0 1px 3px rgba(23, 36, 47, .28);
}
.draw-btn {
  position: relative; display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2);
  transition: background .12s ease, color .12s ease;
}
.draw-btn svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.draw-btn svg .dot { fill: currentColor; stroke: none; }
.draw-btn:hover:not(:disabled) { background: var(--select); color: var(--ink); }
.draw-btn.active { background: var(--survey); color: #fff; }
.draw-btn:focus-visible { outline: 2px solid var(--survey); outline-offset: 1px; }
.draw-clear:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }
.draw-clear:disabled { opacity: .35; }
.draw-sep { height: 1px; margin: 3px 4px; background: var(--rule); }

/* name tooltip to the right of each button (hover or keyboard focus) */
.draw-btn[data-tip]::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translate(-4px, -50%); opacity: 0; pointer-events: none;
  white-space: nowrap; font-size: 12px; font-weight: 500; line-height: 1;
  padding: 6px 9px; border-radius: var(--r-sm); background: var(--ink); color: #f3f6f2;
  box-shadow: 0 4px 12px rgba(23, 36, 47, .25);
  transition: opacity .12s ease, transform .12s ease;
}
.draw-btn:hover::after, .draw-btn:focus-visible::after { opacity: 1; transform: translate(0, -50%); }
.draw-btn:disabled::after { content: none; }

/* Contextual hint pill shown while drawing */
.draw-hint {
  position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #f3f6f2; font-size: 12.5px;
  padding: 7px 8px 7px 15px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(23, 36, 47, .35);
  width: max-content; max-width: calc(100% - 32px);
}
#drawHint[hidden] { display: none; }
.draw-hint button {
  flex: none; border: 1px solid rgba(243, 246, 242, .4); border-radius: 999px;
  background: transparent; color: #f3f6f2; font-size: 12px; padding: 3px 11px;
}
.draw-hint button:hover { background: rgba(243, 246, 242, .15); }

/* ------------------------------------------------------------------ chat panel */

#chat {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--paper); border-left: 1px solid var(--rule);
}

.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 18px; background: var(--ink); color: #f3f6f2;
}
.mark { width: 22px; height: 22px; flex: none; }
.mark path { fill: none; stroke: var(--m-data-bg); stroke-width: 1.6; stroke-linecap: round; }
.mark circle { fill: var(--ink); stroke: #f3f6f2; stroke-width: 1.6; }
.home-link {
  flex: 1 0 auto; min-width: 0; display: flex; align-items: center; gap: 10px;
  margin: -4px 0 -4px -8px; padding: 4px 10px 4px 8px; border-radius: var(--r-md);
  color: inherit; text-decoration: none;
}
.home-link:hover { background: rgba(243, 246, 242, .1); }
.home-link:focus-visible { outline: 2px solid var(--m-data-bg); outline-offset: 0; }
.brand { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.chat-head h1 { font-size: 16px; font-weight: 600; letter-spacing: .01em; margin: 0; }
.area-tag { font-size: 11.5px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-tag[hidden] { display: none; }

/* incident picker: a quiet pill in the header; orange with the name when one is active */
.incident {
  position: relative; flex: 0 1 auto; min-width: 0; display: flex; align-items: center;
  height: 30px; border-radius: 999px; border: 1px solid rgba(243, 246, 242, .28);
  color: #c9d2da; transition: background .12s, border-color .12s;
}
.incident:hover { border-color: rgba(243, 246, 242, .55); color: #fff; }
.incident:focus-within { outline: 2px solid var(--m-data-bg); outline-offset: 1px; }
.incident svg {
  position: absolute; left: 9px; width: 15px; height: 15px; pointer-events: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round;
}
.incident select {
  appearance: none; -webkit-appearance: none; min-width: 0; width: 100%; max-width: 168px; height: 100%;
  padding: 0 24px 0 29px; border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 12.5px; font-weight: 500; text-overflow: ellipsis; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%23aeb9c3' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 14px;
}
.incident select option, .incident select optgroup { color: var(--ink); background: var(--sheet); }
.incident.active { background: #c2410c; border-color: #c2410c; color: #fff; }
.incident.active select { font-weight: 600; }

.head-btn {
  flex: none; width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: transparent; color: #c9d2da;
}
.head-btn:hover { background: rgba(243, 246, 242, .12); color: #fff; }
.head-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* what's attached to the next question: a chip inside the composer */
.ctx {
  display: flex; align-items: center; gap: 7px; margin-bottom: 6px;
  padding: 4px 4px 4px 9px; font-size: 12.5px; line-height: 1.35; color: var(--ink);
  background: var(--select); border: 1px solid #c7d7ec; border-radius: var(--r-md);
}
.ctx[hidden] { display: none; }
.ctx-icon { flex: none; display: grid; color: var(--survey); }
.ctx-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.ctx-text { flex: 1; min-width: 0; }
.ctx-remove {
  flex: none; width: 24px; height: 24px; padding: 0; border: 0; background: transparent;
  border-radius: var(--r-sm); font-size: 17px; line-height: 1; color: var(--ink-2);
}
.ctx-remove:hover { background: rgba(31, 95, 173, .14); color: var(--ink); }

#log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 16px;
}

/* welcome text before the first question */
.welcome h2 { font-size: 19px; line-height: 1.3; font-weight: 600; margin: 4px 0 6px; max-width: 30ch; }
.welcome p { margin: 0; color: var(--ink-2); max-width: 46ch; }
.welcome .welcome-tip { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }
.welcome-examples:empty { display: none; }
.welcome-examples { margin-top: 18px; }
.welcome-examples .try {
  font: 600 11px var(--font-cond); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}
.welcome-examples .examples { display: flex; flex-direction: column; gap: 6px; }
.welcome-examples .examples button {
  text-align: left; padding: 9px 12px; line-height: 1.4; font-size: 13px; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  transition: border-color .12s, background .12s;
}
.welcome-examples .examples button:hover { border-color: var(--survey); background: #f7fafd; }

/* user question */
.q {
  align-self: flex-end; max-width: 88%;
  background: var(--sheet); border: 1px solid var(--rule);
  border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
  padding: 8px 12px; overflow-wrap: anywhere;
}
.q .mode-tag { display: block; margin-bottom: 2px; }

/* assistant answer: text on the paper, with a rule in the mode's colour */
.a {
  --mode: var(--m-auto);
  border-left: 3px solid var(--mode);
  padding: 2px 0 2px 13px; overflow-wrap: anywhere;
}
.a[data-mode="data"]        { --mode: var(--m-data-bg); }
.a[data-mode="analysis"]    { --mode: var(--m-analysis); }
.a[data-mode="environmental"] { --mode: var(--m-env); }
.a[data-mode="wildfire"]    { --mode: var(--m-fire); }
.a .status { color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.a .status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mode);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }
.a .live-steps { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.a .live-steps span {
  font-size: 11.5px; padding: 1px 8px; border-radius: 999px;
  background: var(--sheet); border: 1px solid var(--rule); color: var(--ink-2);
}
.a .live-steps span.running { border-color: var(--mode); color: var(--ink); }
.a .elapsed { font-size: 12px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums; }

.answer p { margin: 0 0 8px; }
.answer p:last-child { margin-bottom: 0; }
.answer ul, .answer ol { margin: 4px 0 8px; padding-left: 20px; }
.answer li { margin: 2px 0; }
.answer h3 { font-size: 14px; margin: 10px 0 4px; }
.answer code { font-size: 12.5px; background: var(--rule-2); padding: 0 4px; border-radius: 3px; }

.a.err { --mode: var(--danger); color: var(--danger); }

.steps { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.steps summary { cursor: pointer; width: fit-content; }
.steps code {
  display: block; white-space: pre-wrap; font-size: 11.5px; color: var(--ink-2);
  margin: 4px 0; padding: 6px 8px; background: var(--rule-2); border-radius: var(--r-sm);
}

/* results under an answer */
.results { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.result {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: 8px 6px 8px 10px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.result:hover { border-color: #b7c4d3; }
.result.is-open {
  border-color: var(--survey); box-shadow: inset 3px 0 0 var(--survey);
}
.result.is-cleared { cursor: default; }
.result.is-cleared:hover { border-color: var(--rule); }
.result.is-cleared { opacity: .6; }
.result.is-cleared .rcount::after { content: " · cleared"; }
.result:focus-visible { outline: 2px solid var(--survey); outline-offset: 1px; }
/* the result's colour on the map (or a table glyph when it draws nothing) */
.rdot {
  flex: none; width: 12px; height: 12px; border-radius: 50%; align-self: start; margin-top: 3px;
  background: var(--rc, var(--ink-3)); box-shadow: 0 0 0 2px var(--sheet), 0 0 0 3px var(--rule);
}
.rdot.table-only { background: none; box-shadow: none; border-radius: 0; width: 14px; height: 14px; color: var(--ink-3); }
.rdot.table-only svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.ropen { flex: none; display: grid; color: var(--ink-3); }
.ropen svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.result:hover .ropen, .result.is-open .ropen { color: var(--survey); }
.result.is-cleared .ropen { visibility: hidden; }
.rlabel { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; line-height: 1.35; color: var(--ink); min-width: 0; }
.rtitle { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rcount { color: var(--ink-2); font-size: 11.5px; }
.rlabel small {
  color: var(--ink-3); font-size: 11.5px; font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* export: an icon button on the card */
.menu.menu-icon > summary {
  width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  border-color: transparent; background: transparent; color: var(--ink-2);
}
.menu.menu-icon > summary::after { content: none; }
.menu.menu-icon > summary:hover { background: var(--select); color: var(--survey); }
.menu.menu-icon[open] > summary { background: var(--select); color: var(--survey); border-color: transparent; }
.menu.menu-icon > summary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.result .error-inline { grid-column: 1 / -1; }
.error-inline { color: var(--danger); font-size: 12px; }

/* export menu */
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; font-size: 12px; padding: 3px 9px;
  border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--sheet);
  white-space: nowrap; user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; color: var(--ink-3); }
.menu[open] > summary { border-color: var(--survey); color: var(--survey); }
.menu-list {
  position: absolute; right: 0; z-index: 20; margin-top: 4px; min-width: 220px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(23, 36, 47, .16); padding: 4px;
}
.menu-list button {
  display: grid; grid-template-columns: 74px 1fr; gap: 6px; width: 100%;
  text-align: left; border: 0; background: none; border-radius: var(--r-sm); padding: 6px 8px;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--select); }
.menu-list b { font-weight: 600; font-size: 12.5px; }
.menu-list span { font-size: 12px; color: var(--ink-2); }

/* ------------------------------------------------------------------ composer */

#composer {
  margin: 8px 12px 12px; padding: 10px 8px 8px 12px;
  margin-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-lg);
  box-shadow: 0 1px 0 rgba(23, 36, 47, .04);
}
#composer:focus-within { border-color: #b7c4d3; }

/* question type: one pill at the bottom-left of the question box, with an upward menu */
.mode-pill, .mode-opt { --c: var(--m-auto); }
:is(.mode-pill, .mode-opt)[data-mode="data"]          { --c: var(--m-data-bg); }
:is(.mode-pill, .mode-opt)[data-mode="analysis"]      { --c: var(--m-analysis); }
:is(.mode-pill, .mode-opt)[data-mode="environmental"] { --c: var(--m-env); }
:is(.mode-pill, .mode-opt)[data-mode="wildfire"]      { --c: var(--m-fire); }
.mode-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.mode-pick { position: relative; min-width: 0; }
.mode-pill {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; height: 32px;
  padding: 0 8px 0 11px; border-radius: 999px; border: 1px solid var(--rule);
  background: var(--paper); font-size: 12.5px; font-weight: 500; color: var(--ink);
}
.mode-pill:hover, .mode-pill[aria-expanded="true"] { border-color: var(--c); background: var(--sheet); }
.mode-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-pill:has(.mode-or) .mode-name { flex: none; }       /* the hint shortens first, never the name */
.mode-or { min-width: 0; color: var(--ink-3); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-pill:hover .mode-or { color: var(--survey); }
.mode-menu-head {
  margin: 4px 10px 4px; font: 600 11px var(--font-cond); letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3);
}
.mode-caret { flex: none; width: 15px; height: 15px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.mode-pill[aria-expanded="true"] .mode-caret { transform: rotate(180deg); }
@media (min-width: 761px) and (max-width: 1100px) {   /* narrower chat column: keep the whole hint visible */
  .mode-pill { gap: 5px; padding: 0 6px 0 9px; }
  .mode-or { font-size: 12px; }
}
.mode-menu {
  position: absolute; left: -6px; bottom: calc(100% + 8px); z-index: 30;
  width: min(320px, calc(var(--chat-w) - 32px)); padding: 4px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  box-shadow: 0 10px 28px rgba(23, 36, 47, .2);
}
.mode-menu[hidden] { display: none; }
.mode-opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none;
}
.mode-opt .mode-dot { margin-top: 6px; }
.mode-opt:hover, .mode-opt:focus-visible { background: var(--select); outline: none; }
.mode-opt[aria-checked="true"] { background: var(--paper); box-shadow: inset 3px 0 0 var(--c); }
.mode-opt-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mode-opt-text b { font-size: 13px; font-weight: 600; }
.mode-opt-text span { font-size: 12px; line-height: 1.35; color: var(--ink-2); }

.mode-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-2);
}
.mode-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--m-auto)); }
.mode-tag[data-mode="data"]          { --c: var(--m-data-bg); }
.mode-tag[data-mode="analysis"]      { --c: var(--m-analysis); }
.mode-tag[data-mode="environmental"] { --c: var(--m-env); }
.mode-tag[data-mode="wildfire"]      { --c: var(--m-fire); }

#modeHint:empty { display: none; }
#modeHint { font-size: 12.5px; color: var(--ink-2); padding: 0 0 6px; margin-bottom: 4px; border-bottom: 1px solid var(--rule-2); }
.hint-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-3); font-size: 12px; }
.hint-close { width: 24px; height: 24px; padding: 0; border: 0; background: none; font-size: 16px; line-height: 1; color: var(--ink-3); }
.hint-close:hover { color: var(--ink); background: var(--paper); }
#modeHint .examples { display: flex; flex-direction: column; gap: 1px; margin: 2px -4px 0; }
#modeHint .examples button {
  border: 0; background: none; text-align: left; padding: 4px; border-radius: var(--r-sm);
  color: var(--survey); font-size: 12.5px; line-height: 1.35;
}
#modeHint .examples button:hover { background: var(--select); }

#input {
  display: block; width: 100%; resize: none; min-height: 44px; max-height: 140px; padding: 4px 2px 6px;
  border: 0; background: transparent; outline: none; line-height: 1.45;
}
#input::placeholder { color: var(--ink-3); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.send {
  flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: var(--survey); display: grid; place-items: center;
}
.send:hover { background: var(--survey-d); }
.send svg { width: 19px; height: 19px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.send:disabled { background: var(--ink-3); opacity: .6; }

/* ------------------------------------------------------------------ results dock */

#dock {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--sheet); border-top: 1px solid var(--rule);
}
#dockHead {
  flex: none; min-height: var(--dock-head-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(150px, 260px) auto;
  grid-template-areas: "toggle id count pick actions";
  align-items: center; gap: 8px 12px;
  padding: 7px 12px 7px 6px; background: var(--sheet); border-bottom: 1px solid var(--rule);
}
.dock-toggle { grid-area: toggle; }
.dock-id { grid-area: id; }
.count-pill { grid-area: count; justify-self: start; }
.result-pick { grid-area: pick; }
.dock-actions { grid-area: actions; }
.dock-toggle {
  width: 32px; height: 32px; padding: 0; border: 0; background: transparent;
  display: grid; place-items: center; border-radius: var(--r-sm); color: var(--ink-2);
}
.dock-toggle:hover { background: var(--paper); color: var(--ink); }
.dock-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#app.dock-collapsed .dock-toggle svg { transform: rotate(180deg); }
.dock-id { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.dock-kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 11px var(--font-cond); letter-spacing: .06em; text-transform: uppercase; color: var(--survey);
}
.dock-kicker.has-color::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--rc);
  box-shadow: 0 0 0 1.5px var(--sheet), 0 0 0 2.5px var(--rule);
}
#dockTitle {
  margin: 0; min-width: 0; font-size: 14px; font-weight: 600; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dock-meta {
  flex: 1 0 100%; font-size: 12px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.count-pill {
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--select); color: var(--survey-d); border-radius: 999px; padding: 3px 10px;
}
.result-pick { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pick-label { flex: none; font-size: 12px; color: var(--ink-3); }
#resultSelect {
  width: 100%; min-width: 0; padding: 5px 8px; border: 1px solid var(--rule);
  border-radius: var(--r-sm); background: var(--paper); font-weight: 500; font-size: 13px;
}
#resultSelect:disabled { color: var(--ink-3); }
.dock-actions { display: flex; align-items: center; gap: 8px; justify-self: end; }
.clear-results { font-size: 12.5px; font-weight: 500; padding: 5px 10px; color: var(--ink-2); }
.clear-results:hover { color: var(--danger); border-color: var(--danger); }
.pager { display: inline-flex; gap: 4px; }
.pager button { width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1; }
#dockHead .menu > summary { padding: 5px 10px; font-weight: 500; }
#dock:not(.has-results) .result-pick,
#dock:not(.has-results) .dock-actions { display: none; }
#dock:not(.has-results) #dockHead { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "toggle id"; }
#dock:not(.has-results) .count-pill { display: none; }
#app.dock-collapsed #tableBody,
#app.dock-collapsed .dock-meta { display: none; }

/* filter row between the dock header and the table */
.table-filter {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 14px; border-bottom: 1px solid var(--rule); background: var(--sheet);
}
.tf-icon { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
#filterInput {
  flex: 0 1 280px; min-width: 0; height: 30px; padding: 0 10px; font-size: 13px; color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--paper);
}
#filterInput:focus { outline: none; border-color: var(--survey); box-shadow: 0 0 0 2px var(--select); background: var(--sheet); }
#filterColumn {
  flex: 0 1 180px; min-width: 0; height: 30px; padding: 0 6px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--paper); color: var(--ink);
}
.tf-status { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dock:not(.has-results) .table-filter,
#app.dock-collapsed .table-filter { display: none; }

#tableBody { flex: 1; min-height: 0; overflow: auto; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 22px 24px; color: var(--ink-2); max-width: 52ch; }
.empty p { margin: 0; }
.empty-title { font-weight: 600; color: var(--ink); }
.empty-mark {
  width: 28px; height: 28px; margin-bottom: 6px; border-radius: 50%; border: 2px solid var(--rule);
  background: radial-gradient(circle at 50% 50%, var(--m-data-bg) 0 4px, transparent 5px);
}

#tableBody table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 12.5px; }
#tableBody th, #tableBody td {
  padding: 7px 12px; text-align: left; white-space: nowrap;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
#tableBody th {
  position: sticky; top: 0; z-index: 2; background: #f6f7f4;
  font: 600 11px var(--font-cond); letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--rule); cursor: pointer; user-select: none;
}
#tableBody th:hover { color: var(--ink); }
#tableBody th[aria-sort] { color: var(--survey); }
#tableBody td { border-bottom: 1px solid var(--rule-2); background: var(--sheet); }
#tableBody td.num, #tableBody th.num { text-align: right; font-variant-numeric: tabular-nums; }
#tableBody td.muted { color: var(--ink-3); }
#tableBody td.idcol { color: var(--ink-3); }
#tableBody th.idx, #tableBody td.idx {
  position: sticky; left: 0; width: 44px; max-width: 44px; padding-right: 8px;
  text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
#tableBody th.idx { z-index: 3; background: #f6f7f4; }
#tableBody td.idx { background: var(--sheet); }
#tableBody tbody tr.can-zoom { cursor: pointer; }
#tableBody td.name { font-weight: 500; color: var(--ink); }
#tableBody tbody tr:hover td { background: var(--row-hover); }
#tableBody tbody tr:hover td.idx { background: var(--row-hover); }
#tableBody tbody tr.active td { background: #fbf6e4; }
#tableBody tbody tr.active td.idx {
  background: #fbf6e4; color: var(--ink);
  box-shadow: inset 3px 0 0 #e8b520;
}

.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--survey); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ------------------------------------------------------------------ map search bar */

.mapsearch {
  width: 400px; max-width: calc(100vw - 32px); background: var(--sheet); border-radius: var(--r-md);
  box-shadow: 0 1px 3px rgba(23, 36, 47, .28); overflow: hidden;
}
.ms-row { display: flex; align-items: center; height: 40px; }
.ms-icon { flex: none; width: 36px; display: grid; place-items: center; color: var(--ink-3); }
.ms-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ms-input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent;
  font-size: 14px; color: var(--ink); padding: 0 6px 0 0;
}
.ms-input::placeholder { color: var(--ink-3); }
.ms-input::-webkit-search-cancel-button { cursor: pointer; }
.mapsearch:focus-within { box-shadow: 0 0 0 2px var(--survey), 0 1px 3px rgba(23, 36, 47, .28); }
.ms-scope, .ms-field {
  border: 0; background: var(--paper); color: var(--ink); font-size: 12.5px; font-weight: 500;
  border-radius: var(--r-sm); padding: 4px 6px; max-width: 150px; cursor: pointer;
}
/* "Places / <layer>": a small chip at the right end, so the text box keeps most of the bar */
.ms-scope {
  flex: none; width: auto; max-width: 112px; margin-right: 6px; padding: 4px 4px 4px 8px;
  border-radius: 999px; font-size: 12px; color: var(--ink-2); text-overflow: ellipsis;
}
.ms-scope:hover { color: var(--ink); background: var(--select); }
.ms-field-row {
  display: flex; align-items: center; gap: 6px; padding: 0 8px 7px 36px;
  font-size: 12px; color: var(--ink-3);
}
.ms-field-row[hidden] { display: none; }
.ms-field { max-width: none; flex: 1; }

.ms-list {
  position: fixed; z-index: 60; margin: 0; padding: 4px; list-style: none; overflow-y: auto;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  box-shadow: 0 10px 28px rgba(23, 36, 47, .2);
}
.ms-list[hidden] { display: none; }
.ms-opt {
  display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: var(--r-sm);
  cursor: pointer;
}
.ms-opt:hover, .ms-opt.active { background: var(--select); }
.ms-label { font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-detail { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-opt.footer { border-top: 1px solid var(--rule-2); margin-top: 3px; border-radius: 0 0 var(--r-sm) var(--r-sm); }
.ms-opt.footer .ms-label { color: var(--survey); font-weight: 500; }
.ms-note { padding: 9px 10px; font-size: 12.5px; color: var(--ink-2); }

/* ------------------------------------------------------------------ tablet */

@media (max-width: 1100px) {
  :root { --chat-w: 340px; --dock-h: 30vh; }
}
@media (min-width: 761px) and (max-width: 1240px) {
  #dock.has-results #dockHead {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "toggle id count" ". pick actions";
  }
  #dock.has-results .result-pick { max-width: 340px; }
  .map-actions .map-btn span { display: none; }      /* icons only next to a narrower map */
  .map-actions .map-btn { width: 40px; padding: 0; justify-content: center; }
}

/* ------------------------------------------------------------------ phone */

@media (max-width: 760px) {
  .mapsearch { width: calc(100vw - 88px); }
  .ms-row { height: 42px; }
  .ms-input { font-size: 16px; }                  /* no iOS zoom-in on focus */
  .ms-scope { max-width: 96px; font-size: 13px; padding: 6px 4px 6px 8px; }
  .ms-field { font-size: 14px; padding: 6px; }
  .ms-opt { padding: 10px 10px; }
  :root { --dock-h: auto; }
  #app, #app.dock-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--map-h, 40dvh) auto minmax(0, 1fr);
    grid-template-areas: "map" "tabs" "panel";
  }
  #chat, #dock { grid-area: panel; border-left: 0; }
  #app[data-panel="chat"]  #dock { display: none; }
  #app[data-panel="table"] #chat { display: none; }
  #app.dock-collapsed #tableBody,
  #app.dock-collapsed .dock-meta { display: block; }
  #dockToggle { display: none; }
  #dockHead, #dock.has-results #dockHead {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "id count" "pick actions";
    padding: 10px 12px; gap: 8px;
  }
  .count-pill { justify-self: end; align-self: center; }
  .pick-label { display: none; }                   /* the select says what it is */
  .dock-actions { justify-self: end; }
  .pager button { width: 36px; height: 36px; }

  #tabs { grid-area: tabs; display: flex; flex-wrap: wrap; background: var(--ink); }
  #tabs [role="tab"] { flex: 1; }
  /* drawing tools: folded behind one Draw button so they cost one icon of map, not a row */
  .draw-toggle { display: inline-flex; width: 42px; height: 42px; padding: 0; justify-content: center; }
  .draw-toggle.drawing { box-shadow: 0 0 0 2px var(--survey), 0 1px 2px rgba(23, 36, 47, .3); color: var(--survey); }
  .draw-rail.open .draw-toggle { background: var(--ink); color: #fff; }
  .draw-rail:not(.open) .draw-bar { display: none; }
  .draw-rail, .draw-bar { flex-direction: row; }       /* opens sideways: the phone map is short */
  .draw-sep { width: 1px; height: auto; margin: 4px 3px; }
  .draw-toggle svg { width: 20px; height: 20px; }
  .draw-btn { width: 42px; height: 42px; }
  .draw-btn svg { width: 22px; height: 22px; }
  .draw-btn[data-tip]::after { content: none; }      /* no hover on touch */
  .draw-hint { font-size: 12px; bottom: 26px; }
  /* layers: bottom sheet over the whole screen, independent of the map's size */
  #layersPanel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    width: 100%; max-height: 75dvh; margin: 0; justify-self: stretch; align-self: end;
    border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -8px 30px rgba(23, 36, 47, .25);
  }
  .layers-head { padding: 12px 14px; }
  .layers-head h2 { font-size: 16px; }
  .layers-done { width: auto; min-height: 40px; padding: 6px 14px; font-size: 14px; font-weight: 500; color: var(--survey); }
  .layers-done svg { display: none; }
  .layers-done span { display: inline; }
  .layers-alloff { min-height: 40px; font-size: 13.5px; }
  .lyr-head { padding: 11px 8px; }
  .lyr-title { font-size: 12.5px; }
  .lyr-row { min-height: 44px; font-size: 15px; padding-left: 34px; }   /* finger-sized rows */
  .lyr-check { width: 36px; height: 21px; }
  .lyr-check::after { width: 17px; height: 17px; }
  .lyr-check:checked::after { transform: translateX(15px); }
  .lyr-check:indeterminate::after { transform: translateX(7.5px); }
  .map-btn span { display: none; }                 /* icon only on the small map */
  .map-actions { flex-direction: column; }
  .map-actions .map-btn { width: 42px; height: 42px; padding: 0; justify-content: center; }
  .map-actions .map-btn + .map-btn { border-left: 0; border-top: 1px solid var(--rule); }

  /* drag handle between the map and the panel */
  #grip {
    flex: 0 0 100%; height: 18px; display: grid; place-items: center;
    cursor: row-resize; touch-action: none; user-select: none;
  }
  #grip span { width: 44px; height: 4px; border-radius: 2px; background: #5d6b78; transition: background .15s; }
  #grip:hover span, #grip:focus-visible span, #grip.dragging span { background: var(--m-data-bg); }
  #grip:focus-visible { outline-offset: -2px; }
  #app.resizing { user-select: none; }
  #tabs button {
    min-height: 40px; border: 0; border-radius: 0; background: none;
    color: #b9c3cc; font-weight: 500; border-bottom: 3px solid transparent;
  }
  #tabs button[aria-selected="true"] { color: #fff; border-bottom-color: var(--m-data-bg); }

  /* the tabs carry the frame on phones: the header is a slim light bar with incident + new chat */
  .chat-head { padding: 6px 8px 6px 14px; background: var(--paper); color: var(--ink); border-bottom: 1px solid var(--rule); }
  .brand h1 { display: none; }               /* the mark alone is the home link on phones */
  .home-link { gap: 8px; margin-left: -6px; padding: 6px 8px 6px 6px; }
  .home-link:hover { background: var(--select); }
  .mark { width: 24px; height: 24px; }
  .area-tag { color: var(--ink-2); font-size: 12.5px; }
  .incident { color: var(--ink-2); border-color: var(--rule); background: var(--sheet); height: 36px; }
  .incident:hover { color: var(--ink); border-color: #b7c4d3; }
  .incident select { font-size: 16px; max-width: 200px; }   /* 16px: no iOS zoom on focus */
  .head-btn { width: 40px; height: 40px; color: var(--ink-2); }
  .head-btn:hover { background: var(--select); color: var(--ink); }
  .mode-pill { height: 36px; font-size: 13.5px; }
  .mode-opt { padding: 11px 10px; }
  #log { padding: 14px 14px 6px; }
  .welcome h2 { font-size: 17px; margin-top: 0; }
  .welcome > p:not(.welcome-tip) { display: none; } /* the examples do this job on phones */
  .welcome-examples { margin-top: 12px; }
  .welcome-examples .examples button { padding: 10px 12px; font-size: 14px; }
  .ctx { font-size: 13px; }
  .ctx-remove { width: 32px; height: 32px; }
  #composer { margin: 6px 8px 8px; margin-bottom: max(8px, env(safe-area-inset-bottom)); }
  #modeHint .examples button { padding: 7px 4px; font-size: 13.5px; }
  #input { font-size: 16px; }                    /* 16px stops iOS zooming into the field */
  .result { padding: 10px 6px 10px 10px; }
  .menu > summary { padding: 7px 12px; font-size: 13px; }
  .answer-actions .act { height: 36px; font-size: 13px; padding: 0 12px; }
  #dockHead button, #dockHead .menu > summary { min-height: 36px; }
  #resultSelect { max-width: none; min-height: 38px; font-size: 16px; }
  .menu-list { min-width: 240px; }
  .menu-list button { padding: 10px 8px; }
}

/* ------------------------------------------------------------------ full map */
/* after the phone block so it wins over the phone grid too */
#app.map-full, #app.map-full.dock-collapsed {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "map";
}
#app.map-full #chat, #app.map-full #dock, #app.map-full #tabs { display: none; }

@media (max-width: 760px) {
  .table-filter { padding: 8px 12px; }
  #filterInput { flex: 1 1 0; height: 38px; font-size: 16px; }      /* no iOS zoom-in */
  #filterColumn { flex: 0 1 132px; height: 38px; font-size: 14px; }
  .tf-icon, .tf-status:empty { display: none; }
  .table-filter { flex-wrap: wrap; }
  .tf-status { flex: 1 0 100%; }
}

/* "Saved answer from N min ago · Run again" under answers served from the answer cache */
/* under each answer: copy / download the short version; full data lives in the results table */
.answer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.answer-actions .act {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 999px;
}
.answer-actions .act:hover:not(:disabled) { color: var(--survey); border-color: #b7c4d3; }
.answer-actions .act:disabled { opacity: .7; cursor: default; }
.answer-actions .act svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.answer-actions .act.link { border-color: transparent; background: none; color: var(--survey); padding: 0 4px 0 6px; }
.answer-actions .act.link:hover { text-decoration: underline; }
.answer-actions .error-inline { flex-basis: 100%; }

.cached-note {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px;
  font-size: 12px; color: var(--ink-3);
}
.cached-note button { font-size: 12px; padding: 2px 9px; color: var(--survey); }
