:root {
  --bg: #080a0f;
  --bg-soft: #0c0f16;
  --panel: rgba(18, 22, 32, 0.82);
  --panel-solid: #111520;
  --panel-2: rgba(255, 255, 255, 0.035);
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef2fb;
  --muted: #8d95aa;
  --faint: #5d6579;
  --accent: #8266ff;
  --accent-soft: #b5a5ff;
  --accent-2: #39d7f2;
  --danger: #ff5e6c;
  --success: #3ddc97;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  --font: "Segoe UI Variable", "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 720px at 16% -12%, rgba(95, 63, 255, 0.22), transparent 62%),
    radial-gradient(900px 640px at 92% -4%, rgba(22, 190, 225, 0.11), transparent 58%),
    radial-gradient(800px 600px at 60% 110%, rgba(130, 102, 255, 0.08), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
}

[hidden] { display: none !important; }

h1, h2, h3, h4, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.muted { color: var(--muted); }
.center { text-align: center; }
.help { color: var(--faint); font-size: 12px; line-height: 1.55; }
.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

/* ---------------------------------------------------------------- shell */

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 258px;
  height: 100vh;
  flex: 0 0 258px;
  padding: 26px 18px 22px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(11, 14, 21, 0.92), rgba(8, 10, 15, 0.78));
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 6px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 6px);
  align-content: center;
  justify-content: center;
  gap: 4px;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(145deg, #9a7dff, #5b3df0 58%, #3a24b8);
  box-shadow: 0 8px 20px rgba(107, 77, 240, 0.4), inset 0 1px rgba(255, 255, 255, 0.4);
}

.brand-mark span {
  width: 6px;
  height: 14px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.55);
}

.brand-mark span:nth-child(2) { height: 20px; margin-top: -3px; }
.brand-mark span:nth-child(3) { height: 10px; margin-top: 2px; }

.brand-text h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text p { font-size: 11px; color: var(--faint); letter-spacing: 0.18em; text-transform: uppercase; }

.device-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel-2);
  cursor: pointer;
  transition: 0.17s ease;
}

.device-card:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }

.device-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
  transition: 0.25s ease;
}

.device-card.connected .device-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.12), 0 0 14px rgba(61, 220, 151, 0.7);
}

.device-card.error .device-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 94, 108, 0.12);
}

.device-copy { min-width: 0; }
.device-copy strong { display: block; font-size: 12.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-copy small { display: block; font-size: 10.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 5px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.035); }

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(130, 102, 255, 0.22), rgba(130, 102, 255, 0.07));
  border-color: rgba(130, 102, 255, 0.28);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
}

.nav-item.active svg { color: var(--accent-soft); stroke-width: 1.8; }

.sidebar-foot { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }

.tip {
  display: flex;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.tip-icon {
  display: grid;
  place-items: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(130, 102, 255, 0.18);
  color: var(--accent-soft);
  font-size: 10px;
  font-weight: 800;
  font-style: italic;
}

.version { color: var(--faint); font-size: 10px; letter-spacing: 0.06em; text-align: center; }

/* ----------------------------------------------------------------- main */

.main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 1290px;
  margin: 0 auto;
  padding: 28px 34px 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 2px 0;
}

.topbar-title h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.topbar-title p { margin-top: 3px; color: var(--muted); font-size: 12.5px; }

.topbar-actions { display: flex; align-items: center; gap: 9px; }

.connection-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.connection-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.connection-pill.connected { color: #9df2c9; border-color: rgba(61, 220, 151, 0.18); }
.connection-pill.connected .dot { background: var(--success); box-shadow: 0 0 9px rgba(61, 220, 151, 0.8); }
.connection-pill.error { color: #ff9aa3; border-color: rgba(255, 94, 108, 0.2); }
.connection-pill.error .dot { background: var(--danger); box-shadow: 0 0 9px rgba(255, 94, 108, 0.7); }

.layer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 20px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.022);
}

.layer-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
}

.layer-note { margin-left: auto; color: var(--faint); font-size: 11px; }

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.segmented button {
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: 0.16s ease;
}

.segmented button:hover { color: var(--text); }

.segmented.wide button { flex: 1; width: auto; }

.segmented button.active {
  background: linear-gradient(135deg, #8b6bff, #6447e8);
  color: #fff;
  box-shadow: 0 3px 10px rgba(107, 77, 240, 0.35);
}

.view { display: none; }
.view.active { display: block; animation: fade-up 0.3s ease both; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------- panels */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(16px);
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-head h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.panel-head p { margin-top: 2px; font-size: 12px; }
.head-actions { display: flex; align-items: center; gap: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid rgba(130, 102, 255, 0.24);
  border-radius: 999px;
  background: rgba(130, 102, 255, 0.13);
  color: var(--accent-soft);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* --------------------------------------------------------------- keycaps */

.bindings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 20px;
  align-items: start;
}

.pad-panel { min-width: 0; }

.pad-stage {
  display: grid;
  place-items: center;
  min-height: 264px;
  padding: 32px 22px;
  border-radius: 20px;
  background:
    radial-gradient(80% 90% at 50% 20%, rgba(130, 102, 255, 0.12), transparent 65%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.pad-body {
  position: relative;
  width: fit-content;
  padding: 24px 26px 17px;
  border-radius: 25px;
  background: linear-gradient(155deg, #232937 0%, #151a24 42%, #0c0f15 100%);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.14),
    inset 0 -3px rgba(0, 0, 0, 0.7),
    0 28px 55px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.pad-body::before,
.pad-body::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #05070a;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

.pad-body::before { left: 10px; }
.pad-body::after { right: 10px; }

.pad-keys {
  display: grid;
  grid-template-columns: repeat(3, 88px);
  gap: 14px;
}

.keycap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 88px;
  padding: 8px 7px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  background: linear-gradient(148deg, #323949 0%, #1b202b 55%, #12161f 100%);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.16),
    inset 0 -4px rgba(0, 0, 0, 0.45),
    0 7px 0 #06080c,
    0 13px 22px rgba(0, 0, 0, 0.5);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.keycap::before {
  content: "";
  position: absolute;
  inset: 5px 8px auto;
  height: 38%;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent);
  pointer-events: none;
}

.keycap:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.16); }

.keycap:active { transform: translateY(3px); box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 3px 0 #06080c, 0 6px 12px rgba(0, 0, 0, 0.45); }

.keycap.selected {
  border-color: rgba(150, 126, 255, 0.9);
  box-shadow:
    0 0 0 2px rgba(130, 102, 255, 0.2),
    0 0 30px rgba(130, 102, 255, 0.32),
    inset 0 1px rgba(255, 255, 255, 0.2),
    0 7px 0 #06080c,
    0 13px 22px rgba(0, 0, 0, 0.5);
}

.keycap .cap-index {
  position: absolute;
  top: 7px;
  left: 9px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.3);
}

.keycap .cap-label {
  position: relative;
  z-index: 1;
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.18;
  text-align: center;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.keycap .cap-kind {
  position: relative;
  z-index: 1;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.34);
}

.keycap.empty .cap-label { color: var(--faint); font-weight: 550; }

.pad-brand {
  margin-top: 16px;
  color: #4d5468;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.38em;
  text-align: center;
}

.pad-brand span { margin-left: 3px; color: #3c4254; }

.pad-hint { margin-top: 14px; font-size: 11.5px; }

.identify-banner {
  margin-bottom: 12px;
  padding: 9px 12px;
  border: 1px solid rgba(57, 215, 242, 0.25);
  border-radius: 10px;
  background: rgba(57, 215, 242, 0.08);
  color: #9ceafb;
  font-size: 11.5px;
  text-align: center;
  animation: fade-up 0.2s ease both;
}

.identify-banner.active { box-shadow: 0 0 0 1px rgba(57, 215, 242, 0.12), 0 0 22px rgba(57, 215, 242, 0.08); }

/* ---------------------------------------------------------------- editor */

.editor-panel { min-height: 388px; }

.empty-editor {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-height: 340px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--panel-2);
  color: var(--faint);
  font-size: 22px;
}

.empty-editor h3 { font-size: 15px; }
.empty-editor p { font-size: 12px; }

.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.key-chip {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(130, 102, 255, 0.3);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(130, 102, 255, 0.28), rgba(130, 102, 255, 0.08));
  color: #d6ccff;
  font-size: 16px;
  font-weight: 750;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12);
}

.editor-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.editor-head p { color: var(--muted); font-size: 11.5px; }

.kind-tabs {
  display: flex;
  gap: 3px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.24);
}

.kind-tabs button {
  flex: 1;
  padding: 8px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  transition: 0.16s ease;
}

.kind-tabs button:hover { color: var(--text); background: rgba(255, 255, 255, 0.035); }

.kind-tabs button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.25);
}

.kind-tabs button[data-kind="none"].active { color: #ffb3ba; background: rgba(255, 94, 108, 0.12); }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field > label { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); }

.shortcut-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  padding: 18px 18px 17px;
  border: 1px dashed var(--border-strong);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  cursor: pointer;
  transition: 0.18s ease;
}

.shortcut-button:hover { border-color: rgba(130, 102, 255, 0.55); background: rgba(130, 102, 255, 0.05); }

.shortcut-button .shortcut-text { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; overflow-wrap: anywhere; }
.shortcut-button .shortcut-sub { color: var(--faint); font-size: 11.5px; }

.shortcut-button.capturing {
  border-style: solid;
  border-color: rgba(130, 102, 255, 0.7);
  background: rgba(130, 102, 255, 0.09);
  animation: capture-pulse 1.3s ease-in-out infinite;
}

@keyframes capture-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(130, 102, 255, 0.28); }
  50% { box-shadow: 0 0 0 6px rgba(130, 102, 255, 0); }
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }

.macro-steps { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }

.macro-step {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}

.step-index {
  display: grid;
  place-items: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(130, 102, 255, 0.14);
  color: var(--accent-soft);
  font-size: 10px;
  font-weight: 800;
}

.step-key { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.macro-empty {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

.delay-row { display: flex; align-items: center; gap: 10px; }
.delay-row input { width: 96px; }

input[type="number"], input[type="text"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  outline: none;
  transition: 0.16s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(130, 102, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(130, 102, 255, 0.13);
}

select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.input-suffix { display: flex; align-items: center; gap: 7px; }
.input-suffix span { color: var(--faint); font-size: 11.5px; }

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: 0.17s ease;
  position: relative;
}

.btn:hover { background: rgba(255, 255, 255, 0.075); border-color: rgba(255, 255, 255, 0.22); }
.btn:active { transform: translateY(1px); }

.btn.active {
  border-color: rgba(57, 215, 242, 0.4);
  background: rgba(57, 215, 242, 0.12);
  color: #9ceafb;
  box-shadow: 0 0 0 1px rgba(57, 215, 242, 0.08);
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #8d6dff, #6447e8);
  color: #fff;
  box-shadow: 0 8px 20px rgba(100, 71, 232, 0.34), inset 0 1px rgba(255, 255, 255, 0.2);
}

.btn.primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, #977bff, #6c4ff0); }

.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.055); }

.btn.danger {
  border-color: rgba(255, 94, 108, 0.3);
  background: rgba(255, 94, 108, 0.12);
  color: #ff9ba4;
}

.btn.danger:hover { background: rgba(255, 94, 108, 0.2); }

.btn.tiny { padding: 6px 10px; font-size: 11.5px; border-radius: 8px; }
.btn.icon-btn { width: 36px; height: 36px; padding: 0; }
.btn.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }

.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- lighting */

.lighting-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.92fr) minmax(0, 1.08fr);
  gap: 30px;
  align-items: center;
  padding: 30px;
  overflow: hidden;
  background:
    radial-gradient(75% 100% at 15% 50%, rgba(130, 102, 255, 0.12), transparent 70%),
    var(--panel);
}

.lighting-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 18px;
  background: radial-gradient(70% 80% at 50% 50%, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.5));
}

.pad-body.mini { padding: 18px 20px 10px; border-radius: 20px; }
.pad-body.mini .pad-keys { grid-template-columns: repeat(3, 62px); gap: 11px; }
.pad-body.mini .keycap { height: 62px; border-radius: 12px; box-shadow: inset 0 1px rgba(255, 255, 255, 0.14), 0 5px 0 #06080c, 0 8px 16px rgba(0, 0, 0, 0.45); cursor: default; }
.pad-body.mini .pad-brand { display: none; }

.pad-body.mini.glow .keycap {
  border-color: var(--glow-border, rgba(255, 255, 255, 0.16));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.22),
    0 0 22px var(--glow),
    0 5px 0 #06080c,
    0 8px 16px rgba(0, 0, 0, 0.45);
}

.pad-body.mini.glow .keycap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(70% 70% at 50% 20%, var(--glow), transparent 75%);
  opacity: 0.16;
  pointer-events: none;
}

.pad-body.mini.off .keycap { opacity: 0.48; box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 5px 0 #06080c; }

.pad-body.mini.wave .keycap { animation: wave-breath 1.7s ease-in-out infinite; }
.pad-body.mini.wave .keycap:nth-child(2) { animation-delay: 0.22s; }
.pad-body.mini.wave .keycap:nth-child(3) { animation-delay: 0.44s; }
.pad-body.mini.wave.reverse .keycap { animation-direction: reverse; animation-delay: 0s; }
.pad-body.mini.wave.reverse .keycap:nth-child(2) { animation-delay: 0.22s; }
.pad-body.mini.wave.reverse .keycap:nth-child(3) { animation-delay: 0.44s; }

@keyframes wave-breath {
  0%, 100% { filter: brightness(0.45); transform: translateY(0); }
  45% { filter: brightness(1.35); transform: translateY(-2px); }
}

.pad-body.mini.reactive .keycap { filter: brightness(0.5); }
.pad-body.mini.reactive .keycap:hover { filter: brightness(1.25); }

.lighting-hero-copy h3 { margin: 6px 0 7px; font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.lighting-hero-copy > p { font-size: 13px; max-width: 46ch; }

.lighting-known { margin-top: 14px; }

.known-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
}

.known-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.known-pill.known { color: #9df2c9; border-color: rgba(61, 220, 151, 0.18); }
.known-pill.known::before { background: var(--success); box-shadow: 0 0 8px rgba(61, 220, 151, 0.7); }

.lighting-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 20px; margin-top: 20px; }

.effect-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }

.effect-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 13px 13px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
  cursor: pointer;
  transition: 0.17s ease;
}

.effect-card:hover { border-color: rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.045); }

.effect-card.active {
  border-color: rgba(130, 102, 255, 0.6);
  background: linear-gradient(145deg, rgba(130, 102, 255, 0.16), rgba(130, 102, 255, 0.04));
  box-shadow: inset 0 0 0 1px rgba(130, 102, 255, 0.12), 0 4px 16px rgba(100, 71, 232, 0.12);
}

.effect-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
}

.effect-card.active .effect-icon { background: rgba(130, 102, 255, 0.18); color: #cbbdff; }
.effect-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.effect-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.effect-name { font-size: 12px; font-weight: 650; }
.effect-tag {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.effect-card.active .effect-tag { color: #cbbdff; border-color: rgba(130, 102, 255, 0.3); }
.effect-desc { color: var(--faint); font-size: 10.5px; line-height: 1.4; }

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }

.swatch {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: 0.16s ease;
  box-shadow: inset 0 -3px 8px rgba(0, 0, 0, 0.28), inset 0 2px 4px rgba(255, 255, 255, 0.25);
}

.swatch:hover { transform: translateY(-2px) scale(1.04); }

.swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12), 0 0 18px var(--swatch);
}

.swatch[data-colour="0"] { background: #f6f8ff; }

.lighting-actions { display: flex; justify-content: flex-end; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }

.note-panel { margin-top: 20px; }
.note-panel h3 { font-size: 13px; margin-bottom: 6px; }
.note-panel p { font-size: 12px; max-width: 90ch; }

/* ----------------------------------------------------------------- backups */

.backup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.backup-grid .panel { display: flex; flex-direction: column; align-items: flex-start; }
.backup-grid .btn { margin-bottom: 10px; }

.backup-list { display: flex; flex-direction: column; gap: 7px; }

.backup-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}

.backup-main { flex: 1; min-width: 0; }
.backup-main strong { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backup-main small { display: block; color: var(--faint); font-size: 10.5px; }

.backup-empty { padding: 24px; text-align: center; color: var(--faint); font-size: 12px; }

.skeleton-list { display: flex; flex-direction: column; gap: 7px; }
.skeleton-list span {
  display: block;
  height: 50px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.raw-config { display: flex; flex-direction: column; gap: 16px; }
.raw-layer h4 { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; }
.raw-table { width: 100%; border-collapse: collapse; }
.raw-table th, .raw-table td { padding: 7px 9px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); font-size: 11.5px; text-align: left; }
.raw-table th { color: var(--faint); font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.raw-table td:first-child { width: 70px; color: var(--muted); }
.raw-table td:last-child { color: var(--text); }
.raw-light { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.raw-light i { width: 9px; height: 9px; border-radius: 50%; background: var(--swatch, #666); display: inline-block; }

/* ------------------------------------------------------------------ modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(8px);
  animation: fade-in 0.16s ease both;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  display: flex;
  flex-direction: column;
  width: min(660px, 100%);
  max-height: min(86vh, 720px);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: #10141e;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
  animation: modal-pop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.modal.small { width: min(430px, 100%); }

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 { font-size: 15px; font-weight: 650; }
.modal-head .icon-btn { font-size: 20px; line-height: 1; color: var(--muted); }

.modal-tabs { display: flex; gap: 4px; padding: 10px 20px 0; }

.modal-tabs button {
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.modal-tabs button:hover { color: var(--text); }
.modal-tabs button.active { color: #fff; background: rgba(255, 255, 255, 0.07); border-color: var(--border); }

.modal-body { padding: 16px 20px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

.modal-capture {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  text-align: left;
}

.modal-capture:hover { border-color: rgba(130, 102, 255, 0.55); }
.modal-capture.capturing { border-style: solid; border-color: rgba(130, 102, 255, 0.7); background: rgba(130, 102, 255, 0.08); animation: capture-pulse 1.3s ease-in-out infinite; }
.modal-capture .capture-main { font-size: 18px; font-weight: 700; }
.modal-capture .capture-sub { color: var(--faint); font-size: 11px; }
.modal-capture .capture-badge { color: var(--accent-soft); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

.mod-toggles { display: flex; gap: 7px; flex-wrap: wrap; margin: 14px 0; }

.mod-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.mod-toggle input { accent-color: var(--accent); margin: 0; }
.mod-toggle.on { color: var(--text); border-color: rgba(130, 102, 255, 0.35); background: rgba(130, 102, 255, 0.1); }

.picker-search { margin-bottom: 12px; }

.key-list { display: flex; flex-direction: column; gap: 12px; }
.key-group h4 { margin: 0 0 6px; color: var(--faint); font-size: 9.5px; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 5px; }

.key-option {
  padding: 7px 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: 0.14s ease;
}

.key-option:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }
.key-option.selected { color: #fff; border-color: rgba(130, 102, 255, 0.7); background: rgba(130, 102, 255, 0.18); box-shadow: 0 0 0 1px rgba(130, 102, 255, 0.15); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }

.media-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  text-align: left;
}

.media-option:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }
.media-option.selected { color: #fff; border-color: rgba(130, 102, 255, 0.65); background: rgba(130, 102, 255, 0.16); }
.media-option .media-glyph { width: 18px; text-align: center; opacity: 0.8; }

.modal-note { margin-top: 12px; color: var(--faint); font-size: 11px; }

/* ------------------------------------------------------------------ toast */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 40px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 11px;
  background: #151a26;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 0.22s ease both;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent-2); }
.toast .toast-icon { flex: 0 0 auto; font-weight: 800; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--accent-2); }
.toast.leaving { animation: toast-out 0.2s ease both; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(5px); } }

/* --------------------------------------------------------------- offline */

.offline-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px;
  border: 1px solid rgba(255, 94, 108, 0.2);
  border-radius: 12px;
  background: rgba(255, 94, 108, 0.06);
}

.offline-card h3 { font-size: 13.5px; color: #ffc2c8; }
.offline-card p { color: var(--muted); font-size: 12px; }
.offline-card code { font-family: var(--mono); font-size: 11px; color: #ffb3ba; }

.save-error { margin-top: 10px; color: #ff9aa3; font-size: 11.5px; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 1120px) {
  .sidebar { width: 228px; flex-basis: 228px; }
  .main { padding: 24px 24px 48px; }
  .bindings-grid { grid-template-columns: 1fr; }
  .editor-panel { min-height: 0; }
  .lighting-grid { grid-template-columns: 1fr; }
  .lighting-hero { grid-template-columns: 1fr; }
  .lighting-preview-wrap { min-height: 180px; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-text h1 { font-size: 15px; }
  .brand-text p { display: none; }
  .device-card { order: 3; flex: 1 1 100%; padding: 8px 10px; }
  .nav { order: 2; margin-left: auto; flex-direction: row; gap: 3px; }
  .nav-item { padding: 8px 10px; }
  .nav-item span { display: none; }
  .nav-item svg { width: 18px; height: 18px; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 40px; }
  .topbar { flex-direction: column; gap: 12px; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .layer-note { width: 100%; margin-left: 0; }
  .pad-stage { padding: 22px 12px; min-height: 210px; }
  .pad-keys { grid-template-columns: repeat(3, 72px); gap: 10px; }
  .keycap { height: 72px; border-radius: 13px; }
  .keycap .cap-label { font-size: 11px; }
  .panel { padding: 17px; }
  .backup-grid { grid-template-columns: 1fr; }
  .effect-grid { grid-template-columns: 1fr; }
  .kind-tabs { flex-wrap: wrap; }
  .kind-tabs button { min-width: 30%; }
  .lighting-hero { padding: 20px; }
  .lighting-hero-copy h3 { font-size: 20px; }
  .modal { max-height: 92vh; }
}

@media (max-width: 460px) {
  .pad-keys { grid-template-columns: repeat(3, 64px); gap: 8px; }
  .keycap { height: 64px; }
  .keycap .cap-index { display: none; }
  .swatch { width: 36px; height: 36px; }
  .key-grid { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
