/* MK1300 Studio — monochrome instrument workspace. RGB is reserved for lighting data. */
* {
  box-sizing: border-box;
}
html {
  scrollbar-gutter: stable;
}
body {
  --bg: #090909;
  --panel: #111;
  --panel2: #1b1b1b;
  --text: #f6f6f6;
  --muted: #a1a1a1;
  --line: #333;
  --accent: #fafafa;
  --ink: #090909;
  --key: #202020;
  --shadow: #0006;
  --danger: #fff;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    13px/1.5 Inter,
    "Helvetica Neue",
    Arial,
    sans-serif;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}
body.light {
  --bg: #fff;
  --panel: #fff;
  --panel2: #f3f3f3;
  --text: #111;
  --muted: #626262;
  --line: #d8d8d8;
  --accent: #111;
  --ink: #fff;
  --key: #f5f5f5;
  --shadow: #0000000d;
  --danger: #111;
  color-scheme: light;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 9px 14px;
  background: var(--panel2);
  cursor: pointer;
  font-weight: 500;
  line-height: 1.35;
  transition:
    background 0.16s,
    border-color 0.16s,
    transform 0.16s,
    box-shadow 0.16s;
}
button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text) 9%, var(--panel));
  border-color: var(--muted);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
button.primary {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 85%, var(--bg));
  box-shadow: 2px 2px 0 var(--muted);
}
button.ghost {
  background: transparent;
}
.danger {
  border-style: dashed;
}
.icon {
  width: 38px;
  height: 38px;
  padding: 9px;
  flex-shrink: 0;
}
.icon svg,
svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
input,
select,
textarea {
  min-width: 0;
  max-width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  transition: border-color 0.16s;
}
input:hover,
select:hover,
textarea:hover {
  border-color: var(--muted);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  flex-shrink: 0;
}
input[type="color"] {
  width: 48px;
  height: 38px;
  padding: 4px;
  cursor: pointer;
}
input[type="range"] {
  width: 100%;
  height: 24px;
  min-height: 24px;
  accent-color: var(--accent);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
select {
  cursor: pointer;
}
a {
  color: inherit;
  text-decoration: none;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 42px;
  font-weight: 550;
  line-height: 1.1;
  letter-spacing: -2px;
}
h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
h3 {
  font-size: 14px;
  font-weight: 600;
}
small,
.muted {
  color: var(--muted);
}
small {
  font-size: 11px;
}
.eyebrow,
.badge,
.brand-sub,
.draft-state,
.board-identity small,
.pattern-bottom,
.stat strong,
output {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
}
.shell {
  min-height: 100vh;
}
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 84px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.7px;
  flex-shrink: 0;
}
.brandmark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: var(--ink);
  border-radius: 2px;
}
.brandmark svg {
  width: 24px;
  height: 24px;
}
.brand-sub {
  display: block;
  font-size: 9px;
  letter-spacing: 3px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--muted);
}
.nav {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.nav button {
  position: relative;
  z-index: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  min-height: 38px;
  padding: 10px 13px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  transition:
    transform 0.2s,
    color 0.16s;
}
.nav button:hover:not(:disabled) {
  background: transparent;
  transform: translateY(-3px);
  color: var(--text);
}
.nav button.active {
  color: var(--ink);
}
.nav button.active:hover {
  color: var(--ink);
}
.nav svg {
  width: 16px;
  height: 16px;
}
.nav-marker {
  position: absolute;
  z-index: 0;
  background: var(--accent);
  border-radius: 5px;
  pointer-events: none;
}
.nav .count {
  display: none;
}
.connection-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.connection-controls > button {
  font-size: 12px;
}
.connection-state {
  font-size: 11px;
  color: var(--muted);
  margin-right: 8px;
  white-space: nowrap;
}
.dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--muted);
  margin-right: 7px;
  vertical-align: 2px;
}
.dot.online {
  background: var(--text);
  box-shadow: 0 0 0 3px var(--panel2);
}
.main {
  min-width: 0;
}
.workspace {
  width: 100%;
  padding: 30px 24px 32px;
}
.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.workspace-title {
  display: flex;
  align-items: center;
  gap: 20px;
}
.draft-state {
  white-space: nowrap;
  font-size: 10px;
  color: var(--muted);
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
}
.workspace-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.profile-menu {
  position: relative;
  min-width: 0;
}
.profile-menu summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.profile-menu summary::-webkit-details-marker {
  display: none;
}
.profile-menu summary:hover {
  background: var(--panel2);
}
.profile-menu summary > span:first-of-type {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-menu summary svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}
.profile-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 45;
  display: grid;
  gap: 4px;
  min-width: 220px;
  max-width: 280px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 5px 5px 0 var(--shadow);
}
.profile-popover strong {
  padding: 8px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.profile-popover button {
  border: 0;
  justify-content: flex-start;
  font-size: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.wrap {
  flex-wrap: wrap;
}
.spread {
  justify-content: space-between;
}
.stack {
  display: grid;
  gap: 20px;
  align-content: start;
}
.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.field {
  display: grid;
  gap: 9px;
  min-width: 0;
}
.field > span,
.field > label {
  font-size: 12px;
  color: var(--muted);
}
.field select {
  width: 100%;
}
.help {
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
}
.control-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
output {
  font-size: 11px;
  color: var(--text);
}
.divider {
  height: 1px;
  background: var(--line);
}
.wide {
  width: 100%;
}
.card,
.board-panel,
.profile-card,
.stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}
.card {
  padding: 22px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.card-head small {
  display: block;
  margin-top: 4px;
}
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
}
.page-body[data-current-page="lighting"],
.page-body[data-current-page="keymap"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}
.page-body[data-current-page="lighting"] > .content-grid,
.page-body[data-current-page="keymap"] > .content-grid {
  display: contents;
}
.page-body[data-current-page="lighting"] > .board-panel,
.page-body[data-current-page="keymap"] > .board-panel {
  grid-column: 1;
  grid-row: 1;
}
.page-body[data-current-page="lighting"] > .content-grid > section,
.page-body[data-current-page="keymap"] > .content-grid > section {
  grid-column: 1;
  grid-row: 2;
}
.page-body[data-current-page="lighting"] > .content-grid > aside {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 108px;
}
.page-body[data-current-page="keymap"] > .content-grid > aside {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 108px;
}
.board-panel {
  overflow: hidden;
}
.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.board-identity {
  gap: 12px;
}
.board-identity strong {
  font-size: 12px;
  letter-spacing: 0.2px;
}
.board-identity small {
  font-size: 10px;
}
.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  max-width: 100%;
}
.segmented button {
  min-height: 30px;
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  border-radius: 1px;
  white-space: nowrap;
}
.segmented button.active {
  background: var(--accent);
  color: var(--ink);
}
.board-stage {
  padding: 38px 32px 40px;
  overflow: auto;
  background-image: radial-gradient(var(--line) 0.6px, transparent 0.6px);
  background-size: 12px 12px;
}
.keyboard {
  position: relative;
  aspect-ratio: 15/5;
  width: 100%;
  min-width: 550px;
  max-width: 1100px;
  margin: 0 auto;
  isolation: isolate;
}
.keyboard:before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -12px -12px -14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  box-shadow:
    0 5px 0 var(--panel2),
    0 10px 20px var(--shadow);
}
.key {
  position: absolute;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-bottom: 3px solid color-mix(in srgb, var(--key) 70%, #000);
  border-radius: 3px;
  background: var(--key);
  box-shadow: 0 2px 0 var(--shadow);
  font-size: clamp(9px, 0.85vw, 13px);
  font-weight: 500;
  line-height: 1;
  transition:
    transform 0.12s,
    background 0.12s,
    border-color 0.12s;
}
.key:hover:not(:disabled) {
  transform: translateY(-2px);
  background: var(--panel2);
  border-color: var(--muted);
}
[data-current-page="lighting"] .key {
  border-color: color-mix(in srgb, var(--rgb) 45%, var(--line));
  box-shadow:
    inset 0 -2px 0 color-mix(in srgb, var(--rgb) 70%, transparent),
    0 2px 0 var(--shadow);
}
.key.selected {
  outline: 2px solid var(--text);
  outline-offset: 1px;
  background: var(--panel2);
}
.key.pressed {
  background: var(--accent);
  color: var(--ink);
  transform: translateY(2px);
}
.key.tested:after,
.key.mapped:before {
  content: "";
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 4px;
  height: 4px;
  background: var(--text);
}
.key.mapped:before {
  bottom: auto;
  top: 5px;
  background: transparent;
  border: 1px solid var(--text);
}
.key .sub {
  position: absolute;
  bottom: 5px;
  font-size: 8px;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
#paint-area {
  touch-action: none;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 20px;
}
.chips button {
  min-height: 30px;
  font-size: 11px;
  padding: 6px 10px;
  background: transparent;
  border-radius: 2px;
}
.chips button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}
.search {
  width: 230px;
  font-size: 12px;
}
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-height: 370px;
  overflow: auto;
  padding: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.pattern {
  display: block;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  text-align: left;
  border-radius: 2px;
}
.pattern:hover:not(:disabled) {
  transform: translateY(-2px);
  background: var(--panel2);
}
.pattern.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.pattern-preview {
  height: 73px;
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 2px;
  padding: 14px 12px;
  background: #111;
}
.pattern-preview i {
  display: block;
  border-radius: 0;
  opacity: 0.9;
}
.pattern-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 11px 12px;
  font-size: 10px;
}
.pattern-bottom > span:first-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.preset-check {
  font-size: 12px;
  width: 12px;
  min-height: 16px;
}
.swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.swatches button {
  min-height: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--swatch);
}
.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  max-height: 350px;
  overflow: auto;
  padding: 3px;
}
.actions-grid button {
  font-size: 11px;
  padding: 10px 6px;
  min-height: 42px;
}
.actions-grid button.chosen {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}
.selected-key {
  font-size: 48px;
  font-weight: 500;
  letter-spacing: -2px;
  line-height: 1.2;
  margin-top: 10px;
}
.destination-scroll {
  overflow: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
}
.destination-keyboard {
  position: relative;
  width: 100%;
  min-width: 760px;
  aspect-ratio: 23/6.4;
}
.destination-keyboard button {
  position: absolute;
  min-height: 0;
  padding: 2px;
  font-size: clamp(9px, 0.8vw, 12px);
  line-height: 1.15;
  background: var(--key);
  border-radius: 2px;
  white-space: pre-line;
  box-shadow: 0 2px 0 var(--line);
}
.destination-keyboard button:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--text);
}
.destination-keyboard button.chosen {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}
.badge {
  font-size: 10px;
  letter-spacing: 0.3px;
  border: 1px solid var(--line);
  padding: 6px 9px;
  color: var(--muted);
  white-space: nowrap;
}
.macro-grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.macro-list {
  display: grid;
  gap: 6px;
  max-height: 660px;
  overflow: auto;
  scrollbar-width: thin;
}
.macro-list button {
  justify-content: space-between;
  text-align: left;
  background: transparent;
  border-color: transparent;
}
.macro-list button.active {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}
.macro-list button.active small {
  color: inherit;
}
.macro-list button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-area {
  display: grid;
  place-items: center;
  min-height: 90px;
  padding: 20px;
  border: 1px dashed var(--line);
  background: var(--bg);
  font-family: Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}
.record-area.recording {
  border: 1px solid var(--accent);
  color: var(--text);
  animation: record-pulse 1.5s infinite;
}
.event-list {
  max-height: 380px;
  overflow: auto;
  scrollbar-width: thin;
}
.event-row {
  display: grid;
  grid-template-columns: 28px minmax(100px, 1fr) 80px 90px 32px 32px 32px;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.event-row input {
  width: 100%;
  padding: 6px;
  min-height: 32px;
}
.event-row button {
  padding: 5px;
  min-height: 32px;
}
.event-row > button.ghost {
  justify-content: flex-start;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.stat {
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.stat:after {
  content: "";
  position: absolute;
  right: 18px;
  top: 20px;
  width: 16px;
  height: 16px;
  background: repeating-linear-gradient(
    90deg,
    var(--line) 0 2px,
    transparent 2px 4px
  );
}
.stat strong {
  display: block;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -1px;
  margin: 12px 0 4px;
  overflow-wrap: anywhere;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.profile-card {
  padding: 22px;
}
.profile-strip {
  display: flex;
  gap: 2px;
  height: 32px;
  margin-bottom: 24px;
}
.profile-strip i {
  flex: 1;
}
.profile-card h3 {
  font-size: 18px;
  overflow-wrap: anywhere;
}
.profile-card .row {
  flex-wrap: wrap;
  margin-top: 20px;
}
.empty {
  padding: 38px 20px;
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
}
.empty h2 {
  font-size: 14px;
}
.empty p {
  margin-top: 8px;
}
.page-body[data-current-page="tester"] > .board-panel {
  margin-bottom: 16px;
}
.test-input {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  font-size: 16px;
}
.log {
  font:
    11px/1.8 Consolas,
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  min-height: 100px;
  overflow: auto;
  padding: 14px;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
}
.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  background: var(--panel2);
  font-size: 12px;
}
.status-banner.error {
  border-left: 3px solid var(--text);
}
dialog {
  width: calc(100% - 40px);
  max-width: 520px;
  padding: 28px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--text);
  border-radius: 4px;
  box-shadow: 7px 7px 0 var(--shadow);
}
dialog::backdrop {
  background: #0009;
  backdrop-filter: blur(5px);
}
dialog h2 {
  font-size: 23px;
  letter-spacing: -0.7px;
  margin-bottom: 18px;
}
dialog p {
  color: var(--muted);
  margin-bottom: 24px;
}
dialog .row {
  justify-content: flex-end;
  margin-top: 24px;
  flex-wrap: wrap;
}
dialog input {
  width: 100%;
}
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 12px 12px 20px;
  background: var(--accent);
  color: var(--ink);
  border: 1px solid var(--muted);
  border-radius: 4px;
  box-shadow: 5px 5px 0 var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition:
    opacity 0.2s,
    transform 0.2s,
    visibility 0.2s;
  font-size: 12px;
}
#toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#toast button {
  color: inherit;
  border: 1px solid currentColor;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 20px;
}
#toast button:hover {
  color: var(--text);
  background: var(--ink);
}
.progress {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  z-index: 99;
  background: linear-gradient(90deg, transparent, var(--text), transparent);
  animation: record-pulse 1s infinite;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  padding: 12px;
  background: var(--accent);
  color: var(--ink);
  z-index: 200;
  transform: translateY(-200%);
}
.skip-link:focus {
  transform: none;
}
code {
  font:
    12px Consolas,
    monospace;
  background: var(--panel2);
  padding: 3px 5px;
}
@keyframes record-pulse {
  50% {
    opacity: 0.5;
  }
}
@media (min-width: 1700px) {
  .workspace {
    padding: 36px 32px;
  }
  .appbar {
    padding-inline: 32px;
  }
  .page-body[data-current-page="lighting"],
  .page-body[data-current-page="keymap"] {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
  .pattern-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    max-height: 430px;
  }
  .board-stage {
    padding-block: 44px;
  }
}
@media (max-width: 1250px) {
  .connection-state {
    display: none;
  }
  .appbar {
    gap: 12px;
    padding: 12px 20px;
  }
  .nav button {
    padding: 10px;
  }
  .nav button span {
    display: none;
  }
  .nav button {
    width: 44px;
  }
  .brand {
    min-width: 130px;
  }
  .pattern-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .board-identity {
    display: grid;
    gap: 2px;
  }
  .workspace-title {
    gap: 14px;
  }
  .draft-state {
    font-size: 9px;
  }
}
@media (max-width: 950px) {
  .page-body[data-current-page="lighting"],
  .page-body[data-current-page="keymap"] {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 12px;
  }
  .card {
    padding: 18px;
  }
  .board-toolbar {
    padding: 14px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .board-stage {
    padding: 30px 26px;
  }
  .workspace {
    padding: 24px 20px;
  }
  .pattern-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card-head {
    flex-wrap: wrap;
  }
  .search {
    width: 100%;
  }
  .workspace-title {
    display: block;
  }
  .draft-state {
    display: inline-block;
    margin-top: 10px;
  }
  .content-grid {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .macro-grid {
    grid-template-columns: 180px minmax(0, 1fr);
  }
  .event-row {
    grid-template-columns: 20px minmax(70px, 1fr) 55px 65px 28px 28px 28px;
    gap: 4px;
  }
}
@media (max-width: 760px) {
  .appbar {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 12px;
  }
  .brand {
    margin-right: auto;
  }
  .nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
    border-radius: 6px;
  }
  .nav button {
    flex: 1;
    padding: 9px;
    width: auto;
  }
  .nav button span {
    display: inline;
    font-size: 10px;
  }
  .nav svg {
    width: 14px;
    height: 14px;
  }
  .connection-controls {
    gap: 6px;
  }
  .workspace {
    padding: 24px 16px;
  }
  .workspace-header {
    margin-bottom: 20px;
  }
  h1 {
    font-size: 34px;
    letter-spacing: -1.3px;
  }
  .workspace-actions {
    gap: 6px;
  }
  .workspace-actions button {
    font-size: 11px;
    padding: 9px 10px;
  }
  .profile-menu summary {
    padding: 8px;
    font-size: 11px;
    gap: 6px;
  }
  .profile-menu summary > span:first-of-type {
    max-width: 95px;
  }
  .page-body[data-current-page="lighting"],
  .page-body[data-current-page="keymap"] {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .page-body[data-current-page="lighting"] > .content-grid > aside,
  .page-body[data-current-page="keymap"] > .content-grid > aside {
    position: static;
    grid-column: 1;
    grid-row: 2;
  }
  .page-body[data-current-page="lighting"] > .content-grid > section,
  .page-body[data-current-page="keymap"] > .content-grid > section {
    grid-row: 3;
  }
  .page-body[data-current-page="lighting"] > .content-grid > aside > .stack {
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 16px;
  }
  .page-body[data-current-page="lighting"] > .content-grid > aside .divider {
    display: none;
  }
  .board-identity {
    display: flex;
    gap: 12px;
  }
  .board-toolbar {
    justify-content: space-between;
  }
  .pattern-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 400px;
  }
  .content-grid {
    grid-template-columns: 1fr;
  }
  .macro-grid {
    grid-template-columns: 1fr;
  }
  .macro-list {
    display: flex;
    max-height: none;
    overflow: auto;
  }
  .macro-list button {
    min-width: 120px;
  }
  .macro-list small {
    margin-left: 10px;
  }
  .stat {
    padding: 16px;
  }
  .stat-grid {
    gap: 10px;
  }
  .stat:after {
    display: none;
  }
  .stat strong {
    font-size: 28px;
  }
  .profile-grid {
    grid-template-columns: 1fr;
  }
  .card-head .search {
    width: auto;
    flex: 1;
  }
  .test-input {
    min-height: 110px;
  }
  .page-body[data-current-page="keymap"] > .content-grid > aside {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .page-body[data-current-page="keymap"] > .content-grid > aside .divider {
    display: none;
  }
}
@media (max-width: 480px) {
  .nav button {
    flex-direction: column;
    gap: 5px;
    min-height: 50px;
    padding: 7px 3px;
  }
  .nav button span {
    font-size: 9px;
  }
  .nav button:hover:not(:disabled) {
    transform: translateY(-2px);
  }
  .brand {
    font-size: 15px;
    min-width: 0;
  }
  .brandmark {
    width: 32px;
    height: 34px;
  }
  .connection-controls > button {
    padding: 8px 10px;
    font-size: 11px;
  }
  .connection-controls > .icon {
    width: 34px;
    padding: 8px;
  }
  .workspace-header {
    flex-wrap: wrap;
    gap: 16px;
  }
  .workspace-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  .draft-state {
    margin: 0;
  }
  .workspace-actions {
    width: 100%;
    justify-content: space-between;
  }
  .profile-menu summary > span:first-of-type {
    max-width: 180px;
  }
  .workspace-actions button {
    font-size: 12px;
    padding: 9px 14px;
  }
  .board-toolbar > .row:last-child {
    width: 100%;
  }
  .board-toolbar .segmented {
    width: 100%;
  }
  .segmented button {
    flex: 1;
  }
  .board-stage {
    padding: 28px 24px;
  }
  .card {
    padding: 16px;
  }
  .card-head {
    gap: 12px;
  }
  .card-head .search {
    width: 100%;
    flex: auto;
  }
  .pattern-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pattern-preview {
    height: 68px;
    padding: 12px 10px;
  }
  .pattern-bottom {
    padding: 10px;
  }
  .chips {
    gap: 5px;
  }
  .chips button {
    padding: 7px 9px;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .stat {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px;
  }
  .stat strong {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    margin: 0;
  }
  .stat small {
    font-size: 10px;
  }
  .two {
    gap: 14px;
  }
  .event-list {
    overflow-x: auto;
  }
  .event-row {
    min-width: 440px;
  }
  .event-row button {
    min-height: 36px;
  }
  .macro-grid .card-head {
    align-items: end;
  }
  .macro-grid .card-head .field {
    width: 100%;
  }
  .page-body[data-current-page="lighting"] > .content-grid > aside > .stack {
    gap: 18px 14px;
  }
  .page-body[data-current-page="lighting"]
    > .content-grid
    > aside
    > .stack
    > div:first-child {
    grid-column: 1/-1;
  }
  .page-body[data-current-page="lighting"]
    > .content-grid
    > aside
    > .stack
    > button {
    grid-column: 1/-1;
  }
  .page-body[data-current-page="lighting"]
    > .content-grid
    > aside
    > .stack
    > .help {
    grid-column: 1/-1;
  }
  .page-body[data-current-page="keymap"] > .content-grid > aside {
    grid-template-columns: 1fr;
  }
  .search {
    width: 100%;
  }
  .spread {
    flex-wrap: wrap;
  }
  .badge {
    white-space: normal;
  }
  #toast {
    bottom: 16px;
    right: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .nav button:hover:not(:disabled),
  .key:hover:not(:disabled),
  .pattern:hover:not(:disabled),
  .destination-keyboard button:hover:not(:disabled) {
    transform: none;
  }
}
