:root {
  --bg: #0b0d10;
  --panel: #15191e;
  --panel-2: #1b2026;
  --line: #303740;
  --text: #f5f7fa;
  --muted: #98a2ad;
  --amber: #ffae37;
  --amber-2: #7a4b09;
  --green: #45d483;
  --red: #ff6874;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% -20%, #26303a 0, var(--bg) 45%); }
button, input, select { font: inherit; }
button, select, input { border: 1px solid var(--line); border-radius: 9px; background: #20262d; color: var(--text); }
button { padding: .7rem 1rem; cursor: pointer; font-weight: 700; }
button:hover:not(:disabled) { border-color: var(--amber); transform: translateY(-1px); }
button:disabled { opacity: .38; cursor: not-allowed; }
button.primary { background: var(--amber); border-color: #ffc46d; color: #231607; }
button.large { min-width: 210px; padding: 1rem 1.4rem; }
button.danger-quiet { color: #ff9da5; }
input, select { padding: .65rem .75rem; }
.app-header { display: flex; justify-content: space-between; gap: 2rem; padding: 2.2rem clamp(1rem, 4vw, 4rem) 1.4rem; border-bottom: 1px solid var(--line); }
h1 { font-size: clamp(2rem, 4vw, 3.7rem); margin: .1rem 0; letter-spacing: -.04em; }
h2 { margin: .15rem 0 .5rem; }
p { color: var(--muted); }
.eyebrow { color: var(--amber); font-size: .73rem; font-weight: 900; letter-spacing: .16em; margin: 0; }
.subtitle { max-width: 760px; margin-bottom: 0; }
.connection-card { min-width: 320px; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(21,25,30,.88); display: grid; gap: .7rem; }
.connection-card label { display: grid; gap: .35rem; color: var(--muted); font-size: .8rem; }
.connection-card small { color: var(--muted); line-height: 1.35; }
.status-dot::before { content: ""; display: inline-block; width: .65rem; height: .65rem; margin-right: .5rem; border-radius: 50%; background: var(--red); }
.status-dot.connected::before { background: var(--green); box-shadow: 0 0 12px var(--green); }
main { width: min(1440px, calc(100% - 2rem)); margin: 1rem auto 3rem; display: grid; gap: 1rem; }
.panel { border: 1px solid var(--line); background: rgba(21,25,30,.94); border-radius: 16px; padding: 1.1rem; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.toolbar { display: flex; align-items: end; gap: 1rem; justify-content: space-between; }
.set-name { display: grid; gap: .35rem; min-width: 240px; color: var(--muted); font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: .55rem; justify-content: flex-end; }
.device { padding: 1.35rem; background: linear-gradient(145deg, #e7e8eb, #bfc3c9); color: #15171a; }
.device .eyebrow { color: #8b5200; }
.device-topline { display: flex; justify-content: space-between; align-items: end; margin-bottom: 1rem; }
.set-health { text-align: right; display: grid; }
.set-health strong { font-size: 1.4rem; }
.set-health span { color: #555d66; }
.pad-grid { display: grid; grid-template-columns: repeat(8, minmax(105px, 1fr)); gap: .8rem; }
.pad { min-width: 0; min-height: 210px; padding: .8rem; border: 2px solid #747b84; border-radius: 12px; background: linear-gradient(145deg, #f2f3f5, #c9ccd1); box-shadow: 0 7px 15px rgba(0,0,0,.24); display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto 1fr auto auto auto; gap: .3rem; transition: .15s ease; }
.pad.loaded { border-color: #a66000; background: linear-gradient(145deg, #ffd590, #d99a3f); }
.pad.drag-over { outline: 4px solid var(--amber); transform: scale(1.02); }
.pad.error { border-color: #d42232; background: #ffc9ce; }
.pad.midi-learn-focus { outline: 4px solid #2879d8; outline-offset: 2px; box-shadow: 0 0 0 6px rgba(40,121,216,.18), 0 7px 15px rgba(0,0,0,.24); }
.pad-number { font-size: 1.2rem; font-weight: 900; white-space: nowrap; }
.pad-note { font: 700 .72rem ui-monospace, monospace; color: #555d66; }
.patch-name { grid-column: 1 / -1; align-self: end; font-size: 1.08rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.patch-file { grid-column: 1 / -1; font-size: .7rem; color: #555d66; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playback-control { grid-column: 1 / -1; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .35rem; color: #4d555e; font-size: .65rem; font-weight: 800; }
.playback-note { display: block; min-width: 0; max-width: 100%; width: 100%; padding: .34rem .38rem; color: #15171a; background: rgba(255,255,255,.72); border-color: rgba(0,0,0,.3); font-size: .7rem; }
.pad-actions { grid-column: 1 / -1; display: flex; gap: .3rem; }
.pad-actions button { flex: 1; padding: .45rem .3rem; font-size: .72rem; color: #15171a; background: rgba(255,255,255,.45); border-color: rgba(0,0,0,.28); }
.transport { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.transport p { margin-bottom: 0; }
.transport-controls { display: flex; align-items: center; gap: 1rem; }
progress { width: 240px; accent-color: var(--amber); }
.log-title { display: flex; justify-content: space-between; align-items: center; }
#activity-log { min-height: 130px; max-height: 280px; overflow: auto; color: #c7f9d8; background: #07090b; border: 1px solid #272d34; border-radius: 10px; padding: 1rem; margin-bottom: 0; font: .78rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
@media (max-width: 1120px) { .pad-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 760px) {
  .app-header, .toolbar, .transport { flex-direction: column; align-items: stretch; }
  .connection-card { min-width: 0; }
  .pad-grid { grid-template-columns: repeat(2, 1fr); }
  .transport-controls { flex-direction: column; align-items: stretch; }
  progress { width: 100%; }
}
