/* Protocol Builder: light, Scratch-style block editor.
   All text uses a terminal-style monospace font. */

:root {
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #ffffff;
  --ink: #2f3542;
  --block-ink: #575e75;
  --muted: #8b93a3;
  --line: #e6e9f0;
  --soft: #f6f8fb;
  --blue: #4c97ff;
  --blue-d: #3373cc;
  --red: #e5484d;
  --amber: #f5a524;
  --green: #59c059;
  --select: #1f6fe5;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 var(--mono);
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.95em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

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

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--soft); border-color: #d6dbe5; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.icon { padding: 6px 9px; font-size: 15px; line-height: 1; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.primary { background: var(--blue); border-color: var(--blue-d); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #3d8bf5; border-color: var(--blue-d); }
.btn.danger { color: var(--red); border-color: #f3c4c6; }
.btn.danger:hover { background: #fff3f3; }
a.btn { display: inline-block; text-decoration: none; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* on a narrow window the buttons wrap rather than being cut off */
  gap: 8px 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
}
.topbar .btn { padding: 6px 9px; }
.topbar-right { display: flex; gap: 6px; margin-left: auto; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 14px; white-space: nowrap; color: inherit; text-decoration: none; border-radius: 8px; }
a.brand:hover .logo { transform: rotate(-8deg); }
a.brand:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.logo { transition: transform 0.15s; }
.brand b { font-weight: 700; color: var(--blue-d); }
.logo { display: inline-block; width: 20px; height: 20px; flex-shrink: 0; background: url(/protocols/favicon.svg) center / contain no-repeat; }
.logo i { display: none; }
.project-name {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 9px;
  min-width: 90px;
  flex: 0 1 240px;
  font-weight: 600;
  text-overflow: ellipsis;
}
.project-name:hover { border-color: var(--line); }
.project-name:focus { outline: none; border-color: var(--blue); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.actions .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* The builder's top bar lines up with the panels below it: the logo and the
   protocol's name over the blocks list, the buttons starting at the divider
   between the blocks and the sandbox, Export and the account on the right. */
:root { --blocks-w: calc(72px + var(--palette-w) + 1px); } /* the category column + the blocks list + its border */
.builder-top {
  display: grid;
  grid-template-columns: calc(var(--blocks-w) - 16px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0;
  padding: 8px 16px;
}
.brand-row { display: flex; align-items: center; gap: 8px; min-width: 0; padding-right: 16px; }
.builder-top .project-name { flex: 1 1 auto; min-width: 0; max-width: 320px; }
.builder-top .actions { gap: 6px; }
.builder-top .topbar-right { gap: 14px; align-items: center; }
#btn-export.has-errors { background: #fff; color: var(--blue-d); }

/* save status next to the project name */
.save-status {
  border: 0;
  background: none;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  cursor: default;
}
.save-status[data-state="local"],
.save-status[data-state="demo"],
.save-status[data-state="retrying"],
.save-status[data-state="signed-out"],
.save-status[data-state="error"] { cursor: pointer; }
.save-status[data-state="local"]:hover { background: var(--soft); color: var(--ink); }
.save-status[data-state="retrying"],
.save-status[data-state="signed-out"] { color: #b7791f; background: #fff8eb; }
.save-status[data-state="demo"] { color: var(--blue-d); background: #eef5ff; font-weight: 600; }
.save-status[data-state="demo"]:hover { background: #e0edff; }
.save-status[data-state="conflict"],
.save-status[data-state="error"] { color: var(--red); background: #fff3f3; }

/* account button (round initials) and its menu */
.account-slot { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--av, var(--blue));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line);
}
.avatar:hover { filter: brightness(1.06); box-shadow: 0 0 0 2px #fff, 0 0 0 3px #cfd5df; }
.avatar.small { width: 30px; height: 30px; font-size: 11px; box-shadow: none; cursor: default; }
.avatar.large { width: 56px; height: 56px; font-size: 18px; cursor: default; }
.account-menu { min-width: 240px; }
.account-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: inherit; text-decoration: none; }
.account-menu a:hover { background: var(--soft); }
.account-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.account-who { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.account-who > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.account-who b, .account-who .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-note { font-size: 11px; color: var(--muted); padding: 6px 10px 4px; }

/* Block Help card, next to the palette */
.help-card {
  position: fixed;
  z-index: 1400;
  width: 290px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(30, 40, 60, 0.16);
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}
.help-card p { margin: 6px 0 8px; }
.help-cat { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); }
.help-cat i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.help-title { font-weight: 700; font-size: 13px; margin-top: 2px; }

/* ---------- layout ---------- */

/* the blocks list and the right-hand panel can be resized by dragging the
   dividers (js/ui/resize.js sets these; the sizes here are the defaults) */
:root { --palette-w: 340px; --side-w: 380px; }
.layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) var(--side-w);
  min-height: 0;
}
.resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 20;
  width: 9px;
  cursor: col-resize;
  touch-action: none;
}
.resize-handle::after { /* a blue line on hover and while dragging */
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: transparent;
  transition: background 0.15s, box-shadow 0.15s;
}
.resize-handle:hover::after, body.resizing .resize-handle.active::after { background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.resize-handle.resize-palette { right: -5px; }
.resize-handle.resize-side { left: -5px; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }

#palette-area {
  position: relative;
  display: flex;
  min-height: 0;
  border-right: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
}
#palette-area input { user-select: text; }

.rail-col {
  width: 72px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
#rail {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  min-height: 0;
  overflow-y: auto;
}

/* Examples, Tour and Block Help, under the categories */
.rail-tools { flex: none; display: flex; flex-direction: column; border-top: 1px solid var(--line); padding: 6px 0 8px; }
.cat .tool-icon {
  display: grid;
  place-items: center;
  background: #fff;
  border-color: #d5dae3;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.tool-icon svg { width: 11px; height: 11px; fill: currentColor; }
.cat.tool:hover .tool-icon { border-color: var(--blue); color: var(--blue-d); transform: scale(1.08); }
.help-toggle.on { color: var(--blue-d); font-weight: 600; }
.help-toggle.on .tool-icon { background: var(--blue); border-color: var(--blue-d); color: #fff; }
.rail-tip {
  position: fixed;
  z-index: 1400;
  width: 230px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(30, 40, 60, 0.16);
  padding: 9px 12px;
  font-size: 11.5px;
  line-height: 1.5;
  pointer-events: none;
  animation: tip-in 0.15s ease both;
}
.rail-tip b { display: block; font-size: 12px; margin-bottom: 2px; }
.rail-tip::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 14px;
  width: 8px;
  height: 8px;
  background: #fff;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
@keyframes tip-in { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 2px;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 10.5px;
  color: var(--muted);
}
.cat:hover { color: var(--ink); }
.cat.active { color: var(--ink); background: var(--soft); }
.cat .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid;
}
.cat.active .dot { box-shadow: 0 0 0 3px #fff, 0 0 0 4px #cfd5df; }

#palette {
  width: var(--palette-w);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 12px 24px;
}
#palette section { padding-top: 6px; }
.pal-search {
  position: sticky;
  top: -6px;
  z-index: 4;
  background: #fff;
  padding: 8px 0 6px;
  margin-top: -6px;
}
.pal-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--soft);
  font-size: 12px;
}
.pal-search input:focus { outline: none; border-color: var(--blue); background: #fff; }
#rail.searching .cat { opacity: 0.45; }
#palette h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  margin: 14px 0 10px;
}
#palette h3 .dot { width: 10px; height: 10px; border-radius: 50%; }
.pal-item { margin: 0 0 12px; zoom: 0.8; }
.pal-item span.f-text {
  display: inline-block;
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 24px;
}
.pal-note { color: var(--muted); font-size: 11.5px; margin: 4px 0 12px; }
.var-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.var-tools .pal-note { flex-basis: 100%; }
.var-chip {
  display: inline-flex;
  align-items: center;
  background: #ff6680;
  border: 1px solid #ff3355;
  border-radius: 999px;
  color: #fff;
  overflow: hidden;
}
.var-chip button { background: none; border: 0; color: #fff; cursor: pointer; padding: 3px 4px 3px 10px; }
.var-chip .var-del { padding: 3px 9px 3px 4px; opacity: 0.8; }
.var-chip .var-del:hover { opacity: 1; }

/* ---------- workspace ---------- */

.ws-wrap { position: relative; min-width: 0; min-height: 0; }
#workspace {
  position: absolute;
  inset: 0;
  overflow: auto;
  background-color: #fff;
  background-image: radial-gradient(#dfe3eb 1px, transparent 1.2px);
  background-size: 24px 24px;
}
.ws-sizer { position: relative; }
.ws-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.ws-hint {
  position: absolute;
  z-index: 0; /* blocks (z-index 1 and up) always cover it */
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.ws-zoom {
  position: absolute;
  /* stay clear of the workspace scrollbars (their size is set from JS) */
  right: calc(20px + var(--scrollbar-w, 0px));
  bottom: calc(20px + var(--scrollbar-h, 0px));
  display: flex;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(40, 50, 70, 0.06);
}
.ws-zoom button {
  border: 0;
  background: none;
  border-radius: 6px;
  min-width: 30px;
  height: 28px;
  cursor: pointer;
  font-size: 12px;
}
.ws-zoom button:hover { background: var(--soft); }
.stack {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* ---------- blocks ---------- */

.block {
  position: relative;
  z-index: 1; /* each block is its own layer; js/ui/render.js layerStack() orders them */
  width: max-content;
  font: 600 12.5px/1 var(--mono);
  color: var(--ct, #fff);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}
/* --outline / --ow: the outline colour and width. Each block resets them, so a
   problem only outlines the block that has it, following its puzzle shape. */
.block { --outline: var(--cd); --ow: 1px; }
.block.has-error { --outline: var(--red); --ow: 2px; }
.block.has-warning { --outline: var(--amber); --ow: 2px; }
/* selected blocks: the block's own outline turns blue, so it follows the exact
   puzzle shape (notch, tab, loop arm) without changing the layout */
.block.selected { --outline: var(--select); --ow: 2px; }
/* two selected blocks touching: one blue line between them, not two */
.block.selected + .block.selected.face,
.block.selected + .block.selected > .c-head,
.block.selected > .c-mouth > .c-body > .block.selected:first-child.face,
.block.selected > .c-mouth > .c-body > .block.selected:first-child > .c-head { border-top-color: var(--c); }
.face {
  position: relative;
  background: var(--c);
  border: var(--ow) solid var(--outline);
  border-radius: 7px;
}
/* the puzzle tab under each block */
.face::after {
  content: "";
  position: absolute;
  left: 14px;
  bottom: -7px;
  width: 26px;
  height: 7px;
  background: var(--c);
  border: var(--ow) solid var(--outline);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  /* the block's colour reaching a little above the tab, between its side
     lines, so the block's bottom edge never shows as a faint line across it */
  box-shadow: 0 -3px 0 calc(-1 * var(--ow)) var(--c);
  z-index: 2;
}
/* the matching notch cut into the top of each block. The tab of the block above
   sits exactly over it, so it only shows when a block isn't connected. */
.shape-stack.face::before,
.c-head::before {
  content: "";
  position: absolute;
  /* 1px smaller than the tab on each side and at the bottom, so a connected
     tab always covers it completely, whatever pixel rounding the browser does */
  left: 15px;
  top: calc(-1 * var(--ow));
  width: 24px;
  height: calc(6px - var(--ow));
  background: #fff;
  border: var(--ow) solid var(--outline);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  /* white fill reaching 2px above the block, so the block's top border never
     peeks through the notch when zoomed (sub-pixel rounding). A connected block
     above is drawn on top (js/ui/render.js layerStack), so it hides that 2px. */
  box-shadow: 0 -2px 0 0 #fff;
  z-index: 1;
}
.shape-stack.face,
.shape-hat.face,
.c-head {
  /* 7px 10px 8px with a 1px outline; thicker outlines eat into the padding */
  padding: calc(8px - var(--ow)) calc(11px - var(--ow)) calc(9px - var(--ow));
  min-height: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
/* the start block: a normal-sized body (same spacing as every block) with a
   rounded cap sitting on top of its left side, like Scratch's hat blocks */
.shape-hat.face {
  min-width: 190px;
  margin-top: 18px;
  border-top-left-radius: 0;
}
.shape-hat.face::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--ow));
  top: calc(-18px - var(--ow));
  width: 120px;
  height: calc(18px + var(--ow));
  background: var(--c);
  border: var(--ow) solid var(--outline);
  border-bottom: 0;
  border-radius: 60px 60px 0 0 / 18px 18px 0 0;
  box-shadow: 0 2px 0 calc(-1 * var(--ow)) var(--c); /* no faint line where the cap meets the body */
}
.b-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 26px; }

/* C and E blocks (loops, if) */
.shape-c, .shape-e { display: flex; flex-direction: column; align-items: stretch; }
/* the inner edges of a C-block (where its mouth opens) are drawn as lines
   starting at the arm, so the outline follows the C shape */
/* a loop's top bar (and else bar) sits above the blocks inside, so its tab covers their notch */
.c-head, .c-mid { z-index: 10000; }
.c-head {
  border-radius: 7px 7px 0 0;
  border-bottom: 0;
  background:
    linear-gradient(var(--outline), var(--outline)) calc(16px - 2 * var(--ow)) 100% / 100% var(--ow) no-repeat,
    var(--c);
}
.c-head::after, .c-mid::after { left: 30px; }
.c-mouth { display: flex; }
.c-arm {
  width: 16px;
  flex: none;
  /* tucked 1px under the top bar and the bottom, so no faint seam shows
     where the pieces meet when zoomed */
  margin: -1px 0;
  background: var(--c);
  border-left: var(--ow) solid var(--outline);
  border-right: var(--ow) solid var(--outline);
}
.c-body {
  min-height: 30px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.c-mid {
  border-radius: 0;
  border-top: 0;
  border-bottom: 0;
  padding: calc(5px - var(--ow)) calc(11px - var(--ow));
  min-height: 30px;
  display: flex;
  align-items: center;
  background:
    linear-gradient(var(--outline), var(--outline)) calc(16px - 2 * var(--ow)) 0 / 100% var(--ow) no-repeat,
    linear-gradient(var(--outline), var(--outline)) calc(16px - 2 * var(--ow)) 100% / 100% var(--ow) no-repeat,
    var(--c);
}
.c-foot {
  height: 22px;
  border-radius: 0 0 7px 7px;
  border-top: 0;
  background:
    linear-gradient(var(--outline), var(--outline)) calc(16px - 2 * var(--ow)) 0 / 100% var(--ow) no-repeat,
    var(--c);
}

/* comments in the palette */
.pal-comment {
  width: 150px;
  height: 64px;
  background: #fff8c5;
  border: 1px solid #e8d98a;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(40, 50, 70, 0.08);
  font-size: 12px;
  color: #5b5320;
  cursor: grab;
  overflow: hidden;
}
.pal-comment-bar { height: 16px; background: #f6e9a0; }
.pal-comment span { display: block; padding: 8px 10px; }
.pal-comment-item { zoom: 1; }
.pal-comment-ghost { position: fixed; z-index: 1500; pointer-events: none; transform: rotate(-3deg); box-shadow: 0 12px 26px rgba(30, 40, 60, 0.22); }

/* comments (sticky notes) */
.note {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: #fff8c5;
  border: 1px solid #e8d98a;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(40, 50, 70, 0.08);
}
.note.moving { box-shadow: 0 10px 24px rgba(40, 50, 70, 0.18); }
.note.selected { border-color: var(--select); box-shadow: 0 0 0 1px var(--select), 0 2px 8px rgba(40, 50, 70, 0.08); } /* the same blue as selected blocks */
.note-bar {
  height: 20px;
  flex: none;
  display: flex;
  justify-content: flex-end;
  background: #f6e9a0;
  border-radius: 8px 8px 0 0;
  cursor: grab;
}
.note-close { border: 0; background: none; color: #9a8a3a; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 6px; }
.note-close:hover { color: var(--red); }
.note textarea {
  flex: 1;
  resize: none;
  border: 0;
  background: transparent;
  padding: 6px 10px 10px;
  font: 12px/1.5 var(--mono);
  color: #5b5320;
  outline: none;
}
.note textarea::placeholder { color: #b5a95e; }
.note-grip {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 10px;
  height: 10px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #d8c873 50%);
  border-radius: 0 0 6px 0;
}

/* inputs inside blocks */
.f-num, .f-text, .f-well {
  font: 500 12.5px var(--mono);
  color: var(--block-ink);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.14);
  height: 26px;
  outline: none;
}
.f-num, .f-text { border-radius: 999px; padding: 0 9px; text-align: center; cursor: text; }
.f-text { text-align: left; padding: 0 11px; }
.f-num::placeholder { color: #b3b9c6; }
/* variable suggestions still appear while typing, without the arrow that squeezes the number */
.f-num::-webkit-calendar-picker-indicator { display: none !important; }
.f-num:focus, .f-text:focus { border-color: rgba(0, 0, 0, 0.35); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55); }
span.f-num, span.f-text, span.f-drop, span.f-well {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
}
.f-drop {
  appearance: none;
  -webkit-appearance: none;
  font: 600 12.5px var(--mono);
  color: #fff;
  background-color: var(--cf);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 9px;
  border: 1px solid var(--cd);
  border-radius: 999px;
  height: 26px;
  padding: 0 24px 0 10px;
  cursor: pointer;
}
.f-drop option { color: var(--ink); background: #fff; }
.f-drop:focus { outline: none; }
.f-drop:focus-visible { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6); }
.f-well {
  border-radius: 8px;
  padding: 0 10px 0 25px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cg fill='%238b93a3'%3E%3Ccircle cx='2' cy='2' r='1.4'/%3E%3Ccircle cx='6' cy='2' r='1.4'/%3E%3Ccircle cx='10' cy='2' r='1.4'/%3E%3Ccircle cx='2' cy='6' r='1.4'/%3E%3Ccircle cx='6' cy='6' r='1.4'/%3E%3Ccircle cx='10' cy='6' r='1.4'/%3E%3Ccircle cx='2' cy='10' r='1.4'/%3E%3Ccircle cx='6' cy='10' r='1.4'/%3E%3Ccircle cx='10' cy='10' r='1.4'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
  background-size: 11px;
}
.f-well:hover { border-color: rgba(0, 0, 0, 0.3); }
.f-well.empty { color: #a7adba; border-style: dashed; }
.f-well.loop { background-color: #fff4dc; border-color: #ffab19; color: #8a5a00; }

.opt-toggle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  margin-left: 2px;
}
.opt-toggle:hover { background: rgba(255, 255, 255, 0.32); }
.b-opts {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 7px;
  border-top: 1px dashed rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

/* selection, problems, dragging */
.block.flash { animation: flash 1.2s ease-out; }
@keyframes flash {
  0%, 40% { filter: drop-shadow(0 0 2px #ffd400) drop-shadow(0 0 8px #ffbf00); }
  100% { filter: none; }
}
.badge {
  position: absolute;
  top: 50%;
  margin-top: -9.5px;
  right: -11px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 12px/1 var(--mono);
  color: #fff;
  border: 2px solid #fff;
  z-index: 3;
  cursor: help;
}
.badge.error { background: var(--red); }
.badge.warning { background: var(--amber); }

#drag-layer { position: fixed; inset: 0; pointer-events: none; z-index: 900; }
.stack.ghost {
  position: fixed;
  transform-origin: 0 0;
  pointer-events: none;
  filter: drop-shadow(0 10px 16px rgba(30, 40, 60, 0.22));
}
.stack.ghost.deleting { opacity: 0.35; }
.stack.ghost.spread > .stack { position: absolute; }
.drop-marker { position: fixed; height: 8px; border-radius: 4px; background: rgba(47, 53, 66, 0.28); }
body.dragging, body.dragging *, body.panning, body.panning * { cursor: grabbing !important; }
body.space-pan #workspace, body.space-pan #workspace * { cursor: grab !important; }
body.selecting, body.selecting * { user-select: none !important; -webkit-user-select: none !important; }
.marquee {
  position: fixed;
  border: 1.5px solid var(--blue);
  background: rgba(76, 151, 255, 0.08);
  border-radius: 3px;
}
body.panning { user-select: none; }
body.dragging #palette-area { background: #fbfbfd; }
body.dragging .ws-hint { opacity: 0; }

/* ---------- side panel ---------- */

.side {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-left: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 12px 9px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--blue); font-weight: 600; }
.count {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  color: #fff;
  font-weight: 700;
}
.count.error { background: var(--red); }
.count.warning { background: var(--amber); }
.tab-panel { flex: 1; overflow: auto; padding: 16px; min-height: 0; }
.side-foot { flex: none; }
.credit {
  display: block;
  font-size: 11px;
  color: var(--muted);
  background: #eef0f3;
  border-top: 1px solid #e1e4ea;
  border-radius: 0;
  padding: 9px 16px;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.credit:hover { color: var(--ink); background: #e6e9ee; }
.panel-help { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.panel-help.about { margin-top: 24px; font-size: 11px; }
.panel-h { font-size: 13px; margin: 22px 0 10px; }

/* deck */
.deck-wrap { display: flex; flex-direction: column; gap: 6px; }
.deck-caption { text-align: center; font-size: 11px; color: var(--muted); }
.deck {
  display: grid;
  grid-template-columns: 16px repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 12px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
}
.deck-corner { width: 16px; }
.deck-colh, .deck-rowh { font-size: 11px; color: var(--muted); text-align: center; align-self: center; }
.slot {
  position: relative;
  aspect-ratio: 1.45;
  min-width: 0;
  border: 1px dashed #cdd3de;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 6px 6px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.slot:hover { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(76, 151, 255, 0.15); }
.slot:not(.empty) { border-style: solid; border-color: #d8dde6; cursor: grab; }

/* dragging labware between slots */
.slot.lifted { opacity: 0.35; border-style: dashed; box-shadow: none; }
.slot-ghost {
  position: fixed;
  z-index: 1500;
  pointer-events: none;
  margin: 0;
  background: #fff;
  border: 2px solid var(--blue) !important;
  box-shadow: 0 14px 30px rgba(30, 40, 60, 0.25);
  transform: rotate(-3deg) scale(0.7);
  transform-origin: top left;
  opacity: 0.95;
}
body.deck-dragging, body.deck-dragging * { cursor: grabbing !important; }
.slot.drop-ok { border: 2px solid var(--blue); background: #eef5ff; box-shadow: 0 0 0 4px rgba(76, 151, 255, 0.18); }
.slot.drop-swap { border: 2px solid var(--amber); background: #fff8eb; box-shadow: 0 0 0 4px rgba(245, 165, 36, 0.18); }
.slot.drop-bad { border: 2px solid var(--red); background: #fff3f3; }
.slot[data-drop]::after {
  content: attr(data-drop);
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9.5px;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  border-radius: 999px;
  padding: 1px 7px;
}
.slot.drop-swap::after { background: var(--amber); }
.slot.drop-bad::after { background: var(--red); }
.slot-id { position: absolute; top: 5px; left: 7px; font-size: 10.5px; color: var(--muted); }
.slot-plus { color: #c3c9d4; font-size: 20px; line-height: 1; }
.slot-label {
  font-size: 11.5px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot-tag {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9.5px;
  background: #e8f1ff;
  color: var(--blue-d);
  border-radius: 999px;
  padding: 1px 6px;
}
.mini { width: 72%; height: auto; max-height: 50%; }
.mini circle, .mini rect { stroke-width: 1.2; }
.cat-tipRack .mini * { fill: #e3eeff; stroke: #4c97ff; }
.cat-wellPlate .mini * { fill: #f1f2f6; stroke: #a9b1bf; }
.cat-reservoir .mini * { fill: #e3f5ec; stroke: #46b98a; }
.cat-tubeRack .mini * { fill: #fbeefb; stroke: #cf63cf; }
.trash-icon { display: grid; place-items: center; color: #8b93a3; }
.trash-icon svg { width: 28px; height: 28px; }
.slot.trash { background: #fafafa; }
/* the OT-2 numbers its slots, so it has no row and column headings */
.deck.numbered { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 12px; }
.slot.fixed { cursor: default; border-style: dashed; }
.slot.fixed:hover { border-color: #d8dde6; box-shadow: none; }

.robot-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}
.robot-pick button {
  border: 0;
  border-radius: 7px;
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.robot-pick button:hover { color: var(--ink); }
.robot-pick button[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(30, 40, 60, 0.14); cursor: default; }
.robot-pick button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.robot-changes { margin: 8px 0 12px; padding-left: 20px; line-height: 1.5; }
.examples-robot .robot-pick { max-width: 360px; margin: 0 0 16px; }
.robot-changes li + li { margin-top: 6px; }

.mount { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.mount-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mount-name { font-weight: 600; }
.mount-select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: #fff; max-width: 220px; }
.rack-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 12px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px 3px 7px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.chip:has(input:checked) { background: #eef5ff; border-color: #b9d3ff; }
.chip.disabled { opacity: 0.45; cursor: not-allowed; }
.chip input { margin: 0 4px 0 0; accent-color: var(--blue); }

/* preview: estimate */
.panel-h.first { margin-top: 0; }
.estimate { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.est-row { display: grid; grid-template-columns: 9.5em 1fr; gap: 10px; padding: 6px 0; font-size: 12.5px; line-height: 1.55; border-top: 1px dashed var(--line); }
.est-row:first-of-type { border-top: 0; }
.est-k { color: var(--muted); }
.est-bad { color: var(--red); }
.est-note { color: var(--muted); font-size: 11.5px; margin: 8px 0 0; }

/* deck: liquids */
.liquid { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.liquid-top { display: flex; align-items: center; gap: 8px; }
.swatch { width: 22px; height: 22px; border-radius: 6px; flex: none; cursor: pointer; border: 1px solid rgba(0, 0, 0, 0.15); position: relative; overflow: hidden; }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.liquid-name { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; font-weight: 600; }
.liquid-name:hover { border-color: var(--line); }
.liquid-name:focus { outline: none; border-color: var(--blue); }
.liquid-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 4px; }
.liquid-del:hover { color: var(--red); }
.fills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; }
.fill-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 10px; }
.fill-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; }
.fill-chip button:hover { color: var(--red); }
.fill-add { border: 1px dashed #c9cfda; background: none; border-radius: 999px; padding: 3px 10px; cursor: pointer; color: var(--muted); }
.fill-add:hover { color: var(--ink); border-color: var(--blue); }

/* preview: animated deck */
.player { margin-bottom: 8px; }
.player-deck { width: 100%; height: auto; display: block; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.pd-slot { fill: #fff; stroke: #dfe3ea; stroke-width: 1; }
.pd-slot-id { font: 600 8px var(--mono); fill: #b0b7c3; }
.pd-label { font: 600 8px var(--mono); fill: var(--ink); }
.pd-trash { fill: #f1f3f6; stroke: #cfd5de; stroke-dasharray: 3 2; }
.pd-trash.fixed { fill: #eceff3; stroke: #b9c0cb; stroke-dasharray: none; stroke-width: 1.2; }
.pd-trash-label { font: 600 10px var(--mono); fill: #a0a8b5; }
.pd-well { fill: #fff; stroke: #c7cdd7; stroke-width: 0.8; transition: fill 0.25s, fill-opacity 0.25s; }
.pd-well.filled { stroke: rgba(0, 0, 0, 0.18); }
.pd-well.active { stroke: var(--ink); stroke-width: 1.6; }
.pd-tip { fill: #dce9ff; stroke: #4c97ff; stroke-width: 0.7; transition: fill 0.2s, stroke 0.2s; }
.pd-tip.used { fill: none; stroke: #d5d9e0; stroke-dasharray: 1.5 1.5; }
.pd-labware { fill: #fafbfc; stroke: #d3d8e0; stroke-width: 0.6; }
.pd-home { font: 600 8px var(--mono); fill: #b0b7c3; }
.pd-head { transition: transform 0.4s ease; }
.pd-head-body { fill: rgba(255, 255, 255, 0.85); stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 1.5; }
.pd-head.has-tip .pd-head-body { stroke-dasharray: none; }
.pd-head.working .pd-head-body { stroke: var(--blue-d); stroke-width: 1.6; }
.pd-nozzle { fill: #fff; stroke: var(--ink); stroke-width: 0.8; transition: fill 0.25s; }
.pd-head-label { font: 700 7px var(--mono); fill: var(--ink); }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.player-head .panel-h { margin: 0; }
.player-head h2 { font-size: 15px; margin: 0; }
.player-popped { margin-top: 22px; }
.player-popped .panel-h { margin: 0 0 6px; }

/* pop-out: the deck preview in a large window */
dialog.modal.player-modal {
  width: min(1100px, 94vw);
  max-height: 94vh;
  padding: 18px 22px 16px;
  overflow: auto;
}
.player-modal .player-head { margin: 0 34px 12px 0; }
.player-modal .player-deck { max-height: calc(94vh - 240px); }
.player-modal .player-caption { font-size: 13.5px; }
.player-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.player-close:hover { color: var(--ink); background: var(--soft); }

.player-controls { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.player-controls .btn.icon { padding: 4px 8px; font-size: 12px; min-width: 30px; }
.player-controls .play { background: var(--blue); color: #fff; border-color: var(--blue-d); }
.player-scrub { flex: 1; min-width: 60px; accent-color: var(--blue); }
.player-speed { border: 1px solid var(--line); border-radius: 7px; padding: 3px 4px; background: #fff; font-size: 12px; }
.player-caption { font-size: 12.5px; line-height: 1.55; margin-top: 8px; min-height: 3.2em; }
.player-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.player-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.block.running { filter: drop-shadow(0 0 2px #ffd400) drop-shadow(0 0 7px #ffbf00); }

/* guided tour */
.tour-layer { position: fixed; inset: 0; z-index: 2000; }
.tour-spot {
  position: fixed;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(30, 38, 54, 0.45);
  outline: 2px solid #fff;
  transition: all 0.25s ease;
  pointer-events: none;
}
.tour-card {
  position: fixed;
  width: min(320px, calc(100vw - 24px));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(20, 30, 50, 0.3);
  padding: 16px 18px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  transition: left 0.25s ease, top 0.25s ease;
}
.tour-card h3 { margin: 2px 0 6px; font-size: 14px; }
.tour-card p { margin: 0 0 12px; }
.tour-count { color: var(--muted); font-size: 11px; }
.tour-actions { display: flex; align-items: center; gap: 6px; }
.tour-actions span { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2100;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 16px; font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(30, 40, 60, 0.25); transition: opacity 0.4s;
}
.toast.out { opacity: 0; }

/* share + history */
.share-row { display: flex; gap: 8px; margin: 10px 0; }
.share-link { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 11.5px; color: var(--muted); background: var(--soft); }
.history-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.history-top p { margin: 0; }
.history-empty { color: var(--muted); text-align: center; padding: 20px 0; }
.history-list { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.history-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.history-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.history-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-actions { display: flex; gap: 4px; flex: none; }

/* python */
.code-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.code-bar .muted { flex: 1; font-size: 11.5px; }
pre.code {
  margin: 0;
  font: 12px/1.65 var(--mono);
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 0;
  overflow: auto;
  tab-size: 4;
}
.ln { display: block; white-space: pre; padding-right: 14px; min-width: max-content; }
.ln .num { display: inline-block; width: 3.2ch; margin-right: 14px; text-align: right; color: #c3c8d2; user-select: none; }
.ln.hl { background: #fff4cc; }
.t-k { color: #774dcb; font-weight: 600; }
.t-s { color: #2f8f46; }
.t-n { color: #d9820f; }
.t-c { color: #9aa1ae; font-style: italic; }
.t-f { color: var(--blue-d); }

/* checks */
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checks li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.5;
}
.checks li.linked { cursor: pointer; }
.checks li.linked:hover { background: var(--soft); }
.checks .icon {
  flex: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  margin-top: 1px;
}
.checks li.error .icon { background: var(--red); }
.checks li.warning .icon { background: var(--amber); }
.checks-ok { text-align: center; padding: 30px 12px; }
.checks-ok .big { font-size: 30px; color: var(--green); }

/* ---------- popovers, menus, dialogs ---------- */

.popover {
  position: fixed;
  z-index: 1200;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(30, 40, 60, 0.18);
  padding: 14px;
  width: max-content;
  max-width: min(420px, calc(100vw - 24px));
  font-size: 12.5px;
}
.pop-title { font-weight: 700; margin-bottom: 8px; }
.pop-loops { display: flex; flex-direction: column; gap: 6px; }
.loop-opt {
  text-align: left;
  background: #fff7e6;
  border: 1px solid #ffcf7a;
  border-radius: 8px;
  padding: 7px 10px;
  color: #8a5a00;
  cursor: pointer;
}
.loop-opt:hover, .loop-opt.on { background: #ffeac2; border-color: #ffab19; }
.pop-or { color: var(--muted); font-size: 11.5px; margin: 10px 0 6px; }
.pop-empty { color: var(--muted); max-width: 300px; }
.pop-bar { display: flex; gap: 6px; align-items: center; }
.pop-select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: #fff; flex: 1; min-width: 0; }
.pop-order, .pop-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.pop-order:hover, .pop-btn:hover { background: var(--soft); }
.pop-btn.primary { background: var(--blue); color: #fff; border-color: var(--blue-d); }
.pop-hint { color: var(--muted); font-size: 11.5px; margin: 10px 0 4px; max-width: 360px; }
.well-grid { display: grid; gap: 3px; align-items: center; justify-items: center; margin: 8px 0 4px; user-select: none; touch-action: none; }
.col-h, .row-h, .corner {
  font-size: 10px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  width: 100%;
  text-align: center;
}
.row-h:disabled { cursor: default; }
.col-h:hover, .row-h:hover:not(:disabled) { color: var(--blue-d); }
.cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: 50%;
  border: 1px solid #c9cfda;
  background: #f4f6f9;
  padding: 0;
  cursor: pointer;
}
.cell.trough { border-radius: 4px; height: calc(var(--cell) * 3); }
.cell.has-liquid { background: color-mix(in srgb, var(--liq) 45%, white); border-color: var(--liq); }
.cell:hover { border-color: var(--blue); }
.cell.on { background: var(--blue); border-color: var(--blue-d); }
.cell.head { box-shadow: 0 0 0 2px rgba(76, 151, 255, 0.35); }
.cell-gap { width: var(--cell); height: var(--cell); }
.pop-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.pop-summary { flex: 1; color: var(--muted); }

.menu {
  position: fixed;
  z-index: 1300;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(30, 40, 60, 0.16);
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 200px;
}
.menu button { text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; }
.menu button:hover:not(:disabled) { background: var(--soft); }
.menu button:disabled { color: var(--muted); cursor: default; }

/* dropdown menus (replace the browser's own <select> pop-ups) */
.dropdown-menu { --accent: var(--blue); min-width: 140px; overflow-y: auto; }
.dropdown-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; white-space: nowrap; }
.dropdown-item .check { width: 1.2ch; flex: none; color: var(--accent); font-weight: 700; }
.dropdown-item.current { font-weight: 600; }
.menu .dropdown-item:hover:not(:disabled),
.menu .dropdown-item.active:not(:disabled) { background: color-mix(in srgb, var(--accent) 13%, white); }

dialog.modal {
  border: 0;
  border-radius: 16px;
  padding: 20px 22px;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-shadow: 0 20px 60px rgba(30, 40, 60, 0.25);
  color: var(--ink);
  font: 13px/1.5 var(--mono);
}
dialog.modal.wide { width: min(640px, calc(100vw - 32px)); }

/* the Examples window: a dashboard of example cards, closed with the × */
dialog.modal.examples-modal { width: min(1000px, calc(100vw - 48px)); padding: 24px 26px 26px; }
.examples-modal h2 { margin-bottom: 4px; }
.examples-sub { margin: 0 0 18px; font-size: 12px; }
.examples-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.example-card { font: inherit; color: inherit; text-align: left; padding: 0; cursor: pointer; width: 100%; }
.example-card .open-it { color: var(--blue-d); font-weight: 600; opacity: 0; transform: translateX(-4px); transition: opacity 0.15s, transform 0.15s; }
.example-card:hover .open-it, .example-card:focus-visible .open-it { opacity: 1; transform: none; }
.example-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.modal-x {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-x:hover { background: var(--soft); color: var(--ink); }
dialog.modal::backdrop { background: rgba(40, 48, 64, 0.25); }
.modal h2 { font-size: 15px; margin: 0 0 14px; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .lw-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .lw-search:focus { outline: none; border-color: var(--blue); }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline select { width: auto; }
.field-error { color: var(--red); font-size: 12px; min-height: 1em; margin: -6px 0 0; }
.slot-current { padding-bottom: 4px; }
.slot-dialog h4 { font-size: 12px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.lw-search { margin: 6px 0 8px; }
.lw-list { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px 8px; }
.lw-list h4 { margin: 10px 4px 4px; }
.lw-option {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border: 0;
  background: none;
  border-radius: 7px;
  cursor: pointer;
}
.lw-option:hover { background: #eef5ff; }
.lw-option code { color: var(--muted); font-size: 10.5px; text-align: right; overflow-wrap: anywhere; }

.noscript { padding: 40px; text-align: center; }

/* ---------- smaller screens ---------- */

@media (max-width: 1400px) {
  .topbar:not(.builder-top) .brand > span:last-child { display: none; }
}

@media (max-width: 1180px) {
  :root { --palette-w: 300px; --side-w: 320px; }
}

@media (max-width: 860px) {
  body { overflow: auto; height: auto; display: block; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: 300px 70vh auto; }
  #palette-area { border-right: 0; border-bottom: 1px solid var(--line); min-width: 0; }
  .rail-col { width: 64px; }
  #palette { flex: 1; width: auto; padding-bottom: 40px; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .tab-panel { overflow: visible; }
  .topbar { flex-wrap: wrap; }
  .builder-top { display: flex; } /* the panels stack, so nothing to line up with */
  .resize-handle { display: none; }
  .actions { flex-wrap: wrap; }
}
