:root {
  color-scheme: light;
  --canvas: #fafbfc;
  --surface: #fff;
  --sidebar: #f6f7f9;
  --ink: #28313e;
  --muted: #77818e;
  --line: #e1e5eb;
  --line-strong: #cbd2dc;
  --accent: #2563eb;
  --accent-soft: #edf3ff;
  --green: #16866c;
  --red: #c84b57;
  --purple: #7858b6;
  --sidebar-width: 300px;
  --inspector-width: 244px;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}
body {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr) 36px;
  min-width: 320px;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
button,
a,
input,
select,
summary {
  touch-action: manipulation;
}
button,
input,
select {
  border-radius: 5px;
}
[hidden] {
  display: none !important;
}
button svg,
summary svg {
  flex: 0 0 auto;
}
svg {
  display: block;
}
:focus-visible {
  outline: 3px solid #91b3ff;
  outline-offset: 2px;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 14px;
  color: #fff;
  background: var(--accent);
  transform: translateY(-150%);
}
.skip-link:focus {
  transform: translateY(0);
}

/* Application chrome stays outside the drawing surface. */
.studio-header {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 16px 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 271px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 450;
  white-space: nowrap;
}
.brand strong {
  font-weight: 700;
}
.brand-mark {
  width: 31px;
  height: 31px;
}
.brand-mark > rect {
  fill: #253e58;
  stroke: none;
}
.brand-mark path,
.brand-mark circle {
  stroke: #e9f2fb;
  stroke-width: 1.4;
}
.brand-mark circle {
  fill: #253e58;
}
.file-menu {
  position: relative;
  flex: 0 0 auto;
}
summary {
  cursor: pointer;
  list-style: none;
}
summary::-webkit-details-marker {
  display: none;
}
.chrome-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.chrome-button:hover,
.file-menu[open] > summary {
  background: var(--sidebar);
  border-color: var(--line);
}
.file-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  display: grid;
  width: 232px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 28px #21324b24;
}
.file-popover button,
.file-popover a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 12px;
  text-decoration: none;
}
.file-popover button:hover,
.file-popover a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.menu-divider {
  height: 1px;
  margin: 5px 7px;
  background: var(--line);
}
.document-title {
  min-width: 60px;
  flex: 1 1 auto;
}
.document-title input {
  width: min(100%, 350px);
  height: 32px;
  padding: 0 9px;
  border: 1px solid transparent;
  background: transparent;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 500;
}
.document-title input:hover,
.document-title input:focus {
  border-color: var(--line);
  background: var(--sidebar);
}
.history-actions,
.run-actions,
.zoom-controls {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
}
.history-actions {
  padding-right: 12px;
  border-right: 1px solid var(--line);
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  padding: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #6b7685;
  font-size: 19px;
}
.icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line);
  background: var(--sidebar);
}
.server-status {
  border: 0;
  padding: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
#simulate[hidden],
#cancel-run[hidden] {
  display: none;
}
.server-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b2bac5;
  content: "";
}
.server-status.online,
.server-status.ready,
.server-status.status-online {
  color: var(--green);
}
.server-status.online::before,
.server-status.ready::before,
.server-status.status-online::before {
  background: var(--green);
}
.server-status.offline,
.server-status.error,
.server-status.status-offline {
  color: var(--red);
}
.server-status.offline::before,
.server-status.error::before,
.server-status.status-offline::before {
  background: var(--red);
}
.run-actions {
  gap: 7px;
  margin-left: 3px;
}
.run-actions select {
  height: 32px;
  max-width: 120px;
  padding: 0 23px 0 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}
.button:hover:not(:disabled) {
  background: var(--sidebar);
}
.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.button-primary:hover:not(:disabled) {
  border-color: #1e55d2;
  background: #1e55d2;
}
.button svg {
  width: 15px;
  height: 15px;
}
.latex-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  box-shadow: 0 16px 60px #16233b33;
}
.latex-dialog::backdrop {
  background: #15233b66;
}
.latex-dialog h2 {
  margin: 0 0 10px;
  font-size: 18px;
}
.latex-dialog p {
  font-size: 12px;
  line-height: 1.6;
}
.latex-dialog textarea {
  display: block;
  width: 100%;
  min-height: 210px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #f8fafc;
  font:
    12px/1.7 ui-monospace,
    monospace;
  tab-size: 2;
}
.latex-tools,
.latex-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.latex-actions {
  justify-content: flex-end;
  margin-top: 20px;
}
.latex-note {
  color: var(--muted);
}
.alignment-guide {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 4 5;
  opacity: 0.55;
}
.button.danger,
.button-danger {
  color: var(--red);
}

.workbench {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.component-library {
  display: flex;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.workbench.library-collapsed .component-library {
  display: none;
}
#toggle-library {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}
#toggle-library svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.3;
}
.library-header {
  flex: 0 0 auto;
  padding: 19px 15px 0;
}
.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.library-heading h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}
.library-count {
  color: #98a1ad;
  font-size: 8px;
  letter-spacing: 0.12em;
  font-weight: 650;
}
.search-field {
  position: relative;
  display: block;
  margin-top: 15px;
}
.search-field svg {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 15px;
  height: 15px;
  stroke: #8b95a3;
  stroke-width: 1.5;
  pointer-events: none;
}
.search-field input {
  width: 100%;
  height: 34px;
  min-width: 0;
  padding: 0 9px 0 31px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11px;
}
.search-field input::placeholder {
  color: #96a0ad;
}
.library-instruction {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}
.library-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 15px 15px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #cdd4dd transparent;
}
#gate-groups {
  display: grid;
}
.palette-group {
  margin-top: 22px;
  min-width: 0;
}
.group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: #637080;
  font-size: 11px;
  font-weight: 600;
}
.group-label h2,
.group-label h3 {
  margin: 0;
  color: #637080;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
}
.group-label > span {
  color: #97a0ac;
  font-size: 9px;
}
.gate-palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.gate-card {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  min-height: 63px;
  padding: 7px 3px;
  border: 1px solid #dce1e9;
  border-radius: 6px;
  background: var(--surface);
  color: #38465a;
  transition:
    border-color 100ms ease,
    background 100ms ease,
    box-shadow 100ms ease;
}
.gate-card:hover {
  border-color: #a9bada;
  background: #fcfdff;
  box-shadow: 0 2px 4px #263d6810;
}
.gate-card[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.gate-card strong {
  max-width: 100%;
  font-size: 11px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gate-card small {
  color: var(--muted);
  font-size: 9px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gate-symbol {
  display: block;
  width: 40px;
  height: 29px;
  overflow: visible;
  color: inherit;
}
.gate-symbol text {
  fill: currentColor;
  stroke: none;
  text-anchor: middle;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}
.gate-card > svg:not(.gate-symbol) {
  width: 38px;
  height: 28px;
}
.saved-group:has(#saved-palette:empty) {
  display: none;
}
.saved-group .gate-card {
  color: var(--purple);
  border-color: #d8cde8;
  background: #fcfaff;
}
.error-card {
  min-height: 57px;
}
.error-symbol {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid #e8bdc1;
  border-radius: 50%;
  color: var(--red);
  background: #fff8f8;
  font:
    600 12px ui-monospace,
    monospace;
}
.palette-note {
  grid-column: 1 / -1;
  margin: 0;
  color: #8b97a7;
  font-size: 11px;
  line-height: 1.65;
}
.library-footer {
  flex: 0 0 auto;
  margin: 0 15px;
  padding: 15px 0 17px;
  border-top: 1px solid var(--line);
}
.library-footer strong {
  display: block;
  margin-top: 9px;
  color: #617084;
  font-size: 10px;
  font-weight: 600;
}
.library-footer p {
  margin: 5px 0 0;
  color: #8b95a3;
  font-size: 10px;
  line-height: 1.6;
}
.connection-guide {
  display: flex;
  align-items: center;
  width: 84px;
  height: 18px;
  color: #8395ac;
}
.connection-guide span {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: var(--surface);
}
.connection-guide i {
  flex: 0 0 38px;
  height: 1.5px;
  background: currentColor;
}
.connection-guide svg {
  width: 13px;
  height: 13px;
  margin-left: 7px;
  stroke: currentColor;
  stroke-width: 1.5;
}

.drawing-tools {
  z-index: 10;
  display: flex;
  flex: 0 0 54px;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 9px 5px;
  border-right: 1px solid var(--line);
  background: #fff;
}
.drawing-tools .mobile-history {
  display: none;
}
.tool-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 60px;
  padding: 7px 1px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #748092;
}
.tool-button svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool-button > span {
  font-size: 8px;
  font-weight: 550;
}
.tool-button kbd {
  position: absolute;
  top: 3px;
  right: 3px;
  color: #a5aebb;
  font-size: 6px;
  border: 0;
  background: none;
  padding: 0;
}
.tool-button:hover {
  color: var(--ink);
  background: var(--sidebar);
}
.tool-button.active,
.tool-button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #dbe7ff;
}
.tool-button.active kbd,
.tool-button[aria-pressed="true"] kbd {
  color: #83a7f4;
}
.delete-tool:hover {
  color: var(--red);
  background: #fff1f1;
}
.tool-divider {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}

/* SVG coordinates and viewport transforms are owned by the graph editor. */
.canvas-area {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--canvas);
}
.canvas-topbar {
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 41px;
  min-width: 0;
  padding: 0 15px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.canvas-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.canvas-title strong {
  font-size: 11px;
  font-weight: 550;
}
.canvas-indicator {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #93a2b4;
}
#graph-counts {
  margin-left: 6px;
  overflow: hidden;
  color: #98a1ae;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.level-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: #929aa6;
  font-size: 10px;
}
.level-field select {
  max-width: 96px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid var(--line);
  background: #fff;
  color: #68768a;
  font-size: 10px;
}
.graph-viewport {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background-color: var(--canvas);
  background-image: radial-gradient(circle, #d8dfe9 0.75px, transparent 0.85px);
  background-size: 20px 20px;
  cursor: default;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
.graph-viewport:focus-visible {
  outline-offset: -3px;
}
.batch-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  font-size: 11px;
}
.batch-actions[hidden] {
  display: none;
}
.batch-actions .button {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 11px;
}
.batch-actions strong {
  margin-right: 3px;
}
.batch-sides,
.batch-errors {
  display: flex;
  gap: 3px;
}
.batch-sides [aria-pressed="true"] {
  color: #2456c6;
  background: #edf3ff;
  border-color: #b5caff;
}
.batch-errors button {
  color: #c73546;
}
.batch-help {
  color: #68768a;
}
.batch-port-number {
  fill: #2456c6;
  font:
    11px system-ui,
    sans-serif;
}
.canvas-welcome {
  position: absolute;
  top: 18%;
  left: 8%;
  right: 8%;
  color: var(--muted);
  pointer-events: none;
}
.canvas-welcome[hidden] {
  display: none;
}
.canvas-welcome h2 {
  font-size: clamp(15px, 2vw, 22px);
  color: #53667e;
  margin: 0 0 12px;
  font-weight: 500;
}
.canvas-welcome p {
  max-width: 330px;
  font-size: 12px;
  line-height: 1.6;
}
.canvas-welcome > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.canvas-welcome button {
  pointer-events: auto;
}
#graph-canvas {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.graph-viewport.wire-mode,
.graph-viewport[data-mode="wire"] {
  cursor: crosshair;
}
.graph-viewport.pan-mode,
.graph-viewport[data-mode="pan"] {
  cursor: grab;
}
.graph-viewport.is-panning,
.graph-viewport.panning {
  cursor: grabbing;
}
.graph-viewport.placing,
.graph-viewport.placing-mode,
.graph-viewport[data-mode="place"] {
  cursor: crosshair;
}
.graph-node {
  cursor: move;
}
.graph-node .node-body {
  fill: #fff;
  stroke: #7e8c9f;
  stroke-width: 1.5;
}
.node-title {
  fill: #314158;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}
.node-label {
  fill: #697d96;
  stroke: var(--canvas);
  stroke-width: 3px;
  stroke-linejoin: round;
  paint-order: stroke fill;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
}
.output-value {
  fill: var(--accent);
  stroke: var(--canvas);
  stroke-width: 3px;
  paint-order: stroke fill;
  font:
    650 17px ui-monospace,
    "SFMono-Regular",
    monospace;
  pointer-events: none;
}
.graph-node.input .node-body,
.graph-node.output .node-body {
  fill: #fcfdff;
}
.graph-node.error .node-body {
  fill: #fffafb;
  stroke: #d29aa2;
}
.graph-node.error .node-title {
  fill: var(--red);
}
.graph-node.box .node-body {
  fill: #fcfaff;
  stroke: #a38ac3;
}
.graph-node.box .node-title {
  fill: var(--purple);
}
.graph-node.selected .node-body {
  stroke: var(--accent);
  stroke-width: 2;
  filter: drop-shadow(0 0 3px #2563eb30);
}
.graph-node.selected .node-title {
  fill: #2458b9;
}
.port {
  fill: #fff;
  stroke: #778aa2;
  stroke-width: 1.6;
  cursor: crosshair;
  pointer-events: all;
}
.port.connected {
  fill: #7089a9;
  stroke: #fff;
  stroke-width: 1.5;
}
.port:hover,
.port.active,
.port.connecting,
.connecting .port,
.port:has(+ .port-hit:hover),
.port:has(+ .port-hit:focus-visible) {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
  filter: drop-shadow(0 0 3px #2563eb99);
}
.port.invalid {
  fill: var(--red);
  stroke: #fff;
}
.port-hit {
  fill: transparent;
  stroke: transparent;
  cursor: crosshair;
  pointer-events: all;
}
.node-menu {
  position: fixed;
  z-index: 90;
  width: 260px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 30px #172b4d24;
  font-size: 13px;
}
.node-menu-heading,
.node-menu > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.node-menu-heading > button {
  padding: 2px 8px;
  font-size: 20px;
}
.node-menu button {
  min-height: 34px;
  border: 1px solid #d9e1eb;
  border-radius: 5px;
  background: #fff;
  color: #314158;
  cursor: pointer;
}
.node-menu > button {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  text-align: left;
}
.node-menu button:hover,
.node-menu button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #eef4ff;
}
.node-menu button:focus-visible,
.spacing-handle:focus-visible rect {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.node-menu span,
.node-menu p {
  color: #697d96;
  font-size: 12px;
}
.node-menu-label {
  display: block;
  margin: 12px 0 6px;
}
.node-menu-options {
  display: flex;
  gap: 6px;
}
.node-menu-options button {
  flex: 1;
  font-size: 15px;
}
.node-menu .pauli-options button {
  color: var(--red);
  border-color: #e7bfc4;
  background: #fff8f8;
}
.spacing-handle {
  cursor: ns-resize;
  stroke: var(--accent);
  stroke-width: 1.4;
  fill: none;
  outline: none;
}
.spacing-handle rect {
  fill: #f2f7ff;
  stroke: #a8c4ed;
}
.spacing-handle:hover rect,
.spacing-handle:focus-visible rect {
  stroke: var(--accent);
}
.spacing-guide {
  stroke-dasharray: 2 2;
  opacity: 0.6;
}
.measurement-readout {
  pointer-events: none;
}
.measurement-readout rect {
  fill: #f2f7ff;
  stroke: #b5c9e4;
  stroke-width: 1;
}
.classical-readout-wire {
  stroke: #6b87ae;
  stroke-width: 1;
  fill: none;
}
.measurement-readout .output-value {
  font-size: 12px;
  stroke: none;
}
.graph-edge {
  fill: none;
  stroke: #657b96;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.graph-edge.selected {
  stroke: var(--accent);
  stroke-width: 3;
}
.graph-edge.active {
  stroke: var(--green);
  stroke-width: 2.5;
}
.graph-edge.invalid {
  stroke: var(--red);
  stroke-dasharray: 5 4;
}
.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  cursor: pointer;
  pointer-events: stroke;
}
.edge-hit:hover + .graph-edge {
  stroke: var(--accent);
}
.wire-preview {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 5 4;
  pointer-events: none;
}
.wire-preview.invalid {
  stroke: var(--red);
}
.wire-bend {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.5;
  cursor: move;
}
.wire-bend:hover {
  fill: var(--accent-soft);
  stroke-width: 2;
}
.selection-rect {
  fill: #2563eb0d;
  stroke: #4b85f6;
  stroke-width: 1;
  stroke-dasharray: 4 3;
  pointer-events: none;
}
.graph-node.placement-ghost {
  opacity: 0.5;
  pointer-events: none;
}
#interaction-preview,
#interaction-preview * {
  pointer-events: none !important;
}
.canvas-empty,
.canvas-empty-state {
  fill: #8794a6;
  color: #8794a6;
  font-family: inherit;
  text-align: center;
  pointer-events: none;
}
.canvas-empty > text {
  fill: #61738c;
  font-size: 21px;
  font-weight: 550;
}
.canvas-empty .empty-caption {
  fill: #91a0b3;
  font-size: 12px;
  font-weight: 400;
}
.canvas-empty-title {
  fill: #52647e;
  font-size: 20px;
  font-weight: 550;
}
.canvas-empty-description {
  fill: #99a3b1;
  font-size: 12px;
}

.properties-drawer {
  z-index: 12;
  flex: 0 0 34px;
  width: 34px;
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: thin;
}
.properties-drawer[open] {
  flex-basis: var(--inspector-width);
  width: var(--inspector-width);
}
.properties-drawer > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  min-height: 41px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 550;
}
.properties-drawer:not([open]) > summary {
  justify-content: flex-start;
  width: 33px;
  padding: 14px 9px;
  writing-mode: vertical-rl;
}
.properties-drawer[open] > summary .drawer-chevron {
  transform: rotate(180deg);
}
.drawer-chevron {
  color: #919baa;
  font-size: 16px;
  font-weight: 400;
}
.inspector-content {
  min-width: 0;
  padding: 16px;
}
.inspector-empty {
  padding: 20px 0 24px;
  color: var(--muted);
  text-align: center;
}
.inspector-empty > svg {
  width: 40px;
  height: 40px;
  margin: 0 auto 17px;
  stroke: #a8b4c4;
  stroke-width: 1.3;
}
.inspector-empty h2,
.inspector-empty h3 {
  margin: 0;
  color: #647286;
  font-size: 12px;
  font-weight: 550;
}
.inspector-empty p {
  margin: 9px auto 0;
  max-width: 180px;
  color: #95a0ae;
  font-size: 11px;
  line-height: 1.7;
}
.inspector-content h2,
.inspector-content h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
}
.inspector-content p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.properties-guide {
  margin: 4px 16px 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.properties-guide strong {
  color: #8b96a6;
  font-size: 10px;
  font-weight: 550;
}
.properties-guide p {
  margin: 7px 0 0;
  color: #a0a9b5;
  font-size: 10px;
  line-height: 1.7;
}
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.field > span,
.field > label {
  color: #7e8b9d;
  font-size: 10px;
  font-weight: 550;
}
.field input,
.field select,
.field textarea,
.inspector-content input:not([type="checkbox"]),
.inspector-content select,
.inspector-content textarea {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  font-size: 11px;
}
.field textarea {
  resize: vertical;
}
.property-list {
  display: grid;
  margin: 0 0 14px;
  padding: 0;
}
.property-row {
  display: grid;
  grid-template-columns: 1fr minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #eef1f5;
  font-size: 11px;
}
.property-row dt {
  color: #8793a3;
}
.property-row dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}
.property-row > span {
  color: #8793a3;
}
.property-row > strong {
  text-align: right;
  font-weight: 550;
}
.inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}
.inspector-content .document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.inspector-content h4 {
  margin: 21px 0 10px;
  color: #718198;
  font-size: 11px;
  font-weight: 600;
}
.inspector-content .button {
  font-size: 11px;
}

.results-panel {
  z-index: 15;
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: #fff;
}
.results-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 15px;
  color: #728095;
  font-size: 10px;
  font-weight: 550;
}
.results-panel > summary > span:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
}
.results-panel > summary svg {
  width: 14px;
  height: 14px;
  stroke: #8b9bb1;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.results-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}
.results-panel[open] .drawer-chevron {
  transform: rotate(180deg);
}
.results-content {
  max-height: 33vh;
  padding: 17px;
  overflow: auto;
  font-size: 12px;
}
.results-content h2,
.results-content h3 {
  margin: 0 0 10px;
  font-size: 13px;
}
.results-content p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.6;
}
.empty-state {
  padding: 7px 0;
  color: var(--muted);
  font-size: 11px;
}
.empty-state strong {
  color: #697b91;
  font-size: 12px;
  font-weight: 550;
}
.empty-state p {
  margin: 7px 0 0;
  color: #97a1af;
  font-size: 11px;
}
.result-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.result-summary code {
  overflow-wrap: anywhere;
}
.trace-legend {
  color: var(--red);
  font-size: 11px;
}
.trace-diagram-scroll {
  margin: 12px 0;
  overflow: auto;
  max-height: 24vh;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
.trace-diagram-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.trace-circuit {
  display: block;
  min-width: 100%;
  max-width: none;
}
.trace-edge {
  fill: none;
  stroke: #16191e;
  stroke-width: 1.25;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.trace-wire-label {
  fill: #627083;
  font:
    11px Inter,
    sans-serif;
}
.trace-node .node-title {
  font-size: 11px;
  font-weight: 550;
  fill: #647083;
}
.trace-details > summary {
  width: fit-content;
  padding: 4px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}
.results-content .trace-record-flips {
  color: var(--red);
}
.trace-record-flips span {
  white-space: nowrap;
}
.trace-navigation {
  margin: 14px 0 8px;
}
.trace-navigation input[type="range"] {
  padding: 0;
  min-height: 20px;
  border: 0;
  accent-color: var(--accent);
}
.trace-transition {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}
.trace-transition > span {
  color: var(--muted);
  font-size: 10px;
}
.trace-transition code {
  max-width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--sidebar);
  font:
    600 14px/1.5 ui-monospace,
    monospace;
  overflow-wrap: anywhere;
}
.result-bits {
  color: var(--accent);
  font:
    600 23px/1.4 ui-monospace,
    "SFMono-Regular",
    monospace;
  letter-spacing: 0.09em;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.result-wire {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 4px 7px 4px 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.results-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: left;
}
.results-content th,
.results-content td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.results-content th {
  color: #7c8898;
  font-weight: 550;
}
.results-content pre,
.inspector-content pre {
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--sidebar);
  font:
    11px/1.6 ui-monospace,
    monospace;
  overflow: auto;
}
.error,
.result-error {
  color: var(--red);
}
.success,
.result-success {
  color: var(--green);
}

.statusbar {
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 0 9px 0 15px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: #8e98a6;
  font-size: 10px;
}
#selected-tool-note {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #77859a;
}
.keyboard-help {
  display: flex;
  align-items: center;
  gap: 13px;
  flex: 0 0 auto;
}
.keyboard-help > span {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  white-space: nowrap;
}
kbd {
  padding: 1px 4px;
  border: 1px solid #e4e8ee;
  border-radius: 3px;
  background: #f8f9fb;
  color: #8c98a8;
  font-family: inherit;
  font-size: 8px;
}
.zoom-controls {
  gap: 1px;
  height: 100%;
  margin-left: 1px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.zoom-controls .icon-button {
  width: 26px;
  height: 27px;
  font-size: 16px;
}
.zoom-controls .chrome-button {
  min-height: 26px;
  padding: 0 7px;
  color: #728097;
  font-size: 10px;
}
#zoom-value {
  min-width: 40px;
  text-align: center;
  font-size: 10px;
}
.toast {
  position: fixed;
  z-index: 100;
  bottom: 48px;
  left: 50%;
  max-width: min(460px, calc(100vw - 28px));
  padding: 11px 15px;
  border: 1px solid #2f435d;
  border-radius: 7px;
  background: #2c3b4f;
  color: #fff;
  box-shadow: 0 5px 20px #23354b20;
  font-size: 12px;
  line-height: 1.5;
  transform: translateX(-50%);
}
.toast.error {
  border-color: #a7434d;
  background: #ad4752;
  color: #fff;
}
.noscript-message {
  position: fixed;
  z-index: 200;
  inset: auto 16px 50px;
  padding: 16px;
  border-radius: 7px;
  background: var(--red);
  color: #fff;
  text-align: center;
}

@media (max-width: 1250px) {
  :root {
    --sidebar-width: 202px;
    --inspector-width: 214px;
  }
  .brand {
    flex-basis: 173px;
  }
  .studio-header {
    gap: 8px;
  }
  .server-status {
    display: none;
  }
  .keyboard-help {
    gap: 9px;
  }
  .keyboard-help > span:last-child {
    display: none;
  }
  .library-header {
    padding-right: 12px;
    padding-left: 12px;
  }
  .library-scroll {
    padding-right: 12px;
    padding-left: 12px;
  }
  .gate-palette {
    gap: 5px;
  }
  .library-footer {
    margin-right: 12px;
    margin-left: 12px;
  }
}
@media (max-width: 1050px) {
  :root {
    --sidebar-width: 184px;
    --inspector-width: 204px;
  }
  .brand {
    flex-basis: 155px;
    font-size: 12px;
  }
  .brand-mark {
    width: 28px;
    height: 28px;
  }
  .properties-drawer {
    position: absolute;
    top: 56px;
    right: 0;
    bottom: 36px;
    width: 33px;
  }
  .properties-drawer[open] {
    width: var(--inspector-width);
    box-shadow: -5px 0 16px #1d304912;
  }
  .canvas-area {
    margin-right: 33px;
  }
  .library-count {
    display: none;
  }
  .keyboard-help {
    display: none;
  }
  .library-instruction {
    font-size: 9px;
  }
  .gate-card {
    min-height: 59px;
  }
  .gate-symbol {
    width: 34px;
  }
  .gate-card strong {
    font-size: 10px;
  }
  #graph-counts {
    font-size: 9px;
  }
}
@media (max-width: 720px) {
  body {
    grid-template-rows: 52px minmax(0, 1fr) 38px;
  }
  .studio-header {
    gap: 5px;
    padding: 0 8px;
  }
  .brand {
    flex: 0 0 auto;
  }
  .brand > span {
    display: none;
  }
  .brand-mark {
    width: 28px;
    height: 28px;
  }
  .file-menu .chrome-button {
    min-height: 36px;
    padding: 0 7px;
  }
  .file-popover {
    left: -31px;
  }
  .document-title input {
    height: 34px;
    padding: 0 6px;
    font-size: 11px;
  }
  .history-actions {
    gap: 0;
    padding-right: 4px;
  }
  .history-actions .icon-button {
    width: 27px;
  }
  .run-actions {
    gap: 4px;
    margin: 0;
  }
  .run-actions select {
    max-width: 79px;
    padding: 0 2px 0 5px;
    font-size: 10px;
  }
  .run-actions .button {
    gap: 3px;
    padding: 0 9px;
  }
  .workbench {
    position: relative;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    grid-template-rows: 131px minmax(0, 1fr);
  }
  .workbench.library-collapsed {
    grid-template-rows: 0 minmax(0, 1fr);
  }
  .component-library {
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 119px minmax(0, 1fr);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .library-header {
    padding: 13px 10px;
    border-right: 1px solid var(--line);
  }
  .library-heading h1 {
    font-size: 11px;
  }
  .search-field {
    margin-top: 10px;
  }
  .search-field input {
    height: 31px;
    padding-left: 24px;
    font-size: 9px;
  }
  .search-field svg {
    top: 9px;
    left: 7px;
    width: 13px;
    height: 13px;
  }
  .library-instruction {
    margin-top: 7px;
    font-size: 8px;
    line-height: 1.6;
  }
  .library-scroll {
    display: flex;
    gap: 17px;
    min-width: 0;
    padding: 11px 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  #gate-groups {
    display: flex;
    gap: 17px;
  }
  .palette-group {
    flex: 0 0 auto;
    margin-top: 0;
  }
  .group-label {
    margin-bottom: 9px;
  }
  .group-label h2,
  .group-label h3 {
    font-size: 9px;
  }
  .group-label > span {
    display: none;
  }
  .gate-palette {
    display: flex;
    gap: 6px;
  }
  .gate-card {
    flex: 0 0 54px;
    width: 54px;
    height: 67px;
    min-height: 67px;
  }
  .palette-note {
    width: 165px;
    margin: 0;
    font-size: 10px;
  }
  .library-footer {
    display: none;
  }
  .drawing-tools {
    grid-column: 1;
    grid-row: 2;
    gap: 3px;
    padding: 7px 3px;
    overflow-y: auto;
  }
  .tool-button {
    min-height: 58px;
    padding: 7px 0;
  }
  .tool-button > span {
    font-size: 7px;
  }
  .tool-button svg {
    width: 20px;
    height: 20px;
  }
  .tool-button kbd {
    display: none;
  }
  .tool-divider {
    margin: 4px;
  }
  .canvas-area {
    grid-column: 2;
    grid-row: 2;
    margin-right: 0;
  }
  .canvas-empty {
    transform: translate(-72px, -40px);
  }
  .canvas-empty > text {
    font-size: 18px;
  }
  .canvas-empty .empty-caption {
    font-size: 10px;
  }
  .canvas-topbar {
    gap: 7px;
    flex-basis: 37px;
    padding: 0 42px 0 10px;
  }
  .canvas-title {
    gap: 5px;
  }
  .canvas-title strong {
    font-size: 10px;
  }
  .canvas-indicator {
    display: none;
  }
  #graph-counts {
    margin-left: 0;
    max-width: 135px;
    font-size: 8px;
  }
  .level-field {
    gap: 4px;
    font-size: 9px;
  }
  .level-field select {
    width: 43px;
    font-size: 9px;
  }
  .properties-drawer,
  .properties-drawer[open] {
    position: absolute;
    top: 131px;
    bottom: auto;
    right: 0;
    width: 35px;
    max-height: calc(100% - 131px);
    border-left: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .library-collapsed .properties-drawer {
    top: 0;
  }
  .properties-drawer > summary,
  .properties-drawer:not([open]) > summary {
    display: flex;
    justify-content: center;
    min-height: 36px;
    width: 34px;
    padding: 0;
    writing-mode: horizontal-tb;
    border-bottom: 0;
  }
  .properties-drawer > summary > span:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .properties-drawer > summary .drawer-chevron {
    display: none;
  }
  .properties-drawer > summary::after {
    content: "☷";
    color: #8492a5;
    font-size: 19px;
  }
  .properties-drawer[open] {
    width: min(260px, calc(100vw - 69px));
    background: #fff;
    box-shadow: -4px 5px 18px #1d304919;
  }
  .properties-drawer[open] > summary {
    justify-content: space-between;
    width: 100%;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
  }
  .properties-drawer[open] > summary > span:first-child {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
  }
  .properties-drawer[open] > summary::after {
    content: "×";
  }
  .properties-guide {
    display: none;
  }
  .inspector-content {
    padding: 13px;
  }
  .results-panel > summary {
    min-height: 33px;
    padding: 0 10px;
  }
  .results-content {
    max-height: 30vh;
    padding: 12px;
  }
  .statusbar {
    gap: 7px;
    padding: 0 5px 0 10px;
  }
  #selected-tool-note {
    font-size: 9px;
  }
  .zoom-controls {
    gap: 0;
    padding-left: 4px;
  }
  .zoom-controls .icon-button {
    width: 28px;
    height: 33px;
  }
  .zoom-controls .chrome-button {
    min-height: 33px;
    padding: 0 6px;
  }
  #zoom-value {
    min-width: 35px;
    font-size: 9px;
  }
}
@media (max-width: 440px) {
  .history-actions {
    display: none;
  }
  .drawing-tools .mobile-history {
    display: flex;
  }
  .component-library {
    grid-template-columns: 102px minmax(0, 1fr);
  }
  .library-header {
    padding-right: 8px;
    padding-left: 8px;
  }
  .library-instruction {
    font-size: 8px;
  }
  #graph-counts {
    max-width: 107px;
  }
  .level-field > span {
    display: none;
  }
  .canvas-topbar {
    gap: 4px;
  }
  .run-actions select {
    max-width: 72px;
  }
}
@media (max-height: 610px) and (min-width: 721px) {
  .library-footer {
    display: none;
  }
  .tool-button {
    min-height: 52px;
  }
  .properties-guide {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Mathematical glyphs and circuit geometry follow quantikz's gate/ctrl/targ,
   swap/targX, meter and ket notation. Both render surfaces use this style. */
@font-face {
  font-family: "QEC Circuit Math";
  src: url("./fonts/qec-circuit-math.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
.quantikz-circuit {
  color: #16191e;
  pointer-events: none;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.quantikz-circuit .q-label {
  fill: currentColor;
  stroke: none;
  font:
    400 18px "QEC Circuit Math",
    "Cambria Math",
    serif;
  text-anchor: middle;
}
.quantikz-circuit .q-ket {
  font-size: 19px;
}
.q-gate,
.q-state-mask {
  fill: #fff;
}
.q-state-mask {
  stroke: none;
}
.q-control-dot,
.q-meter-arrow {
  fill: currentColor;
  stroke: none;
}
.q-target-circle {
  fill: #fff;
}
.q-output {
  fill: #627083;
  stroke: none;
  font:
    11px Inter,
    sans-serif;
}
.component-diagram {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-width: 0;
  pointer-events: none;
}
.gate-card .gate-symbol {
  width: 100%;
  height: auto;
  max-height: 58px;
  overflow: visible;
}
.gate-card.basic-card {
  min-height: 104px;
  padding: 10px 7px;
  gap: 5px;
}
.gate-card.basic-card .component-diagram {
  flex: 1 1 auto;
}
.gate-card.composite-card {
  grid-column: 1 / -1;
  min-height: 100px;
  padding: 12px 12px 9px;
  gap: 7px;
}
.gate-card.composite-card .gate-symbol {
  max-height: none;
}
.gate-card.composite-card strong {
  font-size: 12px;
}
.gate-card strong {
  white-space: normal;
  text-align: center;
}
.graph-node .node-body {
  fill: transparent;
  stroke: transparent;
  pointer-events: all;
}
.graph-node.composite-node .node-body {
  fill: transparent;
  stroke: transparent;
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
.graph-node.input .node-body,
.graph-node.output .node-body,
.graph-node.error .node-body {
  fill: transparent;
  stroke: transparent;
}
.graph-node.box .node-body {
  fill: transparent;
  stroke: transparent;
}
.q-group {
  pointer-events: none;
}
.q-group-frame {
  fill: #dceaff80;
  stroke: #7899c8;
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
.q-group-label {
  fill: #526c91;
  stroke: var(--canvas);
  stroke-width: 3px;
  paint-order: stroke fill;
  font-family: inherit;
  font-size: 10px;
  font-variant: small-caps;
}
.graph-node:hover .node-body {
  fill: #ffffff70;
  stroke: #c1cada;
  stroke-dasharray: 3 3;
}
.graph-node.selected .node-body {
  fill: #f8faff;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
  filter: none;
}
.graph-node .node-title {
  font-size: 11px;
  font-weight: 550;
  fill: #647083;
}
.graph-node.error .quantikz-circuit {
  color: var(--red);
}
.graph-node.error .q-gate {
  fill: #fff8f8;
}
.trace-final-error .quantikz-circuit {
  color: var(--red);
}
.trace-output .q-wire {
  stroke: #16191e;
}
.trace-final-error .q-gate {
  fill: #fff8f8;
}
.graph-edge {
  stroke: #16191e;
  stroke-width: 1.25;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.port {
  stroke: #7c8da3;
  stroke-width: 1.2;
}
.port.connected {
  fill: #fff;
  stroke: #6b7f99;
  opacity: 0;
}
.graph-node:hover .port,
.graph-node.selected .port,
.port.connecting,
.port:has(+ .port-hit:focus-visible),
.graph-viewport.wire-mode .port {
  opacity: 1;
}
.inspector-circuit {
  overflow-x: auto;
  padding: 8px 0 10px;
}
.inspector-circuit .detail-symbol {
  width: 100%;
  min-width: 160px;
  height: auto;
  max-height: 220px;
}
.decomposition-caption {
  margin: 0 0 18px !important;
  font-size: 10px !important;
}
@media (max-width: 1100px) and (min-width: 721px) {
  :root {
    --sidebar-width: 260px;
  }
  .brand {
    flex-basis: 231px;
  }
}
@media (max-width: 720px) {
  .gate-card.basic-card {
    flex-basis: 70px;
    width: 70px;
    height: 82px;
    min-height: 82px;
    padding: 6px;
  }
  .gate-card.composite-card {
    flex-basis: 235px;
    width: 235px;
    height: 82px;
    min-height: 82px;
    padding: 5px 8px;
    gap: 2px;
  }
  .gate-card.composite-card .component-diagram {
    min-height: 0;
    flex: 1 1 auto;
  }
  .gate-card.composite-card .gate-symbol {
    max-height: 48px;
  }
  .gate-card.composite-card strong {
    font-size: 10px;
  }
  .gate-card.composite-card small {
    font-size: 8px;
  }
}

/* Editable group layers and actionable circuit validation. */
.group-layer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid #ccdce6;
  background: #f3f8fb;
  flex: 0 0 auto;
  min-width: 0;
}
.group-layer-context {
  min-width: 0;
}
.group-layer-context > span {
  color: #667588;
  font-size: 11px;
}
#group-layer-path {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  max-width: 100%;
  padding-bottom: 3px;
}
#group-layer-path button {
  border: 0;
  padding: 2px 0;
  background: none;
  color: #235573;
  font-size: 12px;
  cursor: pointer;
}
#group-layer-path button:hover {
  text-decoration: underline;
}
#group-layer-path strong {
  font-size: 12px;
}
#group-layer-path > span {
  color: #9ba9b5;
}
.group-layer-actions,
.warning-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.group-layer-actions .button,
.warning-actions .button {
  min-height: 30px;
  padding: 4px 9px;
}
.circuit-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 10px 14px;
  background: #fff5f2;
  border-bottom: 1px solid #efc4b7;
  color: #873b2b;
  font-size: 12px;
}
.circuit-warning p {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}
.graph-node.has-issue > .node-body {
  stroke: #cd4f36;
  stroke-width: 2;
  fill: #fff6f0;
}
.graph-edge.has-issue,
.port.has-issue {
  stroke: #cd4f36;
  stroke-width: 3;
}
.port.has-issue {
  fill: #ffe0d7;
  opacity: 1;
}
.group-boundary .node-label {
  fill: #456a80;
  font-size: 12px;
}
.group-layer-bar[hidden],
.circuit-warning[hidden] {
  display: none;
}
@media (max-width: 700px) {
  .group-layer-bar {
    gap: 8px;
    padding: 7px 9px;
  }
  .group-layer-context > span {
    display: none;
  }
  .circuit-warning {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 7px;
    padding: 8px 10px;
  }
}

.palette-empty {
  padding: 14px;
  color: #68778b;
  font-size: 12px;
}
.palette-empty p {
  overflow-wrap: anywhere;
}
.error-preview .quantikz-circuit {
  color: var(--red);
}
.error-preview .q-gate {
  fill: #fff8f8;
}
.library-footer[hidden],
.palette-empty[hidden],
.palette-group[hidden],
.gate-card[hidden] {
  display: none;
}

.trace-show-outputs {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  min-height: 28px;
}
.trace-show-outputs[hidden] {
  display: none;
}

.group-dialog {
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid #cbd5df;
  border-radius: 10px;
  box-shadow: 0 18px 70px #17233430;
}
.group-dialog::backdrop {
  background: #18243750;
}
.group-dialog h2 {
  margin: 0 0 10px;
  font-size: 18px;
}
.group-dialog p {
  color: #617085;
  font-size: 13px;
  line-height: 1.5;
}
.group-dialog .error {
  color: #a54130;
}
.group-dialog input {
  width: 100%;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid #becbd7;
  border-radius: 4px;
  font: inherit;
}
.group-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.gate-card.composite-card .component-diagram {
  max-height: 130px;
  overflow: hidden;
}
.gate-card.composite-card .gate-symbol {
  max-height: 126px;
  width: 100%;
}
.terminal-label {
  fill: #516277;
}
