/* ASVAtlas: one dark theme, black surfaces with aqua accents. */
:root {
  --bg: #000000;
  --panel: #0a0f14;
  --panel-2: #0f161d;
  --line: #1a2530;
  --line-strong: #253441;
  --text: #e8eef3;
  --text-2: #b4c2cf;
  --muted: #7f91a2;
  --accent: #3cc8f0;
  --accent-strong: #1fb0dc;
  --accent-soft: rgba(60, 200, 240, 0.12);
  --accent-ink: #00141c;
  --error: #ff8a7a;
  /* Identity ramp (one hue, brighter = more similar), validated against the
     land and sea colours below. */
  --b100: #d5f6ff;
  --b99: #6fd6f5;
  --b97: #27a9d6;
  --blow: #2387ad;
  --map-sea: #03101b;
  --map-land: #18232e;
  --map-border: #2e3e4d;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #03080c 0%, #000 100%);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 34px; height: 34px; fill: none; stroke: var(--accent); stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }
.logo path:first-child { fill: var(--accent-soft); }
.name { font-size: 19px; font-weight: 650; letter-spacing: 0.01em; }
.tagline { font-size: 12px; color: var(--muted); }
.stats { display: flex; gap: 28px; margin: 0; flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column; min-width: 0; }
.stats dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stats dd { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
            max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stat-name { color: var(--accent); }

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 28px 24px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel {
  align-self: start;
  position: sticky;
  top: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel section { display: flex; flex-direction: column; gap: 12px; }
.content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 52px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

/* Inputs */
textarea, .unit-input, #identity-custom {
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  resize: vertical;
  font: 12px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text-2);
}
textarea::placeholder { color: #4d5d6c; }
textarea:focus, .unit-input:focus-within, #identity-custom:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.drop.dragging textarea { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.input-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#seq-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}
.file-button:hover { border-color: var(--accent); color: var(--accent); }
.file-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6;
                   stroke-linecap: round; stroke-linejoin: round; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.field legend { padding: 0; margin-bottom: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.unit-input { display: flex; align-items: center; padding: 0 10px; }
.unit-input input {
  width: 100%; min-width: 0;
  padding: 7px 0;
  border: 0; background: transparent;
  font-variant-numeric: tabular-nums;
}
.unit-input input:focus { outline: none; }
.unit-input span { color: var(--muted); }
#identity-custom { padding: 7px 10px; width: 100%; }

.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block;
  padding: 6px 0;
  text-align: center;
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  cursor: pointer;
}
.segmented span:hover { background: var(--accent-soft); color: var(--text); }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track {
  position: relative; width: 32px; height: 18px; flex: none;
  border-radius: 9px; background: var(--line-strong); transition: background .15s;
}
.track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--text-2); transition: transform .15s, background .15s;
}
.switch input:checked + .track { background: var(--accent-strong); }
.switch input:checked + .track::after { transform: translateX(14px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons */
button { cursor: pointer; }
.primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  letter-spacing: 0.02em;
}
.primary:hover { background: #63d6f6; }
.primary:disabled { cursor: progress; background: var(--accent-strong); }
.spinner {
  display: none; width: 14px; height: 14px;
  border: 2px solid rgba(0, 20, 28, 0.3); border-top-color: var(--accent-ink);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.primary:disabled .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.ghost {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }
#status { margin: -8px 0 0; min-height: 1.5em; font-size: 13px; color: var(--muted); }
#status.error { color: var(--error); }

/* Map */
#map-wrap { position: relative; }
#map { height: 520px; border-radius: 0 0 var(--radius) var(--radius); background: var(--map-sea); }
#map-note {
  position: absolute; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  color: var(--text-2);
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
#map-note[hidden], #legend[hidden] { display: none; }
#legend {
  position: absolute; left: 12px; bottom: 28px; z-index: 600;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 10px;
  background: rgba(10, 15, 20, 0.92);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.legend-title { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 10.5px; }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 50%;
       vertical-align: -1px; box-shadow: 0 0 0 2px var(--map-sea); }
.b100 { background: var(--b100); }
.b99 { background: var(--b99); }
.b97 { background: var(--b97); }
.blow { background: var(--blow); }

.leaflet-container { font: inherit; background: var(--map-sea); }
.leaflet-bar, .leaflet-control-layers {
  border: 1px solid var(--line-strong) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  overflow: hidden;
}
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--panel); color: var(--text-2); border-bottom-color: var(--line-strong);
}
.leaflet-bar a:hover { color: var(--accent); }
.leaflet-control-layers { background: var(--panel); color: var(--text-2); }
.leaflet-control-layers-toggle { filter: invert(0.85) hue-rotate(180deg); }
.leaflet-control-layers-expanded { padding: 8px 10px; }
.leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.7) !important; color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip, .leaflet-tooltip {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-tooltip { border-radius: 6px; font-size: 12px; }
.leaflet-tooltip-top::before { border-top-color: var(--line-strong); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.popup-coords { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.popup-ref { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.popup-ref h3 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.popup-ref .ref-id { color: var(--muted); font-weight: 400; font-size: 12px; }
.popup-ref ul { margin: 4px 0; padding: 0; list-style: none; }
.popup-ref li { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.popup-ref .fields { font-size: 12px; color: var(--muted); }

/* Results */
.downloads { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.downloads > span { margin-right: 4px; }
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.kpis > div { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; }
.kpis > div + div { border-left: 1px solid var(--line); }
.kpi-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th:first-child, td:first-child { padding-left: 18px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.query { cursor: pointer; transition: background .1s; }
tbody tr.query:hover { background: rgba(60, 200, 240, 0.06); }
tbody tr.query.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
tbody tr.nohit td { color: var(--muted); }
.asv-id { font-weight: 600; }
.identity-cell { display: inline-flex; align-items: center; gap: 7px; }
tr.details > td { padding: 0; background: #05090d; }
tr.details table { font-size: 12.5px; }
tr.details th { background: transparent; padding-top: 12px; }
tr.details td { border-bottom-color: #121b23; }
.details-note { padding: 14px 18px; color: var(--muted); }
.taxon { font-style: italic; }
.lineage { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.hint { margin: 0; padding: 10px 18px 14px; font-size: 12px; color: var(--muted); }

.footer {
  padding: 14px 28px 20px;
  font-size: 12px;
  color: #56677a;
  border-top: 1px solid var(--line);
  text-align: center;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .panel { position: static; }
  .topbar { padding: 12px 16px; }
  .stats { gap: 18px; }
  #map { height: 380px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis > div:nth-child(3) { border-left: 0; }
  .kpis > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .stats dd { max-width: 150px; }
  .segmented { grid-template-columns: repeat(3, 1fr); }
  .footer { padding: 12px 16px 16px; }
}

/* Tabs */
.tabbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: #000;
}
.tabbar { flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tabs button { white-space: nowrap; }
.tabs button {
  position: relative;
  padding: 12px 16px 11px;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.layout[hidden] { display: none; }

/* Network form */
.select, .text-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
.select:focus, .text-input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-note { margin: 0; font-size: 12px; color: var(--muted); }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
#net-status { margin: -8px 0 0; min-height: 1.5em; font-size: 13px; color: var(--muted); }
#net-status.error { color: var(--error); }
.switch input:disabled + .track { opacity: 0.4; }
.switch:has(input:disabled) { color: var(--muted); cursor: default; }
.details-actions { padding: 10px 18px 14px; }
.details-actions .ghost { display: inline-flex; gap: 4px; align-items: baseline; }

/* Network tab: map with the network in a translucent panel */
.map-wrap { position: relative; }
.map { height: 460px; border-radius: 0 0 var(--radius) var(--radius); background: var(--map-sea); }
.map.tall { height: 680px; }
.map-note {
  position: absolute; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--text-2);
  background: rgba(0, 0, 0, 0.45); pointer-events: none;
}
.map-note[hidden], #net-overlay[hidden], #net-legend[hidden], #net-group[hidden] { display: none; }

#net-overlay {
  position: absolute; top: 12px; right: 12px; z-index: 800;
  width: 340px; height: 270px;
  display: flex; flex-direction: column;
  background: rgba(5, 12, 18, 0.62);
  border: 1px solid rgba(60, 200, 240, 0.22);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  opacity: 0.82;
  overflow: hidden;
  transition: opacity .2s, width .25s, height .25s;
}
#net-overlay:hover, #net-overlay:focus-within, #net-overlay.expanded { opacity: 1; background: rgba(5, 12, 18, 0.78); }
#net-overlay.expanded { width: min(760px, calc(100% - 24px)); height: min(560px, calc(100% - 24px)); }
.overlay-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-2);
}
.overlay-head span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay-head button {
  padding: 2px 8px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: rgba(10, 15, 20, 0.6); color: var(--text-2); font-size: 12px;
}
.overlay-head button:hover { color: var(--accent); border-color: var(--accent); }
#net-svg { flex: 1; display: block; width: 100%; min-height: 0; cursor: grab; touch-action: none; }
#net-svg:active { cursor: grabbing; }
#net-svg line, #net-svg circle, #net-svg text { vector-effect: non-scaling-stroke; }
.net-edges line { stroke: #6a7d8f; stroke-width: 1.2px; opacity: 0.8; }
.net-steps {
  fill: var(--text-2); text-anchor: middle; dominant-baseline: central;
  paint-order: stroke; stroke: #03080c; stroke-width: 3px;
}
.hap { cursor: pointer; }
.hap-dot { stroke: #03080c; stroke-width: 1.5px; transition: fill .2s; }
.hap.in .hap-dot { filter: drop-shadow(0 0 3px rgba(255, 140, 80, 0.75)); }
.query-ring { fill: none; stroke-width: 2.5px; }
.centre-ring { fill: none; stroke: none; stroke-width: 2.5px; stroke-dasharray: 4 3; }
.hap.centre .centre-ring { stroke: #ffffff; }
.hap-label {
  fill: var(--text-2); dominant-baseline: central; text-anchor: middle;
  paint-order: stroke; stroke: #03080c; stroke-width: 3px;
}
.hap.in .hap-label, .hap.centre .hap-label { fill: var(--text); font-weight: 600; }
.hap-label.hidden { display: none; }
.hap:hover .hap-dot, .hap:focus .hap-dot { stroke: var(--text); stroke-width: 2px; }
.hap:focus { outline: none; }

.map-legend {
  position: absolute; left: 12px; bottom: 28px; z-index: 600;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  max-width: calc(100% - 24px);
  padding: 6px 10px;
  background: rgba(10, 15, 20, 0.92);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.group-dot {
  display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px;
  border-radius: 50%; background: #3987e5; box-shadow: 0 0 0 2px var(--map-sea);
}
.group-dot.in { background: #d95926; box-shadow: 0 0 0 2px var(--map-sea), 0 0 8px rgba(255, 140, 80, 0.8); }
.group-dot.out { background: #3987e5; }
.ring {
  display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px;
  border: 2px solid #3cc8f0; border-radius: 50%;
}

/* Places: pies of the group (warm, glowing) and of the others (cool) */
.pie-icon { background: none; border: 0; }
.pie-icon svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.pie-icon.in svg {
  filter: drop-shadow(0 0 6px rgba(255, 130, 70, 0.85)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.pie-icon.out svg { opacity: 0.85; }

/* Grouping controls */
.slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.slider-head output {
  min-width: 2.2em; padding: 1px 8px; border-radius: 6px; text-align: center;
  background: rgba(217, 89, 38, 0.18); color: #ff9a6a; font-weight: 700; font-variant-numeric: tabular-nums;
}
#net-distance { width: 100%; accent-color: #d95926; margin: 6px 0 0; }
.slider-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.group-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.table-wrap.scroll { max-height: 520px; overflow: auto; }
.table-wrap.scroll thead th { position: sticky; top: 0; z-index: 1; }
#net-table tbody tr.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

@media (max-width: 960px) {
  .tabbar { padding: 0 16px; }
  .map, .map.tall { height: 420px; }
  #net-overlay { width: 220px; height: 170px; }
}

/* Powered by dnambientale.it, at the right of the tab bar */
.powered {
  margin: 6px 0 6px auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.powered:hover, .powered:focus-visible { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.powered-label { color: var(--muted); }
.powered-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: #eef8fc;
  box-shadow: 0 0 0 1px rgba(60, 200, 240, 0.35);
}
.powered-logo img { display: block; width: 22px; height: auto; }
.powered-name { font-weight: 600; color: var(--text); letter-spacing: 0.01em; }
@media (max-width: 480px) {
  .powered-label { display: none; }
}

/* Search tab: "Where in the world is my ASV?" */
.search-page {
  flex: 1;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 28px 24px;
}
.search-page[hidden], .start[hidden], .results-view[hidden] { display: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.link-button {
  padding: 0; border: 0; background: none;
  color: var(--accent); font-size: 13px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.link-button:hover { color: #8fe3fa; }

/* Before a search: one centred form */
.start {
  max-width: 680px;
  margin: 6vh auto 0;
  padding: 32px 36px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.start h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.start-lead { margin: 0 0 6px; color: var(--text-2); font-size: 15px; }
#start-name { color: var(--accent); font-weight: 600; }
.start .input-meta { gap: 16px; }
.start #seq-count { margin-left: auto; }
.start .primary { padding: 13px; font-size: 15px; }
.start #status { margin: -4px 0 0; }
.start-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.advanced { border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary {
  cursor: pointer; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.advanced summary:hover { color: var(--text-2); }
.advanced[open] summary { margin-bottom: 12px; }
.advanced .switch { margin-top: 12px; }

/* After a search: the map first */
.results-view { display: flex; flex-direction: column; gap: 20px; }
.map-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.edit-button { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; font-weight: 600; }
.edit-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6;
                   stroke-linecap: round; stroke-linejoin: round; }
.similarity { display: flex; align-items: center; gap: 12px; }
.similarity legend {
  float: left; margin: 0; padding: 0;
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
}
#identity-group { display: flex; gap: 4px; }
#identity-group span { padding: 6px 13px; }
.map-answer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}
#map-summary { margin: 0; font-size: 15px; color: var(--text); }
#map-summary b { color: var(--accent); font-weight: 650; }
/* A search in progress: aqua text with a dot, slowly pulsing. */
#map-summary.busy {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--accent); font-weight: 600;
  animation: pulse 1.6s ease-in-out infinite;
}
#map-summary.busy::before {
  content: ""; width: 9px; height: 9px; flex: none; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
@keyframes pulse { 50% { opacity: 0.35; } }
#map { transition: opacity .3s; }
#map-wrap.busy #map { opacity: 0.55; }
@media (prefers-reduced-motion: reduce) {
  #map-summary.busy { animation: none; }
}
#map-summary.error { color: var(--error); }
#map-summary .link-button { font-size: 15px; }
#map-wrap { position: relative; }
#map { height: 560px; border-radius: 0 0 var(--radius) var(--radius); background: var(--map-sea); }
.place-tip b { display: block; font-size: 13px; }
.place-tip div { font-size: 12px; }
.popup-country { font-size: 14px; font-weight: 650; }

/* Download menu */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; font-size: 11px; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1000;
  width: 300px;
  display: flex; flex-direction: column;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}
.menu-list button {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 10px;
  border: 0; border-radius: 7px;
  background: none;
  text-align: left;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--accent-soft); }
.menu-list b { font-size: 13px; font-weight: 600; color: var(--text); }
.menu-list span { font-size: 12px; color: var(--muted); }

/* One line per ASV */
.asv-list { margin: 0; padding: 0; list-style: none; }
.asv { border-bottom: 1px solid var(--line); }
.asv-row { display: flex; align-items: center; gap: 12px; padding-right: 18px; }
.asv-main {
  flex: 1; min-width: 0;
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(140px, 1.3fr) minmax(160px, 2fr) 90px;
  align-items: center; gap: 16px;
  padding: 13px 0 13px 18px;
  border: 0; background: none; text-align: left;
  font-size: 13.5px;
}
.asv-main:hover { background: rgba(60, 200, 240, 0.05); }
.asv.open { background: rgba(60, 200, 240, 0.05); box-shadow: inset 3px 0 0 var(--accent); }
.asv-name { font-weight: 650; overflow-wrap: anywhere; }
.asv-taxa { overflow-wrap: anywhere; }
.asv-where { color: var(--text-2); }
.asv-identity { justify-self: end; font-variant-numeric: tabular-nums; }
.asv.nohit .asv-taxa, .asv.nohit .asv-name { color: var(--muted); }
.asv-actions { display: flex; align-items: center; gap: 10px; flex: none; min-width: 96px; justify-content: flex-end; }
.net-button { white-space: nowrap; }

/* Details of an ASV */
.asv-details { padding: 4px 18px 16px 21px; display: flex; flex-direction: column; gap: 8px; }
.asv-details h3 {
  margin: 4px 0 0; font-size: 11px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted);
}
.match-group { padding: 10px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.match-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; }
.match-head > :first-child { font-weight: 600; }
.match-count { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tech summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.tech summary:hover { color: var(--text-2); }
.tech-note { margin: 8px 0; font-size: 12px; color: var(--muted); }
.tech table { font-size: 12.5px; }
.tech th { background: transparent; }

@media (max-width: 960px) {
  .search-page { padding: 16px; }
  .start { margin-top: 2vh; padding: 22px 18px 18px; }
  #map { height: 420px; }
  .asv-row { flex-wrap: wrap; padding: 0 18px 12px 0; }
  .asv-main { grid-template-columns: 1fr auto; gap: 4px 12px; padding-bottom: 6px; }
  .asv-taxa, .asv-where { grid-column: 1 / -1; }
  .asv-identity { grid-row: 1; grid-column: 2; }
  .asv-actions { padding-left: 18px; justify-content: flex-start; }
}
@media (max-width: 560px) {
  .similarity { flex-wrap: wrap; }
  #identity-group { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .start h1 { font-size: 22px; }
}

/* The user's samples: gold stars, apart from the records by shape and colour */
.star-icon { background: none; border: 0; }
.star-icon svg { display: block; filter: drop-shadow(0 0 4px rgba(245, 197, 66, 0.55)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7)); }
i.star {
  display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px;
  background: #f5c542;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
#legend-user[hidden] { display: none; }
.asv-distance { display: block; margin-top: 2px; font-size: 12.5px; color: #f5d27a; }
.asv-distance i.star { width: 10px; height: 10px; }
#location-box code { font-size: 11.5px; color: var(--text-2); }
.legend-star { display: inline-flex; margin-right: 3px; vertical-align: -3px; }
.legend-star + .legend-star { margin-left: -1px; }
.stats div[hidden] { display: none; }

/* Tab "Reference data" */
.about-page { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 20px 28px 24px;
              display: flex; flex-direction: column; gap: 20px; }
.about-page[hidden] { display: none; }
.about-page, .about-page > *, #about-content > * { min-width: 0; }
#about-content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.about-pickers { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 16px 18px; }
.about-pickers .field { min-width: 220px; }
.about-pickers .field-note { flex: 1 1 240px; margin-bottom: 8px; }
.about-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.about-card h1 { margin: 0; font-size: 24px; font-weight: 650; }
.about-card h2 { font-size: 11px; }
.about-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 13px; }
.chip b { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.about-lead { margin: 0; max-width: 820px; color: var(--text-2); font-size: 14.5px; line-height: 1.6; }
.about-figures { display: flex; gap: 32px; flex-wrap: wrap; margin: 4px 0 0; }
.about-figures div { display: flex; flex-direction: column; }
.about-figures dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.about-figures dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.about-table td { vertical-align: top; }
.study-label { font-weight: 600; }
.study-label a { color: var(--accent); text-decoration: none; }
.study-label a:hover { text-decoration: underline; }
.study-citation { max-width: 520px; font-size: 12px; color: var(--muted); display: -webkit-box;
                  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.study-id { font-size: 11.5px; color: #56677a; font-family: ui-monospace, Consolas, monospace; }
.coord-kind { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap;
              border: 1px solid var(--line-strong); color: var(--text-2); }
.coord-kind.kind-sites { border-color: rgba(60, 200, 240, 0.5); color: var(--accent); }
.coord-kind.kind-approximate, .coord-kind.kind-study-area { border-style: dashed; }
.coord-kind.kind-none { color: var(--muted); }
.about-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.about-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px;
               color: var(--text-2); line-height: 1.55; }
.about-notes p { margin: 0; color: var(--text-2); line-height: 1.55; }
.coord-legend { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 4px 0 0; font-size: 13px; }
.coord-legend dd { margin: 0; color: var(--text-2); }
.popup-ref .fields.approx { font-style: italic; }
@media (max-width: 960px) { .about-page { padding: 16px; } }
/* Three tabs on a phone: tighter, and scrollable if still too wide. */
@media (max-width: 480px) {
  .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs button { padding: 12px 9px 11px; font-size: 13px; }
  .tabs button[aria-selected="true"]::after { left: 6px; right: 6px; }
}

/* New search: the evident way to start again */
.bar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.new-search {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--accent); border-radius: 7px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 650;
}
.new-search:hover { background: var(--accent); color: var(--accent-ink); }
.new-search svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.clear-button { color: var(--muted); }
.clear-button:hover { color: var(--error); }
.clear-button[hidden], #clear[hidden] { display: none; }
.asv-distance.none { color: var(--muted); font-style: italic; }

/* Privacy note in the footer */
.privacy { margin: 0 auto 8px; max-width: 720px; }
.privacy summary { cursor: pointer; display: inline-block; color: var(--muted); }
.privacy summary:hover { color: var(--text-2); }
.privacy p { margin: 8px 0 4px; text-align: left; line-height: 1.55; color: var(--text-2); }
