/* CURIE — Seislab-frame layout (fixed top/left/bottom, only .content scrolls),
   CURIE green brand on Seislab's warm-dark palette. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d0a08;
  --surface:    #16120e;
  --surface2:   #1e1a15;
  --border:     #2e2824;
  --accent:     #3eb489;   /* Seislab accent (light teal-green) */
  --accent-hi:  #5edba8;
  --accent2:    #56b4e9;
  --teal:       #009e73;   /* CURIE green */
  --text:       #f2efe9;
  --text-muted: #9e9490;
  --warn:       #e69f00;
  --danger:     #d55e00;
  --font-mono:  'Fira Mono', 'Cascadia Code', monospace;
  --font-ui:    'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius:     6px;
  --sidebar-w:  300px;
  --detail-w:   360px;
}

html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 20px; flex-shrink: 0;
}
.logo-mark { font-size: 22px; color: var(--accent-hi); }
.title-group { display: flex; flex-direction: column; gap: 1px; }
.title-group h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.04em; color: var(--accent-hi); }
.title-group p { font-size: 12.5px; color: var(--text-muted); }
.topbar-link {
  margin-left: auto; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 7px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.topbar-link:hover { border-color: var(--accent); color: var(--accent-hi); }

/* ── Frame: sidebar | content ─────────────────────────────── */
.frame { flex: 1; display: flex; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 12px; overflow-y: auto; flex-shrink: 0;
}

.content {
  flex: 1; min-width: 0; overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column; gap: 16px;
}

/* ── Bottom bar ───────────────────────────────────────────── */
.bottombar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 7px 20px; font-size: 11.5px; color: var(--text-muted); flex-shrink: 0;
}
.bottombar #foot-count { color: var(--accent); font-weight: 600; }
.foot-sep { opacity: 0.5; }
.foot-note { min-width: 0; }
.foot-link {
  margin-left: auto; background: none; border: none; color: var(--accent2);
  cursor: pointer; font-size: 11.5px; text-decoration: underline;
}

/* ── Sidebar: search block ────────────────────────────────── */
.search-block { padding-bottom: 9px; border-bottom: 1px solid var(--border); margin-bottom: 9px; }
.mode-toggle { display: flex; gap: 6px; margin-bottom: 6px; }
.mode-btn {
  flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius); padding: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.mode-btn:hover { border-color: var(--accent); color: var(--text); }
.mode-btn.mode-active { background: rgba(62,180,137,0.16); border-color: var(--accent); color: var(--accent-hi); }

.mode-explainer {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 9px; margin-bottom: 6px; font-size: 11.5px; line-height: 1.4;
}
.mode-explainer .exp-line { color: var(--text-muted); }
.mode-explainer .exp-line b { color: var(--text); font-weight: 600; }
.mode-explainer .exp-try {
  display: inline-block; margin-top: 5px; background: var(--surface2);
  border: 1px solid var(--accent); color: var(--accent-hi); border-radius: 4px;
  padding: 2px 7px; font-size: 11px; cursor: pointer; font-family: var(--font-mono);
}
.mode-explainer .exp-try:hover { background: rgba(62,180,137,0.14); }

.search-block input[type="text"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 7px 10px; font-size: 13.5px; font-family: var(--font-ui);
  outline: none; margin-bottom: 6px; transition: border-color 0.15s;
}
.search-block input[type="text"]:focus { border-color: var(--accent); }
.run-btn {
  width: 100%; background: var(--accent); color: #04140e; border: none; border-radius: var(--radius);
  padding: 7px; font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.15s;
}
.run-btn:hover { background: var(--accent-hi); }

/* ── Sidebar: filter sections ─────────────────────────────── */
.filter-section { margin-bottom: 8px; }
.filter-section h3 {
  color: var(--accent); font-size: 12px; font-weight: 600;
  border-bottom: 1px solid var(--border); padding-bottom: 3px; margin-bottom: 5px;
  display: flex; align-items: center; gap: 5px;
}
.info-icon { font-size: 11px; opacity: 0.7; cursor: help; }
.info-icon:hover { opacity: 1; color: var(--accent-hi); }

.sidebar select, .sidebar input[type="number"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 5px 8px; font-size: 12.5px; font-family: var(--font-ui);
  outline: none; appearance: none;
}
.sidebar select { cursor: pointer; }
.sidebar select:focus, .sidebar input:focus { border-color: var(--accent); }
.year-row { display: flex; gap: 6px; margin-top: 5px; }

.toggle-row { display: flex; flex-wrap: wrap; gap: 5px; }
.toggle {
  flex: 1; min-width: 58px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius); padding: 5px 7px;
  font-size: 12px; font-weight: 600; cursor: pointer; text-align: center;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.toggle:hover { border-color: var(--accent); color: var(--text); }
.toggle.on { background: rgba(0,158,115,0.16); border-color: var(--teal); color: var(--accent-hi); }

.preset-row { display: flex; gap: 5px; }
.preset {
  flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius); padding: 4px 3px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-align: center; transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.preset:hover { border-color: var(--accent); color: var(--text); }
.preset.preset-active { background: var(--accent); border-color: var(--accent); color: #04140e; }

.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-val { font-family: var(--font-mono); font-size: 12px; color: var(--text); min-width: 26px; }

.link-btn {
  background: none; border: none; color: var(--text-muted); font-size: 12px;
  cursor: pointer; text-decoration: underline; padding: 2px 0;
}
.link-btn:hover { color: var(--text); }

/* ── Cards (map + results) ────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 15px 17px; }
.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-header h2 { font-size: 15px; font-weight: 700; }
.spacer { flex: 1; }
.badge {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 8px; font-size: 11px; color: var(--text-muted); white-space: nowrap;
}

#map-wrap { position: relative; width: 100%; height: 460px; }
#map-canvas { width: 100%; height: 100%; display: block; border-radius: var(--radius); cursor: crosshair; background: #0a0f14; }
.map-tooltip {
  position: absolute; pointer-events: none; background: rgba(30,26,21,0.97);
  border: 1px solid var(--accent); border-radius: var(--radius); padding: 7px 10px;
  font-size: 12px; color: var(--text); max-width: 240px; display: none; z-index: 5; line-height: 1.45;
}
.map-tooltip b { color: var(--accent-hi); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); cursor: pointer; }
.legend-item:hover { color: var(--text); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* active filter chips */
#active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface2);
  border: 1px solid var(--teal); color: var(--accent-hi); border-radius: 20px;
  padding: 2px 6px 2px 10px; font-size: 11.5px;
}
.chip button { background: none; border: none; color: var(--accent-hi); cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px; }
.chip button:hover { color: var(--text); }

/* results */
#results { display: flex; flex-direction: column; gap: 8px; }
.result { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; cursor: pointer; transition: border-color 0.12s; }
.result:hover, .result.active { border-color: var(--accent); }
.result-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.result-plant { font-weight: 600; font-size: 13px; }
.result-fam { font-size: 11px; padding: 1px 7px; border-radius: 4px; color: #04140e; font-weight: 600; }
.result-meta { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.result-score { font-size: 10px; font-family: var(--font-mono); color: var(--accent2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
.result-snippet { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.result-snippet mark { background: rgba(62,180,137,0.28); color: var(--text); border-radius: 2px; padding: 0 1px; }
.empty { text-align: center; color: var(--text-muted); padding: 34px 20px; font-size: 13px; }

/* ── EDA trends band ──────────────────────────────────────── */
.trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.tcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.tcard-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.tcard-note { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; margin-top: auto; }
.tcard-note b { color: var(--text); }
.tbars { display: flex; align-items: flex-end; gap: 2px; height: 44px; }
.tbar { flex: 1; background: var(--accent); border-radius: 1px 1px 0 0; min-height: 2px; opacity: 0.82; }
.tbar:hover { opacity: 1; }
.spark { width: 100%; height: 34px; }
.tcard-hero { justify-content: center; }
.tstat { font-size: 34px; font-weight: 700; color: var(--accent-hi); font-family: var(--font-mono); line-height: 1; }
.cbars { display: flex; flex-direction: column; gap: 5px; }
.cbar { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.cbar-k { width: 64px; color: var(--text-muted); text-transform: capitalize; }
.cbar-track { flex: 1; height: 7px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.cbar-fill { display: block; height: 100%; background: var(--teal); border-radius: 4px; }
.cbar-v { width: 30px; text-align: right; font-family: var(--font-mono); color: var(--text); }

/* ── Failure-mode field guide ─────────────────────────────── */
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.fam-card {
  background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 10px 12px; cursor: pointer; transition: background 0.12s;
}
.fam-card:hover { background: #241f19; }
.fam-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.fam-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.fam-count { font-size: 11px; font-family: var(--font-mono); color: var(--text-muted); }
.fam-terms { display: flex; flex-wrap: wrap; gap: 4px; }
.term { font-size: 10.5px; font-family: var(--font-mono); background: var(--bg); border: 1px solid var(--border); color: var(--accent2); border-radius: 3px; padding: 1px 5px; }

/* ── Disclosures (sidebar filters + map) ──────────────────── */
details.filters { margin-bottom: 8px; }
details.filters > summary,
#map-details > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
}
details.filters > summary::-webkit-details-marker,
#map-details > summary::-webkit-details-marker { display: none; }
details.filters > summary {
  font-size: 12px; font-weight: 600; color: var(--accent);
  border-bottom: 1px solid var(--border); padding: 4px 0 5px;
}
details.filters > summary::before { content: "▸"; font-size: 10px; }
details.filters[open] > summary::before { content: "▾"; }
details.filters[open] > summary { margin-bottom: 8px; }
#map-details > summary { font-size: 13px; font-weight: 700; color: var(--text); }
#map-details > summary::before { content: "▸"; color: var(--text-muted); }
#map-details[open] > summary::before { content: "▾"; }
#map-details[open] > summary { margin-bottom: 12px; }

/* ── Detail panel (slide-in) ──────────────────────────────── */
.detail-panel {
  position: fixed; top: 0; right: 0; width: var(--detail-w); height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border);
  padding: 16px; padding-top: 20px; overflow-y: auto;
  transform: translateX(100%); transition: transform 0.28s ease; z-index: 60;
  display: flex; flex-direction: column; gap: 13px;
}
.detail-panel.open { transform: translateX(0); }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail-header h3 { font-size: 15px; font-weight: 700; line-height: 1.35; color: var(--accent-hi); }
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.close-btn:hover { color: var(--text); }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meta-block { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 11px; }
.meta-block h4 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 3px; }
.meta-block p { font-size: 13px; }
.cause-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.cause-chip { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); }
.cause-chip.on { border-color: var(--teal); color: var(--accent-hi); }
.detail-body { font-size: 13px; line-height: 1.6; color: var(--text); white-space: pre-wrap; max-height: 300px; overflow-y: auto; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.adams-link { font-size: 12px; color: var(--accent2); text-decoration: none; }
.adams-link:hover { text-decoration: underline; }
.similar-btn { width: 100%; background: var(--surface2); border: 1px solid var(--accent); color: var(--accent-hi); border-radius: var(--radius); padding: 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.similar-btn:hover { background: rgba(62,180,137,0.12); }
.similar-btn:disabled { opacity: 0.5; cursor: default; }
.similar-list { display: flex; flex-direction: column; gap: 6px; }
.similar-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; cursor: pointer; font-size: 12px; }
.similar-item:hover { border-color: var(--accent); }
.similar-item .s-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.similar-item .s-plant { font-weight: 600; }
.similar-item .s-meta { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; }

/* ── Floating tooltip ─────────────────────────────────────── */
.tooltip {
  display: none; position: fixed; background: rgba(30,26,21,0.98); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 9px 11px; font-size: 12px; color: var(--text);
  pointer-events: none; z-index: 100; max-width: 280px; line-height: 1.5;
}

/* ── About modal ──────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 200; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 26px 28px; max-width: 480px; width: 100%; position: relative;
}
.modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-brand { font-size: 22px; color: var(--accent-hi); letter-spacing: 0.04em; }
.modal-tagline { color: var(--text-muted); font-size: 13px; margin: 2px 0 14px; }
.modal-body { font-size: 13.5px; line-height: 1.6; color: var(--text); }
.modal-section { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.modal-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); margin-bottom: 6px; }
.modal-section p { font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }
.modal-section a { color: var(--accent2); text-decoration: none; }
.modal-section a:hover { text-decoration: underline; }

/* ── Toast ────────────────────────────────────────────────── */
#toast {
  display: none; position: fixed; bottom: 54px; left: 50%; transform: translateX(-50%);
  background: rgba(30,26,21,0.98); border: 1px solid var(--danger); color: var(--text);
  padding: 9px 18px; border-radius: var(--radius); font-size: 13px; z-index: 150;
}
.hidden { display: none !important; }
