:root {
  color-scheme: dark;
  font-family: Inter, Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #ebf5ff;
  background: #0b1420;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body {
  min-height: 0;
  margin: 0;
  background: radial-gradient(ellipse at 14% -8%, #22465a 0, transparent 55%), radial-gradient(ellipse at 90% 65%, #1b2042 0, transparent 40%), #0b1420;
}
button, select { font: inherit; }
button { cursor: pointer; }
main { width: min(1540px, calc(100% - 32px)); min-width: 0; margin: auto; padding: 22px 0 38px; container-type: inline-size; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.brand { color: #a9ff7b; font-size: 11px; font-weight: 900; letter-spacing: .16em; }
h1 { margin: 6px 0 0; font-size: clamp(26px, 4vw, 40px); letter-spacing: -.035em; }
h2 { margin: 0 0 7px; font-size: 20px; letter-spacing: -.02em; }
.subtitle { margin: 6px 0 14px; color: #a8bbcf; font-size: 14px; line-height: 1.5; }
.badge { border: 1px solid #477b80; border-radius: 30px; background: #153340; color: #c5f9f6; padding: 9px 13px; font-size: 11px; font-weight: 750; }
.action-tip { margin: 0 0 14px; border-left: 3px solid #8def8e; background: #112330; padding: 10px 13px; color: #c2d5e2; font-size: 12px; line-height: 1.6; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.tab { min-height: 42px; padding: 10px 20px; border: 1px solid #3b556c; border-radius: 10px; background: #1b2939; color: #c2d7e9; font-weight: 800; }
.tab.active { color: #0b1821; background: #a1f978; border-color: #bcffa5; }
.tab:hover:not(.active) { border-color: #84dad3; }
:focus-visible { outline: 3px solid #73e4d2; outline-offset: 3px; }
.figure { min-width: 0; min-height: 0; overflow: hidden; padding: 12px; border: 1px solid #385a72; border-radius: 15px; background: #0c1623; box-shadow: 0 15px 40px #0005; }
.figure svg { display: block; width: 100%; max-width: 100%; height: auto; margin: auto; }
.figure.keyboard-view { background: #0c1623; }
.figure.keyboard-view svg, .figure:not(.keyboard-view) svg { min-width: 0; }
.figure [data-code], .figure [data-control] { cursor: pointer; }
.figure [data-code]:focus .key-face, .figure [data-control]:focus .key-face { stroke: #74efbd; stroke-width: 18px; }
.tip { margin: 9px 4px 15px; color: #9caec4; font-size: 12px; line-height: 1.55; }
.layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(250px, .74fr); gap: 14px; }
.box { min-width: 0; padding: 16px; border: 1px solid #324b61; border-radius: 14px; background: #111f2e; }
.small { margin: 0 0 12px; color: #a5b9cf; font-size: 12px; line-height: 1.55; }
#action-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.row { display: grid; grid-template-columns: minmax(80px, 1fr) auto; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #26384a; }
.row:last-child { border: 0; }
.row-label { font-size: 12px; font-weight: 700; }
.row-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.binding { min-width: 44px; min-height: 40px; padding: 6px 8px; border: 1px solid #508599; border-radius: 8px; background: #1a3b4c; color: #b8edfa; font-size: 12px; font-weight: 850; }
.binding.armed, .binding:hover { background: #a0f9e9; color: #071f27; }
.row[data-kind="move"] .binding { border-color: #5f9452; color: #c6ff9a; }
.row[data-kind="rotate"] .binding { border-color: #856ba7; color: #ebd0ff; }
.row[data-kind="drop"] .binding { border-color: #ac8754; color: #ffe0aa; }
label { display: block; margin: 14px 0 7px; color: #a9c8d7; font-size: 12px; font-weight: 800; }
select { width: 100%; min-height: 44px; padding: 10px; border: 1px solid #526e8d; border-radius: 9px; background: #142638; color: #e9f3ff; font-weight: 600; }
.buttons { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.btn { min-height: 40px; padding: 8px 10px; border: 1px solid #4b7690; border-radius: 9px; background: #223d51; color: #e9f6ff; font-size: 12px; font-weight: 700; }
.btn:hover { background: #29536d; }
.btn.primary { border-color: #5cce98; background: #1c7759; }
#status { min-height: 60px; padding: 11px; border: 1px solid #3a6377; border-radius: 10px; background: #1b3243; color: #c9e9f3; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
#status.error { border-color: #d15b77; background: #432738; color: #ffd3dd; }
#status.armed { border-color: #76e5d7; background: #164b51; color: #d1fff1; }
.hidden { display: none !important; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.card { min-height: 90px; padding: 12px; border: 1px solid #3d566a; border-radius: 11px; background: #172638; color: #d9eafb; text-align: left; }
.card:hover, .card.active { border-color: #93f7a0; background: #1f3a34; }
.card strong { display: block; margin-bottom: 5px; color: #a7ffa3; font-size: 12px; }
.card span { color: #bad0e1; font-size: 11px; line-height: 1.45; }
.detail { min-height: 90px; padding: 12px; border: 1px solid #4c7d86; border-radius: 11px; background: #193342; color: #d4e9f5; font-size: 13px; line-height: 1.55; }
.note { margin: 11px 0 0; padding: 7px 10px; border-left: 3px solid #7eefa2; color: #bfcbdb; font-size: 11px; line-height: 1.6; }
code { color: #c6ff9a; }
@container (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .box { padding: 14px; }
}
@container (max-width: 520px) {
  .top { gap: 10px; }
  .badge { margin-left: auto; }
  .action-tip { font-size: 11px; }
  .tabs { gap: 6px; }
  .tab { flex: 1; padding: 9px 7px; font-size: 12px; }
  .figure { min-height: 0; padding: 8px; border-radius: 11px; }
  .cards { grid-template-columns: 1fr; }
  #action-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .row-actions { justify-content: flex-start; }
  .buttons .btn { flex: 1 1 130px; }
  .layout { gap: 10px; }
}
@container (max-width: 360px) {
  .box { padding: 11px; }
  h2 { font-size: 18px; }
  .row-label { line-height: 1.4; }
  .buttons { display: grid; grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 950px) {
  .layout { grid-template-columns: 1fr; }
  .box { padding: 14px; }
}
@media (max-width: 580px) {
  main { width: calc(100% - 20px); padding: 12px 0 20px; }
  .badge { margin-left: auto; }
  .action-tip { font-size: 11px; }
  .tabs { gap: 6px; }
  .tab { flex: 1; padding: 9px 7px; font-size: 12px; }
  .figure { min-height: 0; padding: 8px; border-radius: 11px; }
  .cards { grid-template-columns: 1fr; }
  .row-label { font-size: 11px; }
  .binding { min-width: 40px; min-height: 40px; padding: 6px; }
  .buttons .btn { flex: 1 1 auto; }
  .layout { gap: 10px; }
}

/* Only the SVG viewport scrolls horizontally; its height follows the scaled SVG. */
html, body { overflow-x: hidden; }
#diagram-view { min-width: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: rgba(0, 255, 255, .7) rgba(0, 0, 0, .3); }
#diagram-view::-webkit-scrollbar { height: 6px; }
#diagram-view::-webkit-scrollbar-track { background: rgba(0, 0, 0, .3); border-radius: 3px; }
#diagram-view::-webkit-scrollbar-thumb { background: linear-gradient(90deg, rgba(255, 0, 255, .6), rgba(0, 255, 255, .6)); border-radius: 3px; }
#diagram-view::-webkit-scrollbar-thumb:hover { background: linear-gradient(90deg, rgba(255, 0, 255, .8), rgba(0, 255, 255, .8)); }
.figure #diagram-view svg { max-width: none; margin: 0; }
#keyboard-zoom { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 8px; font-size: 12px; }
#keyboard-zoom[hidden] { display: none; }
#keyboard-zoom button { width: 28px; height: 28px; padding: 0; border: 1px solid #a7ff24; border-radius: 50%; background: #a7ff2433; color: #dfffbc; font-size: 18px; }
#keyboard-zoom button:disabled { opacity: .4; cursor: default; }
