/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #080e1a;
  --surface:     #0f1929;
  --surface-2:   #162236;
  --surface-3:   #1d2d45;
  --border:      rgba(255,255,255,0.07);
  --border-mid:  rgba(255,255,255,0.12);
  --text:        #e8f0fe;
  --text-muted:  #7a90aa;
  --text-dim:    #4a607a;
  --blue:        #3b82f6;
  --cyan:        #06b6d4;
  --teal:        #14b8a6;
  --green:       #22c55e;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --nav-h:       60px;
  --radius:      14px;
  --max-w:       1140px;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; }

body {
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.page-map { height: 100%; overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }

/* ── Site Nav ────────────────────────────────────────────────────────────────── */
.site-nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  background: rgba(8,14,26,0.90);
  backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--border);
  z-index: 900;
}

.nav-inner {
  height: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.nav-brand-icon {
  width: 24px;
  height: 24px;
  color: var(--cyan);
  flex-shrink: 0;
}

.nav-brand-title {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(130deg, #06b6d4 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
}

.nav-link {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.nav-link:hover  { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--cyan); background: rgba(6,182,212,0.1); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Status dot ─────────────────────────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.4s, box-shadow 0.4s;
}
.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
  animation: breathe 2.4s ease-in-out infinite;
}
.status-dot.error { background: var(--red); }

@keyframes breathe {
  0%,100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.15); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0.04); }
}

/* ── Page layout ────────────────────────────────────────────────────────────── */
.page-wrap {
  padding-top: var(--nav-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.site-footer a { color: var(--text-muted); text-decoration: underline; }
.site-footer a:hover { color: var(--text); }

/* ════════════════════════════════════════════════════════════════════════════
   HOMEPAGE
   ════════════════════════════════════════════════════════════════════════════ */

/* Hero */
.hero {
  padding: 4.5rem 1.25rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(6,182,212,0.14), transparent),
    radial-gradient(ellipse 50% 40% at 15% 110%, rgba(59,130,246,0.09), transparent);
  pointer-events: none;
}

.hero-icon {
  font-size: 3.5rem;
  margin-bottom: 1.1rem;
  display: block;
  filter: drop-shadow(0 0 24px rgba(6,182,212,0.55));
  animation: float 3.5s ease-in-out infinite;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.hero-title {
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #e8f0fe 0%, #06b6d4 55%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.hero-sub {
  font-size: clamp(0.92rem, 2.5vw, 1.1rem);
  color: var(--text-muted);
  max-width: 460px;
  margin: 0 auto 2.5rem;
  line-height: 1.65;
}

.hero-cta {
  display: flex;
  gap: 0.875rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 16px rgba(6,182,212,0.28);
}
.btn-primary:hover { box-shadow: 0 8px 28px rgba(6,182,212,0.4); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-mid);
}
.btn-secondary:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.35); }

/* River cards section */
.river-section {
  padding: 0 1.25rem 3rem;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.section-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.river-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.river-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--rc, var(--cyan));
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.river-card:hover {
  transform: translateY(-4px);
  border-color: var(--rc, var(--cyan));
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  background: var(--surface-2);
}

.rc-temp {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--rc, var(--cyan));
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}
.rc-temp-unit {
  font-size: 1.3rem;
  font-weight: 600;
  vertical-align: super;
  opacity: 0.8;
}

.rc-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.rc-verdict {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.rc-ago {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.8rem;
}

.rc-arrow {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  font-size: 0.85rem;
  color: var(--rc, var(--cyan));
  opacity: 0;
  transition: opacity 0.18s, right 0.15s;
}
.river-card:hover .rc-arrow { opacity: 1; right: 0.8rem; }

/* About section */
.about-section {
  border-top: 1px solid var(--border);
  padding: 3rem 1.25rem;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.18s, background 0.18s;
}
.about-card:hover { border-color: var(--border-mid); background: var(--surface-2); }

.about-card-icon { font-size: 1.75rem; margin-bottom: 0.75rem; display: block; }
.about-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.about-card-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.diy-teaser {
  border-top: 1px solid var(--border);
  padding: 2.5rem 1.25rem;
  text-align: center;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.diy-teaser-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.diy-teaser-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}


/* ════════════════════════════════════════════════════════════════════════════
   MAP PAGE
   ════════════════════════════════════════════════════════════════════════════ */

body.page-map .page-wrap { padding-top: 0; min-height: 0; }

.map-container {
  position: fixed;
  inset: var(--nav-h) 0 0 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #07111f;
}

/* Dark OSM tiles — invert so land goes dark, rivers stay blue */
.leaflet-tile {
  filter: invert(1) hue-rotate(180deg) saturate(1.6) contrast(0.88);
}

/* Temperature marker */
.t-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.22);
  box-shadow: 0 4px 16px rgba(0,0,0,0.55);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: var(--mc, #06b6d4);
  line-height: 1;
  user-select: none;
  transition: transform 0.18s, box-shadow 0.18s;
}
.t-marker:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 22px rgba(0,0,0,0.7);
}

.marker-val { font-size: 0.9rem; }

/* Cluster bubble */
.cluster-bubble {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(15,25,41,0.92);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 0 4px rgba(6,182,212,0.18), 0 4px 16px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--cyan);
  cursor: pointer;
  transition: transform 0.18s;
}
.cluster-bubble:hover { transform: scale(1.1); }


/* ════════════════════════════════════════════════════════════════════════════
   SENSORS PAGE
   ════════════════════════════════════════════════════════════════════════════ */

.nodes-header {
  padding: 2.5rem 1.25rem 0;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.nodes-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.nodes-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 460px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  padding: 0.65rem 1rem 0.65rem 2.4rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.12);
}

#node-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Node grid */
#node-grid {
  padding: 1.75rem 1.25rem 3rem;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.empty-msg {
  grid-column: 1 / -1;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 3rem 0;
  text-align: center;
}

/* Node card */
.node-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--nc, var(--cyan));
  border-radius: var(--radius);
  padding: 1.1rem;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.node-card:hover {
  transform: translateY(-3px);
  border-color: var(--nc, var(--cyan));
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  background: var(--surface-2);
}

.nc-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.nc-top > div:first-child { min-width: 0; }

.nc-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

.nc-id {
  font-size: 0.66rem;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
  margin-top: 0.2rem;
}

.nc-badge {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  white-space: nowrap;
  letter-spacing: -0.02em;
  justify-self: end;
}

.nc-verdict {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.65rem;
}

.nc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.nc-meta-item {
  font-size: 0.68rem;
  color: var(--text-dim);
  background: var(--surface-3);
  border-radius: 6px;
  padding: 0.18rem 0.5rem;
}


/* ════════════════════════════════════════════════════════════════════════════
   DIY PAGE
   ════════════════════════════════════════════════════════════════════════════ */

.diy-header {
  padding: 3rem 1.25rem 2.5rem;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  border-bottom: 1px solid var(--border);
}

.diy-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cyan);
  background: rgba(6,182,212,0.1);
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  margin-bottom: 1rem;
}

.diy-title {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: 0.9rem;
  background: linear-gradient(135deg, #e8f0fe 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.diy-lead {
  font-size: 1.02rem;
  color: var(--text-muted);
  line-height: 1.72;
  max-width: 600px;
}

.diy-content {
  padding: 2.5rem 1.25rem 4rem;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.diy-section { margin-bottom: 3rem; }

.diy-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.diy-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.78;
  margin-bottom: 1rem;
}
.diy-text:last-child { margin-bottom: 0; }

/* Hardware list */
.hw-list {
  display: grid;
  gap: 0.75rem;
}

.hw-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: border-color 0.15s, background 0.15s;
}
.hw-item:hover { border-color: var(--border-mid); background: var(--surface-2); }

.hw-icon { font-size: 1.5rem; flex-shrink: 0; margin-top: 0.05rem; }

.hw-info { flex: 1; min-width: 0; }

.hw-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.hw-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.hw-badge {
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(6,182,212,0.1);
  color: var(--cyan);
  border-radius: 6px;
  padding: 0.18rem 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
}

/* Steps */
.steps { display: grid; gap: 1.25rem; }

.step {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--cyan);
  color: #080e1a;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.step-body { flex: 1; min-width: 0; }

.step-title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.step-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.68;
}

.code-block {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--cyan);
  margin-top: 0.65rem;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
}

/* Info box */
.info-box {
  background: rgba(6,182,212,0.05);
  border: 1px solid rgba(6,182,212,0.18);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
}
.info-box-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 0.35rem;
}
.info-box-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* Diagram */
.flow-diagram {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  justify-content: center;
  margin: 1.5rem 0;
}

.flow-box {
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  min-width: 90px;
}

.flow-box .fb-icon { font-size: 1.2rem; display: block; margin-bottom: 0.3rem; }
.flow-box .fb-label { color: var(--text-muted); }
.flow-box .fb-name { color: var(--text); font-weight: 600; font-size: 0.78rem; }

.flow-arrow {
  color: var(--text-dim);
  font-size: 1.1rem;
  padding: 0 0.5rem;
  flex-shrink: 0;
}


/* ════════════════════════════════════════════════════════════════════════════
   HISTORY DRAWER  (shared by map + sensors pages)
   ════════════════════════════════════════════════════════════════════════════ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 1100;
  pointer-events: none;
  transition: background 0.3s;
}
.drawer-overlay.open {
  background: rgba(0,0,0,0.55);
  pointer-events: auto;
}

.history-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1200;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 1.5rem 1.5rem 2rem;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32,0.72,0,1);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.history-drawer.open { transform: translateY(0); }

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.drawer-title-block { flex: 1; min-width: 0; }

.drawer-title-block h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.drawer-meta { font-size: 0.72rem; color: var(--text-muted); }

.drawer-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Range tabs */
.range-tabs {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.rtab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rtab:hover  { color: var(--text); }
.rtab.active { background: var(--surface-3); color: var(--text); }

/* Close button */
.btn-close {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-muted);
}
.btn-close svg { width: 16px; height: 16px; }
.btn-close:hover { background: var(--border-mid); color: var(--text); }

/* Chart */
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 200px;
  max-height: 280px;
}

/* Stats row */
.drawer-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.stat { display: flex; flex-direction: column; gap: 0.2rem; }

.stat-label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--cyan);
}


/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 520px) {
  .nav-brand-title { font-size: 0.9rem; }
  .nav-link        { font-size: 0.76rem; padding: 0.3rem 0.45rem; }
  .hero            { padding: 2.5rem 1rem 2rem; }
  .river-grid      { grid-template-columns: 1fr 1fr; }
  #node-grid       { grid-template-columns: 1fr; }
  .diy-content     { padding: 2rem 1rem 3rem; }
  .flow-diagram    { gap: 0.3rem; }
  .flow-arrow      { padding: 0 0.2rem; }
}

@media (min-width: 700px) {
  /* Drawer slides in from the right on desktop */
  .history-drawer {
    left: auto;
    right: 0;
    top: var(--nav-h);
    bottom: 0;
    width: 440px;
    max-height: none;
    border-radius: 0;
    border-right: none;
    border-top: none;
    border-bottom: none;
    transform: translateX(100%);
  }
  .history-drawer.open  { transform: translateX(0); }
  .drawer-overlay.open  { background: rgba(0,0,0,0.25); }
}

@media (min-width: 900px) {
  .river-grid { grid-template-columns: repeat(4, 1fr); }
}
