/* 65_editor.css - KP Equipment slice O5 (Fable): the viewer / editor split (decision D88).
 * The viewer is the page as it loads. body.is-editing turns on the editor: the house bar shows "Editing <site>" + Done
 * and an amber edge, the view toolbar gives way to the edit bar (top bar on tablet and PC, bottom bar on a phone), the
 * drawer's editing actions appear, and a tip sits on the stage. Tokens from 01_tokens.css only; breakpoints match
 * 30_plan.css (phone <= 700, tablet to 1299, PC from 1300) and are `screen` scoped. */

body.plan-root { grid-template-rows: auto auto auto 1fr auto; }
/* O5b: pin each band to its row. A hidden or fixed band leaves the grid flow, and auto-placement would then put the
 * stage in an `auto` row (height 0, blank plan) and the footer in the 1fr row. */
body.plan-root > .kp-bar { grid-row: 1; }
body.plan-root > .toolbar { grid-row: 2; }
body.plan-root > .editbar { grid-row: 3; }
body.plan-root > .plan-main { grid-row: 4; }
body.plan-root > .foot { grid-row: 5; }

/* ---- shared icon look (house bar and edit bar) ---- */
.bar-btn svg, .edit-tool svg, .edit-title svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bar-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.bar-btn-primary { background: var(--kp-bar-on); border-color: var(--kp-bar-on); color: var(--navy); font-weight: 600; }
.bar-btn-primary:hover { background: #f1f5f9; }
[data-theme="dark"] .bar-btn-primary { color: var(--on-brand); }
[data-theme="dark"] .bar-btn-primary:hover { background: var(--brand-hover); }
.bar-btn:disabled { opacity: .55; cursor: default; }

/* 2D / 3D switch slot: rendered only when 65_editor.js turns VIEW_3D on */
.view-switch { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--kp-bar-tint); border: 1px solid var(--kp-bar-line); }
.view-switch[hidden] { display: none; }
.view-btn { min-height: 38px; min-width: 44px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-pill); background: transparent; color: var(--kp-bar-ink); font: inherit; font-weight: 500; cursor: pointer; }
.view-btn[aria-pressed="true"] { background: var(--kp-bar-on); color: var(--navy); font-weight: 600; }
[data-theme="dark"] .view-btn[aria-pressed="true"] { color: var(--on-brand); }
.view-btn:focus-visible { box-shadow: 0 0 0 2px var(--kp-bar-ring); }

/* ---- house bar: edit state ---- */
.edit-title { display: none; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px 0 12px; border-radius: var(--r-pill); background: var(--kp-bar-tint); border: 1px solid var(--kp-bar-line); font-weight: 600; white-space: nowrap; }
.edit-title svg { color: var(--amber-action, #f59e0b); }
#done-btn { display: none; margin-left: auto; }
body.is-editing .edit-title { display: inline-flex; }
body.is-editing #done-btn { display: inline-flex; }
body.is-editing .site-switch, body.is-editing .search, body.is-editing #theme-btn, body.is-editing #edit-btn, body.is-editing #view-switch { display: none; }
body.is-editing .kp-bar { box-shadow: var(--kp-bar-shadow), inset 0 -3px 0 0 var(--amber-action, #f59e0b); }
body.is-editing .toolbar { display: none; }

/* ---- edit bar ---- */
.editbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-2) var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--line); }
.editbar[hidden] { display: none; }
.tool-group { display: inline-flex; align-items: center; gap: var(--sp-1); }
.tool-group + .tool-group { padding-left: var(--sp-3); border-left: 1px solid var(--line); }
.edit-tool { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.edit-tool:hover { background: var(--surface-alt); }
.edit-tool[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-hover); }
.edit-tool[aria-pressed="true"] svg { stroke-width: 2.4; }
.edit-tool:disabled { opacity: .5; cursor: default; }
.edit-tool[aria-disabled="true"] { position: relative; border-style: dashed; border-color: var(--ink-muted); background: var(--surface-alt); color: var(--ink-soft); cursor: pointer; } /* rc3-A2: a refused Undo / Redo can be tapped for the reason. FX-1: it no longer looks dead like a disabled one - a full-strength icon, a dashed edge, and a dot in the colour of the notice it opens */
.edit-tool[aria-disabled="true"]::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.edit-tool:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: none; }
.edit-tip { flex: 1 1 200px; margin: 0; font-size: 13px; color: var(--ink-soft); }
.editbar > .edit-tip { display: none; } /* FX-1 (A-03): the instruction lives in one place, the tip on the plan (.stage-tip), as it always did on a phone. In the bar it said the same words a second time and, at 1024, pushed the zoom buttons onto a second row: the plan lost 56 px of height after it was fitted, and the scale card then covered an area name */
.edit-zoom { margin-left: auto; }
.editbar-undrawn { display: none; flex: 1 1 100%; margin: 0; font-size: 14px; color: var(--ink-soft); }
.editbar.is-undrawn .tool-group, .editbar.is-undrawn .edit-tip { display: none; }
.editbar.is-undrawn .editbar-undrawn { display: block; }

/* ---- stage while editing ---- */
.stage-tip { position: absolute; top: var(--sp-3); left: 50%; z-index: 6; display: none; max-width: calc(100% - 24px); margin: 0; padding: 8px 14px; border-radius: var(--r-pill); background: var(--navy); color: #ffffff; font-size: 13px; line-height: 1.35; text-align: center; box-shadow: var(--shadow); transform: translateX(-50%); pointer-events: none; }
[data-theme="dark"] .stage-tip { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
body.is-editing .stage-tip { display: block; }
body.is-editing.is-moving .stage-tip, body.is-editing.drawer-open .stage-tip, .editbar.is-undrawn ~ .plan-main .stage-tip { display: none; }
body.is-editing .hint { display: none; }
body.is-editing[data-tool="select"] .machine { cursor: move; }

/* G8: the Sheet open in Edit edits numbers, not the drawing: the tool row (the phone bottom dock), the action bar and
 * the stage tip leave; the unsaved bar (.dft-bar: count, Save, Changes) is not touched */
body.is-editing.is-sheet .editbar, body.is-editing.is-sheet .sel-bar, body.is-editing.is-sheet .stage-tip { display: none; }

/* the viewer shows a record; only the editor shows its editing actions */
body:not(.is-editing) .drawer-actions { display: none; }

/* ---- tablet: room for a finger or a pen ---- */
@media screen and (min-width: 701px) and (max-width: 1299px) {
  .edit-tool { min-height: 48px; padding: 0 16px; }
  .edit-zoom .tool-btn { min-height: 48px; }
}
@media screen and (min-width: 1300px) {
  .editbar { padding: var(--sp-2) var(--sp-5); }
}

/* ---- phone: the edit bar is a bottom bar ---- */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .search { flex: 1 1 140px; }           /* the second row keeps search, Dark and Edit plan on one line at 390 px */
  #edit-btn { padding: 0 12px; }
  body.is-editing .kp-bar-title { display: none; }
  body.is-editing .kp-spacer { display: none; }
  .edit-title { padding: 0 12px 0 10px; font-size: 14px; }
  #done-btn { order: 1; }
  .editbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; flex-wrap: nowrap; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) calc(var(--sp-2) + env(safe-area-inset-bottom)); border-bottom: 0; border-top: 1px solid var(--line); box-shadow: var(--shadow-lg); overflow-x: auto; }
  .tool-group { flex: 0 0 auto; }
  .edit-tool { flex-direction: column; gap: 3px; min-width: 64px; min-height: 54px; padding: 5px 10px; font-size: 11px; line-height: 1.1; }
  .edit-tool svg { width: 20px; height: 20px; }
  .edit-tip { display: none; }
  .edit-zoom #ed-zoom-in, .edit-zoom #ed-zoom-out { display: none; }
  .editbar-undrawn { font-size: 13px; }
  body.is-editing .plan-main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  body.is-editing .foot { display: none; }
  body.is-editing .drawer { bottom: calc(72px + env(safe-area-inset-bottom)); max-height: 54dvh; padding-bottom: 0; }
  .stage-tip { top: var(--sp-2); font-size: 12.5px; padding: 7px 12px; }
}

/* ---- D96 (Fable, 09/11/2026): the record never covers the plan ----
 * Phone: a tap shows a PEEK card (handle, id, name, status, area; at most 28dvh); the handle or a swipe up opens the full
 * record; a swipe down, Close or a tap on empty plan hides it. Tablet and PC: the side panel keeps a hide tab on its left
 * edge; hidden, only the tab stays at the screen edge and the plan takes the room. Editor: a move shows a compact confirm
 * strip and then a short note, never the record. Looks copied from KP CIC (57): 96_matrix.css dialog.mx-drawer / .mx-close
 * (16px top radius, --shadow-lg, 44px close), 04_shell.css .toast (left accent bar, --r-m, fade + rise), 95h .cs-strip. */
.drawer-area { display: none; margin: 4px 0 0; font-size: 14px; color: var(--ink-soft); overflow-wrap: anywhere; }
.drawer-tab { position: absolute; top: 50%; right: var(--drawer-w); z-index: 7; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 10px 0 12px; border: 1px solid var(--line); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--surface); color: var(--ink-soft); font: inherit; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; transform: translateY(-50%); transition: right .22s ease; }
.drawer-tab[hidden] { display: none; }
.drawer-tab:hover { color: var(--ink); background: var(--surface-alt); }
.drawer-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.drawer-tab-ic { font-size: 24px; line-height: 1; transition: transform .22s ease; }
.drawer-tab-text { writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: .02em; white-space: nowrap; }
body.drawer-tucked .drawer-tab { right: 0; }
body.drawer-tucked .drawer-tab-ic { transform: rotate(180deg); }
body.drawer-tucked .drawer { flex-basis: 0; width: 0; border-left: 0; box-shadow: none; overflow: hidden; }
body.drawer-tucked .drawer > * { min-width: var(--drawer-w); box-sizing: border-box; }
.stage-note { position: absolute; left: 50%; bottom: var(--sp-4); z-index: 21; margin: 0; max-width: calc(100% - 2 * var(--sp-3)); padding: 10px 14px 10px 13px; border: 1px solid var(--line); border-left: 3px solid var(--ok, #16a34a); border-radius: var(--r); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--shadow-lg); transform: translate(-50%, 8px) scale(.98); opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.stage-note[hidden] { display: none; }
.stage-note.is-in { opacity: 1; transform: translate(-50%, 0); }
body.is-editing .movebar-text > span:first-child b:first-child { font-family: var(--mono); }
@media (prefers-reduced-motion: no-preference) { .drawer { transition: flex-basis .22s ease, width .22s ease, max-height .22s ease; } }
@media (prefers-reduced-motion: reduce) { .drawer-tab, .drawer-tab-ic, .stage-note { transition: none; } }

@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .drawer-tab { display: none; }
  .drawer-handle { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; width: 100%; height: auto; min-height: 28px; margin: 0; padding: 10px 0 4px; border: 0; border-radius: var(--r) var(--r) 0 0; background: transparent; cursor: pointer; touch-action: none; }
  .drawer-handle::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
  /* T89b: a 44 px tall touch area for the 28 px strip (8 px above it, 8 px below over the head padding). The look does not change. */
  .drawer-handle::after { content: ''; position: absolute; left: 0; right: 0; top: -8px; bottom: -8px; }
  .drawer-handle:focus-visible { outline: 2px solid var(--brand); outline-offset: -4px; }
  .drawer-head { touch-action: none; }
  .drawer.is-peek { max-height: 28dvh; }
  .drawer.is-peek .drawer-body { display: none; }
  .drawer.is-peek .drawer-area { display: block; }
  .drawer.is-peek .drawer-head { border-bottom: 0; padding-bottom: var(--sp-3); }
  /* the confirm strip: one compact row above the edit bar, never the record */
  body.is-editing .movebar { left: var(--sp-2); right: var(--sp-2); bottom: var(--sp-2); flex-wrap: nowrap; gap: var(--sp-2); min-height: 56px; padding: 6px 6px 6px var(--sp-3); }
  body.is-editing .movebar-text { flex: 1 1 auto; min-width: 0; font-size: 13.5px; }
  body.is-editing .movebar-text > span:first-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  body.is-editing .movebar-hint { display: none; }
  body.is-editing .movebar-btns { flex: 0 0 auto; }
  body.is-editing .movebar-btns .tool-btn { flex: 0 0 auto; min-height: 44px; padding: 0 10px; }
  .stage-note { bottom: 44px; max-width: calc(100% - 2 * var(--sp-2)); } /* T33: clear of the scale bar */
  .draw-bar { top: var(--sp-2); max-width: calc(100% - 2 * var(--sp-2)); }
}

/* T33: drawing tools */
.draft-layer { pointer-events: none; }
.draft-shape { fill: var(--brand); fill-opacity: .14; stroke: var(--brand); stroke-width: 2; stroke-dasharray: 6 4; }
.draft-shape.is-open { fill: none; }
.draft-pt { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.draft-pt.is-first { fill: var(--brand); }
.machine .shp.shp-new { stroke-width: 1.75; }
.loose-shape .shp { fill: var(--brand); fill-opacity: .12; stroke: var(--brand); stroke-width: 1.75; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.draw-bar { position: absolute; left: 50%; top: var(--sp-3); z-index: 22; display: flex; align-items: center; gap: var(--sp-2); padding: 6px 8px 6px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); transform: translateX(-50%); white-space: nowrap; }
.draw-bar[hidden] { display: none; }
.draw-bar-text { font-size: 14px; font-weight: 600; }
.draw-bar .tool-btn[hidden] { display: none; }
body[data-tool="rect"] #stage svg, body[data-tool="polygon"] #stage svg { cursor: crosshair; }
/* A5-1: resize handles - small navy/white squares, a dashed frame; the hit square is larger (44 px on touch) and invisible */
.rs-layer .rs-frame { fill: none; stroke: var(--navy); stroke-width: 1.5; stroke-dasharray: 4 3; pointer-events: none; }
.rs-layer .rs-handle { fill: #ffffff; stroke: var(--navy); stroke-width: 1.5; pointer-events: none; }
[data-theme="dark"] .rs-layer .rs-frame { stroke: #ffffff; }
[data-theme="dark"] .rs-layer .rs-handle { fill: var(--navy); stroke: #ffffff; }
.rs-layer .rs-hit { fill: transparent; stroke: none; pointer-events: all; touch-action: none; }
.rs-layer .rs-nwse { cursor: nwse-resize; }
.rs-layer .rs-nesw { cursor: nesw-resize; }
.rs-layer .rs-ns { cursor: ns-resize; }
.rs-layer .rs-ew { cursor: ew-resize; }
body.is-resizing .sel-ring { visibility: hidden; }

/* A5-2: Group into machine - picked loose shapes, the edit-bar action, the panel */
body.is-editing .loose-shape.is-picked .shp { stroke: var(--brand); stroke-width: 3px; stroke-dasharray: 6 3; vector-effect: non-scaling-stroke; fill: var(--brand-soft); }
.edit-group-go[hidden] { display: none; }
.group-panel { position: fixed; z-index: 1000; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; display: grid; gap: var(--sp-3, 12px); padding: var(--sp-4, 16px); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md, 10px); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28), 0 12px 40px rgba(0, 0, 0, .3); }
.group-panel[hidden], .group-panel .gp-box[hidden] { display: none; }
.gp-title { margin: 0; font-size: 18px; }
.gp-count, .gp-num, .gp-err { margin: 0; font-size: 14px; }
.gp-num { color: var(--ink-soft); }
.gp-err { color: var(--danger, #b42318); }
.gp-err:empty { display: none; }
.gp-modes { display: flex; flex-wrap: wrap; gap: var(--sp-2, 8px); }
.gp-box { display: grid; gap: var(--sp-2, 8px); }
.gp-field { display: grid; gap: 4px; font-size: 14px; }
.gp-field input { min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm, 6px); background: var(--surface); color: var(--ink); font: inherit; }
.gp-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 240px; overflow: auto; }
.gp-none { font-size: 14px; color: var(--ink-soft); }
.gp-pick { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 44px; padding: 0 10px; text-align: left; border: 1px solid var(--line); border-radius: var(--r-sm, 6px); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.gp-pick[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.gp-pick-id { font-family: var(--mono, monospace); font-weight: 600; }
.gp-actions { display: flex; justify-content: flex-end; gap: var(--sp-2, 8px); }

/* A5-3: Undo / Redo - two icon buttons in their own group (the Group into machine button sits between it and the tools).
 * Phone: the bottom bar never wraps (nowrap, it scrolls sideways), so Undo / Redo go first and narrower to stay in view. */
.edit-history { padding-left: var(--sp-3); border-left: 1px solid var(--line); }
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .edit-history { order: -1; padding-left: 0; border-left: 0; padding-right: var(--sp-2); border-right: 1px solid var(--line); }
  .edit-history .edit-tool { min-width: 48px; padding: 5px 8px; }
}

/* ==== A6b (Fable, 09/11/2026): notes and strips that never hide each other or cut their words ====
 * - The stage note wraps instead of ending in an ellipsis. Its accent says what kind of note it is: information is neutral
 *   (the default), a change saved on this device is green, a failed save is red (data-tone, set in 50_plan.js).
 * - The hint pill takes its natural width (left: 50% used to squeeze it to half the stage) and steps below the draw bar
 *   while a shape is open (the draw bar is 58 px tall).
 * - Phone: the confirm strip puts its words on their own line above two full-width buttons, so nothing is cut. */
.stage-note { width: max-content; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; text-wrap: balance; border-left-color: var(--info); }
.stage-note[data-tone="ok"] { border-left-color: var(--success); }
.stage-note[data-tone="bad"] { border-left-color: var(--danger); }
.stage-note .nb { white-space: nowrap; } /* an equipment id never breaks at its hyphens */
@media screen and (min-width: 701px) and (max-width: 1299px) and (min-height: 501px) { .stage-note { bottom: 48px; } } /* clear of the scale bar, as on a phone */
/* rc3-A2: the reason for a refused Undo / Redo - the same note, but it wraps, can be tapped and carries a Close button */
.stage-note.is-why:not([hidden]) { display: flex; align-items: center; gap: var(--sp-3); max-width: min(calc(100% - 2 * var(--sp-3)), 560px); padding: 8px 8px 8px 13px; font-weight: 500; pointer-events: auto; }
.stage-note-text { flex: 1 1 auto; min-width: 0; text-wrap: pretty; }
.stage-note-x { flex: 0 0 auto; }
.stage-note.is-why[data-tone] { border-left-color: var(--info); } /* FX-1: a refused Undo / Redo is information, not a failure - the neutral accent, whatever tone the caller passed */
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) { /* the edit bar sits above the plan here: the reason shows just under it */
  .stage-note.is-why { top: var(--sp-3); bottom: auto; transform: translate(-50%, -8px) scale(.98); }
  .stage-tip:has(~ .stage-note.is-why.is-in) { visibility: hidden; } /* one message at a time: the tool tip gives way while the reason shows in its place */
  .stage-note.is-why.is-in { transform: translate(-50%, 0); }
}
.stage-tip { width: max-content; text-wrap: balance; }
.stage:has(.draw-bar:not([hidden])) .stage-tip { top: calc(var(--sp-3) + 66px); }
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .stage-tip { border-radius: var(--r); }
  .stage:has(.draw-bar:not([hidden])) .stage-tip { top: calc(var(--sp-2) + 66px); }
}
@media screen and (max-width: 560px) {
  body.is-editing .movebar { flex-wrap: wrap; row-gap: var(--sp-2); padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3); }
  body.is-editing .movebar-text { flex: 1 1 100%; }
  body.is-editing .movebar-text > span:first-child { display: block; overflow: visible; -webkit-line-clamp: none; }
  body.is-editing .movebar-btns { flex: 1 1 100%; }
  body.is-editing .movebar-btns .tool-btn { flex: 1 1 0; }
}

/* ==== P1 (Fable, 10/11/2026): three layout faults ====
 * 1. Small phones (up to 403 px): the header is always ONE row and every control is a full 44 px target. The row cannot
 *    wrap; spacing tightens, and from 359 px down the second site reads "Balm." (its spoken name stays Balmalcolm). A
 *    browser that cannot do that shortens the name with an ellipsis instead. This also replaces the 30-39 px view buttons
 *    75_sheet.css gave these widths (the .view-switch in the selector is what wins over that file).
 * 2. The search hint never clips: 65_editor.js picks the longest hint that fits the box (end of that file).
 * 4. Phone edit bar: no sideways scroll. The tools share the first row, Undo / Redo and Fit sit under them; on a wide or
 *    sideways phone everything is one row. The plan and the record keep clear of the bar at its real height
 *    (--editbar-h, measured by 65_editor.js; the px values are the fallback until it has measured). */
@media screen and (max-width: 403px) {
  .plan-root .kp-bar { flex-wrap: nowrap; gap: 4px; padding: 4px 8px; }
  .plan-root .kp-bar .kp-spacer { display: none; }
  .plan-root .kp-bar .site-switch { flex: 0 1 auto; min-width: 0; }
  .plan-root .kp-bar .site-btn { flex: 0 0 auto; min-width: 44px; padding: 0 6px; font-size: 14px; white-space: nowrap; }
  .plan-root .kp-bar .site-btn[data-site="balmalcolm"] { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
  .plan-root .kp-bar .view-switch { flex: 0 0 auto; margin-left: auto; }
  .plan-root .kp-bar .view-switch .view-btn { width: 44px; min-width: 44px; padding: 0; }
  .plan-root .kp-bar .more-btn { flex: 0 0 44px; }
  .plan-root .kp-bar .sample-badge { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .plan-root .kp-bar .edit-title { flex: 0 1 auto; min-width: 0; overflow: hidden; }
}
@media screen and (max-width: 383px) { .plan-root .kp-bar { gap: 2px; padding: 4px; } .plan-root .kp-bar .site-btn { padding: 0 4px; font-size: 13px; } }
@media screen and (max-width: 359px) {
  @supports (content: "a" / "b") {
    .plan-root .kp-bar .site-btn[data-site="balmalcolm"] { font-size: 0; }
    .plan-root .kp-bar .site-btn[data-site="balmalcolm"]::after { content: "Balm." / ""; font-size: 13px; }
  }
}
@media screen and (max-width: 330px) { .plan-root .kp-bar { gap: 1px; padding: 4px 3px; } }

@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .editbar { flex-wrap: wrap; gap: 6px var(--sp-2); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); overflow: visible; }
  .editbar:not(.is-undrawn) > .tool-group:not(.edit-history):not(.edit-zoom) { order: 0; flex: 1 1 336px; min-width: 0; max-width: 460px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; align-items: stretch; }
  .editbar .edit-tool { min-width: 44px; padding: 5px 1px; white-space: normal; text-align: center; }
  .editbar .edit-history { order: 1; padding-right: 0; border-right: 0; }
  .editbar .edit-history .edit-tool { min-width: 48px; min-height: 44px; padding: 0 8px; }
  .editbar .edit-group-go { order: 2; flex: 1 1 0; min-width: 0; max-width: 220px; padding: 4px 10px; font-size: 14px; line-height: 1.15; white-space: normal; }
  .editbar .edit-zoom { order: 3; margin-left: auto; }
  body.is-editing { --eb-h: var(--editbar-h, calc(72px + env(safe-area-inset-bottom))); }
  body.is-editing .plan-main { padding-bottom: var(--eb-h); }
  body.is-editing .drawer { bottom: var(--eb-h); }
}
@media screen and (max-width: 560px) { body.is-editing { --eb-h: var(--editbar-h, calc(124px + env(safe-area-inset-bottom))); } }

/* ==== D2 (Fable, 14/11/2026): the save state while editing on a phone ====
 * The phone edit bar covers the footer, so its save line had nowhere to show. 37_sync_ui.js keeps a twin of that line
 * (#svs-chip, signed in only) inside the edit bar; here it takes the first row of the bottom bar. The bar grows by that
 * row and --editbar-h (measured by 65_editor.js) follows, so the plan, the record and the confirm strip stay clear.
 * Tablet and PC keep the footer in view while editing, so the twin is not drawn there. The state colour and icon come
 * from 37_sync_ui.css ([data-svs-tone]); a button in the row (Try again, Sign in again) is a full 44 px target. */
.svs-chip { display: none; }
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .editbar > .svs-chip { order: -2; flex: 0 0 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-width: 0; min-height: 20px; padding: 0 var(--sp-1); color: var(--ink-soft); font-size: 13px; line-height: 1.4; } /* FX-1: 13 px, as the save line in the footer */
  .svs-chip-state { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; padding-left: 17px; text-indent: -17px; } /* D2b: hanging indent (13 px icon + 4 px gap), so a second line starts under the words, not under the icon */
  .svs-chip .svs-hint { display: block; text-indent: 0; } /* D2b: what to do next is always its own line, e.g. "Press Done, then open Changes." */
  .svs-chip .svs-hint:empty { display: none; }
  .svs-chip .svs-lead { color: var(--ink); font-weight: 600; }
  .svs-chip:is([data-svs-tone="offline"], [data-svs-tone="auth"], [data-svs-tone="attn"], [data-svs-tone="error"]) .svs-lead { color: var(--svs-c); }
  .svs-chip .svs-ic { width: 13px; height: 13px; margin-right: 4px; vertical-align: -2px; }
  .svs-chip .svs-act { flex: none; }
}

/* P1 round 2: small tablets (701-900) keep the header on one row at 768 and give the search box room for its hint; larger
 * phones (404-700) get full 44 px view buttons, and the mark steps aside up to 439 px so the row still fits. */
@media screen and (min-width: 701px) and (max-width: 900px) and (min-height: 501px) {
  .plan-root .kp-bar { gap: 6px; padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .plan-root .kp-bar .site-btn { padding: 0 10px; }
  .plan-root .kp-bar .kp-spacer { flex: 0.001 1 0; }
  .plan-root .kp-bar .search { flex: 1 1 140px; min-width: 132px; }
  .plan-root .kp-bar .search-input { padding: 0 10px 0 38px; }
}
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .plan-root .kp-bar .view-switch .view-btn { min-width: 44px; }
}
@media screen and (max-width: 439px) { .plan-root .kp-bar .brand { display: none; } }

/* ==== R30c begin: look fixes from the R30a walk. Presentation only.
 * 1. Upright tablet (701-900): the navy bar sits on ONE row from about 740 px up. Nothing leaves the bar; the gaps
 *    tighten and the search field gives up its spare width first. The bar may still wrap (it never clips) on a
 *    narrower window. In 3D the toolbar stays on one row too; the Area caption steps aside, as it already does on a
 *    phone and from 901 px, and the toolbar lines up with the bar at 12 px.
 * 2. Narrow PC window or a tablet on its side (901-1299): the bar stays on one row; the search field shrinks first.
 * 3. Show retired: the label owns a full 44 px touch area (its padding sits inside the row gap, nothing moves).
 * 4. Phone: the footer lines and the Edit plan tool labels reach 12 px; the toolbar strip fades out under its chevron. */
@media screen and (min-width: 701px) and (max-width: 900px) and (min-height: 501px) {
  .plan-root .kp-bar { gap: 4px; }
  .plan-root .kp-bar .brand, .plan-root .kp-bar .site-switch, .plan-root .kp-bar .view-switch, .plan-root .kp-bar .bar-btn, .plan-root .kp-bar .edit-title, .plan-root .kp-bar .more-menu { flex: 0 0 auto; }
  .plan-root .kp-bar .more-menu { gap: 4px; }
  .plan-root .kp-bar .site-btn { padding: 0 8px; }
  .plan-root .kp-bar .view-btn, .plan-root .kp-bar .bar-btn { padding: 0 10px; white-space: nowrap; }
  .plan-root .kp-bar .search { flex: 1 1 96px; min-width: 96px; }
  .plan-root .kp-bar .sample-badge { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .plan-root .toolbar { column-gap: var(--sp-3); padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .plan-root .toolbar .field-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .plan-root .toolbar .select { max-width: 200px; }
  body.is-3d .toolbar { flex-wrap: nowrap; }
  body.is-3d .toolbar > * { flex: 0 0 auto; }
  body.is-3d .toolbar .tool-btn { white-space: nowrap; }
  body.is-3d .toolbar .counts { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media screen and (min-width: 701px) and (max-width: 800px) and (min-height: 501px) {
  .plan-root .kp-bar .view-btn, .plan-root .kp-bar .bar-btn { padding: 0 8px; }
  .plan-root .kp-bar .search-input { padding: 0 6px 0 36px; }
  .plan-root .toolbar .select { max-width: 164px; }
}
@media screen and (min-width: 901px) and (max-width: 1299px) and (min-height: 501px) {
  .plan-root .kp-bar { flex-wrap: nowrap; }
  .plan-root .kp-bar .brand, .plan-root .kp-bar .site-switch, .plan-root .kp-bar .view-switch, .plan-root .kp-bar .bar-btn, .plan-root .kp-bar .edit-title, .plan-root .kp-bar .more-menu { flex: 0 0 auto; }
  .plan-root .kp-bar .view-btn, .plan-root .kp-bar .bar-btn { white-space: nowrap; }
  .plan-root .kp-bar .search { min-width: 96px; }
  .plan-root .kp-bar .sample-badge { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media screen and (min-width: 901px) and (max-width: 1099px) and (min-height: 501px) {
  .plan-root .kp-bar { gap: var(--sp-2); }
}
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) {
  .plan-root .toolbar .check { padding: 0 var(--sp-2); margin: 0 calc(-1 * var(--sp-2)); }
}
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .plan-root .foot { font-size: 12px; }
  .plan-root .editbar .edit-tool { font-size: 12px; }
  .plan-root .toolbar::after { flex-basis: 60px; background: linear-gradient(to right, transparent, var(--surface) 68%); }
}
/* R30c end ==== */

/* ==== R30d begin: what the R30a / R30c proofs left. Presentation only.
 * 1. Search hint: the clear button takes no room while the field is empty, so the hint the page picks (65_editor.js)
 *    really fits; if words ever do not fit they end in an ellipsis, never mid-letter.
 * 2. Upright tablet (701-900, touch), 2D plan: the toolbar is ONE row. The count line stacks into two short lines
 *    between the tick box and the buttons (a third on a very narrow row); every word stays. The - and + zoom buttons
 *    step aside (pinch zooms, Fit stays), as they already do on a phone and from 901 px. A mouse at these widths
 *    keeps the old two-row toolbar with - and +.
 * 3. 3D at 701-800: the Area list gives up 14 px so the count line is whole. */
.plan-root .kp-bar .search-input { text-overflow: ellipsis; }
.plan-root .kp-bar .search-input:placeholder-shown::-webkit-search-cancel-button { display: none; }
@media screen and (min-width: 701px) and (max-width: 900px) and (min-height: 501px) and (pointer: coarse) {
  body:not(.is-3d):not(.is-sheet) .toolbar { flex-wrap: nowrap; column-gap: var(--sp-2); }
  body:not(.is-3d):not(.is-sheet) .toolbar > :not(#counts) { flex: 0 0 auto; }
  body:not(.is-3d):not(.is-sheet) .toolbar > .counts:empty { display: none; }
  body:not(.is-3d):not(.is-sheet) .toolbar .tool-btn { white-space: nowrap; }
  body:not(.is-3d):not(.is-sheet) .toolbar #zoom-in, body:not(.is-3d):not(.is-sheet) .toolbar #zoom-out { display: none; }
  body:not(.is-3d):not(.is-sheet) .toolbar .select { max-width: 150px; }
  body:not(.is-3d):not(.is-sheet) .toolbar > #counts { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; font-size: 12px; line-height: 14px; }
  body:not(.is-3d):not(.is-sheet) .toolbar .counts-sep { display: none; }
  body:not(.is-3d):not(.is-sheet) .toolbar .counts-main, body:not(.is-3d):not(.is-sheet) .toolbar .counts-rest { display: block; min-width: 0; }
  body:not(.is-3d):not(.is-sheet) .toolbar .counts-a, body:not(.is-3d):not(.is-sheet) .toolbar .counts-b { display: inline-block; white-space: nowrap; }
}
@media screen and (min-width: 701px) and (max-width: 800px) and (min-height: 501px) and (pointer: coarse) {
  body:not(.is-3d):not(.is-sheet) .toolbar .select { max-width: 124px; }
}
@media screen and (min-width: 701px) and (max-width: 760px) and (min-height: 501px) and (pointer: coarse) {
  body:not(.is-3d):not(.is-sheet) .toolbar .select { max-width: 112px; }
}
@media screen and (min-width: 701px) and (max-width: 800px) and (min-height: 501px) {
  body.is-3d .toolbar .select { max-width: 150px; }
}
/* R30d end ==== */

/* ==== R30e begin: phone toolbar edge (R30b read, N1). Presentation only.
 * Phone, touch, 2D plan: the row at rest ends on a whole control. Area, Changes and Fit fill the row up to the 44 px
 * strip that carries the "more" chevron, and the Area list takes the spare width, so no chip is cut at the screen
 * edge. Colour, Key, Show retired and the count follow in the same sideways row and come fully into view with a
 * swipe; a control reached by keyboard stops clear of the chevron strip. A mouse window this narrow keeps the old row. */
@media screen and (max-width: 700px) and (pointer: coarse) {
  body:not(.is-3d):not(.is-sheet) .toolbar { scroll-padding: 0 52px 0 8px; }
  body:not(.is-3d):not(.is-sheet) .toolbar .select { width: calc(100vw - 228px); min-width: 96px; max-width: none; }
  body:not(.is-3d):not(.is-sheet) .toolbar .changes-btn { min-width: 116px; }
  body:not(.is-3d):not(.is-sheet) .toolbar #zoom-in, body:not(.is-3d):not(.is-sheet) .toolbar #zoom-out { display: none; }
  body:not(.is-3d):not(.is-sheet) .toolbar .marks { margin-left: 30px; }
  body:not(.is-3d):not(.is-sheet) .toolbar::after { flex-basis: 44px; background: linear-gradient(to right, transparent, var(--surface) 50%); }
}
/* R30e end ==== */

/* ==== JD1 begin (Fable, 17/11/2026): the plan toolbar on Jakub's brief. Replaces R9a (D354) and D348's words on the button.
 * 1. The Area button says "Area" until an area is picked (50_plan.js, paintAreaBtn). Then it shows the picked names and
 *    this file cuts them to the width of the button with an ellipsis, so a wider button shows more of the name. With two
 *    or more picked a small count sits in front of the names (drawn from data-picked; the spoken name lists them all).
 *    Tablet and PC: the button is as wide as its words, up to the width each screen size already allowed. The "Area"
 *    caption beside it is kept for screen readers only, because the button now says the word itself.
 * 2. Phone, any window up to 700 px and a phone on its side, 2D plan and 3D: the row never scrolls sideways. Area,
 *    Changes and Fit share it in equal widths (3D has no Fit: Area and Changes share it). One 44 px button at the end
 *    of the row opens a second line with Colour, Key and Show retired in equal widths and the machine count under
 *    them: two presses reach any of them. While it is shut the count is still read out. The opener is a details
 *    element in the page (no script); it does not show on tablet or PC, where everything already fits in the row.
 *    A mouse in a narrow window keeps - and + beside Fit, so there Fit keeps its own width and Area and Changes share
 *    the rest equally. The spreadsheet row is not touched.
 * The phone selectors name the toolbar class twice on purpose: they must win over the older phone rows (A6a, A6b, R30e, R30f). */
.toolbar .tb-more { display: none; }
.toolbar .tb-more-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; list-style: none; -webkit-tap-highlight-color: transparent; }
.toolbar .tb-more-btn::-webkit-details-marker { display: none; }
.toolbar .tb-more-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toolbar .tb-more[open] > .tb-more-btn { border-color: var(--brand); background: var(--brand-soft); }
.plan-root .toolbar .field-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toolbar .area-pick-btn { width: auto; min-width: 88px; }
.toolbar .area-pick-btn[data-picked]:not([data-picked="0"]) { font-weight: 600; }
.toolbar .area-pick-btn[data-picked]:not([data-picked="0"]):not([data-picked="1"])::before { content: attr(data-picked); display: inline-block; box-sizing: border-box; min-width: 18px; height: 18px; margin-right: 6px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: var(--on-brand); font-size: 12px; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px; }
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  body.plan-root:not(.is-sheet) .toolbar.toolbar { flex-wrap: wrap; gap: 0 6px; padding: 4px 8px; overflow: hidden; scroll-padding: 0; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar::after { content: none; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .field { order: 1; display: flex; flex: 1 1 0; min-width: 0; gap: 0; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar #area-select { flex: 1 1 auto; min-width: 0; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .area-pick-btn { width: 100%; min-width: 0; max-width: none; padding: 0 24px 0 8px; background-position: right 6px center; font-size: 14px; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .changes { order: 2; flex: 1 1 0; min-width: 0; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .changes-btn { width: 100%; min-width: 0; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .zoom { order: 3; flex: 1 1 0; min-width: 0; margin: 0; gap: var(--sp-1); }
  body.plan-root:not(.is-sheet) .toolbar.toolbar #zoom-fit { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 14px; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .tb-more { display: block; order: 4; flex: 0 0 44px; }
  /* the second line while it is shut: Colour, Key and Show retired are away; the count is kept for screen readers */
  body.plan-root:not(.is-sheet) .toolbar.toolbar .marks, body.plan-root:not(.is-sheet) .toolbar.toolbar .check { display: none; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .counts { order: 8; position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* the second line while it is open: a break, then Colour | Key | Show retired in equal widths, then the count.
   * 34 px = the 6 px gap between Colour and Key plus the 2 x 14 px of edge and padding that Show retired starts from. */
  body.plan-root:not(.is-sheet) .toolbar.toolbar:has(.tb-more[open])::before { content: ""; order: 5; flex: 0 0 100%; height: 0; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar:has(.tb-more[open]) .marks { display: flex; order: 6; flex: 2 1 34px; min-width: 0; gap: 6px; margin: 6px 0 0; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar:has(.tb-more[open]) .marks-btn { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 14px; line-height: 1.15; white-space: normal; }
  body.plan-root:not(.is-sheet):not(.is-3d) .toolbar.toolbar:has(.tb-more[open]) .check { display: flex; box-sizing: border-box; order: 7; flex: 1 1 0; min-width: 0; justify-content: center; gap: 6px; margin: 6px 0 0; padding: 0 6px; font-size: 14px; line-height: 1.15; white-space: normal; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar:has(.tb-more[open]) .counts { position: static; width: auto; height: auto; margin: 4px 0 2px; overflow: visible; clip: auto; flex: 0 0 100%; font-size: 12px; line-height: 16px; white-space: normal; }
}
@media screen and (max-width: 700px) and (hover: hover) and (pointer: fine) {
  body.plan-root:not(.is-sheet) .toolbar.toolbar .zoom { flex: 0 0 auto; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar #zoom-fit { flex: 0 0 auto; min-width: 44px; padding: 0 var(--sp-3); }
}
@media screen and (max-width: 339px) {
  body.plan-root:not(.is-sheet) .toolbar.toolbar { column-gap: 4px; padding-left: 6px; padding-right: 6px; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .area-pick-btn, body.plan-root:not(.is-sheet) .toolbar.toolbar .changes-btn, body.plan-root:not(.is-sheet) .toolbar.toolbar #zoom-fit { font-size: 13px; }
  body.plan-root:not(.is-sheet) .toolbar.toolbar .changes-btn, body.plan-root:not(.is-sheet) .toolbar.toolbar #zoom-fit { padding: 0 4px; }
}
/* JD1 end ==== */

/* ==== R30f begin: phone toolbar edge in the 3D view (what R30e left). Presentation only.
 * Phone, touch, 3D: the row at rest ends on a whole control, as the 2D plan row does since R30e. The 3D row has no
 * Fit button, so Area and Changes fill the row up to the 44 px strip that carries the "more" chevron, and the Area
 * list takes the spare width (8 + 8 + 116 + 44 = 176). Colour starts just past the screen edge, so nothing sits half
 * under the strip. Colour, Key and the count follow in the same sideways row and come fully into view with a swipe;
 * a control reached by keyboard stops clear of the chevron strip. The 2D plan row and the spreadsheet row are not
 * touched; a mouse window this narrow keeps the old row. */
@media screen and (max-width: 700px) and (pointer: coarse) {
  body.is-3d:not(.is-sheet) .toolbar { scroll-padding: 0 52px 0 8px; }
  body.is-3d:not(.is-sheet) .toolbar .select { width: calc(100vw - 176px); min-width: 96px; max-width: none; }
  body.is-3d:not(.is-sheet) .toolbar .changes-btn { min-width: 116px; }
  body.is-3d:not(.is-sheet) .toolbar .marks { margin-left: 36px; }
  body.is-3d:not(.is-sheet) .toolbar::after { flex-basis: 44px; background: linear-gradient(to right, transparent, var(--surface) 50%); }
}
/* R30f end ==== */

/* ==== F12c begin (Fable, 15/11/2026): the View / Edit switch gets a look and a full hit area ====
 * #mode-switch had no styles at all, so it drew as two bare browser buttons, 45 x 21 and 39 x 21, and where the
 * header is tight (a 360 px phone, a 1100 px window) it folded into two stacked slivers. It is now the same pill
 * switch as 2D / 3D / Sheet beside it: each half 44 px high and at least 44 px wide on every screen, the pressed
 * half marked the same way, in both themes. It never shrinks and never folds.
 * Phone, in View: the header has about 52 px for it and two 44 px halves need 88, so only the half you can press
 * ("Edit") is shown there. In Edit both halves show: there is room beside "Editing ...". Tokens only. */
.mode-switch { display: inline-flex; flex: 0 0 auto; border-radius: var(--r-pill); background: var(--kp-bar-tint); box-shadow: inset 0 0 0 1px var(--kp-bar-line); }
.mode-switch[hidden], .mode-btn[hidden] { display: none; }
.mode-btn { position: relative; z-index: 0; flex: 0 0 auto; min-height: 44px; min-width: 44px; margin: 0; padding: 0 10px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--kp-bar-ink); font: inherit; font-size: 15px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; }
.mode-btn[aria-pressed="true"] { color: var(--navy); font-weight: 600; }
[data-theme="dark"] .mode-btn[aria-pressed="true"] { color: var(--on-brand); }
.mode-btn[aria-pressed="true"]::before { content: ""; position: absolute; inset: 3px; z-index: -1; border-radius: var(--r-pill); background: var(--kp-bar-on); }
.mode-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--kp-bar-ring); }
@media screen and (max-width: 1199px) { .mode-btn { padding: 0 8px; } } /* the header is at its tightest from 901 to 1199 px */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .mode-btn { font-size: 14px; }
  body:not(.is-editing) .mode-switch .mode-btn[aria-pressed="true"] { display: none; }
  body:not(.is-editing) .mode-switch .mode-btn { min-width: 48px; }
}
/* F12c end ==== */
/* ==== F12e begin (Fable, 15/11/2026): the Shape button, its arrow and its list; the Sheet in Edit on a phone ====
 * 1. 65_editor.js builds .edit-shape > #tool-shape (draws the shape named on it) + #tool-shape-more (the arrow) +
 *    #tool-shape-menu (role=menu, one .edit-shape-item per shape). None of it had a rule, so the open list sat in the
 *    tool row as more tool buttons and made the bar taller. Now it is one split button with a pop-up list:
 *    PC and tablet - the list hangs under the button, over the plan, and the bar keeps its height;
 *    phone - the list is fixed to the screen just above the bottom bar (--eb-h: the bar, plus the unsaved bar when
 *    there is one), so it never covers Save and is not clipped if the bar ever scrolls sideways.
 *    Rows are 48 px (52 px on a phone); the arrow is 44 px wide at every size. Page tokens only, so dark follows.
 * 2. Sheet open in Edit on a phone: the tool dock is hidden (G8, above) but the plan area still kept the room for
 *    it, an empty band under the cards. The room is now only what the unsaved bar needs (--dft-h, 63_draft.css).
 * Presentation only: no id, role or state is added or read differently. */
.edit-shape { position: relative; display: inline-flex; align-items: stretch; }
.edit-shape > .edit-shape-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.edit-shape > .edit-shape-more { justify-content: center; min-width: 44px; margin-left: -1px; padding: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.edit-shape > .edit-shape-btn[aria-pressed="true"], .edit-shape > .edit-tool:focus-visible { position: relative; z-index: 1; }
.edit-shape > .edit-shape-more[aria-expanded="true"] { position: relative; z-index: 2; background: var(--brand-soft); border-color: var(--brand); color: var(--brand-hover); }
.edit-shape-more svg { transition: transform .15s ease; }
.edit-shape-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.edit-shape-menu { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; box-sizing: border-box; display: grid; gap: 2px; width: max-content; min-width: 220px; max-width: calc(100vw - 16px); margin: 0; padding: var(--sp-1); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.edit-shape-menu[hidden] { display: none; }
.editbar .edit-shape-menu .edit-shape-item { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: var(--sp-3); box-sizing: border-box; width: 100%; min-width: 0; min-height: 48px; margin: 0; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font-size: 15px; font-weight: 500; line-height: 1.2; text-align: left; white-space: nowrap; }
.editbar .edit-shape-menu .edit-shape-item svg { width: 22px; height: 22px; }
.editbar .edit-shape-menu .edit-shape-item > span { flex: 1 1 auto; min-width: 0; }
.editbar .edit-shape-menu .edit-shape-item:hover { background: var(--surface-alt); }
.editbar .edit-shape-menu .edit-shape-item[aria-checked="true"] { background: var(--brand-soft); color: var(--brand-hover); font-weight: 600; }
/* the tick on the shape in use: drawn, not a character, so it needs no font and reads the same in dark */
.editbar .edit-shape-menu .edit-shape-item::after { content: ""; flex: none; box-sizing: border-box; width: 7px; height: 12px; margin: 0 6px 3px var(--sp-2); border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); visibility: hidden; }
.editbar .edit-shape-menu .edit-shape-item[aria-checked="true"]::after { visibility: visible; }
.editbar .edit-shape-menu .edit-shape-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { .edit-shape-more svg { transition: none; } }
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .editbar .edit-shape { position: static; display: grid; grid-template-columns: minmax(0, 1fr) 44px; }
  .edit-shape-more svg { transform: rotate(180deg); } /* the list opens upward from the bottom bar */
  .edit-shape-more[aria-expanded="true"] svg { transform: none; }
  .edit-shape-menu { position: fixed; top: auto; left: var(--sp-2); right: var(--sp-2); bottom: calc(var(--eb-h, 124px) + 6px); width: auto; min-width: 0; max-width: 420px; max-height: calc(100dvh - var(--eb-h, 124px) - 24px); overflow-y: auto; overscroll-behavior: contain; }
  .editbar .edit-shape-menu .edit-shape-item { min-height: 52px; font-size: 16px; }
  .editbar .edit-shape-menu .edit-shape-item svg { width: 24px; height: 24px; }
  body.is-editing.is-sheet .plan-main { padding-bottom: 0; }
  body.is-editing.is-sheet:has(.dft-bar) .plan-main { padding-bottom: var(--dft-h, 0px); }
}
/* F12e end ==== */

/* ==== H-B (Fable, 16/11/2026): the phone top bar. One row from 320 px up; Edit is a pencil (D343) ====
 * Eight 44 px controls need 352 px before any gap, so at 360 px the old bar had no room: the site switch was allowed
 * to shrink and "Balm..." ran under Edit. From 404 to 439 px the bar wrapped to two rows.
 * Now, on a phone (html[data-device="phone"]), while viewing:
 * 1. The site switch never shrinks. Balmalcolm reads "Balm." (a screen reader still says "Balmalcolm").
 * 2. Edit is a 44 x 44 pencil button. Its name is "Edit plan" (aria-label on #mode-edit in the page).
 * 3. The bar never wraps. The one part that gives is the 2D / 3D / Sheet switch: its three parts are 44 px wide when
 *    there is room (368 px and up) and narrow evenly below that (41 px at 360, never under 30). They stay 44 px tall.
 * H-C: the pencil is drawn by CSS inside the phone scope only (a mask on #mode-edit::after). The page keeps the plain
 * word "Edit" in the button, so tablet and PC show it exactly as before. Where masks are missing the word stays. */
html[data-device="phone"] body:not(.is-editing) .kp-bar { flex-wrap: nowrap; }
html[data-device="phone"] .plan-root .kp-bar .site-switch { flex: none; }
html[data-device="phone"] .plan-root .kp-bar .site-btn { flex: none; min-width: 44px; padding: 0 5px; font-size: 13px; white-space: nowrap; overflow: visible; text-overflow: clip; }
@supports (content: "a" / "b") {
  html[data-device="phone"] .plan-root .kp-bar .site-btn[data-site="balmalcolm"] { font-size: 0; }
  html[data-device="phone"] .plan-root .kp-bar .site-btn[data-site="balmalcolm"]::after { content: "Balm." / ""; font-size: 13px; }
}
@supports not (content: "a" / "b") { /* an old browser keeps the full word, cut with dots, as before */
  html[data-device="phone"] .plan-root .kp-bar .site-switch { flex: 0 1 auto; min-width: 0; }
  html[data-device="phone"] .plan-root .kp-bar .site-btn[data-site="balmalcolm"] { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
}
html[data-device="phone"] .plan-root .kp-bar .view-switch { flex: 0 1 auto; min-width: 0; margin-left: auto; }
html[data-device="phone"] .plan-root .kp-bar .view-switch .view-btn { flex: 1 1 44px; width: 44px; min-width: 30px; padding: 0; }
html[data-device="phone"] .plan-root .kp-bar .more-btn { flex: 0 0 44px; }
html[data-device="phone"] body:not(.is-editing) .mode-switch #mode-edit:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; height: 44px; padding: 0; }
@supports ((-webkit-mask-image: none) or (mask-image: none)) {
  html[data-device="phone"] body:not(.is-editing) .mode-switch #mode-edit:not([hidden]) { gap: 0; font-size: 0; }
  html[data-device="phone"] body:not(.is-editing) .mode-switch #mode-edit:not([hidden])::after { content: ""; flex: none; width: 20px; height: 20px; background-color: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L18 10l-4-4L4 16zM13 7l4 4'/%3E%3C/svg%3E") center / 20px 20px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L18 10l-4-4L4 16zM13 7l4 4'/%3E%3C/svg%3E") center / 20px 20px no-repeat; }
}
@media (forced-colors: active) { html[data-device="phone"] body:not(.is-editing) .mode-switch #mode-edit:not([hidden])::after { forced-color-adjust: none; background-color: ButtonText; } }
/* ==== end H-B ==== */

/* ==== N1-7 (Fable, 16/11/2026): phone - full-size view switch and a shorter edit dock. CSS only. ====
 * 1. View switch. At 360 px the bar was 8 px too full and the switch was the one part allowed to shrink, so 2D, 3D
 *    and Table were 41.3 px wide. On screens 360 to 367 px wide the bar now gives those 8 px back itself: 2 px less
 *    padding on each side and 1 px less between the groups. Every segment is then a full 44 x 44. Nothing else in the
 *    bar changes size, the switch may still shrink on a screen narrower than 360 px, and from 368 px up there was
 *    room already. View mode only: the Edit bar is left as it was.
 * 2. Edit dock. The save line had a row of its own above the tools, which made the dock 143 px tall on a 780 px
 *    screen. While it is the quiet line (saved or saving, nothing to do) it now sits in the empty middle of the
 *    Undo / Redo / Fit row, on two short lines, and the tool row is 48 px tall instead of 54. Every control is still
 *    at least 44 x 44. A save line that needs attention (offline, sign-in, error, a button, or a "what to do next"
 *    line) keeps its own full row, exactly as before. The page measures the dock (--editbar-h), so the selection bar
 *    and the draft bar above it follow by themselves. */
@media screen and (min-width: 360px) and (max-width: 367.98px) {
  html[data-device="phone"] body.plan-root:not(.is-editing) header.kp-bar { column-gap: 1px; padding-left: 2px; padding-right: 2px; }
}
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .plan-root .editbar > .svs-chip:not([data-svs-act]):not([data-svs-tone="offline"]):not([data-svs-tone="auth"]):not([data-svs-tone="attn"]):not([data-svs-tone="error"]):not(:has(.svs-hint:not(:empty))) { order: 2; flex: 1 1 150px; min-width: 150px; min-height: 44px; align-self: center; }
  .plan-root .editbar > .tool-group:not(.edit-history):not(.edit-zoom) .edit-tool { min-height: 48px; padding-top: 4px; padding-bottom: 4px; }
}
/* ==== end N1-7 ==== */

/* ==== R3 begin (Fable, 17/11/2026): the dock save line breaks between sentences. Presentation only.
 * Phone edit dock (#svs-chip). The line is two sentences ("Saved to the database." and "Last checked at 03:40.")
 * and it wrapped wherever the width ran out: "Saved to the database. Last / checked at 03:40.". Each sentence is now
 * one piece that moves to the next line whole, so a line ends where a sentence ends. Only a sentence that is wider
 * than the line by itself still wraps (a long date in the 163 px middle slot at 360), in even lines, never with one
 * word alone. The first line keeps its hanging indent for the icon. Tablet and PC do not draw this line. */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .svs-chip .svs-lead, .svs-chip .svs-rest { display: inline-block; max-width: 100%; vertical-align: top; text-indent: 0; text-wrap: balance; }
}
/* R3 end ==== */

/* ==== R4b begin (Fable, 17/11/2026): Show retired takes a finger over its whole label. Presentation only.
 * The label is 44 px tall and about 128 px wide, but a touch screen gives a press to the innermost control under the
 * finger, so the label's own padding lost to the 20 px box inside it or to the control beside it: a real press 3 px
 * inside the label's corner did not tick the box at 800 or at 1280. The box no longer takes presses itself; every
 * press inside the label goes to the label, which ticks the box as it always did. Keyboard use is unchanged (Tab to
 * the box, Space to tick). Nothing moves and nothing changes size. */
.plan-root .toolbar .check input { pointer-events: none; }
/* R4b end ==== */

/* ==== R10css (17/11/2026): four look fixes from the release looks. CSS only, nothing above this line is changed. ==== */

/* R10css-1: an unsaved machine's heading reads "Number on save to database". In Edit the heading has the first row to
 * itself, so its last 22 to 37 px ran behind the Close button. The heading now keeps the button's width plus the usual
 * gap free at its right end, and long words wrap to a second line instead. A saved machine's number (KP-EQ-0130) is far
 * shorter than the room that is left, so it does not move. */
body.is-editing .drawer-head > div > .drawer-id { padding-right: calc(44px + var(--sp-2)); line-height: 1.25; }

/* R10css-2: while a machine is being moved, the move bar sits bottom-centre and reached over the left end of the scale
 * bar (168 px at 800 wide). Up to 1439 px wide the scale bar steps aside for the length of the move, as the hint
 * already does (60_changes.css) and as both do while the shelf is open (56_shelf.css). 1440 and wider: unchanged. */
@media screen and (max-width: 1439px) {
  body.is-moving .scale { display: none; }
}

/* R10css-4: when the open Area list is long enough to reach the bottom of the plan, its last 10 px lay across the top
 * of the hint chip. The list was on top, so its rows read in full and the chip looked cut. The chip steps aside while
 * the list is open and comes back when it closes. */
body:has(#area-pick-list:not([hidden])) .hint { display: none; }

/* R10css-5 (phone layout): the Save refusal for a new machine with no area. "Show changes" sat beside the two sentences
 * and left them 197 px, so each wrapped. It now sits under them, as it already does in the bars with one sentence, and
 * each sentence has the full width (312 px at 360). No text size changes; the bar is 12 px lower than before. */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .dft-bar[data-state="busy"]:has(.dft-sub) .dft-main:has(> .dft-link) { flex-direction: column; align-items: flex-start; justify-content: center; }
  .dft-bar[data-state="busy"]:has(.dft-sub) .dft-main > .dft-link { margin: -10px 0 -6px 16px; }
}
/* ==== R10css end ==== */
