/* ─── Design Tokens ─────────────────────────────────────────── */
:root {
  --bg:        #09090f;
  --surface:   #111119;
  --surface2:  #1a1a26;
  --surface3:  #222230;

  --border:    rgba(140, 140, 220, 0.10);
  --border2:   rgba(140, 140, 220, 0.20);
  --border3:   rgba(140, 140, 220, 0.35);

  --blue:      #4f8ef7;
  --blue-dim:  rgba(79, 142, 247, 0.15);
  --red:       #f7654f;
  --red-dim:   rgba(247, 101, 79, 0.15);
  --green:     #3fd68a;
  --green-dim: rgba(63, 214, 138, 0.15);
  --amber:     #f5c842;
  --amber-dim: rgba(245, 200, 66, 0.15);
  --purple:    #a78bfa;

  --text:      #e4e4f0;
  --muted:     #6868a0;
  --faint:     #33334a;

  --mono: 'JetBrains Mono', monospace;
  --sans: 'DM Sans', sans-serif;

  --radius-sm: 5px;
  --radius:    8px;
  --radius-lg: 12px;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── App Header ─────────────────────────────────────────────── */
.app-header {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: baseline; gap: 12px; }
.header-left h1 {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--blue);
}
.header-left h1 .sep { color: var(--muted); margin: 0 2px; }
.header-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ─── Tab Nav ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 5px 16px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  border: 1px solid transparent;
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); border-color: var(--border2); }
.tab.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 500;
}

/* ─── Panels ─────────────────────────────────────────────────── */
main { height: calc(100vh - 52px); overflow: hidden; }
.panel { display: none; height: 100%; }
.panel.active { display: flex; flex-direction: column; }

/* ─── Shared Layout: Sidebar + Canvas ───────────────────────── */
.panel-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100%;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ─── Sidebar Primitives ─────────────────────────────────────── */
.ctrl-label {
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.ctrl-label .val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

select, .select {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
select:focus { border-color: var(--blue); }

input[type=range] {
  width: 100%;
  height: 3px;
  appearance: none;
  background: var(--surface3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  border: none;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid var(--bg);
  transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.divider { height: 1px; background: var(--border); flex-shrink: 0; }

/* ─── Metric Cards ───────────────────────────────────────────── */
.metric-grid {
  display: grid;
  gap: 6px;
}
.metric-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.metric-card .m-label { font-size: 11px; color: var(--muted); }
.metric-card .m-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

/* ─── Legend ─────────────────────────────────────────────────── */
.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-line { width: 16px; height: 2px; flex-shrink: 0; border-radius: 1px; }

/* ─── Section Title ──────────────────────────────────────────── */
.section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  padding: 6px 12px;
  font-family: var(--sans);
  font-size: 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--border3); color: var(--text); }
.btn.active, .btn:active { background: var(--blue-dim); border-color: var(--blue); color: var(--blue); }

/* ─── Canvas Wrapper ─────────────────────────────────────────── */
.canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}
.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ─── Bottom Bar ─────────────────────────────────────────────── */
.bottom-bar {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.bottom-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-right: 4px;
}
