/* Place analysis: map selection toolbar, the analysis sheet (tabs per place), the "Place" panel section.
   Tokens from css/tokens.css. Cyan (--accent) only for the user's selection: active tool, active tab, the
   selected epochs in the water gauge, the drawn outline. Data colours only from the class palette. */
:root { --an-unsure: #f4a582; --an-dry: #2b4763; --an-unseen: #1a3654; --an-w: 404px; }

/* ---------------------------------------------------------------- toolbar on the map */
.an-tools { position: absolute; top: 10px; left: 10px; z-index: 800; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 20px); }
.an-tool { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 5px 11px 5px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: rgba(16, 36, 58, .94); color: var(--text); font: 600 var(--fs-12)/1.2 var(--font);
  cursor: pointer; box-shadow: 0 2px 10px #0005; }
.an-tool:hover { background: var(--panel-2); }
.an-tool[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #0c2a3c; }
.an-tool:focus-visible, .an-tab:focus-visible, .an-btn:focus-visible, .pl-row:focus-visible, .pl-link:focus-visible, .an-grip:focus-visible,
.an-tab-x:focus-visible, .pl-del:focus-visible, .an-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.an-tool-ico { display: inline-flex; width: 18px; height: 18px; }
.an-tool-ico svg { width: 18px; height: 18px; }
.an-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 810; display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; border-radius: 999px; background: #04202b; border: 1px solid var(--accent); color: var(--text);
  font: var(--fs-14)/1.3 var(--font); box-shadow: var(--shadow); max-width: calc(100% - 24px); }
.an-hint[hidden] { display: none; }
.an-drawing, .an-drawing .leaflet-interactive { cursor: crosshair !important; }
.an-drawing { touch-action: none; }

/* ---------------------------------------------------------------- buttons */
.an-btn { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--panel-2); color: var(--text); font: 600 var(--fs-12)/1.2 var(--font); cursor: pointer; }
.an-btn:hover { background: var(--panel-3); }
.an-btn-sm { min-height: 28px; padding: 3px 10px; }
.an-btn-ghost { background: transparent; }
.an-btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); margin-top: 10px; }
.an-btn-primary:hover { background: #fff; }

/* ---------------------------------------------------------------- the sheet */
.an-has-sheet { position: relative; }
.an-sheet { position: absolute; top: 0; right: 0; bottom: 0; width: min(var(--an-w), 100%); z-index: 900; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: -10px 0 30px #0007; color: var(--text); font-family: var(--font); }
.an-sheet[hidden] { display: none; }
.an-grip { display: none; }
.an-tabs { display: flex; gap: 2px; overflow-x: auto; padding: 8px 8px 0; border-bottom: 1px solid var(--border); scrollbar-width: thin; flex: none; }
.an-tab-wrap { display: inline-flex; align-items: stretch; flex: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; border-bottom: 2px solid transparent; }
.an-tab-wrap.is-on { border-bottom-color: var(--accent); background: var(--panel-2); }
.an-tab { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 8px 4px 8px 10px; border: 0; background: none; color: var(--muted);
  font: 600 var(--fs-12)/1.2 var(--font); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-tab-wrap.is-on .an-tab { color: var(--text); }
.an-tab-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--muted); flex: none; }
.an-tab[data-kind="hotspot"] .an-tab-dot { background: var(--cls-new); border-radius: 50%; }
.an-tab[data-kind="district"] .an-tab-dot { background: transparent; border: 1.5px solid var(--text-2); }
.an-tab[data-kind="area"] .an-tab-dot { background: transparent; border: 1.5px dashed var(--accent); }
.an-tab-x { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 8px; cursor: pointer; border-radius: 4px; }
.an-tab-x:hover { color: var(--text); background: var(--panel-3); }
.an-body { flex: 1; overflow-y: auto; padding: 14px 18px 24px; overscroll-behavior: contain; }

.an-head { display: grid; gap: 4px; margin-bottom: 10px; }
.an-kind { margin: 0; color: var(--muted); font-size: var(--fs-12); }
.an-kind::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; background: var(--muted); vertical-align: 0; }
.an-kind[data-kind="hotspot"]::before { background: var(--cls-new); border-radius: 50%; }
.an-kind[data-kind="area"]::before { background: transparent; border: 1.5px dashed var(--accent); }
.an-kind[data-kind="district"]::before { background: transparent; border: 1.5px solid var(--text-2); }
.an-name { margin: 0; font: 600 var(--fs-24)/1.2 var(--font); letter-spacing: -0.01em; }
.an-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* the summary is the lead of the sheet: larger, plain, generous measure */
.an-summary { margin: 4px 0 16px; font-size: var(--fs-18); line-height: 1.5; color: var(--text); max-width: 60ch; }
.an-summary.is-loading { color: var(--muted); }
.an-lead { margin: 0 0 8px; font-size: var(--fs-14); line-height: 1.5; color: var(--text-2); }
.an-note { margin: 8px 0 0; font-size: var(--fs-12); line-height: 1.5; color: var(--muted); }
.an-block { padding: 14px 0 6px; border-top: 1px solid var(--border); }
.an-h4 { margin: 0 0 10px; font: 600 var(--fs-14)/1.3 var(--font); color: var(--text); }

/* ---------------------------------------------------------------- water gauge */
.an-gauge { margin: 0; }
.an-g-cols { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; align-items: end; }
.an-g-col { display: grid; justify-items: center; gap: 3px; padding: 4px 2px 6px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.an-g-col.is-sel { border-color: var(--accent); }
.an-g-val { font: 600 var(--fs-14)/1 var(--font); font-variant-numeric: tabular-nums; }
.an-g-bar { position: relative; width: 100%; max-width: 44px; height: 112px; border-radius: 4px; overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--an-unseen) 0 4px, #24405c 4px 6px); }
.an-g-bar > span { position: absolute; left: 0; right: 0; bottom: 0; }
.an-g-dry { height: var(--seen); background: var(--an-dry); }
.an-g-water { height: var(--w); background: var(--cls-permanent); }
.an-g-col.is-none .an-g-bar { opacity: .5; }
.an-g-id { font: 600 var(--fs-12)/1 var(--font); color: var(--text); }
.an-g-date { font-size: var(--fs-11); color: var(--muted); white-space: nowrap; }
.an-g-flag { font-size: var(--fs-11); line-height: 1.2; color: var(--warn); border: 1px solid #6b5420; border-radius: 4px; padding: 0 4px; min-height: 15px; }
.an-g-flag.is-empty { border-color: transparent; }
.an-g-cover { font-size: var(--fs-11); color: var(--muted); }
.an-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: var(--fs-12); color: var(--muted); }
.an-legend span, .an-s-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; flex: none; }
.sw-water { background: var(--cls-permanent); }
.sw-dry { background: var(--an-dry); }
.sw-unseen { background: repeating-linear-gradient(135deg, var(--an-unseen) 0 3px, #3a5a7a 3px 5px); }

/* ---------------------------------------------------------------- stacked bars */
.an-stack { margin: 0; }
.an-s-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--panel-3); }
.an-s-seg { height: 100%; }
.an-s-seg + .an-s-seg { box-shadow: inset 1px 0 0 var(--panel); }
.an-s-seg.is-nodata { background: repeating-linear-gradient(135deg, var(--an-unseen) 0 3px, #3a5a7a 3px 5px); }
.an-s-legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: var(--fs-12); }
.an-s-legend li { display: grid; grid-template-columns: 11px 1fr auto 44px; gap: 8px; }
.an-s-l { color: var(--text-2); }
.an-s-legend b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.an-s-legend small { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- hotspot block */
.an-hot { padding: 0 0 14px; }
.an-qa { display: grid; gap: 8px; margin: 0 0 12px; }
.an-qa > div { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-2); border-left: 3px solid var(--border-strong); }
.an-qa > div.is-storm { border-left-color: var(--cls-new); }
.an-qa > div.is-pre { border-left-color: var(--cls-seasonal); }
.an-qa dt { font: 600 var(--fs-12)/1.3 var(--font); color: var(--muted); }
.an-qa dd { margin: 3px 0 0; font-size: var(--fs-14); line-height: 1.45; }
.an-swipe { margin: 0; }
.an-seg { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: 8px; border-radius: var(--radius-sm); background: var(--bg-2); }
.an-seg button { border: 0; background: none; color: var(--muted); font: 600 var(--fs-12)/1 var(--font); padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.an-seg button[aria-pressed="true"] { background: var(--panel-3); color: var(--text); }
.an-chip-stack { position: relative; width: 100%; max-width: 360px; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.an-chip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.an-chip-outline[hidden] { display: none; }
.an-chip-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px #0008; pointer-events: none; }
.an-chip-date { position: absolute; top: 6px; padding: 2px 6px; border-radius: 4px; background: #000a; color: #fff; font-size: var(--fs-11); }
.an-chip-date.is-l { left: 6px; } .an-chip-date.is-r { right: 6px; }
.an-chip-range { width: 100%; max-width: 360px; margin: 6px 0 0; accent-color: var(--text-2); }
.an-toggle { border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text); border-radius: var(--radius-sm); font: 600 var(--fs-12)/1 var(--font); padding: 5px 9px; cursor: pointer; margin-right: 4px; }
.an-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.an-h4 + .an-swipe { margin-top: 0; }

/* ---------------------------------------------------------------- details */
.an-details { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.an-details > summary, .an-tech > summary, .pl-sugg > summary { cursor: pointer; font: 600 var(--fs-14)/1.3 var(--font); color: var(--text); padding: 4px 0; }
.an-dl { margin: 8px 0 0; display: grid; gap: 10px; }
.an-dl dt { font: 600 var(--fs-12)/1.3 var(--font); color: var(--muted); }
.an-dl dd { margin: 2px 0 0; font-size: var(--fs-14); line-height: 1.5; color: var(--text-2); }
.an-warn { margin: 6px 0 0; padding-left: 18px; color: var(--warn); font-size: var(--fs-12); line-height: 1.5; }
.an-tech { margin-top: 12px; }
.an-tech > summary { font-size: var(--fs-12); color: var(--muted); }
.an-tech ul { margin: 6px 0 0; padding-left: 18px; font-size: var(--fs-12); line-height: 1.5; color: var(--muted); }

/* ---------------------------------------------------------------- panel section "Place" */
.pl { display: grid; gap: 14px; }
.pl-intro { margin: 0; font-size: var(--fs-14); line-height: 1.5; color: var(--text-2); }
.pl-link { border: 0; padding: 0; background: none; color: var(--text); font: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; cursor: pointer; }
.pl-link:hover { text-decoration-color: var(--text); }
.pl-sugg { border-top: 1px solid var(--border); padding-top: 8px; }
.pl-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 6px 0; font-size: var(--fs-12); color: var(--muted); }
.pl-key .pl-dot + * { margin-right: 8px; }
.pl-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.pl-row { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 6px 8px; border: 0;
  border-radius: var(--radius-sm); background: none; color: var(--text); font: var(--fs-14)/1.3 var(--font); text-align: left; cursor: pointer; }
.pl-row:hover { background: var(--panel-2); }
.pl-row.is-on { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.pl-name small { margin-left: 6px; color: var(--muted); font-size: var(--fs-12); }
.pl-val { color: var(--text-2); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.pl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #fff; flex: none; }
.pl-dot.is-pre { background: var(--cls-seasonal); }
.pl-dot.is-storm { background: var(--cls-new); }
.pl-dot.is-area { background: transparent; border: 1.5px dashed var(--accent); border-radius: 2px; }
.pl-mine { border-top: 1px solid var(--border); padding-top: 10px; }
.pl-h { margin: 0 0 4px; font: 600 var(--fs-14)/1.3 var(--font); }
.pl-empty { margin: 4px 0 0; font-size: var(--fs-12); color: var(--muted); line-height: 1.5; }
.pl-area { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.pl-del { border: 0; background: none; color: var(--muted); font-size: 18px; width: 34px; height: 34px; border-radius: var(--radius-sm); cursor: pointer; }
.pl-del:hover { color: var(--text); background: var(--panel-2); }

/* ---------------------------------------------------------------- phones: bottom sheet */
@media (max-width: 640px) {
  .an-tool { min-height: 32px; padding: 4px 9px 4px 6px; font-size: var(--fs-11); }
  .an-sheet { top: auto; left: 0; width: 100%; max-height: 64%; border-left: 0; border-top: 1px solid var(--border); border-radius: 14px 14px 0 0; box-shadow: 0 -10px 30px #0008; }
  .an-sheet.is-min .an-body { display: none; }
  .an-grip { display: flex; justify-content: center; align-items: center; height: 20px; border: 0; background: none; cursor: pointer; flex: none; }
  .an-grip span { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); }
  .an-tabs { padding-top: 0; }
  .an-body { padding: 12px 16px 20px; }
  .an-name { font-size: var(--fs-18); }
  .an-summary { font-size: var(--fs-14); }
  .an-g-bar { height: 84px; }
  .an-hint { bottom: auto; top: 86px; border-radius: var(--radius); font-size: var(--fs-12); flex-wrap: wrap; justify-content: center; }
}
@media (prefers-reduced-motion: no-preference) {
  .an-sheet:not([hidden]) { animation: an-in .18s ease-out; }
  @keyframes an-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 640px) {
  @keyframes an-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* while a selection tool is active, the swipe divider must not catch the drag */
.an-drawing-on .compare-handle, .an-drawing-on .compare-line { pointer-events: none; }

