:root {
  color-scheme: dark light;
  --bg: #111;
  --bg2: #181818;
  --bg3: #202020;
  --fg: #f5f5f5;
  --accent: #4fc3f7;
  --accent-soft: #4fc3f733;
  --border: #333;
  --border-strong: #777;
  --danger: #ff5252;
  --success: #4caf50;
  --muted: #999;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
          "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }

/* Prevent accidental text selection while dragging UI */
body, header, main, #workspace, #waveform-container, #keymap-container,
#inspector, .panel, #status, #keymap-label, #waveform-overlay, #dropHint {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
/* Allow selection in form controls */
input, textarea, select {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
  display: flex;
  flex-direction: column;
}
header {
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
header h1 {
  font-size: 14px;
  margin: 0 12px 0 0;
  font-weight: 600;
  white-space: nowrap;
}
header .group {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
button, select, input[type="number"], input[type="text"] {
  font-family: inherit;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--fg);
  padding: 4px 8px;
}
button { cursor: pointer; border-color: var(--border-strong); }
button.primary { background: var(--accent); color: #000; border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button.small { font-size: 11px; padding: 2px 6px; }
label { font-size: 11px; color: var(--muted); }
#status {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
main { flex: 1; display: flex; min-height: 0; }
#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
}
#waveform-container {
  flex: 1;
  min-height: 160px;
  border-bottom: 1px solid var(--border);
  position: relative;
  background: radial-gradient(circle at top, #222 0, #111 55%, #050505 100%);
}
#waveformCanvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
#waveform-overlay {
  position: absolute;
  left: 8px;
  bottom: 4px;
  font-size: 10px;
  color: var(--muted);
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}
#keymap-container { height: 110px; background: #111; position: relative; }
#keymapCanvas { width: 100%; height: 100%; display: block; cursor: ew-resize; }
#keymap-label {
  position: absolute;
  left: 8px;
  top: 4px;
  font-size: 10px;
  color: var(--muted);
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}
#inspector {
  width: 300px;
  max-width: 360px;
  padding: 8px;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}
#inspector h2 { font-size: 13px; margin: 0 0 4px 0; font-weight: 600; }
.panel { border-radius: 6px; border: 1px solid var(--border); padding: 6px 8px 8px; background: var(--bg3); }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.row:last-child { margin-bottom: 0; }
.row label { flex: 0 0 90px; }

/* rows where contents should hug the right edge */
.row-right {
  justify-content: flex-end;
}

.row input[type="number"], .row input[type="text"], .row select { flex: 1; min-width: 0; }
.row-small label { flex: 0 0 60px; }
.hint { font-size: 10px; color: var(--muted); margin-top: 4px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px;
  padding: 1px 6px; border-radius: 999px; background: #00000055; border: 1px solid #ffffff22;
}
.pill span { color: var(--muted); } .pill strong { font-weight: 600; }
.tag { font-size: 10px; padding: 1px 4px; border-radius: 4px; background: #ffffff11; border: 1px solid #ffffff22; margin-left: 4px; color: var(--muted); }
.visually-hidden { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#dropHint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; font-size: 12px; color: var(--muted);
}
#dropHint span { padding: 6px 10px; border-radius: 999px; border: 1px dashed var(--border-strong); background: #000000aa; backdrop-filter: blur(6px); }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.segmented .seg-btn {
  border: 0;
  padding: 2px 8px;
  background: var(--bg3);
  color: var(--fg);
  font-size: 11px;
  cursor: pointer;
}
.segmented .seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.segmented .seg-btn.active {
  background: var(--accent-soft);
  color: var(--fg);
  border-color: var(--accent);
}

/* Make zoom editor feel draggable */
#regionZoomCanvas { cursor: ew-resize; }
