/* figure-canvas — tool CSS.
   Chunk 7: editor shell rewritten as a window-sized app (top bar,
   48 px rail, 280 px library flyout, flexible board, 288 px
   inspector, 28 px bottom bar). The canvas engine rules
   (.ed-canvas, .ed-sel-box, .ed-handle, .ed-anchor, .ed-guide,
   .ed-tile, .ed-layers, dialogs, sheets, print) are unchanged.
   Scoped under .tool-body; legacy tokens that collide with the
   Chunk 1 design system are renamed --lg-*. */
.tool-body {
  height: 100%;
}
.tool-body .unit-toggle {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.tool-body .unit-btn {
  padding: 8px 12px;
  min-height: 36px;
  border: 1px solid var(--lg-line);
  background: var(--lg-surface);
  color: var(--lg-ink);
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}
.tool-body .unit-btn.active {
  background: var(--lg-primary);
  border-color: var(--lg-primary);
  color: var(--on-lg-primary);
  font-weight: 600;
}
.tool-body .check {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 600;
}
.tool-body .check input {
  width: 20px;
  height: 20px;
  accent-color: var(--lg-primary);
  flex: none;
}
.tool-body .editor {
  --ed-top: 44px;
  --ed-left: 280px;
  --ed-right: 288px;
  --ed-rail: 48px;
  --ed-bottom: 28px;
  --ed-accent: #e67e22;
  --ed-sel: #e67e22;
  --ed-guide: #d63384;
  --ed-board: #e9eef5;
  height: 100%;
  display: flex;
  flex-direction: column;
}
/* Full screen: the editor itself becomes the viewport; the compact
   site header hides (the old ".editor.full .site-header" selector
   could never match — the header is not a descendant). */
.tool-body .editor.full {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--lg-bg);
}
body.is-canvas-app:has(.editor.full) .site-header,
body.is-canvas-app:has(.editor.full) .site-footer {
  display: none;
}
.tool-body .ed-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
/* ---------- Top bar (44 px) ---------- */
.tool-body .ed-topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--ed-top);
  flex: none;
  padding: 0 8px;
  background: var(--lg-surface);
  border-bottom: 1px solid var(--lg-line);
  position: relative;
  z-index: 60;
}
.tool-body .ed-topbar .sep {
  width: 1px;
  height: 24px;
  background: var(--lg-line);
  margin: 0 4px;
  flex: none;
}
.tool-body .ed-name {
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--lg-ink);
  border-radius: 6px;
  padding: 8px 8px;
  min-width: 60px;
  max-width: 220px;
  flex: 1 1 140px;
}
.tool-body .ed-name:hover, .tool-body .ed-name:focus {
  border-color: var(--lg-line);
  background: var(--lg-surface);
}
.tool-body .ed-saved {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--lg-muted);
  white-space: nowrap;
  flex: none;
}
.tool-body .ed-saved .icon {
  width: 14px;
  height: 14px;
  color: var(--lg-primary);
}
.tool-body .ed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--lg-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tool-body .ed-btn:hover {
  background: var(--soft);
}
.tool-body .ed-btn[aria-pressed="true"], .tool-body .ed-btn.active {
  background: var(--soft);
  border-color: var(--lg-primary);
  color: var(--lg-primary);
}
.tool-body .ed-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.tool-body .ed-btn .icon {
  width: 18px;
  height: 18px;
}
.tool-body .ed-btn.primary {
  background: var(--lg-primary);
  color: var(--on-lg-primary);
}
.tool-body .ed-btn.primary:hover {
  filter: brightness(1.1);
}
.tool-body .ed-zoom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tool-body .ed-zoom select {
  border: 1px solid var(--lg-line);
  background: var(--lg-surface);
  color: var(--lg-ink);
  border-radius: 6px;
  height: 32px;
  font: inherit;
  font-size: 13px;
  padding: 0 4px;
}
.tool-body .ed-topbar .spacer {
  flex: 1;
}
.tool-body .ed-more-menu {
  display: none;
}
.tool-body .ed-menu {
  position: relative;
}
.tool-body .ed-menu-pop {
  position: absolute;
  top: 36px;
  right: 0;
  min-width: 220px;
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 8px;
  z-index: 80;
  display: none;
}
.tool-body .ed-menu-pop.open {
  display: block;
}
.tool-body .ed-menu-pop button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--lg-ink);
  font: inherit;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.tool-body .ed-menu-pop button:hover {
  background: var(--soft);
}
.tool-body .ed-menu-pop button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.tool-body .ed-menu-pop button .icon {
  width: 18px;
  height: 18px;
  flex: none;
}
.tool-body .ed-menu-pop .mi-sep {
  height: 1px;
  background: var(--lg-line);
  margin: 4px 4px;
}
.tool-body .ed-menu-pop .mi-head {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--lg-muted);
  padding: 8px 12px 4px;
}
.tool-body .ed-menu-pop .mi-key, .tool-body .ed-ctx .mi-key {
  margin-left: auto;
  font-size: 12px;
  color: var(--lg-muted);
  white-space: nowrap;
}
.tool-body .ed-menu-pop .menu-check {
  margin-left: auto;
  visibility: hidden;
  color: var(--lg-primary);
}
.tool-body .ed-menu-pop button.on .menu-check {
  visibility: visible;
}
/* ---------- Work area: rail | flyout | centre | inspector ---------- */
.tool-body .ed-work {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}
.tool-body .ed-rail {
  width: var(--ed-rail);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  background: var(--lg-surface);
  border-right: 1px solid var(--lg-line);
  overflow-y: auto;
  overflow-x: hidden;
}
.tool-body #toolStrip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tool-body #toolStrip .ed-btn {
  width: 40px;
  height: 40px;
  padding: 0;
}
.tool-body #toolStrip .ed-btn .icon {
  width: 20px;
  height: 20px;
}
.tool-body #toolStrip .ed-btn[aria-pressed="true"] {
  box-shadow: inset 3px 0 0 var(--lg-primary);
}
.tool-body .ed-rail-sep {
  width: 24px;
  height: 1px;
  background: var(--lg-line);
  margin: 8px 0;
  flex: none;
}
.tool-body .ed-rail-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--lg-ink);
  cursor: pointer;
  padding: 0;
}
.tool-body .ed-rail-btn:hover {
  background: var(--soft);
}
.tool-body .ed-rail-btn[aria-pressed="true"], .tool-body .ed-rail-btn.active {
  background: var(--soft);
  border-color: var(--lg-primary);
  color: var(--lg-primary);
}
.tool-body .ed-rail-btn .icon {
  width: 20px;
  height: 20px;
}
.tool-body .ed-shapes-menu {
  position: fixed;
  z-index: 90;
  min-width: 190px;
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 8px;
  display: none;
}
.tool-body .ed-shapes-menu.open {
  display: block;
}
.tool-body .ed-shapes-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--lg-ink);
  font: inherit;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.tool-body .ed-shapes-menu button:hover {
  background: var(--soft);
}
.tool-body .ed-shapes-menu button[aria-pressed="true"] {
  color: var(--lg-primary);
  background: var(--soft);
}
.tool-body .ed-shapes-menu button .icon {
  width: 18px;
  height: 18px;
}
/* ---------- Library flyout (280 px) ---------- */
.tool-body .ed-flyout {
  width: var(--ed-left);
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--lg-surface);
  border-right: 1px solid var(--lg-line);
}
.tool-body .ed-flyout:not(.open) {
  display: none;
}
.tool-body .ed-panel-h {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  flex: none;
  padding: 0 12px;
  border-bottom: 1px solid var(--lg-line);
  font-weight: 700;
  font-size: 14px;
}
.tool-body .ed-panel-h .spacer {
  flex: 1;
}
.tool-body .ed-panel-b {
  padding: 12px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
.tool-body .ed-lib-search {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: var(--lg-surface);
  color: var(--lg-ink);
  font: inherit;
  font-size: 14px;
}
.tool-body .ed-lib-search-wrap {
  position: relative;
  margin-bottom: 8px;
}
.tool-body .ed-lib-search-wrap .icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--lg-muted);
  pointer-events: none;
}
.tool-body .ed-cats {
  display: flex;
  gap: 4px;
  margin: 12px 0;
  overflow-x: auto;
  padding-bottom: 4px;
  flex-wrap: nowrap;
}
.tool-body .ed-cat {
  padding: 4px 12px;
  min-height: 28px;
  border: 1px solid var(--lg-line);
  background: var(--lg-surface);
  color: var(--lg-ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.tool-body .ed-cat[aria-pressed="true"] {
  background: var(--lg-primary);
  border-color: var(--lg-primary);
  color: var(--on-lg-primary);
}
.tool-body .ed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px;
}
.tool-body .ed-tile {
  min-height: 72px;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: var(--lg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: grab;
  padding: 4px;
  position: relative;
}
.tool-body .ed-tile svg {
  width: 36px;
  height: 36px;
}
.tool-body .ed-tile .t-name {
  font-size: 12px;
  line-height: 1.1;
  text-align: center;
  color: var(--lg-muted);
  overflow: hidden;
  overflow-wrap: anywhere;
  /* Chunk 8: was display -webkit-box with line-clamp 2. As a flex item the
     box is blockified, the clamp hid the 3rd line of long names ("Non-
     enveloped virus" lost "virus") and the clipped line reported phantom
     scrollWidth (74 vs a 70px box). A plain block shows the whole name. */
  display: block;
}
.tool-body .ed-tile-wrap {
  position: relative;
}
.tool-body .ed-tile:hover, .tool-body .ed-tile:focus-visible {
  border-color: var(--lg-accent);
  outline: 3px solid var(--lg-accent);
  outline-offset: 0;
}
.tool-body .ed-tile-wrap .fav {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  background: transparent;
  color: var(--lg-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tool-body .ed-tile-wrap .fav svg {
  width: 14px;
  height: 14px;
}
.tool-body .ed-tile-wrap .fav.on {
  color: var(--lg-accent);
}
.tool-body .ed-recent-h {
  font-size: 12px;
  font-weight: 700;
  color: var(--lg-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 12px 0 8px;
}
.tool-body .ed-recent {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tool-body .ed-recent .ed-tile {
  width: 52px;
  height: 52px;
  min-height: 52px;
  flex: none;
}
.tool-body .ed-recent .ed-tile svg {
  width: 32px;
  height: 32px;
}
.tool-body .ed-fav-empty {
  font-size: 13px;
  color: var(--lg-muted);
}
/* ---------- Centre: connector row, board, bottom bar ---------- */
.tool-body .ed-centre {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tool-body .ed-conn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 8px 12px;
  background: var(--lg-surface);
  border-bottom: 1px solid var(--lg-line);
  font-size: 13px;
}
.tool-body .ed-conn-row[hidden] {
  display: none;
}
.tool-body .ed-conn-row .ed-sel-in {
  flex: 1;
  min-width: 0;
}
.tool-body .ed-board {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background-color: var(--ed-board);
  background-image: radial-gradient(circle, rgba(15,42,68,.14) 1px, transparent 1px);
  background-size: 20px 20px;
}
[data-theme="dark"] .tool-body .ed-board {
  background-color: #0e1b2d;
  background-image: radial-gradient(circle, rgba(255,255,255,.09) 1px, transparent 1px);
}
.tool-body .ed-board-inner {
  position: absolute;
  inset: 0;
  overflow: auto;
}
.tool-body .ed-ruler-t, .tool-body .ed-ruler-l {
  position: absolute;
  background: var(--lg-surface);
  z-index: 5;
}
.tool-body .ed-ruler-t {
  top: 0;
  left: 24px;
  right: 0;
  height: 24px;
  border-bottom: 1px solid var(--lg-line);
}
.tool-body .ed-ruler-l {
  top: 24px;
  left: 0;
  bottom: 0;
  width: 24px;
  border-right: 1px solid var(--lg-line);
}
.tool-body .ed-stage {
  position: relative;
  margin: 24px;
  transform-origin: 0 0;
}
.tool-body .ed-artboard {
  background: #fff;
  box-shadow: 0 2px 16px rgba(15,42,68,.25);
  position: relative;
}
.tool-body .ed-artboard svg {
  display: block;
}
.tool-body .ed-canvas {
  touch-action: none;
  display: block;
}
/* Chunk 9 (test 8): the overlay svg sits over the artboard by class now,
   not by an inline style; the export actions row and the phone sheet
   close buttons likewise. */
.tool-body #overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tool-body #expActions {
  margin-top: 12px;
}
.tool-body .ed-sheet-close {
  position: absolute;
  right: 8px;
}
.tool-body .ed-canvas text {
  user-select: none;
}
.tool-body .ed-sel-box {
  fill: none;
  stroke: var(--ed-sel);
  stroke-width: 1.5;
}
.tool-body .ed-handle {
  fill: #fff;
  stroke: var(--ed-sel);
  stroke-width: 1.5;
  cursor: nwse-resize;
}
.tool-body .ed-rot-handle {
  fill: #fff;
  stroke: var(--ed-sel);
  stroke-width: 1.5;
  cursor: grab;
}
.tool-body .ed-anchor {
  fill: var(--lg-primary);
  stroke: #fff;
  stroke-width: 1.5;
}
.tool-body .ed-guide {
  stroke: var(--ed-guide);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
.tool-body .ed-size-read {
  font: 600 12px system-ui, sans-serif;
  fill: var(--lg-primary);
}
/* Empty state: centred card on the artboard, three template tiles. */
.tool-body .ed-empty {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 7;
  width: calc(100% - 48px);
  max-width: 420px;
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 16px 24px;
  text-align: center;
  /* The card must not block the canvas: clicks on its background pass
     through so tools (e.g. Text) work on an empty artboard. Only its
     interactive children (template tiles, tour button) take clicks. */
  pointer-events: none;
}
.tool-body .ed-empty .ed-tpl,
.tool-body .ed-empty #emptyTour {
  pointer-events: auto;
}
.tool-body .ed-empty h2 {
  margin: 0 0 4px;
  font-size: 20px;
}
.tool-body .ed-empty p {
  margin: 0 0 12px;
  color: var(--lg-muted);
  font-size: 14px;
}
.tool-body .ed-empty-tpls {
  display: grid;
  /* Chunk 8: was repeat(3, 1fr); on a phone the card is ~300px wide and
     each column was ~90px, so "1-compartment" (85px at 13px) clipped.
     auto-fill keeps 3 columns on desktop and drops to 2 on phones. */
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.tool-body .ed-empty-tpls .ed-tpl svg {
  width: 100%;
  height: 64px;
}
/* Floating context toolbar: 12 px above the selection. */
.tool-body .ed-ctxbar {
  position: absolute;
  z-index: 30;
  display: flex;
  gap: 4px;
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 4px;
}
.tool-body .ed-ctxbar[hidden] {
  display: none;
}
.tool-body .ed-ctxbar button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--lg-ink);
  cursor: pointer;
  padding: 0;
}
.tool-body .ed-ctxbar button:hover {
  background: var(--soft);
}
.tool-body .ed-ctxbar button .icon {
  width: 18px;
  height: 18px;
}
.tool-body .ed-ctxbar .ed-menu-pop {
  top: 38px;
  left: 0;
  right: auto;
}
.tool-body .ed-ctxbar-fill {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  color: var(--lg-ink);
}
.tool-body .ed-ctxbar-fill:hover {
  background: var(--soft);
}
.tool-body .ed-ctxbar-fill .icon {
  width: 18px;
  height: 18px;
}
.tool-body .ed-ctxbar-fill input[type="color"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
.tool-body .ed-pixel-prev {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 8;
  background: #fff;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow-lift);
}
.tool-body .ed-pixel-prev img {
  display: block;
  max-width: 320px;
  max-height: 240px;
}
/* Bottom bar (28 px): hint | selection size/coordinates | zoom. */
.tool-body .ed-bottombar {
  height: var(--ed-bottom);
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--lg-surface);
  border-top: 1px solid var(--lg-line);
  font-size: 12px;
  color: var(--lg-muted);
}
.tool-body .ed-bottombar .ed-status {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-body .ed-bottombar .ed-coords {
  flex: none;
}
.tool-body .ed-zoom-b {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.tool-body .ed-zoom-b .ed-btn {
  height: 24px;
  min-width: 24px;
}
.tool-body .ed-zoom-b .ed-btn .icon {
  width: 14px;
  height: 14px;
}
.tool-body #zoomPctB {
  min-width: 42px;
  text-align: center;
  font-size: 12px;
}
.tool-body .ed-mobilebar {
  display: none;
}
/* ---------- Inspector (288 px) ---------- */
.tool-body .ed-panel.side.right {
  width: var(--ed-right);
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--lg-surface);
  border-left: 1px solid var(--lg-line);
}
.tool-body .ed-panel.side.right:not(.open) {
  display: none;
}
.tool-body .ed-insp-head {
  display: flex;
  flex: none;
  border-bottom: 1px solid var(--lg-line);
}
.tool-body .ed-tabs {
  display: flex;
  flex: 1;
}
.tool-body .ed-tab {
  flex: 1;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--lg-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  padding: 0 4px;
}
.tool-body .ed-tab[aria-selected="true"] {
  color: var(--lg-primary);
  border-bottom-color: var(--lg-primary);
}
.tool-body .ed-insp-close {
  flex: none;
  align-self: center;
  margin-right: 4px;
}
.tool-body .ed-insp {
  padding: 12px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
.tool-body .ed-sec {
  font-size: 12px;
  font-weight: 700;
  color: var(--lg-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 12px 0 8px;
}
.tool-body .ed-sec:first-child {
  margin-top: 0;
}
.tool-body .ed-sec-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.tool-body .ed-sec-toggle .icon {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform .15s ease;
}
.tool-body .ed-sec.collapsed .ed-sec-toggle .icon {
  transform: rotate(-90deg);
}
.tool-body .ed-sec-body.collapsed {
  display: none;
}
.tool-body .ed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tool-body .ed-row label {
  flex: 1;
  font-size: 13px;
}
.tool-body .ed-row .ctl {
  flex: none;
}
.tool-body .ed-num {
  width: 72px;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: var(--lg-surface);
  color: var(--lg-ink);
  font: inherit;
  font-size: 13px;
  text-align: right;
}
.tool-body .ed-sel-in {
  min-height: 32px;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: var(--lg-surface);
  color: var(--lg-ink);
  font: inherit;
  font-size: 13px;
  padding: 0 8px;
  max-width: 100%;
}
.tool-body .ed-color {
  width: 32px;
  height: 32px;
  padding: 4px;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: var(--lg-surface);
  cursor: pointer;
}
.tool-body .ed-range {
  flex: 1;
  accent-color: var(--lg-primary);
}
.tool-body .ed-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tool-body .ed-sw {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--lg-line);
  cursor: pointer;
  padding: 0;
}
.tool-body .ed-sw[aria-pressed="true"] {
  outline: 3px solid var(--lg-accent);
  outline-offset: 1px;
}
.tool-body .ed-seg {
  display: inline-flex;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  overflow: hidden;
}
.tool-body .ed-seg button {
  border: 0;
  background: var(--lg-surface);
  color: var(--lg-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  min-height: 32px;
  padding: 0 12px;
  cursor: pointer;
}
.tool-body .ed-seg button[aria-pressed="true"] {
  background: var(--lg-primary);
  color: var(--on-lg-primary);
}
.tool-body .ed-mini {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: var(--lg-surface);
  color: var(--lg-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tool-body .ed-mini:hover {
  background: var(--soft);
}
.tool-body .ed-mini[aria-pressed="true"] {
  background: var(--soft);
  border-color: var(--lg-primary);
  color: var(--lg-primary);
}
.tool-body .ed-mini.danger {
  color: var(--lg-err);
}
.tool-body .ed-mini .icon {
  width: 18px;
  height: 18px;
}
.tool-body .ed-align-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.tool-body .ed-align-grid .ed-mini {
  padding: 4px 0;
}
.tool-body .ed-note {
  font-size: 13px;
  color: var(--lg-muted);
}
.tool-body .ed-layer-search {
  width: 100%;
  min-height: 32px;
  padding: 8px 12px;
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: var(--lg-surface);
  color: var(--lg-ink);
  font: inherit;
  font-size: 13px;
  margin-bottom: 8px;
}
.tool-body .ed-layers {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
}
.tool-body .ed-layer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.tool-body .ed-layer:hover {
  background: var(--soft);
}
.tool-body .ed-layer[aria-selected="true"] {
  background: var(--soft);
  border-color: var(--lg-primary);
}
.tool-body .ed-layer .thumb {
  width: 24px;
  height: 24px;
  flex: none;
  border: 1px solid var(--lg-line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.tool-body .ed-layer .thumb svg {
  width: 100%;
  height: 100%;
}
.tool-body .ed-layer .lname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  background: transparent;
  border: 0;
  color: var(--lg-ink);
  text-align: left;
  padding: 0;
}
.tool-body .ed-layer .lname:focus {
  outline: 2px solid var(--lg-accent);
}
.tool-body .ed-layer .ltype {
  font-size: 12px;
  color: var(--lg-muted);
  flex: none;
}
.tool-body .ed-layer .licon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 0;
  background: transparent;
  color: var(--lg-muted);
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.tool-body .ed-layer .licon .icon {
  width: 16px;
  height: 16px;
}
.tool-body .ed-layer .licon[aria-pressed="true"] {
  color: var(--lg-primary);
}
.tool-body .ed-layer.grp {
  font-weight: 700;
}
.tool-body .ed-layer .kids {
  margin-left: 16px;
}
/* ---------- Dialogs ---------- */
.tool-body .ed-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,42,68,.45);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tool-body .ed-overlay.open {
  display: flex;
}
.tool-body .ed-dialog {
  background: var(--lg-surface);
  color: var(--lg-ink);
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  max-width: 720px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 16px;
}
.tool-body .ed-dialog-wide {
  max-width: 960px;
}
/* Chunk 9 (test 8): the narrow restore dialog keeps its 440 px cap by
   class now, not by an inline style. */
.tool-body .ed-dialog-narrow {
  max-width: 440px;
}
.tool-body .ed-dialog h2 {
  margin-top: 0;
}
.tool-body .ed-dialog .ed-close {
  float: right;
}
.tool-body .ed-tpl-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  margin-top: 12px;
}
.tool-body .ed-tpl-cats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tool-body .ed-tpl-cats button {
  text-align: left;
  padding: 8px 12px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--lg-ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.tool-body .ed-tpl-cats button:hover {
  background: var(--soft);
}
.tool-body .ed-tpl-cats button[aria-pressed="true"] {
  background: var(--soft);
  border-color: var(--lg-primary);
  color: var(--lg-primary);
  font-weight: 700;
}
.tool-body .ed-tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.tool-body .ed-tpl {
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--lg-surface);
  padding: 0;
  text-align: left;
  font: inherit;
  color: var(--lg-ink);
}
.tool-body .ed-tpl:hover {
  border-color: var(--lg-primary);
}
.tool-body .ed-tpl svg {
  display: block;
  width: 100%;
  height: 110px;
  background: #fff;
}
.tool-body .ed-tpl .t {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere; /* Chunk 8: long hyphenated words ("1-compartment") must be able to break in a narrow card */
}
.tool-body .ed-tpl .d {
  padding: 0 12px 12px;
  font-size: 12px;
  color: var(--lg-muted);
}
.tool-body .ed-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.tool-body .ed-export-prev {
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  text-align: center;
}
.tool-body .ed-export-prev svg {
  max-width: 100%;
  max-height: 220px;
}
.tool-body .ed-ctx {
  position: fixed;
  z-index: 320;
  min-width: 200px;
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 8px;
  display: none;
}
.tool-body .ed-ctx.open {
  display: block;
}
.tool-body .ed-ctx button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--lg-ink);
  font: inherit;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.tool-body .ed-ctx button:hover {
  background: var(--soft);
}
.tool-body .ed-ctx button:disabled {
  opacity: .45;
}
.tool-body .ed-ctx button .icon {
  width: 18px;
  height: 18px;
}
.tool-body .ed-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 340;
  background: var(--primary-dark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-lift);
  display: none;
  max-width: 90vw;
}
.tool-body .ed-toast.show {
  display: block;
}
.tool-body .ed-tour {
  position: fixed;
  z-index: 330;
  max-width: 320px;
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 16px;
}
.tool-body .ed-tour h3 {
  margin-top: 0;
}
.tool-body .ed-kbd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tool-body .ed-kbd-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--lg-line);
}
.tool-body .ed-kbd-table td:first-child {
  white-space: nowrap;
  font-weight: 600;
}
.tool-body kbd {
  background: var(--soft);
  border: 1px solid var(--lg-line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 8px;
  font: 600 12px ui-monospace, monospace;
}
.tool-body .tour-target {
  outline: 3px solid var(--ed-accent) !important;
  outline-offset: 2px;
  border-radius: 10px;
}
/* ---------- Bottom sheets (phone) ---------- */
.tool-body .ed-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 310;
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-bottom: 0;
  border-radius: 10px 16px 0 0;
  box-shadow: var(--shadow-lift);
  height: 65vh;
  display: none;
  flex-direction: column;
}
.tool-body .ed-sheet.open {
  display: flex;
}
.tool-body .ed-sheet[data-h="0"] {
  height: 40vh;
}
.tool-body .ed-sheet[data-h="1"] {
  height: 65vh;
}
.tool-body .ed-sheet[data-h="2"] {
  height: 92vh;
}
.tool-body .ed-sheet-h {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  position: relative;
  cursor: grab;
  touch-action: none;
  flex: none;
}
.tool-body .ed-sheet-h::before {
  content: "";
  position: absolute;
  top: 8px;
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--lg-line);
}
.tool-body .ed-sheet-h .t {
  font-weight: 700;
}
.tool-body .ed-sheet-b {
  overflow-y: auto;
  padding: 0 16px 24px;
  min-height: 0;
  flex: 1;
}
.tool-body .ed-sheet-b .ed-lib-search {
  padding-left: 12px;
}
.tool-body .ed-sheet-b .ed-grid {
  max-height: none;
}
/* ---------- About sheet (breadcrumb, H1, lede live here) ---------- */
.tool-body .ed-about {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 280;
  max-height: 82dvh;
  overflow-y: auto;
  background: var(--lg-surface);
  border-top: 1px solid var(--lg-line);
  box-shadow: 0 -8px 32px rgba(15,42,68,.18);
  transform: translateY(105%);
  transition: transform .2s ease;
}
.tool-body .ed-about.open {
  transform: none;
}
.tool-body .ed-about-inner {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.tool-body .ed-about-close {
  position: absolute;
  top: 12px;
  right: 12px;
}
.tool-body .ed-about .breadcrumb {
  margin-bottom: 8px;
}
.tool-body .ed-about h1 {
  margin: 0 0 8px;
}
.tool-body .ed-about .lede {
  margin: 0 0 12px;
}
.tool-body .ed-guide {
  margin-top: 24px;
}
.tool-body .ed-guide summary {
  cursor: pointer;
  font-weight: 700;
}
.tool-body .ed-guide table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tool-body .ed-guide td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--lg-line);
}
.tool-body .ed-guide td:first-child {
  white-space: nowrap;
  font-weight: 600;
}
/* ---------- Tablet (600–1023 px): centre group into View menu, panels become drawers ---------- */
@media (max-width: 1023px) {
  .tool-body .ed-topbar .ed-zoom {
    display: none;
  }
  .tool-body .ed-flyout {
    position: fixed;
    top: 44px;
    bottom: 0;
    left: 0;
    z-index: 290;
    width: min(340px, 92vw);
    box-shadow: var(--shadow-lift);
    transition: transform .2s ease;
  }
  .tool-body .ed-flyout:not(.open) {
    display: flex;
    transform: translateX(-105%);
  }
  .tool-body .ed-flyout.open {
    transform: none;
  }
  .tool-body .ed-panel.side.right {
    position: fixed;
    top: 44px;
    bottom: 0;
    right: 0;
    z-index: 290;
    width: min(340px, 92vw);
    box-shadow: var(--shadow-lift);
    transition: transform .2s ease;
  }
  .tool-body .ed-panel.side.right:not(.open) {
    display: flex;
    transform: translateX(105%);
  }
  .tool-body .ed-panel.side.right.open {
    transform: none;
  }
}
/* ---------- Phones (<600 px): artboard fills the screen, 64 px bottom toolbar ---------- */
@media (max-width: 599px) {
  .tool-body .ed-topbar {
    padding: 0 4px;
  }
  .tool-body .ed-topbar #fileBtn,
  .tool-body .ed-topbar #viewBtn,
  .tool-body .ed-topbar .ed-zoom,
  .tool-body .ed-topbar #tplBtn,
  .tool-body .ed-topbar #helpBtn,
  .tool-body .ed-topbar #fsBtn,
  .tool-body .ed-topbar .ed-btn-label {
    display: none;
  }
  .tool-body .ed-topbar .ed-more-menu {
    display: inline-flex;
  }
  .tool-body .ed-topbar .ed-saved #saveStateText {
    display: none;
  }
  .tool-body .ed-rail {
    display: none;
  }
  .tool-body .ed-flyout,
  .tool-body .ed-panel.side.right {
    display: none !important;
  }
  .tool-body .ed-bottombar {
    display: none;
  }
  .tool-body .ed-stage {
    margin: 16px;
  }
  .tool-body .ed-mobilebar {
    display: flex;
    flex: none;
    height: 64px;
    background: var(--lg-surface);
    border-top: 1px solid var(--lg-line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .tool-body .ed-mobilebar .ed-btn {
    flex-direction: column;
    min-width: 52px;
    min-height: 56px;
    font-size: 12px;
    gap: 4px;
  }
  .tool-body .ed-mobilebar .ed-btn .icon {
    width: 22px;
    height: 22px;
  }
  .tool-body .ed-tpl-layout {
    grid-template-columns: 1fr;
  }
  .tool-body .ed-tpl-cats {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .tool-body .ed-ctxbar {
    display: none;
  }
  .tool-body .ed-pixel-prev img {
    max-width: 200px;
    max-height: 150px;
  }
}
@media (pointer: coarse) {
  .tool-body .ed-topbar .ed-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .tool-body .ed-btn-icon, .tool-body .ed-dialog .ed-close, .tool-body .ed-about-close, .tool-body .ed-insp-close {
    min-width: 44px;
    min-height: 44px;
  }
  .tool-body .ed-tile-wrap .fav {
    width: 44px;
    height: 44px;
  }
  .tool-body .ed-rail-btn, .tool-body #toolStrip .ed-btn {
    width: 44px;
    height: 44px;
  }
  .tool-body .ed-ctxbar button {
    width: 44px;
    height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tool-body .ed-flyout, .tool-body .ed-panel.side.right, .tool-body .ed-sheet, .tool-body .ed-about, .tool-body .ed-sec-toggle .icon {
    transition: none !important;
  }
}
@media print {
  .tool-body {
    font-size: 16px;
    line-height: 1.5;
    color: var(--lg-ink);
  }
  .tool-body .ed-topbar, .tool-body .ed-rail, .tool-body .ed-flyout,
  .tool-body .ed-panel.side.right, .tool-body .ed-bottombar,
  .tool-body .ed-mobilebar, .tool-body .ed-ctxbar, .tool-body .ed-empty,
  .tool-body .ed-pixel-prev, .tool-body .ed-about, .tool-body .ed-conn-row {
    display: none !important;
  }
  .tool-body #board, .tool-body #boardInner, .tool-body #stage {
    position: static !important;
    overflow: visible !important;
    height: auto !important;
    margin: 0 !important;
    transform: none !important;
  }
  .tool-body #artboard {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    box-shadow: none !important;
  }
  .tool-body #overlay, .tool-body .ed-ruler-t, .tool-body .ed-ruler-l {
    display: none !important;
  }
}
.tool-body #canvas {
  touch-action: none;
}
.tool-body .palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tool-body .palette-grid .btn {
  flex: 0 1 auto;
}
