:root {
  --bg: #0f1012;
  --side: #131417;
  --panel: #17191c;
  --panel-2: #1d2024;
  --line: #262a2f;
  --line-2: #32373d;
  --text: #eceef0;
  --muted: #8c939b;
  --faint: #5b6168;
  --accent: #2bff66;
  --accent-ink: #03150a;
  --accent-soft: rgba(43, 255, 102, 0.14);
  --slow: #38c8ff;
  --fast: #ffd23f;
  --back: #ff52d9;
  --danger: #ff6b6b;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
kbd {
  font: 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  color: var(--text);
}

.app { display: grid; grid-template-columns: 216px 1fr; height: 100vh; }

/* Sidebar */
.side {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  gap: 26px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 4px; }
/* The app icon, cropped to its tile (the SVG has macOS icon padding). */
.brand-mark { width: 42px; height: 42px; flex: none; object-view-box: inset(100px); }
.brand-name { font-weight: 900; font-size: 19px; letter-spacing: 0.06em; line-height: 1.05; }
.brand-sub { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; margin-top: 3px; }

.tabs { display: flex; flex-direction: column; gap: 8px; }
.tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tab:hover { border-color: var(--line-2); background: var(--panel-2); }
.tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 24px rgba(43, 255, 102, 0.25);
}

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 0 4px; }
.pin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.bad { background: var(--danger); }
.tl { color: var(--faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main */
.main {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 24px 22px;
  overflow-y: auto;
  min-width: 0;
}

.target {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 46px;
}
.target-kind {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 5px;
  padding: 3px 7px;
  flex: none;
  align-self: center;
}
.target-kind.off { background: var(--line-2); color: var(--muted); }
.target-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.target-meta { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-left: auto; white-space: nowrap; }
.target-meta b { color: var(--text); font-weight: 600; }

.notice {
  border: 1px solid rgba(255, 210, 63, 0.35);
  background: rgba(255, 210, 63, 0.08);
  color: #ffe08a;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 12.5px;
}

.panel { display: flex; flex-direction: column; gap: 14px; }
.panel[hidden] { display: none; }
.hint { color: var(--muted); font-size: 12px; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Graph editor */
.editor-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: 300px;
  flex: none;
}
.graph { width: 100%; height: 100%; display: block; cursor: crosshair; }
.graph.disabled { opacity: 0.35; pointer-events: none; }
.speed-readout {
  position: absolute;
  top: 10px;
  right: 14px;
  font: 12px var(--mono);
  color: var(--muted);
  pointer-events: none;
}
.speed-readout b { color: var(--text); font-weight: 600; }

/* Buttons and segmented controls */
.btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #262a2f; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 6px 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg.peak button { display: inline-flex; align-items: center; gap: 6px; }
.seg.peak svg { width: 22px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.save-row { display: flex; gap: 8px; }
.save-row[hidden] { display: none; }
.save-row input {
  flex: 0 1 260px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 8px 12px;
  outline: none;
  user-select: text;
}
.save-row input:focus { border-color: var(--accent); }

/* Presets */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.preset {
  position: relative;
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 8px 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  transition: border-color 0.12s, transform 0.12s;
}
.preset:hover { border-color: var(--line-2); }
.preset:active { transform: scale(0.98); }
.preset.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.preset canvas { width: 100%; height: 54px; display: block; }
.preset span { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 0;
  background: var(--line-2);
  color: var(--text);
  font-size: 13px;
  line-height: 20px;
  cursor: pointer;
  display: none;
}
.preset:hover .del { display: block; }
.presets .group-title { grid-column: 1 / -1; margin-top: 4px; }

/* Effect cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.off .field { opacity: 0.45; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card h2 { margin: 0; font-size: 14px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }
.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; align-items: center; gap: 12px; }
.field > .label { width: 76px; flex: none; }
.field[hidden] { display: none; }
.fx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.slider input[type="range"] { flex: 1; min-width: 0; }
.slider output { width: 40px; text-align: right; font: 12px var(--mono); color: var(--text); }

input[type="range"] { appearance: none; height: 22px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--accent);
}

.check { gap: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.switch { position: relative; width: 40px; height: 22px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0;
  border-radius: 11px;
  background: var(--line-2);
  transition: background 0.15s;
  pointer-events: none;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.pad {
  position: relative;
  width: 192px;
  height: 108px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 25% 100%,
    var(--panel-2);
  cursor: crosshair;
}
.pad-dot {
  position: absolute;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(43, 255, 102, 0.5);
  pointer-events: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #2a1517;
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ffc9c9;
  padding: 9px 14px;
  border-radius: 10px;
  max-width: 70%;
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.info { background: #12241a; border-color: rgba(43, 255, 102, 0.4); color: #c8ffd9; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
