/* TurkeyBoards Tools — Ergogen Builder. Builds on editor.css (shell, panel, tabs) and components.css. */

.ergo .ed-main { --panel-w: 400px; }
#preview { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
#preview:focus { outline: none; }
#preview:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
#preview.panning { cursor: grabbing; }
.engine-state { font: 400 12px/1 var(--font-mono); color: var(--ink-muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.engine-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.engine-state.is-ready::before { background: var(--success); }
.engine-state.is-error { color: var(--danger); }
.engine-state.is-error::before { background: var(--danger); }

/* preview drawing (millimetres) */
.pv-edge { fill: var(--brand-deck); fill-opacity: .35; fill-rule: evenodd; stroke: var(--brand-feather); stroke-width: .5; }
.pv-plate { fill: none; stroke: var(--brand-beak); stroke-width: .45; stroke-dasharray: 2 1.2; }
.pv-key rect { fill: var(--keycap); stroke: var(--brand-outline); stroke-width: .5; }
.pv-key.is-thumb rect { fill: var(--brand-feather-light); }
.pv-part rect { fill: var(--surface); fill-opacity: .55; stroke: var(--brand-beak); stroke-width: .35; stroke-dasharray: 1.4 .8; }
.pv-body rect { fill: var(--surface); fill-opacity: .95; stroke: var(--brand-beak); stroke-width: .5; }
.pv-body text { fill: var(--ink); font: 700 3px var(--font-mono); }
.pv-part.is-clash rect, .pv-body.is-clash rect, .pv-hole circle { fill: var(--surface); stroke: var(--brand-outline); stroke-width: .5; }
.pv-hole .ring, .pv-body.is-hole .ring { fill: none; stroke: var(--ink-muted); stroke-width: .3; stroke-dasharray: .8 .6; }
.pv-body.is-hole circle:not(.ring) { fill: var(--surface); stroke: var(--brand-outline); stroke-width: .5; }
.pv-led rect { fill: #fff3bf; stroke: #f08c00; stroke-width: .4; }
.pv-led circle { fill: #f08c00; opacity: .6; }
.pv-key.is-clash rect { stroke: var(--danger); stroke-width: .9; stroke-dasharray: none; }
.pv-key.is-clash rect { fill: color-mix(in srgb, var(--danger) 18%, var(--keycap)); }
.pv-net { fill: #001634; font: 700 3.6px var(--font-mono); }
.pv-row { fill: #0078b4; }
.pv-dim { fill: var(--ink-muted); font: 400 4.2px var(--font-mono); }
.preview-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 8px; padding: 24px; color: var(--ink-muted); }
.preview-empty b { color: var(--ink); font-size: 16px; }
.preview-empty p { margin: 0; max-width: 40em; font-size: 13px; }

/* first-visit card */
.nudge-card { position: absolute; top: 16px; left: 16px; max-width: 340px; padding: 14px 16px; background: var(--surface); border: 2px solid var(--sticker-edge); border-radius: var(--radius-lg); box-shadow: var(--shadow-sticker); display: grid; gap: 6px; font-size: 13px; line-height: 20px; }
.nudge-card b { font: 700 15px/20px var(--font-display); }
.nudge-card p { margin: 0; color: var(--ink-muted); }

/* design controls */
fieldset.design { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 22px; }
fieldset.design:disabled { opacity: .45; }
.dock-bottom fieldset.design { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; column-gap: 28px; }
.detached-note { display: grid; gap: 6px; padding: 12px; border-radius: var(--radius-md); border: 1.5px solid var(--warning); background: var(--surface-sunken); font-size: 13px; line-height: 19px; }
.detached-note p { margin: 0; color: var(--ink-muted); }
.seg-wide { display: flex; width: 100%; border-radius: var(--radius-md); }
.seg-wide button { flex: 1; height: auto; min-height: 30px; padding: 6px 8px; border-radius: 8px; line-height: 15px; display: grid; justify-items: center; gap: 2px; }
.seg-wide button small { font: 400 10px/12px var(--font-mono); color: var(--ink-muted); }
.col-table { display: grid; gap: 4px; }
.ct-h, .ct-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.ct-h span { font: 700 10.5px/14px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.ct-name { font: 700 12px/1 var(--font-mono); display: grid; gap: 3px; }
.ct-name small { font: 400 10px/1.2 var(--font-mono); color: var(--ink-muted); }
.ct-row label { position: relative; display: block; }
.ct-row input { padding-right: 26px; height: 30px; }
.ct-row i { position: absolute; right: 8px; top: 6px; font: 400 11px/18px var(--font-mono); color: var(--ink-muted); font-style: normal; pointer-events: none; }
#pin-count.is-warn { color: var(--warning); }

/* YAML editor: a textarea over a coloured copy of the same text, with line numbers */
.code-group { display: grid; gap: 10px; }
.code-bar { display: flex; align-items: center; gap: 10px; }
.check.small { font-size: 13px; }
.code-wrap { --code-h: max(300px, calc(100vh - 360px)); display: grid; grid-template-columns: auto minmax(0, 1fr); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-sunken); overflow: hidden; }
.code-wrap:focus-within { border-color: var(--brand-feather-deep); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-feather) 30%, transparent); }
.code-lines { margin: 0; padding: 10px 6px 10px 10px; font: 400 12.5px/19px var(--font-mono); color: var(--ink-muted); text-align: right; opacity: .7; overflow: hidden; user-select: none; height: var(--code-h); border-right: 1px solid var(--line); min-width: 3.2em; }
.code-lines b.is-err { color: var(--danger); }
.code-stack { position: relative; height: var(--code-h); min-width: 0; }
.code-hl, textarea.code { position: absolute; inset: 0; margin: 0; padding: 10px 12px; font: 400 12.5px/19px var(--font-mono); white-space: pre; tab-size: 2; overflow: auto; border: 0; }
.code-hl { pointer-events: none; color: var(--ink); overflow: hidden; }
textarea.code { resize: none; background: transparent; color: transparent; caret-color: var(--ink); outline: none; width: 100%; height: 100%; }
textarea.code::selection { background: color-mix(in srgb, var(--brand-feather) 40%, transparent); color: transparent; }
.y-line { display: inline-block; min-width: 100%; }
.y-line.is-err { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.y-key { color: var(--brand-feather-deep); font-weight: 700; }
[data-theme="dark"] .y-key { color: var(--brand-feather); }
.y-punct, .y-dash { color: var(--ink-muted); font-style: normal; }
.y-str { color: #2f9e44; }
.y-num { color: #e8590c; }
.y-bool { color: #ae3ec9; }
.y-re { color: #c2255c; }
.y-com { color: var(--ink-muted); font-style: italic; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .y-key { color: var(--brand-feather); } :root:not([data-theme="light"]) .y-str { color: #8ce99a; } :root:not([data-theme="light"]) .y-num { color: #ffa94d; } :root:not([data-theme="light"]) .y-bool { color: #e599f7; } :root:not([data-theme="light"]) .y-re { color: #faa2c1; } }
[data-theme="dark"] .y-str { color: #8ce99a; }
[data-theme="dark"] .y-num { color: #ffa94d; }
[data-theme="dark"] .y-bool { color: #e599f7; }
[data-theme="dark"] .y-re { color: #faa2c1; }
.dock-bottom .code-wrap { --code-h: max(160px, calc(var(--panel-h, 320px) - 170px)); }
kbd { font: 400 11px/1 var(--font-mono); padding: 2px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }
/* wide code view: the editor takes most of the window, the preview stays beside it */
body.code-wide.code-tab .ed-main:not(.dock-bottom) { grid-template-columns: minmax(280px, 1fr) min(62vw, 980px) !important; }
body.code-wide.code-tab .ed-main.dock-bottom { grid-template-rows: minmax(160px, 1fr) min(64vh, 720px) !important; }
body.code-wide.code-tab .dock-bottom .code-wrap { --code-h: calc(min(64vh, 720px) - 170px); }
.engine-state.is-busy::before { background: var(--brand-feather); animation: tbt-pulse .8s ease-in-out infinite alternate; }
@keyframes tbt-pulse { from { opacity: .3; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .engine-state.is-busy::before { animation: none; } }

/* output */
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.file-list li div { display: grid; gap: 2px; min-width: 0; }
.file-list b { font: 700 12.5px/18px var(--font-mono); overflow-wrap: anywhere; }
.file-list span { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.file-list .tb-btn { flex: none; }
.pin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pin-table th, .pin-table td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.pin-table thead th { font: 700 10.5px/14px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.pin-table tbody th { font-weight: 400; color: var(--ink-muted); }
.pin-table td { font-family: var(--font-mono); }
.pin-table .is-warn { color: var(--warning); }
#qmk-snippet { min-height: 220px; margin-top: 8px; }
.next-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 13px; line-height: 20px; }
.st-error { color: var(--danger); white-space: normal; }

/* guided setup: a card over the preview, keeping the preview visible */
.wizard { position: fixed; z-index: 55; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(56px + env(safe-area-inset-bottom, 0px)); width: min(460px, calc(100vw - 32px)); }
.wizard-card { padding: 18px; background: var(--surface); border: 2px solid var(--sticker-edge); border-radius: var(--radius-lg); box-shadow: var(--shadow-sticker), var(--shadow-pop); display: grid; gap: 10px; }
.wiz-top { display: flex; justify-content: space-between; align-items: center; }
.wizard h2 { margin: 0; font: 700 20px/26px var(--font-display); letter-spacing: -0.02em; }
.wiz-lede { margin: 0; font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.wiz-options { display: grid; gap: 8px; }
.wiz-opt { text-align: left; display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-md); border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font: 400 12.5px/18px var(--font-ui); }
.wiz-opt b { font-size: 14px; }
.wiz-opt span { color: var(--ink-muted); }
.wiz-opt:hover { background: var(--surface-sunken); }
.wiz-opt[aria-pressed="true"] { border: 2px solid var(--sticker-edge); background: var(--brand-feather); color: var(--on-feather); box-shadow: 2px 2px 0 var(--sticker-edge); }
.wiz-opt[aria-pressed="true"] span { color: var(--on-feather); }
.tour-dots { display: flex; gap: 5px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.tour-dots i.on { background: var(--brand-feather-deep); width: 16px; border-radius: 3px; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-spacer { flex: 1; }
@media (max-width: 900px) { .wizard { bottom: 16px; } .code-wrap { --code-h: 320px; } }
.thumb-sizes { display: flex; flex-wrap: wrap; gap: 6px; }
.thumb-sizes label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-muted); }
.thumb-sizes select { width: auto; min-width: 0; padding-right: 22px; }

/* footprints that aren't part of Ergogen (the Seeed XIAOs) */
.nonstd { border: 1px dashed var(--warning); border-radius: var(--radius-md); padding: var(--space-3); margin: var(--space-2) 0 var(--space-3); display: grid; gap: var(--space-2); justify-items: start; }
.nonstd p { margin: 0; font-size: 13px; color: var(--ink-muted); line-height: 1.5; }
.nonstd-tag { display: inline-block; font-style: normal; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--warning); border: 1px solid currentColor; border-radius: var(--radius-pill); padding: 1px 8px; vertical-align: 1px; }

/* editing on the picture */
#preview .pv-key, #preview .pv-part, #preview .pv-body, #preview .pv-hole { cursor: pointer; }
#preview .pv-key.is-sel, #preview .pv-part.is-sel, #preview .pv-part.is-sel-group, #preview .pv-body.is-sel, #preview .pv-body.is-sel-group { cursor: move; }
#preview.dragging, #preview.dragging * { cursor: grabbing !important; }
.pv-key.is-sel rect { stroke: var(--selection); stroke-width: 1.1; fill: color-mix(in srgb, var(--selection) 22%, var(--keycap)); }
.pv-key.is-thumb.is-sel rect { fill: color-mix(in srgb, var(--selection) 35%, var(--brand-feather-light)); }
.pv-part.is-sel rect, .pv-body.is-sel rect, .pv-body.is-sel circle:not(.ring), .pv-hole.is-sel circle:not(.ring) { stroke: var(--selection); stroke-width: .9; }
.pv-part.is-sel-group rect { stroke: var(--selection); stroke-dasharray: 1.4 .8; }
.pv-edge.is-sel { stroke: var(--selection); stroke-width: 1; fill-opacity: .5; }
#preview.dragging .pv-key.is-sel rect { fill-opacity: .85; }
/* the edit card (.pv-pop), its right-click menu (.pv-menu), the drag badge, sliders and steppers are shared with the
   Layout Editor: they're in editor.css */

/* the designer's own board shapes, and the outline's automatic patches */
/* your own board shapes: under the keys and parts. Not selected: nothing (it's part of the outline) until hovered or the board is selected; clicked
   by a wide invisible edge (.pv-shape-hit). Selected: a light fill and a solid edge; its corner dots go on top. */
.pv-shape { fill: none; stroke: var(--brand-feather); stroke-opacity: 0; stroke-width: .3; stroke-dasharray: 1.2 1; pointer-events: none; }
.pv-sg:hover .pv-shape, #preview.shapes-on .pv-shape { stroke-opacity: 1; }
.pv-shape.is-cut { fill: var(--danger); fill-opacity: .1; stroke: var(--danger); pointer-events: visiblePainted; cursor: pointer; }
.pv-shape.is-sel { fill: var(--brand-feather); fill-opacity: .2; stroke-opacity: 1; stroke-width: .6; stroke-dasharray: none; pointer-events: visiblePainted; cursor: move; }
.pv-shape.is-sel.is-cut { fill: var(--danger); fill-opacity: .16; }
.pv-shape-hit { fill: none; stroke: transparent; stroke-width: 12px; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: pointer; }
/* the board card's and the panel's top and bottom edge choices */
#edges-field { gap: 4px; }
#edges-field > span small { font-weight: 400; letter-spacing: 0; text-transform: none; }
#edges-field > .tb-seg + span { margin-top: 6px; }
.pv-handle { fill: var(--surface); stroke: var(--brand-feather); stroke-width: .5; cursor: grab; }
.pv-handle.is-on { fill: var(--brand-feather); }
.pv-auto { fill: var(--success); fill-opacity: .1; stroke: var(--success); stroke-width: .35; stroke-dasharray: .9 .7; pointer-events: none; }
.pv-body.is-back rect { stroke-dasharray: 1 .6; fill-opacity: .55; }
.shape-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.shape-list:empty { display: none; }
.shape-list li { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm, 6px); }
.shape-list li > div { flex: 1; min-width: 0; display: grid; }
.shape-list b { font-size: 13px; }
.shape-list span { font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shape-list li.is-lost span { color: var(--danger); }
.pp-pts { display: grid; gap: 4px; }
.pp-pt { display: grid; grid-template-columns: 22px 1fr 1fr 28px; gap: 4px; align-items: center; }
.pp-pt > span { font: 700 11px var(--font-mono); color: var(--ink-muted); text-align: center; border-radius: 4px; }
.pp-pt.is-on > span { background: var(--brand-feather); color: #fff; }
.pp-pt input { min-width: 0; }
