*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: system-ui, sans-serif;
  font-size: 14px;
  background: #1a1a1a;
  color: #e0e0e0;
  margin: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 700px;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 24px;
  color: #fff;
}

.error-banner {
  background: #5c1a1a;
  border: 1px solid #a03030;
  color: #ffaaaa;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.warn-banner {
  background: #3a3000;
  border: 1px solid #887700;
  color: #ffdd55;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta {
  background: #252525;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.meta-name {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 15px;
  font-weight: 600;
  padding: 5px 8px;
  outline: none;
}

.meta-name:focus { border-color: #666; }

.meta-actions {
  display: flex;
  gap: 8px;
}

.meta-actions button {
  background: #333;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ccc;
  cursor: pointer;
  font-size: 13px;
  padding: 5px 14px;
}

.meta-actions button:hover {
  background: #444;
  color: #fff;
}

.meta-comment {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #ccc;
  font-family: inherit;
  font-size: 13px;
  padding: 5px 8px;
  resize: vertical;
  outline: none;
  width: 100%;
}

.meta-comment:focus { border-color: #666; }

.meta-timestamp {
  font-size: 11px;
  color: #555;
}

.midi-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #252525;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.midi-bar select {
  background: #1a1a1a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ccc;
  font-size: 13px;
  padding: 5px 8px;
  flex: 1;
  min-width: 160px;
  outline: none;
}

.midi-bar select:focus { border-color: #666; }

.midi-bar button {
  background: #333;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ccc;
  cursor: pointer;
  font-size: 13px;
  padding: 5px 14px;
  white-space: nowrap;
}

.midi-bar button:hover:not(:disabled) { background: #444; color: #fff; }

.midi-bar button:disabled { opacity: 0.4; cursor: default; }

.midi-status-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.midi-status {
  font-size: 12px;
  color: #ffdd55;
}

.midi-status--error     { color: #ff8080; }
.midi-status--connected { color: #66cc66; }

.section-heading {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin: 28px 0 0;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-heading:hover { color: #888; }

.section-chevron {
  font-size: 10px;
}

.section-items {
  border: 1px solid #2e2e2e;
  border-radius: 6px;
  margin-top: 6px;
  overflow: hidden;
}

.item {
  display: flex;
  flex-direction: column;
  padding: 7px 12px;
  border-bottom: 1px solid #2e2e2e;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item:last-child { border-bottom: none; }

.item.invalid { background: #2a1f1f; }

.item-left {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.item-label {
  font-size: 20px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-id {
  font-family: monospace;
  font-size: 17px;
  color: #555;
  white-space: nowrap;
}

.item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.item-range {
  font-size: 17px;
  color: #555;
  white-space: nowrap;
}

.item input:not([type="range"]) {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 20px;
  padding: 4px 8px;
  width: 110px;
  text-align: right;
  outline: none;
  transition: border-color 0.15s;
}

.item input:not([type="range"]):focus { border-color: #666; }

.item.invalid input:not([type="range"]) {
  border-color: #a03030;
  color: #ff8080;
}

.item-error {
  font-size: 17px;
  color: #ff6060;
  white-space: nowrap;
}

.item-slider {
  width: 220px;
  align-self: flex-end;
  margin-top: 4px;
  accent-color: #666;
}

.item-stepper {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.item-stepper button {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 3px;
  color: #888;
  cursor: pointer;
  font-size: 9px;
  line-height: 1;
  padding: 2px 5px;
  width: 22px;
}

.item-stepper button:hover {
  background: #3a3a3a;
  color: #ccc;
}

.item select {
  appearance: none;
  -webkit-appearance: none;
  background: #1a1a1a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
  font-family: inherit;
  font-size: 20px;
  outline: none;
  padding: 4px 30px 4px 8px;
  transition: border-color 0.15s;
}

.item select:focus { border-color: #666; }

.item-bitfield {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 8px 0 2px;
}

.item-bitfield-spacer {
  flex: 1;
}

.item-bitfield-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bitfield-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  color: #ccc;
  cursor: pointer;
  user-select: none;
}

.bitfield-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 3px;
  cursor: pointer;
  outline: none;
  position: relative;
  transition: border-color 0.15s;
}

.bitfield-row input[type="checkbox"]:focus { border-color: #666; }

.bitfield-row input[type="checkbox"]:checked {
  background: #333;
  border-color: #666;
}

.bitfield-row input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid #e0e0e0;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
