:root {
  --bg:             #000;
  --bg-surface:     #1a1a1a;
  --bg-input:       #000;
  --bg-header:      #000;
  --bg-sidebar:     #080808;
  --bg-button:      #1a1a1a;
  --bg-button-hover:#222;
  --bg-chevron:     #0a0a0a;
  --bg-chevron-hover:#1a1a1a;

  --accent:         #fff;
  --accent-bg:      #fff;
  --accent-hover:   #ddd;
  --accent-border:  #999;
  --accent-label:   #fff;

  --text:           #fff;
  --text-bright:    #fff;
  --text-dim:       #ddd;
  --text-muted:     #ccc;
  --text-faint:     #ccc;
  --text-input:     #fff;
  --text-placeholder:#444;

  --border:         #222;
  --border-input:   #333;
  --border-hover:   #555;

  --radius:         0px;
  --radius-lg:      0px;
  --ctrl-height:    26px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Barlow Condensed', 'DIN Condensed', 'DIN Alternate', 'Arial Narrow', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: var(--bg-header);
  padding: 12px 24px;
  border-bottom: 2px solid #fff;
  display: flex;
  align-items: center;
  gap: 24px;
}

header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  text-transform: uppercase;
}

nav { display: flex; gap: 0; }

.tab {
  padding: 7px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #ccc;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color 0.1s;
}
.tab:hover { color: #bbb; }
.tab.active {
  color: #fff;
  border-bottom-color: #fff;
}

main { padding: 0; max-width: none; margin: 0; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Two-column layout */
.mappings-layout {
  display: flex;
  height: calc(100vh - 56px);
}

.device-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.category-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.cat-tab {
  flex: 1;
  padding: 10px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #ccc;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: color 0.1s;
}
.cat-tab:hover { color: #bbb; }
.cat-tab.active {
  color: #fff;
  border-bottom-color: #fff;
}

.device-list-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.device-list-search input {
  width: 100%;
  background: #000;
  border: 1px solid var(--border-input);
  color: var(--text-input);
  padding: 6px 10px;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
}
.device-list-search input:focus {
  border-color: #fff;
  outline: none;
}

#device-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

#device-list li {
  padding: 7px 14px;
  cursor: pointer;
  font-size: 14px;
  color: #ccc;
  border-left: 2px solid transparent;
  font-family: inherit;
  transition: color 0.1s;
}

#device-list li:hover {
  background: #111;
  color: #ccc;
}

#device-list li.selected {
  background: #1a1a1a;
  color: #fff;
  border-left-color: #fff;
}

.device-panel {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  background: var(--bg);
}

.toolbar {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}

select, input[type="text"] {
  background: #000;
  border: 1px solid var(--border-input);
  color: var(--text-input);
  padding: 6px 10px;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
}

select:focus, input[type="text"]:focus {
  border-color: #fff;
  outline: none;
}

button {
  padding: 6px 14px;
  border: 1px solid var(--border-input);
  border-radius: 0;
  background: var(--bg-button);
  color: #ddd;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.1s;
}
button:hover { background: var(--bg-button-hover); color: #fff; border-color: #555; }
button.primary {
  background: #fff;
  border-color: #fff;
  color: #000;
}
button.primary:hover { background: #ddd; }
button.danger { background: #1a0000; border-color: #600; color: #f66; }
button.danger:hover { background: #300; }

.hidden { display: none !important; }

.device-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.device-header h2 {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
  color: #fff;
  font-family: inherit;
}

.placeholder-msg {
  color: #333;
  padding: 80px 20px;
  text-align: center;
  font-size: 15px;
  font-family: inherit;
}

.bank {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.bank-header {
  margin-bottom: 10px;
}
.bank-name-input {
  font-size: 13px; font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: transparent; border: none; border-bottom: 1px solid transparent;
  color: #ccc; width: 200px; padding: 2px 4px;
  font-family: inherit;
  transition: border-color 0.1s, color 0.1s;
}
.bank-name-input:hover { border-bottom-color: #444; }
.bank-name-input:focus { border-bottom-color: #fff; color: #fff; outline: none; }

.param-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.param-slot {
  position: relative;
}
.param-slot input {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
  background: #000;
  border: 1px solid var(--border-input);
  border-radius: 0;
  color: #ccc;
  font-family: inherit;
  transition: border-color 0.1s;
}
.param-slot input:focus { border-color: #fff; outline: none; background: #0a0a0a; }
.param-slot input:hover { border-color: var(--border-hover); }
.param-slot label {
  font-size: 10px; color: #444;
  position: absolute; top: -5px; left: 8px;
  background: var(--bg-surface); padding: 0 4px;
  font-weight: 600;
  font-family: inherit;
}

.param-slot input {
  cursor: grab;
}
.param-slot input.dragging {
  opacity: 0.4;
}
.param-slot input.drag-over {
  border-color: #fff;
  background: #111;
}

#save-status {
  font-size: 13px; color: #ccc; margin-left: 8px;
}

#midi-status {
  display: flex; gap: 12px; align-items: center;
  margin: 20px 24px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0;
}
#midi-state { font-size: 14px; font-family: inherit; }
#midi-connected-options {
  display: flex; gap: 8px; align-items: center;
  margin-left: auto;
}

.config-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  margin: 0 24px 12px;
}
.config-section h3 { font-size: 14px; margin-bottom: 8px; color: #ccc; font-family: inherit; }

/* Controller Editor */
.ctrl-layout {
  padding: 0 24px;
}

.ctrl-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.preset-tabs {
  display: flex;
  gap: 0;
}

.preset-tab {
  padding: 8px 16px;
  font-size: 14px; font-weight: 600;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #ccc;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.1s;
}
.preset-tab:hover { color: #bbb; }
.preset-tab.active {
  color: #fff;
  border-bottom-color: #fff;
}

.preset-name-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.ctrl-ch-label {
  font-size: 12px;
  color: #ddd;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#preset-name-input {
  width: 200px;
  height: var(--ctrl-height);
  font-size: 14px;
}

.ctrl-toolbar {
  display: flex; gap: 8px;
}

.ctrl-section-divider {
  border-top: 1px solid var(--border);
  margin: 24px 0 16px;
}

.ctrl-section-title {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: inherit;
}

.layout-tabs {
  display: flex;
  gap: 0;
}

.layout-tab {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--border-input);
  border-radius: 0;
  background: #000;
  color: #ddd;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.1s;
}
.layout-tab:hover { background: #111; color: #bbb; }
.layout-tab.active {
  background: #fff;
  border-color: #fff;
  color: #000;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.ctrl-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0;
  position: relative;
}

.ctrl-number {
  font-size: 16px;
  font-weight: 700;
  color: #ccc;
  text-align: center;
  padding: 5px 0 2px;
  font-family: inherit;
}

.ctrl-separator {
  border: none;
  border-top: 1px solid #555;
  margin: 0;
}

.ctrl-section {
  padding: 6px 8px 8px;
}

.ctrl-section-label {
  font-size: 11px;
  font-weight: 700;
  color: #ccc;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 4px;
  font-family: inherit;
}

.ctrl-section-push {
  border: 1px solid #555;
  margin: 6px 6px 8px;
}

.ctrl-section .ctrl-name {
  display: block;
  width: 108px;
  margin: 0 auto 4px;
  text-align: center;
  background: #222;
}

.ctrl-fields {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.ctrl-type {
  background: #000;
  border: 1px solid var(--border-input);
  color: #ccc;
  padding: 0 2px;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  width: 50px;
  height: var(--ctrl-height);
}

.ctrl-type-fixed {
  font-size: 14px;
  color: #eee;
  width: 28px;
  flex-shrink: 0;
  text-align: center;
  font-family: inherit;
}

.ctrl-name {
  background: #000;
  border: 1px solid var(--border-input);
  color: var(--text-input);
  padding: 0 6px;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  width: 82px;
  height: var(--ctrl-height);
}
.ctrl-name::placeholder {
  color: var(--text-placeholder);
  font-style: normal;
}

.ctrl-num-wrap {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-input);
  border-radius: 0;
  overflow: hidden;
  height: var(--ctrl-height);
}
.ctrl-num-wrap input {
  background: #000;
  border: none;
  color: var(--text-input);
  padding: 0 4px;
  font-size: 14px;
  font-family: inherit;
  width: 36px;
  text-align: center;
  -moz-appearance: textfield;
}
.ctrl-num-wrap input::-webkit-inner-spin-button,
.ctrl-num-wrap input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ctrl-num-chevrons {
  display: flex;
  flex-direction: column;
}
.ctrl-num-chevrons button {
  background: #111;
  border: none;
  border-left: 1px solid var(--border);
  color: #ccc;
  font-size: 8px;
  line-height: 1;
  padding: 0 5px;
  flex: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctrl-num-chevrons button:hover {
  background: #222;
  color: #fff;
}
.ctrl-num-chevrons button + button {
  border-top: 1px solid var(--border);
}

.ctrl-note {
  background: #000;
  border: 1px solid var(--border-input);
  color: var(--text-input);
  padding: 0 4px;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  width: 50px;
  height: var(--ctrl-height);
}

.ctrl-oct {
  background: #000;
  border: 1px solid var(--border-input);
  color: var(--text-input);
  padding: 0 4px;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  width: 42px;
  height: var(--ctrl-height);
}

.ctrl-ch {
  background: #000;
  border: 1px solid var(--border-input);
  color: var(--text-input);
  padding: 0 4px;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  width: 42px;
  height: var(--ctrl-height);
}

.toggle-label {
  font-size: 13px;
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.toggle-label input[type="checkbox"] {
  accent-color: #fff;
}

#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
#modal {
  background: #111; border: 1px solid #333;
  border-radius: 0; padding: 24px;
  min-width: 300px; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
#modal h3 { margin-bottom: 12px; color: #fff; font-family: inherit; font-size: 16px; }
#modal-body { margin-bottom: 16px; font-size: 14px; }
#modal-body input { width: 100%; margin-top: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
