:root {
  --bg: #f6f1e7;
  --bg-ink: #1d1a17;
  --bg-muted: #6f6a61;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: #e1d6c6;
  --accent: #1e7f6a;
  --accent-soft: #cfe8df;
  --accent-warm: #cc6b2c;
  --shadow: 0 18px 40px rgba(29, 26, 23, 0.12);
  --radius: 16px;
}

body {
  margin: 0;
  font-family: "Alegreya Sans", "Trebuchet MS", sans-serif;
  color: var(--bg-ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(204, 107, 44, 0.16), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(30, 127, 106, 0.18), transparent 45%),
    linear-gradient(120deg, #f9f4ea 0%, #f4ede0 55%, #efe6d5 100%);
}

#app {
  display: flex;
  height: 100vh;
  gap: 16px;
  padding: 14px;
  box-sizing: border-box;
  animation: fadeIn 700ms ease-out;
}

#mapPane {
  position: relative;
  flex: 1 1 64%;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(225, 214, 198, 0.7);
}

#map {
  width: 100%;
  height: 100%;
}

#panel {
  flex: 1 1 36%;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid var(--panel-border);
  padding: 18px 18px 22px;
  overflow: auto;
  backdrop-filter: blur(8px);
  animation: riseIn 800ms ease-out;
}

h3,
h4 {
  margin: 0 0 8px;
  font-family: "Playfair Display", "Palatino", serif;
  letter-spacing: 0.2px;
}
.muted {
  color: var(--bg-muted);
}

.map-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 800;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(29, 26, 23, 0.12);
  border-radius: 12px;
  padding: 10px;
  min-width: 200px;
  box-shadow: 0 8px 18px rgba(29, 26, 23, 0.18);
  pointer-events: none;
}

.legend-grid {
  border: 1px dashed rgba(29, 26, 23, 0.15);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 10px;
}

.legend-title {
  font-size: 12px;
  color: var(--bg-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--bg-ink);
  margin-bottom: 4px;
}

.legend-row:last-child {
  margin-bottom: 0;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(29, 26, 23, 0.2);
  flex: 0 0 14px;
}

.line-swatch {
  width: 24px;
  height: 0;
  border-top: 2px solid #111827;
  flex: 0 0 24px;
}

.line-swatch.exceed {
  border-top-color: #ef4444;
}

.line-swatch.threshold {
  border-top-color: #ef4444;
  border-top-style: dashed;
}

.line-swatch.compare {
  border-top-color: #0f172a;
  border-top-style: dashed;
}

.ring-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #1e3a8a;
  flex: 0 0 14px;
}

.ring-swatch.weekday {
  background: #ffffff;
}

.ring-swatch.weekend {
  background: #bfdbfe;
}

.map-legend .quiet {
  background: #10b981;
}
.map-legend .moderate {
  background: #f59e0b;
}
.map-legend .loud {
  background: #ef4444;
}
.map-legend .very_loud {
  background: #fb7185;
}
.map-legend .extreme {
  background: #7f1d1d;
}

.radial-quiet {
  background: #dbeafe;
}
.radial-moderate {
  background: #93c5fd;
}
.radial-loud {
  background: #60a5fa;
}
.radial-very_loud {
  background: #2563eb;
}
.radial-extreme {
  background: #1e3a8a;
}
.radial-nodata {
  background: #e5e7eb;
}

.controls {
  display: grid;
  gap: 10px;
  margin: 12px 0 12px;
}
.ridge-controls {
  margin: 6px 0 10px;
}
.control {
  border: 1px solid rgba(225, 214, 198, 0.9);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 24px rgba(29, 26, 23, 0.08);
  animation: riseIn 700ms ease-out;
}
.control .row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.control label {
  font-size: 12px;
  color: var(--bg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
select,
input[type="range"] {
  width: 100%;
}
select,
input[type="number"],
input[type="range"] {
  border-radius: 10px;
  border: 1px solid rgba(29, 26, 23, 0.15);
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.9);
  font-family: "Alegreya Sans", "Trebuchet MS", sans-serif;
}
.control input[type="checkbox"] {
  accent-color: var(--accent);
}
.valuepill {
  border: 1px solid rgba(29, 26, 23, 0.12);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--bg-ink);
  background: #fff7ed;
  font-family: "IBM Plex Mono", "Menlo", monospace;
}

.kpi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.card {
  border: 1px solid rgba(225, 214, 198, 0.8);
  border-radius: 14px;
  padding: 12px;
  background: #fffaf2;
  box-shadow: 0 8px 18px rgba(29, 26, 23, 0.08);
}
.card .label {
  font-size: 12px;
  color: var(--bg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.card .value {
  font-size: 18px;
  font-weight: 600;
  font-family: "IBM Plex Mono", "Menlo", monospace;
}

.section {
  margin-top: 16px;
}
.chartwrap {
  border: 1px solid rgba(225, 214, 198, 0.9);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(29, 26, 23, 0.1);
  animation: riseIn 700ms ease-out;
}
.charttitle {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.charttitle .small {
  font-size: 12px;
  color: var(--bg-muted);
}
.chartmeta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--bg-muted);
}

#ridgeline svg {
  width: 100%;
  height: auto;
  display: block;
}
#radial svg {
  width: 100%;
  height: auto;
  display: block;
}

.axis text {
  font-size: 10px;
  fill: var(--bg-muted);
}
.axis path,
.axis line {
  stroke: rgba(29, 26, 23, 0.1);
}

.radialRow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  #app {
    flex-direction: column;
    height: auto;
  }

  #mapPane {
    flex: none;
    height: 52vh;
  }

  #panel {
    flex: none;
    max-height: none;
  }
}
.radialCard {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
}
.radialCardTitle {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.badge {
  font-size: 11px;
  border: 1px solid #e5e7eb;
  padding: 2px 6px;
  border-radius: 999px;
  color: #111;
  background: #fff;
}
.samplemeta {
  margin-top: 10px;
  font-size: 12px;
  color: #6b7280;
}

.chart-hover-tooltip {
  position: fixed;
  z-index: 2000;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(29, 26, 23, 0.2);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(29, 26, 23, 0.18);
  padding: 8px 10px;
  font-size: 12px;
  color: #1f2937;
  pointer-events: none;
  max-width: 240px;
}

.chart-hover-tooltip .title {
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}
