:root {
  --bg: #06131e;
  --bg2: #0b2434;
  --panel: rgba(8, 21, 33, 0.78);
  --panel2: rgba(10, 28, 41, 0.88);
  --text: #ecf6ff;
  --muted: #98b5c8;
  --border: rgba(98, 156, 194, 0.22);
  --accent: #57c1ff;
  --accent-warm: #ffd166;
  --blue: #1f77b4;
  --green: #2ca02c;
  --red: #d62728;
  --yellow: #f1c40f;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(1000px 700px at 15% 0%, rgba(62, 153, 255, 0.16), transparent 55%),
    radial-gradient(800px 520px at 100% 10%, rgba(34, 211, 238, 0.12), transparent 52%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  color: var(--text);
  font-family: "Segoe UI", "Aptos", system-ui, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(7, 20, 31, 0.94), rgba(7, 20, 31, 0.72));
  backdrop-filter: blur(10px);
}

.brand .eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.brand .title {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.brand .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control.slider {
  min-width: 340px;
}

.control-label {
  font-size: 12px;
  color: var(--muted);
}

.select {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}

input[type="range"] {
  width: 100%;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 22, 34, 0.9);
  color: var(--text);
  font-size: 12px;
  min-width: 50px;
}

.button {
  background: linear-gradient(180deg, rgba(87, 193, 255, 0.28), rgba(87, 193, 255, 0.13));
  color: var(--text);
  border: 1px solid rgba(87, 193, 255, 0.35);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 650;
  cursor: pointer;
}

.button:hover {
  border-color: rgba(87, 193, 255, 0.62);
}

.layout {
  min-height: calc(100% - 78px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.main-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.hero {
  margin: 12px 12px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: center;
}

.hero-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.hero-stat {
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(13, 35, 50, 0.82), rgba(7, 24, 35, 0.92));
  border: 1px solid rgba(98, 156, 194, 0.18);
}

.hero-stat-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.hero-stat-value {
  font-size: 20px;
  font-weight: 700;
}

.viewer {
  position: relative;
  padding: 12px;
  min-height: 0;
}

.canvas {
  width: 100%;
  height: 100%;
  min-height: 540px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(7, 10, 14, 0.65);
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 24px 50px rgba(0, 0, 0, 0.18);
}

.canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 14%, rgba(255, 255, 255, 0) 86%, rgba(255, 255, 255, 0.03)),
    repeating-linear-gradient(
      to bottom,
      rgba(120, 200, 255, 0.03),
      rgba(120, 200, 255, 0.03) 1px,
      rgba(0, 0, 0, 0) 3px,
      rgba(0, 0, 0, 0) 6px
    );
  mix-blend-mode: screen;
  opacity: 0.55;
}

.hint {
  position: absolute;
  left: 22px;
  bottom: 22px;
  font-size: 12px;
  color: rgba(154, 176, 201, 0.95);
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid rgba(31, 42, 58, 0.9);
  background: rgba(15, 22, 34, 0.8);
}

.flash {
  position: absolute;
  inset: 12px;
  border-radius: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

.flash.on {
  opacity: 0.55;
}

.side {
  padding: 12px;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(11, 28, 40, 0.72), rgba(6, 19, 30, 0.35));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.14);
}

.panel-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--accent-warm);
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  font-size: 13px;
}

.k {
  color: var(--muted);
}

.v {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: grid;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.swatch.blue { background: var(--blue); }
.swatch.green { background: var(--green); }
.swatch.red { background: var(--red); }
.swatch.yellow { background: var(--yellow); }

.small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.meta-notes {
  margin-top: 8px;
}

code {
  background: rgba(15, 22, 34, 0.75);
  border: 1px solid rgba(31, 42, 58, 0.9);
  padding: 2px 6px;
  border-radius: 8px;
  color: var(--text);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .side {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .control.slider {
    min-width: 240px;
  }

  .viewer {
    height: 70vh;
  }
}
