/* The editor's layout (docs/design/editor.html): a title bar over the
   text, the view and the property sheet. Colours, type and controls come from
   /theme.css, the docs site's own visual system (docs/assets/theme.css).
   The view is the plate the docs' renders sit on; the theme accent marks the
   selection; --over/--band paint overhang on a model, --err marks errors and destructive actions. */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: var(--fs-m)/1.45 var(--f-body); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:root { --grid: 1; }

/* The panes' grid is set by js/layout.js (Edit, Inspect, Look; sizes
   remembered); this is the Edit layout before it runs. */
#app { display: grid; height: 100dvh; grid-template-rows: 48px minmax(0, 1fr);
       grid-template-columns: 520px 6px minmax(0, 1fr);
       grid-template-areas: "title title title" "side sash-side view"; }

/* ---- the sidebar: the tile browser, and beside it the editor page ----
   Choosing a tile slides the page in from the right; ‹ slides back (the same slide as every level's). */
/* clip, not hidden: a hidden box can still be scrolled (focus, a cursor kept in view), which leaves the track part way */
#side { grid-area: side; position: relative; overflow: clip; min-width: 0; min-height: 0; background: var(--panel); }
/* the two pages are stacked in one box, and the one slide of the panel (js/slide.js) takes one away and the other in; the one left is only invisible */
#track { position: relative; height: 100%; width: var(--sidew, 100%); flex: none; }
#side { display: flex; }
#app[data-side="left"] #side { justify-content: flex-end; }
.revealing { overflow: hidden; }
@media (max-width: 900px) { #track { width: 100%; } }
#browser, #editpage { position: absolute; inset: 0; min-width: 0; display: flex; flex-direction: column; background: var(--panel); }
#browser.off, #editpage.off { visibility: hidden; }
/* the crumbs: Places, the folders, the tile, then the thing and the control the level is at; and the Tile | Source switch */
/* the ones behind give way first, so where you are is always readable */
#rochip { flex: none; margin-left: 4px; }
/* what the level sits in: a line or two, never the parent's own panel; the Tile | Source switch is at its right */
#ctx, .ctxbar { flex: none; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel); color: var(--muted); font: var(--fs-s)/var(--lh-s) var(--f-body); }
#ctx.named { min-height: 56px; }
#ctx .ctx-name { color: var(--ink); font: 800 var(--fs-xl)/var(--lh-xl) var(--f-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ctx .help { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); }
#ctx-lines, #bctx-lines { flex: 1; min-width: 0; }
#ctx .ln, #bctx .ln { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ctx .ln:first-child, #bctx .ln:first-child { color: var(--ink); }
#ctx.named .ln:first-child { color: var(--muted); }
#face { flex: none; }

/* the browser: the folder levels above the tile (js/editor/places.js) */
#browser { gap: 0; }
.crumbbar { flex: none; display: flex; align-items: center; gap: 4px; min-height: 40px; padding: 4px 8px 4px 6px; border-bottom: 1px solid var(--line); background: var(--bg); min-width: 0; }
.crumbbar .up { flex: none; width: var(--h-md); height: var(--h-md); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--r); background: none; color: var(--accent); cursor: pointer; }
.crumbbar .up:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.crumbbar .up:disabled { opacity: .3; cursor: default; background: none; }
.crumbbar .up:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* the path is one line that keeps its end in view: what is behind fades away at the left */
.crumbbar .cr { flex: 1 1 0; min-width: 0; display: flex; align-items: center; overflow: hidden; position: relative; }
.crumbbar .cr.clipped { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 22px); mask-image: linear-gradient(90deg, transparent 0, #000 22px); }
.crumbs { display: flex; align-items: center; gap: 1px; flex: none; }
.crumbbar .sep { color: var(--line-2); padding: 0 1px; flex: none; display: inline-flex; }
.crumbbar .cr button { flex: none; background: none; border: 1px solid transparent; border-radius: var(--r); height: var(--h-sm); padding: 0 6px; color: var(--muted); cursor: pointer; font-size: var(--fs-m); white-space: nowrap; max-width: 14em; overflow: hidden; text-overflow: ellipsis; }
.crumbbar .cr button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.crumbbar .cr button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.crumbbar .cr .cur { color: var(--ink); font-weight: 650; }
.crumbbar .cr button.drop { color: var(--ink); background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
#tilebtn { display: inline-flex; align-items: baseline; gap: 7px; font-weight: 600; }
#tilebtn:hover { border-color: var(--line); background: var(--panel); }
#forward { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#browsebar { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 8px; }
#browsebar input { width: 100%; min-width: 0; }
#folder-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#folder-actions:empty { display: none; }
#folder-actions .btn { height: var(--h-sm); padding: 0 10px; font-size: var(--fs-s); }
#folder-vp { position: relative; flex: 1; min-height: 0; overflow: clip; }
.flvl { position: absolute; inset: 0; overflow-y: auto; padding-bottom: 14px; background: var(--panel); outline: none; }
.flvl.ghost { pointer-events: none; }
/* a folder level's rows are the tile level's rows (the same .orow), with a picture at the left */
.flist { margin: 0; position: relative; }
.flist .flab { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 12px 4px; }
.flist .flab small, .outline .olab small { font: 400 var(--fs-s)/var(--lh-s) var(--f-body); color: var(--muted); }
.flist .fnote { margin: 8px 14px; color: var(--muted); font-size: var(--fs-s); line-height: 1.5; }
.flist .fnote code { font: var(--fs-s) var(--f-code); }
.flist .orwrap.sel > .orow { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.fico { flex: none; width: 22px; /* h: a folder glyph box */ height: 22px; display: grid; place-items: center; color: var(--muted); }
.orow:hover .fico, .orow:focus-visible .fico { color: var(--accent); }
.orow .thumb.sz { margin: 0; }
.orow .thumb.sz svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.orow .thumb.sz line { stroke: color-mix(in srgb, var(--plate-ink) 38%, var(--plate)); stroke-width: 1; }
.orow .dot { margin-left: 2px; }
.orow .fcount { flex: none; color: var(--muted); font: 500 var(--fs-s) var(--f-code); }
.orwrap:has(.omore) > .orow .fcount { margin-right: 24px; }
.orow .tx .sub b { font-weight: 500; color: var(--ink); opacity: .75; }
/* dragging a tile: the folder that can take it is lit under the pointer */
.flist.dragging, .flist.dragging .orow { cursor: grabbing; user-select: none; }
.flist.dragging .orwrap.cand > .orow { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.orwrap.drop > .orow { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
.flist .orwrap.lift { opacity: .45; box-shadow: none; background: none; border-radius: 0; }
.dragchip { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; max-width: 220px; padding: 5px 10px; border-radius: var(--r); background: var(--raised); border: 1px solid var(--accent); box-shadow: var(--shadow); font: 600 var(--fs-m) var(--f-body); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* one level on screen, full height; a deeper one comes in from the right (js/editor/levels.js) */
#stage { flex: 1; min-height: 0; position: relative; overflow: clip; }
#levels { position: absolute; inset: 0; overflow: clip; }
.lvl { position: absolute; inset: 0; background: var(--panel); outline: none; will-change: transform; }
#stage[data-face="source"] #levels, #stage[data-face="tile"] #source { display: none; }
#stage[data-face="plates"] #levels, #stage[data-face="plates"] #source, #stage[data-face="inventory"] #levels, #stage[data-face="inventory"] #source { display: none; }
#stage:not([data-face="plates"]) #platespanel, #stage:not([data-face="inventory"]) #inventorypanel { display: none; }
#source, #platespanel, #inventorypanel { position: absolute; inset: 0; }
#modes { margin-left: 6px; }


/* ---- sashes: every pane edge can be dragged ---- */
.sash { position: relative; z-index: 4; cursor: col-resize; touch-action: none; background: var(--line); background-clip: content-box; padding: 0 2.5px; }
.sash[aria-orientation="horizontal"] { cursor: row-resize; padding: 2.5px 0; }
.sash::before { content: ""; position: absolute; inset: 0 -4px; }
.sash[aria-orientation="horizontal"]::before { inset: -4px 0; }
.sash:hover, .sash.on { background-color: var(--accent); padding: 0 1.5px; }
.sash[aria-orientation="horizontal"]:hover, .sash[aria-orientation="horizontal"].on { padding: 1.5px 0; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }
body.resizing-rows, body.resizing-rows * { cursor: row-resize !important; user-select: none; }
body.resizing #canvas, body.resizing-rows #canvas { pointer-events: none; }
.pane-x { flex: none; width: var(--h-sm); height: var(--h-sm); display: inline-grid; place-items: center; border: 0; border-radius: var(--r); background: none; color: var(--muted); cursor: pointer; }
.pane-x:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
#about dt { color: var(--muted); } #about dd { margin: 0; color: var(--ink); font-family: var(--f-code); overflow-wrap: anywhere; }
#about .about-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 14px; }
#about .about-hero .mark { width: 96px; height: 96px; color: var(--accent); }
#about .about-hero .wordmark { font-size: var(--fs-xl); margin: 0; }
#about .semver { font-size: var(--fs-l); font-weight: 600; }
#about .build { color: var(--muted); margin: 0 6px 0 4px; }
#keys { width: min(520px, calc(100% - 32px)); }
#keys .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 24px; }
#keys dl { grid-template-columns: auto 1fr; font-size: var(--fs-m); }
#keys dt { white-space: nowrap; } #keys dd { text-align: left; color: var(--ink); }
#layout-seg { width: 100%; }

/* ---- the title bar ---- */
#title { grid-area: title; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid var(--line); position: relative; z-index: 6; background: var(--bg); min-width: 0; }
#title .wordmark { font-size: var(--fs-l); flex: none; }

#tilebtn.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
#tilebtn #tilename { overflow: hidden; text-overflow: ellipsis; }
#tilebtn .where { font-weight: 400; color: var(--muted); font-size: var(--fs-s); }
#rename { font: 600 var(--fs-m)/var(--lh-m) var(--f-body); color: var(--ink); background: var(--raised); border: 1px solid var(--accent); border-radius: var(--r); height: var(--h-md); padding: 0 8px; flex: 1; min-width: 0; outline: 3px solid color-mix(in srgb, var(--accent) 20%, transparent); }
#rename.bad { border-color: var(--err); outline-color: color-mix(in srgb, var(--err) 20%, transparent); }
#savestate { flex: none; font-size: var(--fs-s); color: var(--muted); white-space: nowrap; }
#savestate button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
#savestate button:hover { text-decoration: underline; }
#savestate.bad { color: var(--ink); }
#rochip { flex: none; margin-left: 6px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: var(--r); color: var(--muted); font: var(--fs-s)/var(--lh-s) var(--f-body); cursor: help; }
#history-controls { display: flex; align-items: center; gap: 5px; flex: none; }
.history-split { position: relative; display: inline-flex; }
.history-split > button { height: var(--h-md); color: var(--muted); background: var(--raised); border: 1px solid var(--line); cursor: pointer; }
.history-split > button:first-child { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; font: 500 var(--fs-s)/var(--lh-s) var(--f-body); border-radius: var(--r) 0 0 var(--r); }



.history-split > button:nth-child(2) { width: var(--h-sm); padding: 0; margin-left: -1px; display: inline-grid; place-items: center; border-radius: 0 var(--r) var(--r) 0; }
.history-split > button:hover:not(:disabled) { color: var(--ink); border-color: var(--line-2); z-index: 1; }
.history-split > button:disabled { opacity: .42; cursor: default; }
.history-menu { top: 35px; left: 0; width: min(400px, calc(100vw - 24px)); max-height: min(440px, calc(100vh - 72px)); overflow-y: auto; padding: 5px; }
.history-split:last-child .history-menu { left: auto; right: 0; }
.history-menu button { display: grid; grid-template-columns: minmax(112px, max-content) minmax(0, 1fr) auto; grid-template-areas: "action change distance"; align-items: center; width: 100%; min-height: 30px; gap: 10px; padding: 4px 8px; color: var(--ink); background: none; border: 0; border-radius: var(--r); text-align: left; cursor: pointer; }
.history-menu button:hover, .history-menu button:focus-visible { background: var(--panel); }
.history-menu:has(.with-pic) { width: min(540px, calc(100vw - 24px)); }
.history-menu button.with-pic { grid-template-columns: auto minmax(96px, max-content) minmax(0, 1fr) auto; grid-template-areas: "pics action change distance"; }
.history-menu .pics { grid-area: pics; display: flex; align-items: center; gap: 3px; }
.history-menu .h-pic { width: 56px; border: 1px solid var(--line); border-radius: var(--r); }
.history-menu .h-pic.bad { background: color-mix(in srgb, var(--err) 14%, var(--plate)); }
.history-menu .h-to { width: 0; height: 0; border: 4px solid transparent; border-left: 5px solid var(--muted); border-right: 0; }
.history-menu .action { grid-area: action; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-menu .distance { grid-area: distance; color: var(--muted); font-size: var(--fs-s); white-space: nowrap; }
.history-menu .change { grid-area: change; display: flex; gap: 7px; min-width: 0; overflow: hidden; }
.history-menu code { display: block; min-width: 0; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: pre; padding: 0; font: var(--fs-s)/1.35 var(--f-code); }
.history-menu code.removed { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.history-menu code.added { color: var(--moss); }
#title .grow { flex: 1; }

.menu { position: absolute; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 8px; z-index: 20; }
.menu-find { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.menu-find input { min-width: 0; }
.card { position: absolute; z-index: 20; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 12px 14px; }
/* the export and target cards drop down over the view, never over a pane */
#export-card, #target-card { top: 50px; right: 10px; width: 320px; max-height: calc(100% - 64px); overflow: auto; }
#export-card, #target-card { display: flex; flex-direction: column; gap: 10px; }
#export-card[hidden], #target-card[hidden] { display: none; }

#export-card .seg, #target-card .seg { width: 100%; }
#export-target { margin: 0; color: var(--muted); font-size: var(--fs-s); }
/* the build target: one chip in the title bar, base system and printer */
#target { display: inline-flex; align-items: center; gap: 8px; height: var(--h-md); border: 1px solid var(--line); background: var(--raised); border-radius: var(--r); padding: 0 12px; cursor: pointer; font: var(--fs-s)/var(--lh-s) var(--f-body); white-space: nowrap; color: var(--ink); }
#target:hover, #target[aria-expanded="true"] { border-color: var(--line-2); background: var(--panel); }
#target #target-printer { color: var(--muted); }
#target .bar { width: 1px; height: 12px; background: var(--line-2); flex: none; }
/* ---- the printer chooser (js/editor/printer-chooser.js): the target card and the plates panel ---- */
#target-printers { margin: 0; }
.pc, .pc-pick, .pc-importview { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.pc-list { position: relative; max-height: min(252px, 30vh); min-height: 96px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); overscroll-behavior: contain; }
.pc-group { position: sticky; top: 0; z-index: 1; padding: 4px 9px; background: var(--panel); border-bottom: 1px solid var(--line); }
.pc-group.mine { color: var(--accent); }
.pc-row, .pc-irow { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 9px; color: var(--ink); background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; cursor: pointer; font: var(--fs-m) var(--f-body); }
.pc-row { align-items: center; gap: 10px; }
.pc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pc-bed { flex: none; width: auto; color: var(--muted); }
.pc-bed .bedrect { fill: none; stroke: currentColor; }
.pc-bed rect:not(.bedrect) { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: none; }
.pc-bed.none { width: 8px; }
.pc-scale { margin: 0; color: var(--muted); font-size: var(--fs-s); }
.pc-foot > summary { list-style: none; cursor: pointer; width: 100%; justify-content: space-between; }
.pc-foot > summary::-webkit-details-marker { display: none; }
.pc-foot[open] > summary { margin-bottom: 6px; }
.pc-row:last-child, .pc-irow:last-child { border-bottom: 0; }
.pc-row:hover:not(:disabled), .pc-row:focus-visible, .pc-irow:hover { background: var(--panel); }
.pc-row.on { box-shadow: inset 3px 0 0 var(--accent); }
.pc-row.on .pc-name { color: var(--accent); font-weight: 600; }
.pc-row:disabled { cursor: default; opacity: .75; }
.pc-top { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.pc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-meta { color: var(--muted); font-size: var(--fs-s); }
.pc .own { margin-left: auto; color: var(--muted); font-size: var(--fs-s); font-weight: 500; }
.pc .verify { margin-left: auto; flex: none; color: var(--muted); font-size: var(--fs-s); font-weight: 600; border-bottom: 2px solid var(--caution); line-height: 1.25; }
.pc .verify + .own { margin-left: 0; }
.pc-none { margin: 0; padding: 10px; color: var(--muted); font-size: var(--fs-s); }
.pc-ams > button { flex: 1; }
.pc-foot { display: flex; flex-direction: column; gap: 6px; }
.pc-foot:empty { display: none; }
.pc-import, .pc-go { width: 100%; justify-content: center; }
.pc-ihead { display: flex; align-items: center; gap: 10px; }
.pc-ititle { font-weight: 600; font-size: var(--fs-m); }
.pc-irow { cursor: pointer; }
.pc-irow.have { opacity: .7; cursor: default; }
.pc-itext { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.pc-problems { color: var(--muted); font-size: var(--fs-s); }
.pc-problems summary { cursor: pointer; }
.pc-problems ul { margin: 6px 0 0; padding-left: 16px; max-height: 120px; overflow: auto; }
#target-note { margin: 0; color: var(--muted); font-size: var(--fs-s); }
#target-note code { font: var(--fs-s) var(--f-code); }
#target-card.bad #target-note { color: var(--err); }
#export-why { margin: 0; color: var(--muted); font-size: var(--fs-s); overflow-wrap: anywhere; }
#export-why.bad { color: var(--ink); }
#export-why code { font: var(--fs-s) var(--f-code); }
#export:disabled { opacity: .5; cursor: default; }




/* a tile's state is the status mark (theme.css .dot) */
.dot.ready.over { box-shadow: 0 0 0 2px var(--raised), 0 0 0 3.5px var(--band); }

/* ---- the source ---- */
#source { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
/* a part the tile uses is shown instead of the tile's own text: the only time the source has a bar */
#partbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 36px 6px 12px; font-size: var(--fs-s); color: var(--muted); border-bottom: 1px solid var(--line); }
#partbar #sourcepath { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
#partbar .back { white-space: nowrap; font-size: var(--fs-s); }
#partbar .back:hover { text-decoration: underline; }
#code { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* the editor: CodeMirror (js/text.js), in the theme's colours */
#code .cm-editor { flex: 1; min-height: 0; height: 100%; font: var(--fs-s)/1.75 var(--f-code); color: var(--ink); background: transparent; }
#code .cm-editor.cm-focused { outline: none; }
#code .cm-scroller { font: inherit; line-height: inherit; }
#code .cm-content { padding: 8px 0 40px; caret-color: var(--ink); }
#code .cm-cursor { border-left-color: var(--ink); }
#code.ro .cm-cursor { border-left-color: var(--muted); }
#code .cm-gutters { background: var(--panel); border: 0; color: var(--line-2); }
#code .cm-lineNumbers .cm-gutterElement { padding: 0 4px 0 10px; min-width: 32px; }
#code .cm-activeLineGutter { background: none; color: var(--muted); }
#code .cm-foldGutter .cm-gutterElement { color: var(--muted); padding: 0 2px; cursor: pointer; }
#code .cm-foldPlaceholder { background: var(--raised); border: 1px solid var(--line); color: var(--muted); padding: 0 4px; margin: 0 2px; }
#code .cm-selectionBackground, #code .cm-focused .cm-selectionBackground, #code .cm-content ::selection { background: color-mix(in srgb, var(--accent) 32%, transparent) !important; }
#code .cm-selectionMatch { background: color-mix(in srgb, var(--accent) 14%, transparent); }
#code .cm-matchingBracket { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; outline: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); }
#code .cm-nonmatchingBracket { background: none; color: var(--err); }
#code .cm-line.ln-sel { background: color-mix(in srgb, var(--accent) 20%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
#code .cm-line.ln-hov { background: color-mix(in srgb, var(--accent) 9%, transparent); }
#code .cm-line.ln-err { text-decoration: underline wavy var(--err); text-underline-offset: 4px; }
#code .cm-lint-marker-error { content: none; width: var(--mark); height: var(--mark); border-radius: var(--r-mark); background: var(--err); margin: 8px 3px 0; }
#code .cm-gutter-lint { width: 14px; } #code .cm-gutter-lint .cm-gutterElement { padding: 0; }
#code .cm-panels { background: var(--bg); color: var(--ink); border-color: var(--line); }
#code .cm-panels-top { border-bottom: 1px solid var(--line); }
#code .cm-search { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 6px 30px 6px 10px; font: var(--fs-s) var(--f-body); }
#code .cm-search br { display: none; }
#code .cm-search label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--fs-s); }
#code .cm-textfield { font: var(--fs-s) var(--f-code); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 3px 6px; width: 9em; }
#code .cm-textfield:focus { border-color: var(--accent); outline: none; }
#code .cm-button { font: 500 var(--fs-s) var(--f-body); color: var(--ink); background: var(--raised); background-image: none; border: 1px solid var(--line); border-radius: var(--r); padding: 2px 8px; }
#code .cm-button:hover { border-color: var(--line-2); }
#code .cm-search [name=close] { position: absolute; top: 6px; right: 8px; color: var(--muted); background: none; border: 0; font-size: var(--fs-l); cursor: pointer; }
#code .cm-searchMatch { background: color-mix(in srgb, var(--accent) 20%, transparent); outline: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
#code .cm-searchMatch-selected { background: color-mix(in srgb, var(--accent) 40%, transparent); }
#code .cm-tooltip { background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
#code .cm-tooltip-lint { font: var(--fs-s)/1.45 var(--f-body); max-width: 360px; }
#code .cm-diagnostic-error { border-left-color: var(--err); }

/* completion */
#comp { position: fixed; z-index: 30; width: 340px; max-height: 260px; overflow: auto; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 4px; }
#comp .it, .value-pop .it { display: grid; grid-template-columns: 12px auto minmax(0, 1fr); gap: 9px; align-items: center; padding: 5px 8px; border-radius: var(--r); cursor: pointer; }
#comp .it.on, #comp .it:hover, .value-pop .it.on, .value-pop .it:hover { background: var(--panel); }
#comp .it .sw { width: 10px; height: 10px; border-radius: var(--r-mark); background: var(--fam, var(--line-2)); box-shadow: none; }
#comp .it .nm, .value-pop .it .nm { font: 600 var(--fs-s) var(--f-code); }
#comp .it .ds, .value-pop .it .ds { color: var(--muted); font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* a level's sheet fills its level */
.lvlbox { height: 100%; min-height: 0; display: flex; flex-direction: column; background: var(--panel); user-select: none; }
.lvlbox .lt { flex: none; display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.lvlbox .heading { min-width: 0; display: grid; gap: 2px; }

.lvlbox .lt b { color: var(--ink); font-size: var(--fs-l); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvlbox .lt a { color: var(--muted); font-size: var(--fs-s); margin-left: auto; white-space: nowrap; }
.lvlbox .body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 12px 16px; }
.lvlbox .empty { margin: auto; max-width: 22ch; padding: 28px 18px; color: var(--muted); text-align: center; line-height: 1.55; }
.lvlbox .empty b { display: block; margin-bottom: 5px; color: var(--ink); font: 700 var(--fs-l)/1.1 var(--f-display); }
.lvlbox .empty.unread { margin: 0; max-width: none; text-align: left; padding: 16px 14px 16px 12px; border-left: 3px solid var(--err); }
.lvlbox .empty.unread b { color: var(--err); font: 600 var(--fs-l)/var(--lh-l) var(--f-body); }
.unread .de-text { margin-top: 4px; font-size: var(--fs-m); line-height: var(--lh-m); overflow-wrap: anywhere; color: var(--ink); }
.unread .de-text code { display: block; font: var(--fs-s) var(--f-code); color: var(--muted); }
.unread .de-at, .unread .de-help { color: var(--muted); font-size: var(--fs-s); }
.unread .de-help { margin-top: 2px; font-size: var(--fs-m); }
.unread .w { font: var(--fs-s) var(--f-code); background: rgb(26 23 20 / .08); border-radius: var(--r); padding: 0 3px; }
.unread .de-acts { display: flex; gap: 8px; margin-top: 10px; }
/* a sheet that goes on below the pane says so, as the tile list does with its shadow */
.lvlbox .grp { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-s); color: var(--muted); margin: 8px 0 2px; padding-top: 6px; border-top: 1px solid var(--line); }

.lvlbox .add { margin-top: 10px; }
.lvlbox .row { display: grid; grid-template-columns: 100px minmax(0, 1fr) var(--h-sm) var(--h-sm); align-items: center; min-height: var(--h-md); gap: 4px 0; }
.lvlbox .row .x { grid-column: 3; } .lvlbox .row .chev, .lvlbox .row .x:last-child { grid-column: 4; }
.lvlbox .row .cell:last-child { grid-column: 2 / 5; } .lvlbox .row .cell:has(+ .x:last-child) { grid-column: 2 / 4; } /* a value runs to the one right edge when nothing follows it */
.lvlbox .row .nm { font-size: var(--fs-m); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvlbox .row.faint .nm, .lvlbox .row.faint .val { opacity: .55; }
/* a control not written shows what a build uses, faint, with where that comes from beside it; a chosen word is outlined, not filled */
.lvlbox .row .from { color: var(--muted); font: var(--fs-s) var(--f-body); white-space: nowrap; flex: none; }
.lvlbox .row .absent { font-style: italic; }
.lvlbox .row .lost { color: var(--err); }
.lvlbox .row.faint .words button.on, .lvlbox .row.faint .flip.on { background: none; color: var(--ink); border-color: var(--muted); opacity: .75; }
.lvlbox .row.faint .word-select { color: var(--muted); opacity: .75; }
.lvlbox .cell { min-width: 0; min-height: var(--h-md); display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.lvlbox .val { font: var(--fs-m) var(--f-code); padding: 2px 6px; border-radius: var(--r); cursor: text; white-space: normal; overflow-wrap: anywhere; }
.lvlbox .val:not(:has(.num)) { font-family: var(--f-body); }
.lvlbox .val:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lvlbox .val .q { display: none; }
.lvlbox .val.ro { cursor: default; } .lvlbox .val.ro:hover { background: none; }
.lvlbox .num { border-bottom: 1px dashed var(--accent); cursor: ew-resize; touch-action: none; }
.lvlbox .val.ro .num { border-bottom: 0; cursor: default; }
.lvlbox .num.active { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.lvlbox .unit { color: var(--muted); font: var(--fs-s) var(--f-code); }
/* a length as written: its unit, with the program's words in a tooltip; beside it, quieter, what it prints on the build target */
.lvlbox .val .u { margin-left: .2em; text-decoration: underline dotted var(--muted); text-underline-offset: 2px; }
.lvlbox .printed { color: var(--muted); font: var(--fs-s) var(--f-code); margin-left: 6px; white-space: nowrap; }
.lvlbox .printed.stale { opacity: .45; }
.lvlbox .printed .pnum { border: 0; background: none; padding: 0; color: inherit; font: inherit; cursor: text; border-bottom: 1px dashed var(--muted); }
.lvlbox .printed .pnum:hover { color: var(--ink); border-bottom-color: var(--accent); }
.lvlbox .printed input.pedit { width: auto; height: auto; padding: 0 2px; font: inherit; }
.lvlbox .printed input.pedit.bad { border-color: var(--err); }
.lvlbox .words, .value-pop .words { display: flex; flex-wrap: wrap; gap: 4px; }
.lvlbox .words button, .lvlbox .flip, .value-pop .words button { border: 1px solid var(--line); background: none; border-radius: var(--r); padding: 0 6px; font-size: var(--fs-s); cursor: pointer; }
.lvlbox .words button.on, .lvlbox .flip.on, .value-pop .words button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.lvlbox .word-select { width: 100%; min-width: 0; padding-right: 24px; cursor: pointer; }
.lvlbox .cell > .word-select { width: auto; flex: 1 1 7rem; } /* the mark of where an inherited value comes from sits beside it */
.lvlbox .word-select:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 20%, transparent); outline-offset: 0; }
.lvlbox .word-select:disabled { cursor: default; opacity: .7; }
.lvlbox button:disabled { cursor: default; opacity: .7; }
.lvlbox .x { display: inline-grid; place-items: center; width: var(--h-sm); height: var(--h-sm); border: 0; border-radius: var(--r); background: none; color: var(--muted); cursor: pointer; padding: 0; }
.lvlbox .x:hover { color: var(--ink); }
.lvlbox .note { color: var(--muted); font-size: var(--fs-s); margin: 0 0 6px; }
.lvlbox .linkish, #partbar .back { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.lvlbox .linkish:hover { text-decoration: underline; }
.lvlbox .more { font-size: var(--fs-s); margin-top: 6px; }
/* a tile's size, picked from a grid under the field (lens.js sizeGrid) */
/* the helper under a typed value: what it takes, a check, a number or a range, what can go at the caret */
.value-pop { position: fixed; z-index: 50; display: grid; gap: 6px; padding: 8px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); font-size: var(--fs-s); }
.value-pop .vp-takes { color: var(--muted); }
.value-pop .vp-check { color: var(--ink); font-weight: 600; }
.value-pop .vp-check::before { content: "≠ "; color: var(--muted); }
.value-pop .vp-list { max-height: 200px; overflow: auto; }
.value-pop .it { grid-template-columns: auto minmax(0, 1fr); }
.size-grid { position: fixed; z-index: 50; padding: 8px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.size-cells { display: grid; gap: 3px; width: max-content; }
.size-cell { width: 16px; height: 16px; /* h: a cell of the size grid */ border: 1px solid var(--line-2); border-radius: var(--r-mark); background: var(--bg); cursor: pointer; transition: background .06s, border-color .06s; }
.size-cell.on { background: var(--accent); border-color: var(--accent-hi); }
.size-label { margin-top: 6px; font: var(--fs-s) var(--f-body); color: var(--muted); text-align: center; white-space: nowrap; }
.lvlbox input.edit { width: 100%; height: var(--h-sm); padding: 0 5px; font-family: var(--f-code); border-color: var(--accent); }
.lvlbox .entry-actions { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg); }
.lvlbox .entry-actions button { justify-content: center; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* ---- the view: the plate ---- */
#view { --msgh: 0px; grid-area: view; position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background:
    radial-gradient(ellipse 48% 15% at 18% 55%, var(--sky-cloud) 0, transparent 72%),
    radial-gradient(ellipse 75% 34% at 38% 108%, var(--sky-haze) 0, transparent 72%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 56%, var(--sky-horizon) 100%); }
#canvas { position: absolute; inset: 0 0 calc(26px + var(--msgh)) 0; width: 100%; height: calc(100% - 26px - var(--msgh)); display: block; touch-action: none; outline: none; }
#canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
#viewbar { position: absolute; inset: 10px 10px calc(26px + var(--msgh)) 10px; z-index: 3; display: flex; justify-content: flex-end; align-items: flex-start; gap: 6px; pointer-events: none; }
#viewbar > * { pointer-events: auto; }
#views { width: max-content; }
#views > button { width: 28px; padding: 0; }
#views .ico, #allviews .ico { color: var(--ink); }
#views > button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }

#display { top: 40px; right: 0; width: 276px; max-height: calc(100% - 40px); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding: 12px; }
#display > * { flex: none; } /* the menu scrolls; its rows keep their height */
#display .cap { margin-top: 4px; }
#display .cap:first-child { margin-top: 0; }

#display[hidden] { display: none; }
#display .switch { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: var(--h-sm); }
#display .switch kbd { justify-self: end; }
#display #b-proj { justify-content: space-between; width: 100%; }
#backdrops { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#backdrops .bd { display: flex; align-items: center; gap: 8px; height: var(--h-md); padding: 0 8px; background: none; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; font: 400 var(--fs-s)/var(--lh-s) var(--f-body); color: var(--ink); }
#backdrops .bd:hover { border-color: var(--line-2); }
#backdrops .bd.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
#backdrops .bd-sw { flex: none; width: 24px; height: 16px; /* h: a swatch of the backdrop */ border-radius: var(--r-mark); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .2); }
.bd-wilderness .bd-sw { background: linear-gradient(#8fb6d9 0 45%, #5f8f45 45%); }
.bd-cavern .bd-sw { background: linear-gradient(#3a2c24 0 45%, #16384a 45%); }
.bd-table .bd-sw { background: linear-gradient(#2c2420 0 40%, #9b7b5a 40%); }
.bd-plain .bd-sw { background: #d9e0eb; }
#display .foot .linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
#display .foot .linkish:hover { text-decoration: underline; }
#display .foot kbd { color: var(--muted); }
#display .foot { display: flex; gap: 16px; border-top: 1px solid var(--line); padding-top: 8px; }
#allviews { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
#allviews button { display: flex; align-items: center; gap: 4px; height: var(--h-md); padding: 0 6px; white-space: nowrap; background: none; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; font: 400 var(--fs-s)/var(--lh-s) var(--f-body); color: var(--ink); }
#allviews button:hover { border-color: var(--line-2); }
#allviews button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
#hint { position: absolute; pointer-events: none; color: var(--chip-ink); background: var(--chip-bg); border: 1px solid var(--chip-line); border-radius: var(--r); padding: 3px 8px; font-size: var(--fs-s); white-space: nowrap; box-shadow: 0 6px 16px -10px rgb(26 23 20 / .5); display: none; z-index: 3; }
#toast { position: absolute; z-index: 7; left: 50%; bottom: 90px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 8px 9px 8px 13px; font-size: var(--fs-s); }
#toast button { border: 0; border-radius: var(--r); padding: 3px 7px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); cursor: pointer; font-weight: 600; }

/* overlays on the plate: always the plate's own light chrome, in both themes */
#doc-error { position: absolute; inset: 0 0 calc(26px + var(--msgh)) 0; display: grid; place-items: center; padding: 24px 24px 64px; pointer-events: none; }
#doc-error:empty { display: none; }
.doc-error { pointer-events: auto; width: min(460px, 100%); color: var(--chip-ink); background: var(--chip-bg); border: 1px solid var(--chip-line); border-left: 3px solid var(--chip-err); border-radius: var(--r-lg); box-shadow: var(--chip-shadow); backdrop-filter: blur(10px); padding: 14px 16px; }
.doc-error .de-title { font: 600 var(--fs-l)/var(--lh-l) var(--f-body); color: var(--chip-err); }
.doc-error .de-text { margin-top: 4px; font-size: var(--fs-m); line-height: var(--lh-m); overflow-wrap: anywhere; }
.doc-error .de-at, .doc-error .de-help { color: var(--chip-muted); font-size: var(--fs-s); }
.doc-error .de-help { margin-top: 2px; font-size: var(--fs-m); }
.doc-error .w { font: var(--fs-s) var(--f-code); background: rgb(26 23 20 / .08); border-radius: var(--r); padding: 0 3px; }
.doc-error .de-acts { display: flex; gap: 8px; margin-top: 10px; }
#empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; }
.empty-card { width: min(420px, 100%); text-align: center; color: var(--chip-ink); background: var(--chip-bg); border: 1px solid var(--chip-line); border-radius: var(--r-lg); box-shadow: var(--chip-shadow); backdrop-filter: blur(10px); padding: 28px; }
.empty-card .mark { display: inline-block; width: 42px; height: 42px; color: var(--plate-ink); }
.empty-card h1 { font: 700 var(--fs-xl)/1 var(--f-display); margin: 8px 0; }
.empty-card p { color: var(--chip-muted); margin: 0 auto 20px; max-width: 32ch; }
.empty-card .row-btns { justify-content: center; flex-wrap: wrap; }


.fam-water { --fam: var(--water); } .fam-base { --fam: var(--line-2); }

/* ---- the record card ---- */
dl { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 5px 12px; margin: 0; font-size: var(--fs-m); }
dt { color: var(--muted); } dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
dd.bad { color: var(--over); font-weight: 600; } dd.warn { color: var(--band); } dd.ok { color: var(--ok); }
#legend { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); font-size: var(--fs-s); } #legend li { display: flex; gap: 8px; align-items: center; margin: 5px 0; }
.sw { width: 12px; height: 12px; border-radius: var(--r-mark); flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .18); }

/* ---- smaller screens: the panes narrow, then flow under the view ---- */
@media (max-width: 1200px) { .history-label { display: none; } }
@media (max-width: 760px) { #target #target-printer, #target .dot { display: none; } }
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: 48px 62vh auto; grid-template-areas: "title" "view" "side"; }
  #side { height: 75vh; border-top: 1px solid var(--line); }
  .sash, #panelbtn { display: none !important; }
  #title .wordmark .txt { display: none; }
  .history-label { display: none; }
}
/* a phone: the title bar is two rows (what you are making and how far back you can go, then the target and the buttons), not one
   row that runs off the screen or lets the mode buttons stack over the view */
@media (max-width: 560px) {
  #app { grid-template-rows: auto 62vh auto; }
  #title { flex-wrap: wrap; row-gap: 4px; padding-block: 6px; min-height: 48px; }
  #title .seg, #title .seg > button { white-space: nowrap; flex-wrap: nowrap; }
  #title #savestate:empty { display: none; }
  #title .grow { flex: 0 0 100%; height: 0; }   /* the line break: the target and the buttons start the second row */
  #title #target { margin-right: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* the map overlay and the bar (stage 4: place and draw) */
#over { position: absolute; inset: 0 0 calc(26px + var(--msgh)) 0; width: 100%; height: calc(100% - 26px - var(--msgh)); pointer-events: none; z-index: 1; }
#canvas.tool { cursor: crosshair; }
#canvas.grab { cursor: grab; }
#place { position: absolute; left: 50%; bottom: 38px; transform: translateX(-50%); width: min(460px, calc(100% - 24px)); z-index: 3; display: flex; flex-direction: column; gap: 6px; }
#place-in { width: 100%; box-sizing: border-box; font: 500 var(--fs-m) var(--f-code); padding: 0 12px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink); box-shadow: var(--shadow); }
#place-in::placeholder { color: var(--muted); font-family: var(--f-body); }
#place-in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow); }
#place-list { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 4px; max-height: 240px; overflow: auto; }
#place-list .it { display: grid; grid-template-columns: 12px auto minmax(0, 1fr); gap: 9px; align-items: center; padding: 5px 8px; border-radius: var(--r); cursor: pointer; }
#place-list .it.on, #place-list .it:hover { background: var(--panel); }
#place-list .it .sw { width: 10px; height: 10px; border-radius: var(--r-mark); background: var(--fam, var(--line-2)); }
#place-list .it b { font: 600 var(--fs-s) var(--f-code); }
#place-list .it span { color: var(--muted); font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tool { display: flex; align-items: center; gap: 10px; align-self: center; background: var(--accent); color: var(--on-accent); border-radius: var(--r); height: var(--h-md); padding: 0 3px 0 14px; font-size: var(--fs-s); box-shadow: var(--shadow); max-width: 100%; }
#tool[hidden] { display: none; }
#tool b { font: 600 var(--fs-s) var(--f-code); white-space: nowrap; }
#tool span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
#tool button { border: 0; background: color-mix(in srgb, var(--on-accent) 18%, transparent); color: inherit; width: var(--h-sm); height: var(--h-sm); border-radius: var(--r); cursor: pointer; flex: none; display: grid; place-items: center; padding: 0; }

/* a seed's dice: another arrangement */
.lvlbox .dice { flex: none; width: var(--h-sm); height: var(--h-sm); display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--muted); cursor: pointer; padding: 0; }
.lvlbox .dice:hover { color: var(--accent); border-color: var(--accent); }


/* the debug layer's legend: top left of the view, only while the layer is on */
#debug-legend { left: 10px; top: 50px; width: 290px; max-height: calc(100% - 130px); overflow: auto; padding: 10px 12px; }
#debug-legend .cap { display: flex; justify-content: space-between; align-items: center; }
#debug-rows { list-style: none; margin: 8px 0 0; padding: 0; font-size: var(--fs-s); }
#debug-rows li { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
#debug-rows .sw { flex: none; width: 12px; height: 12px; border-radius: var(--r-mark); }
#debug-rows .sw.dot { border-radius: 50%; /*round*/ box-shadow: inset 0 0 0 2px rgb(0 0 0 / .35); }
#debug-rows .sw.line { height: 3px; border-radius: var(--r-mark); }
#debug-rows .sw.column { width: 4px; height: 14px; border-radius: var(--r-mark); margin: 0 4px; }
#debug-rows .sw.ramp { width: 36px; height: 8px; border-radius: var(--r-mark); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .18); }
#debug-rows .sw.sheet { opacity: .6; outline: 1px solid currentColor; }
#debug-rows .n { margin-left: auto; color: var(--muted); font: var(--fs-s) var(--f-code); }
#debug-thinned { margin: 6px 0 0; color: var(--muted); font-size: var(--fs-s); }

/* the start-up failure banner (index.html): shown only when the editor could not load or start */
#boot-error { position: fixed; inset: 16px 16px auto; z-index: 1000; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-lg); background: var(--raised); color: var(--ink); border: 2px solid var(--err); box-shadow: 0 8px 30px rgb(0 0 0 / .35); }
#boot-error b { color: var(--err); }

/* ---- the status line and the messages panel (js/editor/panel.js) ----
   One stream of messages, drawn twice: 26 px under the view, and a panel that rises over the view's
   lower part.  Notes are --caution, errors --err (the interface's danger); on the model the gate's
   --over and --band are overhang's alone. */
/* the status line is the shared component (theme.css `.statusline`, js/view/status-line.js): the bar is only where it sits */
#statusbar { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; /* h: the status line, a bar */ min-height: 0; z-index: 6; gap: 14px; padding: 0 12px 0 0; }
#sb-main { height: 100%; min-height: 0; white-space: nowrap; min-width: 0; flex-wrap: nowrap; }
#sb-counts:not(:empty)::before { content: "· "; }





#sb-saved.bad { color: var(--ink); }
#sb-saved:empty { display: none; }
#statusbar .grow { flex: 1; }

#msgpanel { position: absolute; left: 0; right: 0; bottom: 26px; z-index: 6; display: flex; flex-direction: column; height: min(340px, 56%); background: var(--bg); border-top: 1px solid var(--line-2); }
#msgpanel[hidden] { display: none; }
#msg-sash { position: absolute; left: 0; right: 0; top: -3px; height: 6px; background-color: transparent; }
#msg-sash:hover, #msg-sash.on { background-color: var(--accent); }
#msg-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); }
#msg-head b { font-size: var(--fs-s); }
#msg-filters { flex: none; }

#msg-filters .n { color: var(--muted); font-size: var(--fs-s); }
#msg-filters .on .n { color: inherit; opacity: .8; }
#msg-head .grow { flex: 1; }
#msg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 0; }
#msgpanel #legend { flex: none; display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 0; padding: 5px 12px; border-top: 1px solid var(--line); font-size: var(--fs-s); color: var(--muted); }
#msgpanel #legend li { display: flex; gap: 6px; align-items: center; margin: 0; }
#view.msgs-open #place { bottom: calc(var(--msgh) + 38px); }
#view.msgs-open #toast { bottom: calc(var(--msgh) + 90px); }

/* ---- the tile level: what the tile holds, as rows ---- */
.outline { margin: 6px -12px 0; position: relative; }
.outline .olab { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 12px 4px; }

.outline .oempty { margin: 6px 12px; color: var(--muted); font-size: var(--fs-s); }
.orwrap { position: relative; background: var(--panel); }
.orow { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 4px 10px 4px 12px; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; color: var(--ink); cursor: pointer; font: inherit; position: relative; }
.orwrap:last-child > .orow, .orwrap:has(+ .olab) > .orow { border-bottom: 1px solid var(--line); }
.orow:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.orow:focus-visible { outline: none; background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
/* a row's ⋯ sits left of its chevron, over the row (a button cannot hold a button) */
.orwrap:has(.omore) > .orow .chev { margin-left: 24px; }
.omore { position: absolute; right: 30px; top: 50%; transform: translateY(-50%); width: var(--h-sm); height: var(--h-sm); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--r); background: none; color: var(--muted); cursor: pointer; opacity: .55; }
.orwrap:hover .omore, .omore:focus-visible, .omore[aria-expanded="true"], .orwrap:focus-within .omore { opacity: 1; }
.omore:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); color: var(--ink); }
.omore:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.orow.oadd { color: var(--accent); min-height: 40px; }
.orow.oadd .nm { color: var(--accent); }
.orow.oadd .plus { flex: none; width: 14px; text-align: center; font: 500 var(--fs-l)/1 var(--f-body); }
.orow.oadd[aria-busy="true"] { opacity: .6; cursor: progress; }
/* a stack row is lifted by the pointer and a line shows where it will stand */
.outline.dragging, .outline.dragging .orow { cursor: grabbing; user-select: none; }
.orwrap.lift { z-index: 3; background: var(--raised); box-shadow: var(--shadow); border-radius: var(--r); pointer-events: none; }
.orwrap.lift > .orow { border-color: transparent; }
.odrop { position: absolute; left: 10px; right: 10px; height: 3px; margin-top: -1.5px; background: var(--accent); border-radius: var(--r-mark); pointer-events: none; z-index: 4; }
.odrop::before { content: ""; position: absolute; left: -3px; top: -2px; width: 7px; height: 7px; border-radius: 50%; /*round*/ background: var(--accent); }
.orow .tx { min-width: 0; flex: 1; display: grid; gap: 1px; }
.orow .nm { font-size: var(--fs-m); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow .sub { color: var(--muted); font: 400 var(--fs-s)/var(--lh-s) var(--f-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the stack row's thickness bar: its height band on one scale for the whole stack (view/outline.js), the tile's zero a tick */
.orow .trow { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.orow .tbar { position: relative; flex: 1; height: 6px; border-radius: var(--r-mark); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.orow .tbar b { position: absolute; top: 0; bottom: 0; border-radius: var(--r-mark); background: var(--fam, var(--stone)); }
.orow .tbar .z { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.orow .trange { flex: none; color: var(--muted); font: 400 var(--fs-s)/1 var(--f-code); white-space: nowrap; }
.orow .no { flex: none; width: 14px; text-align: right; color: var(--muted); font: 600 var(--fs-s) var(--f-code); }
/* a stack row's number, swatch, name and chevron share the name's first line (baseline); the padding keeps the row at 46 px, its ⋯ is on that line too */
.orow:has(> .no) { align-items: baseline; padding-block: 11.5px; }
.orow:has(> .no):has(.sub) { padding-block: 4.5px; }
.orwrap:has(> .orow > .no) > .omore { top: 9.5px; transform: none; }
.orwrap:has(> .orow > .no):has(.sub) > .omore { top: 2.5px; }
.orow:has(> .no) .chev { align-self: flex-start; margin-top: -2px; } /* on the name's line: its center is 21.5 px down, or 14.5 with a sub-line, either way 12 px under the box's top */

.orow:has(> .no) .badge { align-self: flex-start; margin-top: 5.5px; }
.orow:has(> .no) :is(.no, .nm) { line-height: 20px; }
.orow:has(> .no) .sub { line-height: 16px; }
.orow:has(> .no) .gl { align-self: flex-start; margin-top: 3.5px; }
.orow .gl { flex: none; width: 13px; height: 13px; border-radius: var(--r-mark); background: var(--fam, var(--line-2)); }
.orow .gl.line { background: none; border-radius: 0; height: 0; width: 15px; border-top: 2px solid var(--water); transform: rotate(-24deg); }
.orow .gl.region { background: color-mix(in srgb, var(--moss) 28%, transparent); border: 1.5px solid var(--moss); border-radius: var(--r); }
.orow .chev, .lvlbox .chev { flex: none; display: inline-grid; place-items: center; color: var(--muted); width: var(--h-sm); height: var(--h-sm); background: none; border: 0; padding: 0; cursor: pointer; }
.lvlbox .chev:hover, .orow:hover .chev { color: var(--accent); }
.fam-surface { --fam: var(--earth); } .fam-plant { --fam: var(--moss); } .fam-thing { --fam: var(--stone); }
.orow .badge { flex: none; min-width: var(--mark); height: var(--mark); border-radius: var(--r-mark); background: var(--caution); box-shadow: 0 0 0 2px var(--panel); color: #1A1714; font: 700 var(--fs-s)/var(--lh-s) var(--f-body); text-align: center; }
.orow .badge.error { background: var(--err); color: #fff; }
.orow .badge:not(:empty) { min-width: 16px; height: 16px; /* h: a count badge, not a control */ line-height: 16px; padding: 0 4px; border-radius: var(--r); }

/* the Shape rows' pictures: a region's mask as the build paints it, a line's points, on the plate */
.thumb { position: relative; flex: none; display: block; border: 1px solid color-mix(in srgb, var(--plate-ink) 30%, var(--plate)); border-radius: var(--r); background: var(--plate); overflow: hidden; }
.thumb.region i { position: absolute; inset: 0; background: color-mix(in srgb, var(--moss) 62%, var(--plate-ink)); -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.thumb.region.empty { border-style: dashed; }
.thumb.line svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.thumb.line polyline { fill: none; stroke: color-mix(in srgb, var(--water) 55%, var(--plate-ink)); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* the row menu, the Add list and the name field: popups over the page */
.rmenu { position: fixed; z-index: 60; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); overflow-y: auto; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 6px; }
.rmenu.addmenu { width: 340px; }
.rmenu .rhead { padding: 8px 8px 4px; }
.rmenu .rsep { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.ritem { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 8px; border: 0; border-radius: var(--r); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.ritem:hover, .ritem:focus-visible { background: color-mix(in srgb, var(--accent) 13%, transparent); outline: none; }
.ritem:focus-visible { box-shadow: inset 3px 0 0 var(--accent); }
.ritem .gl { flex: none; width: 13px; height: 13px; border-radius: var(--r-mark); background: var(--fam, var(--line-2)); }
.ritem .tx { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ritem .nm { font-size: var(--fs-m); font-weight: 550; }
.ritem .sub { color: var(--muted); font-size: var(--fs-s); line-height: 1.35; }
.ritem kbd { flex: none; margin-left: auto; color: var(--muted); font: 500 var(--fs-s) var(--f-code); }
.ritem.danger .nm { color: var(--err); }
.ritem.off { cursor: default; }
.ritem.off .nm, .ritem.off .gl { opacity: .55; }
.ritem.off:hover { background: none; }
.ritem.off:focus-visible { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.ritem .sub.why { font-style: italic; }
.addmenu .ritem .sub:not(.why) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.addmenu .ritem .sub.why { white-space: normal; }
.rpop { width: 290px; padding: 12px; }
.rlab { display: block; margin-bottom: 6px; font: 600 var(--fs-s)/1.2 var(--f-body); }
.rerr { min-height: 18px; /* h: the error line keeps its room */ margin-top: 4px; color: var(--err); font-size: var(--fs-s); }
.rnote { margin: 2px 0 10px; color: var(--muted); font-size: var(--fs-s); line-height: 1.45; }
.rbtns { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- the control level ---- */
#lens-control .body { display: grid; gap: 8px; align-content: start; }
.pabout { margin: 0 0 4px; color: var(--ink); opacity: .85; font-size: var(--fs-m); line-height: 1.5; }
.plab { margin: 10px 0 0; }
.pfield { display: grid; gap: 5px; }
.pin { font-family: var(--f-code); }

.pin:disabled { opacity: .7; }
.pcheck { color: var(--err); font-size: var(--fs-s); }
.pforms { align-self: start; justify-self: start; }

.pnames button { font: var(--fs-s) var(--f-code) !important; }
.pmore { font-size: var(--fs-s); color: var(--muted); }
.pmore summary { cursor: pointer; }
.pforms-help { display: grid; grid-template-columns: 1fr; gap: 2px; margin: 6px 0 0; }
.pforms-help dt { font: var(--fs-s) var(--f-code); color: var(--ink); } .pforms-help dd { margin: 0 0 6px; text-align: left; color: var(--muted); }
.ptakes { grid-template-columns: auto 1fr; }
.ptakes dd { text-align: left; font: var(--fs-s) var(--f-code); }
.pwritten code { display: block; padding: 8px 9px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); font: var(--fs-s)/1.5 var(--f-code); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.lvlbox .lt.slim { min-height: 34px; padding: 6px 12px; }

/* ---- the plates panel (js/editor/plates.js): the printer, the mode, the spacing, the plates, Export ---- */
.pl-sec { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.pl-sec:last-child { border-bottom: 0; }
.pl-sec h3 { margin: 0 0 8px; }
.seed-in { display: flex; align-items: center; gap: 8px; min-width: 0; }
.seed-in > :first-child { flex: 1; min-width: 0; }
.pl-field { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 30px; margin: 3px 0; }
.pl-lab { color: var(--muted); font-size: var(--fs-s); }

.pl-num { display: inline-flex; align-items: baseline; gap: 5px; }
.pl-num input { width: 74px; font-family: var(--f-code); }
.pl-num input:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 20%, transparent); outline-offset: 0; }
.pl-sec .note.ok { color: var(--muted); }
.pl-sec .note.bad { color: var(--err); }
.pl-sec .note.warn { color: var(--ink); }
.pl-sec .note.verify { font-style: italic; }
.pl-plates { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
/* a plate as a small picture of its bed (view/plates-panel.js Bed): one scale, every piece its own top-down picture */
.pl-bed { grid-column: 1 / -1; position: relative; display: block; width: 100%; margin-bottom: 4px; background: var(--plate); border: 1px solid var(--plate-ink); border-radius: var(--r-mark); overflow: hidden; }
.pl-bp { position: absolute; display: block; box-sizing: border-box; background: var(--plate-hi); border: 1px solid color-mix(in srgb, var(--plate-ink) 40%, transparent); overflow: hidden; }
.pl-bp.pin { box-shadow: inset 0 0 0 1.5px var(--accent); }
.pl-bimg { position: absolute; left: 50%; top: 50%; display: block; }
.pl-bimg .pl-bpic { width: 100%; height: 100%; aspect-ratio: auto; }
.pl-plate { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 2px; align-content: start; text-align: left; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--ink); cursor: pointer; font: var(--fs-m) var(--f-body); }
.pl-plate:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.pl-plate.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.pl-plate b { font-weight: 650; }
.pl-plate .pl-n { color: var(--muted); font-size: var(--fs-s); justify-self: end; }
.pl-plate .pl-fil, .pl-plate .pl-what { grid-column: 1 / -1; color: var(--muted); font-size: var(--fs-s); }
.pl-plate .pl-fil { font-size: var(--fs-s); }
.pl-export .btn { width: 100%; justify-content: center; }
.pl-files { display: grid; gap: 2px; margin: 6px 0 4px; }
.pl-files code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-s); }
body.plates #place { display: none; }
.pl-help { color: var(--muted); }

/* ---- the inventory (js/editor/inventory.js, js/inventory.js; docs/inventory.html) ---- */
/* the pills on a tile's row in a folder: have is filled, need an outline; caution is the notes colour as a stripe, never orange or red (those are overhang) */
.orow .ipill, .mp-pills .ipill, .mp-title .ipill { flex: none; padding: 1px 7px; border-radius: var(--r); font: 600 var(--fs-s)/1.5 var(--f-body); white-space: nowrap; }
.orow .ipill.have, .mp-pills .ipill.have, .mp-title .ipill.have { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.orow .ipill.need, .mp-pills .ipill.need, .mp-title .ipill.need { color: var(--muted); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line-2); }
.orwrap:has(.omore) > .orow .ipill { margin-right: 24px; }
.orow .ipill.caution, .mp-pills .ipill.caution, .mp-title .ipill.caution { background: var(--raised); color: var(--ink); box-shadow: inset 3px 0 0 var(--caution), inset 0 0 0 1px var(--line-2); }
/* the tile level's block */
.inv-block { margin: 6px 0 4px; padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.inv-block h3 { margin: 0 0 6px; }
.inv-have { margin: 0 0 6px; font-size: var(--fs-m); }
.inv-have.none { color: var(--muted); }
.inv-edited { margin: 0 0 6px; padding-left: 8px; font-size: var(--fs-s); color: var(--ink); box-shadow: inset 3px 0 0 var(--caution); }
.inv-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inv-ask .pl-field { grid-template-columns: auto auto; margin: 0; }
.inv-ask .btn { margin-left: auto; }
/* the list's pieces in the plates' panel */
.pl-pc { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 4px; padding: 2px 0; font-size: var(--fs-s); }
.pl-pc.skip { opacity: .55; }
.pl-pn { min-width: 0; display: grid; }
.pl-pn b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-ps { color: var(--muted); font-size: var(--fs-s); }
.pl-cnt { min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; }
.pl-step { width: var(--h-sm); height: var(--h-sm); display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--ink); cursor: pointer; }
.pl-step:hover:not(:disabled) { border-color: var(--accent); }
.pl-step:disabled { opacity: .4; cursor: default; }
/* the plates panel: the summary line, the pieces against the shelf, the sheet after a print */
.inv-sum { margin: 0 0 8px; font-size: var(--fs-m); color: var(--muted); }
.inv-sum b { color: var(--ink); font-weight: 650; }
.pl-kinds { display: grid; gap: 2px; margin-top: 8px; }
.pl-kind { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; padding: 3px 0 3px 8px; font-size: var(--fs-s); }
.pl-kind b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-kind .pl-kw { display: none; }
.pl-kind .pl-kt { color: var(--muted); text-align: right; }
.pl-kind.caution { box-shadow: inset 3px 0 0 var(--caution); }
.pl-kind.caution .pl-kt { color: var(--ink); }
.pl-sheet { display: grid; gap: 1px; margin: 4px 0 8px; max-height: 260px; overflow: auto; }
.pl-piece { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; column-gap: 8px; padding: 4px 6px; border-radius: var(--r); font-size: var(--fs-s); cursor: pointer; }
.pl-piece:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.pl-piece input { accent-color: var(--accent); }
.pl-piece b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-piece .pl-seed { color: var(--muted); font-family: var(--f-code); font-size: var(--fs-s); }
.pl-piece .pl-res { width: 3.6em; text-align: right; color: var(--muted); }
.pl-piece.bad { background: color-mix(in srgb, var(--err) 9%, transparent); }
.pl-piece.bad .pl-res { color: var(--err); }
.pl-after-go { display: flex; align-items: center; gap: 12px; }
/* the inventory's own view: full width, no model */
body.inventory #app { grid-template-columns: minmax(0, 1fr) 0 0 !important; grid-template-areas: "title title title" "side side side" !important; }
body.inventory #view, body.inventory #sash-side { display: none !important; }
/* the inventory is the whole window: its track takes the width, not the side panel's remembered one (--sidew) */
body.inventory #track { width: 100%; }
#inventorypanel .lvlbox .body { max-width: 920px; width: 100%; margin: 0 auto; }
#inventorypanel .lvlbox .lt { padding-inline: max(12px, calc((100% - 920px) / 2 + 12px)); }
.inv-face { margin-left: auto; }
.inv-filters { display: flex; flex-wrap: wrap; gap: 2px 18px; margin-bottom: 6px; }
.inv-filters .pl-field { grid-template-columns: auto auto; margin: 3px 0; }
.inv-totals { margin: 4px 0 10px; color: var(--muted); font-size: var(--fs-s); }
.inv-group { margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); }
.inv-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding: 8px 10px 6px; border-bottom: 1px solid var(--line); }
.inv-head b { font-size: var(--fs-m); font-weight: 650; }
.inv-tag { color: var(--muted); font-size: var(--fs-s); white-space: nowrap; }
.inv-tag.edited { color: var(--ink); padding-left: 7px; box-shadow: inset 3px 0 0 var(--caution); margin-left: auto; }
/* the shelf: a tile's prints as a grid of cards, each its picture (view/inventory-panel.js PieceCard) */
.inv-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; padding: 8px 10px 10px; }
.inv-card { display: grid; grid-template-rows: auto 1fr auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); overflow: hidden; min-width: 0; }
.inv-card.off { color: var(--muted); }
.inv-card.off .inv-pic { opacity: .5; }
.inv-shot { position: relative; }
.inv-shot .inv-pic { width: 100%; aspect-ratio: 176 / 124; }
.inv-badge { position: absolute; right: 6px; top: 6px; padding: 1px 6px; border-radius: var(--r-mark); background: var(--ink); color: var(--bg); font: 700 var(--fs-s)/1.4 var(--f-body); }
.inv-meta { display: grid; gap: 1px; padding: 5px 8px 3px; min-width: 0; align-content: start; }
.inv-meta b { font-weight: 650; font-size: var(--fs-m); }
/* the colour and the date wrap rather than clip: "printed 9 Nov" is what the card is for */
.inv-sub { color: var(--muted); font-size: var(--fs-s); overflow-wrap: anywhere; }
.inv-card .inv-acts { padding: 2px 8px 7px; }
.inv-reprint-row { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.inv-wrap { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.inv-wrap:first-of-type { border-top: 0; }
.inv-piece { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 10px; font-size: var(--fs-m); }
.inv-piece.off { color: var(--muted); }
.inv-what { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.inv-pic { width: 44px; border-radius: var(--r); }
.inv-acts { display: flex; gap: 12px; }
.inv-acts .linkish:disabled { opacity: .4; cursor: default; }
.inv-reprint, .inv-relink { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px 8px; background: color-mix(in srgb, var(--panel) 70%, transparent); font-size: var(--fs-s); }
.inv-reprint .pl-lab { color: var(--muted); }
.inv-reprint select, .inv-relink select { width: auto; max-width: 100%; flex: 0 1 300px; }
.inv-gone { color: var(--ink); padding-left: 8px; box-shadow: inset 3px 0 0 var(--caution); }
.inv-source { margin: 0 0 10px; padding: 8px 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); font: var(--fs-s)/1.55 var(--f-code); overflow: auto; user-select: text; }
.inv-source .ln { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); }
.inv-source .no { color: var(--muted); text-align: right; padding-right: 10px; user-select: none; }
.inv-source .tx { white-space: pre; }
@media (max-width: 700px) { .inv-piece { grid-template-columns: 1fr; } }

/* ---- the map's panel (js/editor/scene-panel.js; docs/maps.html): the map, one piece, a property ---- */
/* the map as a plan (view/map-panel.js MapPlan): the squares on the plate, each piece its own top-down picture */
.mplan-wrap { display: flex; gap: 14px; align-items: flex-start; margin: 4px 0 10px; }
.mplan { position: relative; flex: 0 1 220px; min-width: 0; max-height: 300px; background: var(--plate); border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.mplan-grid { position: absolute; inset: 0; width: 100%; height: 100%; }
.mplan-grid path { fill: none; stroke: color-mix(in srgb, var(--plate-ink) 22%, transparent); stroke-width: 1; vector-effect: non-scaling-stroke; }
.mplan-p { position: absolute; display: block; padding: 0; margin: 0; border: 1px solid color-mix(in srgb, var(--plate-ink) 45%, transparent); background: var(--plate-hi); cursor: pointer; overflow: hidden; border-radius: var(--r-mark); box-sizing: border-box; }
.mplan-p:hover, .mplan-p:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -1px; z-index: 1; }
.mplan-p.on { outline: 2px solid var(--accent); outline-offset: -1px; z-index: 2; }
.mplan-img { position: absolute; left: 50%; top: 50%; display: block; }
.mplan-img .mplan-pic { width: 100%; height: 100%; aspect-ratio: auto; }
.mplan-p.skip { border-style: dashed; }
.mplan-p.skip .mplan-img { opacity: .38; }
.mplan-mark { position: absolute; left: 3px; top: 3px; width: 11px; height: 11px; display: none; box-shadow: 0 0 0 1px rgb(255 255 255 / .95); border-radius: var(--r-mark); }
.mplan-p.have .mplan-mark { display: block; background: var(--ok); }
.mplan-p.other .mplan-mark { display: block; background: var(--caution); }
.mplan-key { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: var(--fs-m); min-width: 0; }
.mplan-key li { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.mplan-key .mplan-n { color: var(--ink); margin-bottom: 3px; }
.mplan-sw { flex: none; width: 10px; height: 10px; border-radius: var(--r-mark); box-sizing: border-box; }
.mplan-sw.have { background: var(--ok); }
.mplan-sw.other { background: var(--caution); }
.mplan-sw.need { background: var(--plate); box-shadow: inset 0 0 0 1px var(--line-2); }
.mplan-sw.skip { border: 1.5px dashed var(--line-2); }
@media (max-width: 460px) { .mplan-wrap { flex-direction: column; } .mplan { flex-basis: auto; width: min(100%, 240px); } }
.mp-row { display: flex; gap: 8px; margin: 8px 0 2px; }
.mp-row.wrap { flex-wrap: wrap; }
.mp-row .btn { white-space: nowrap; }
.mp-group { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 8px; margin: 0 0 4px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--ink); cursor: pointer; font: var(--fs-m) var(--f-body); }
.mp-group:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.mp-group b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.mp-pills { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.mp-group.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--raised)); box-shadow: inset 3px 0 0 var(--accent); }
.mp-h { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 4px; }
.mp-list { margin-top: 6px; }
.mp-list .note { margin: 6px 0; }
.mp-tray { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 8px; padding: 3px 0; font-size: var(--fs-m); }
.mp-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mp-title b { font-size: var(--fs-l); font-weight: 650; }
.mp-id { font: var(--fs-s) var(--f-code); color: var(--muted); }
.mp-val { font: var(--fs-m) var(--f-code); color: var(--ink); }
.mp-btns { display: inline-flex; align-items: center; gap: 6px; }
.mp-prop { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 30px; margin: 3px 0; padding: 0; background: none; border: 0; text-align: left; color: var(--ink); cursor: pointer; font: var(--fs-m) var(--f-body); }
.mp-prop:hover .mp-go { color: var(--accent); }
.mp-go { color: var(--muted); font-size: var(--fs-l); padding-right: 2px; }
.mp-choice { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; gap: 8px; align-items: baseline; text-align: left; padding: 6px 8px; margin: 0 0 3px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--ink); cursor: pointer; font: var(--fs-m) var(--f-body); }
.mp-choice:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.mp-choice.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.mp-choice b { font: 600 var(--fs-s) var(--f-code); }
.mp-sub { color: var(--muted); font-size: var(--fs-s); }
.mp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.mp-chip { padding: 3px 10px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--raised); color: var(--ink); cursor: pointer; font: 600 var(--fs-s) var(--f-code); }
.mp-chip:hover:not(:disabled) { border-color: var(--accent); }
.mp-chip.on { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); }
body.map #place { display: none; }
#canvas.grab { cursor: grab; }

/* ---- the Add step's level (js/view/map-panel.js AddView; docs/maps.html): the piece list above, the folder's list with pictures below; its trail is the panel's ---- */
#lens-add, #lens-add2 { container-type: size; }
.addlvl { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.add-up { flex: 0 1 auto; max-height: 34%; min-height: 0; overflow: auto; padding: 2px 12px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.add-up .mp-h { margin-top: 8px; }
.add-fold { display: none; flex: none; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* a short panel keeps one line of the list: what is on the map and what was just added */
@container (max-height: 540px) { .add-up { display: none; } .add-fold { display: block; } }
.add-low { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.add-filter { flex: none; padding: 0 12px 8px; }
.add-filter input { width: 100%; min-width: 0; }
.add-body { position: relative; flex: 1; min-height: 0; overflow: clip; }
.agrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 2px 12px 10px; }
.arow { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 0 8px; }
.arow b { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: var(--fs-s); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asize { color: var(--muted); font-size: var(--fs-s); white-space: nowrap; }
.apic { width: 100%; aspect-ratio: 176 / 124; background: var(--plate, #D9E0EB); border-radius: calc(var(--r) - 1px) calc(var(--r) - 1px) 0 0; overflow: hidden; }
.apic img { width: 100%; height: 100%; display: block; }
.apic.bad { box-shadow: inset 0 0 0 2px var(--err); }
.acard .ipill { margin: 0 8px; justify-self: start; padding: 1px 7px; border-radius: var(--r); font: 600 var(--fs-s)/1.5 var(--f-body); }
.acard .ipill.have { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.acard .ipill.need { color: var(--muted); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line-2); }
/* the row of the tile just put on the map lights up and fades (two names, so a second tile of the same row lights it again) */
@keyframes mp-just0 { from { box-shadow: 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 28%, var(--raised)); } to { box-shadow: 0 0 0 2px transparent; } }
@keyframes mp-just1 { from { box-shadow: 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 28%, var(--raised)); } to { box-shadow: 0 0 0 2px transparent; } }
.mp-group.just0 { animation: mp-just0 1.7s ease-out; }
.mp-group.just1 { animation: mp-just1 1.7s ease-out; }
@media (prefers-reduced-motion: reduce) { .mp-group.just0, .mp-group.just1 { animation: none; box-shadow: 0 0 0 2px var(--accent); } }

/* ---- have and need on the map's pieces (js/editor/scene.js): over the view, never orange or red (those are overhang) ---- */
#mpills { position: absolute; inset: 0 0 calc(26px + var(--msgh)) 0; overflow: hidden; pointer-events: none; z-index: 1; }
body:not(.map) #mpills { display: none; }
#ppins { position: absolute; inset: 0 0 calc(26px + var(--msgh)) 0; overflow: hidden; pointer-events: none; z-index: 1; }
.mp-tag { position: absolute; left: 0; top: 0; padding: 1px 7px; border-radius: var(--r); font: 600 var(--fs-s)/1.5 var(--f-body); white-space: nowrap; background: color-mix(in srgb, var(--bg) 82%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 3px rgba(0, 0, 0, .25); will-change: transform; }
.mp-tag.have { background: color-mix(in srgb, var(--accent) 78%, var(--bg)); color: var(--on-accent, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, #000), 0 1px 3px rgba(0, 0, 0, .3); }
.mp-tag.need { color: var(--muted); font-weight: 500; }
.mp-tag.caution { box-shadow: inset 3px 0 0 var(--caution), inset 0 0 0 1px var(--line-2), 0 1px 3px rgba(0, 0, 0, .25); }

/* ---- one thing alone: the thing's own view beside the tile's ---- */
#thing-switch { width: max-content; }
#thingview { position: absolute; inset: 0 0 calc(26px + var(--msgh)) 0; z-index: 2; background: var(--plate); }
#thingview[hidden] { display: none; }
#view.thing-on #canvas, #view.thing-on #over, #view.thing-on #views, #view.thing-on #dispbtn, #view.thing-on #mpills, #view.thing-on #ppins, #view.thing-on #place { visibility: hidden; }
#thing-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#thing-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
#thing-panel { position: absolute; inset: 0; pointer-events: none; }
#thing-panel > * { pointer-events: auto; }
.thing-card { position: absolute; left: 10px; top: 10px; z-index: 4; width: min(320px, calc(100% - 20px)); max-height: calc(100% - 190px); overflow-y: auto; overscroll-behavior: contain; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
.thing-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.thing-head b { font-family: var(--f-code); overflow-wrap: anywhere; }
.thing-of, .thing-busy, .thing-card .from { color: var(--muted); }
.thing-seed { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.thing-seed input { width: 5.5em; height: var(--h-sm); box-sizing: border-box; font: var(--fs-s)/var(--lh-s) var(--f-code); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 0 6px; }
.thing-seed .btn { height: var(--h-sm); padding: 0 10px; }
.thing-seed .dice { flex: none; width: var(--h-sm); height: var(--h-sm); display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--muted); cursor: pointer; padding: 0; }
.thing-seed .dice:hover { color: var(--accent); border-color: var(--accent); }
.thing-draft { margin: 0; color: var(--muted); font: var(--fs-s)/var(--lh-s) var(--f-body); }
.thing-problem { margin: 0; padding: 6px 8px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--err); color: var(--ink); overflow-wrap: anywhere; }
.thing-extent, .thing-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; margin: 0; font: var(--fs-s)/var(--lh-s) var(--f-body); }
.thing-extent > div, .thing-controls > div { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 6px; }
.thing-extent dt, .thing-controls dt { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.thing-extent dd, .thing-controls dd { margin: 0; font-family: var(--f-code); overflow-wrap: anywhere; }
.thing-extent .from, .thing-controls .from { font-family: var(--f-body); }
.thing-extent .from { display: block; }
.thing-extent .sw { display: inline-block; flex: none; width: 18px; height: 8px; box-sizing: border-box; background: var(--plate); border-top: 3px solid var(--plate-ink); border-radius: var(--r-mark); }
.thing-extent .sw.most { border-top-color: var(--accent); }
.thing-strip { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; gap: 6px; align-items: stretch; padding: 8px 10px 10px; overflow-x: auto; overscroll-behavior-x: contain; background: linear-gradient(0deg, color-mix(in srgb, var(--plate) 92%, transparent), transparent); }
.thing-strip .seed-card { flex: 0 0 104px; }
.thing-more { flex: none; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
@media (max-width: 560px) {
  .thing-card { top: 52px; max-height: calc(100% - 52px - 132px); width: calc(100% - 20px); }
  .thing-controls, .thing-looks, .thing-draft { display: none; }
  .thing-strip .seed-card { flex-basis: 84px; }
  .thing-extent > div, .thing-controls > div { grid-template-columns: 5.5em minmax(0, 1fr); }
}
