#builder-dialog {
  --bw-ink: #344538;
  --bw-rule: #53634c;
  --bw-paper: #fbf8e9;
  width: min(1140px, calc(100% - 32px)); max-width: none; max-height: 94dvh;
  padding: 0; overflow: auto; overscroll-behavior: contain; border: 2px solid #314235; border-radius: 6px;
  background: var(--bw-paper); color: var(--bw-ink); box-shadow: 5px 6px 0 #29382c;
}
#builder-dialog::backdrop { background: #152d26a8; }
#builder-dialog [hidden] { display: none !important; }
#builder-dialog svg { display: inline-block; width: 1.15em; height: 1.15em; flex: none; vertical-align: middle; }
#builder-dialog button:focus-visible { outline: 3px solid #c68416; outline-offset: 2px; }
.bw-head, .bw-head h2, .bw-exit, .bw-route, .bw-route li, .bw-view figcaption, .bw-view figcaption > span,
.bw-foot, .bw-back, .bw-primary, .bw-recipe dt, .bw-stamp { display: flex; align-items: center; }
.bw-head { justify-content: space-between; gap: 10px; min-height: 51px; padding: 7px 17px; background: #354d3d; color: #fffde7; border-bottom: 2px solid #2c3f31; }
.bw-head h2 { gap: 9px; margin: 0; font-size: clamp(17px,2.6vw,21px); line-height: 1.35; }
.bw-head h2 svg { color: #dfecb0; }
.bw-exit { gap: 6px; min-height: 33px; padding: 3px 9px; border: 1px solid #96a88a; border-radius: 3px; background: #46634e; color: #fffce8; font-size: 13px; font-weight: 700; }
.bw-exit:hover:not(:disabled) { background: #527259; }
.bw-route { gap: 0; list-style: none; margin: 0; padding: 9px 17px; border-bottom: 1px solid #b4b89b; background: #e8ebd5; }
.bw-route li { position: relative; flex: 1; gap: 6px; color: #626b58; font-size: 14px; font-weight: 700; white-space: nowrap; }
.bw-step-link { display:inline-flex; align-items:center; gap:5px; min-height:28px; padding:2px; border:0; border-radius:3px; background:none; color:inherit; font:inherit; }
.bw-step-link:disabled { opacity:1; }
.bw-step-link:enabled > span:last-child { text-decoration:underline dotted #7d906d; text-underline-offset:3px; }
.bw-step-link:enabled:hover { background:#d3dfbb; }
.bw-route li:not(:last-child)::after { content: ""; flex: 1; height: 1px; margin: 0 9px 0 4px; background: #b6bea5; }
.bw-stop { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid #a2ab8f; border-radius: 3px; color: #657157; font: 700 12px/1 var(--mono); }
.bw-route [data-state="current"] { color: #374b33; }
.bw-route [data-state="current"] .bw-stop { color: #3d4427; border-color: #676b47; background: #f4d787; box-shadow: 1px 1px 0 #727653; }
.bw-route [data-state="done"] .bw-stop { background: #59764c; border-color: #516845; color: #fffde5; }
.bw-workbench { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(280px,1fr); gap: clamp(15px,2vw,24px); align-items: start; padding: clamp(13px,1.75vw,20px); }
.bw-left { min-width:0; }
.bw-view { min-width: 0; margin: 0; overflow: hidden; border: 1.5px solid #55614a; border-radius: 3px; box-shadow: 2px 2px 0 #a5a68c; background: #e2dfc9; }
.bw-stage { position: relative; isolation: isolate; container-type:size; height:clamp(225px,28vw,377px); background:#dcdcc8; background-image:linear-gradient(0deg,#e7e8d6 1px,transparent 1px),linear-gradient(90deg,#e7e8d6 1px,transparent 1px); background-size:12px 12px; }
.bw-stage.bw-placeable { cursor: crosshair; }
.bw-scene { display:block; position:absolute; left:50%; top:50%; translate:-50% -50%; width:min(100cqw,calc(100cqh * var(--bw-aspect,1.77778))); aspect-ratio:var(--bw-aspect,1.77778); }
.bw-scene > .bw-water-transition { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.bw-view figcaption { min-height: 33px; gap: 12px; justify-content: space-between; padding: 5px 10px; border-top: 1px solid #8d987f; background: #e6ead5; color: #4f6048; font-size: 12px; }
.bw-view figcaption > span { flex: none; gap: 5px; }
.bw-view figcaption strong { text-align: right; font-weight: 750; }
.bw-stamp { position: absolute; top: 11px; left: 11px; z-index: 2; gap: 5px; padding: 5px 9px; border: 1px solid #61734e; box-shadow: 2px 2px 0 #374d396b; border-radius: 3px; background: #f0f4dced; color: #38533b; font-size: 13px; font-weight: 750; pointer-events: none; animation: bw-stamp-in .23s ease-out; }
@keyframes bw-stamp-in { from { opacity: 0; translate: 0 -5px; } }
.bw-inspector { min-width: 0; }
.bw-panel-head { margin: 0 0 11px; }
.bw-panel-head h3 { margin: 0; color: #354833; font-size: clamp(20px,2.15vw,26px); line-height: 1.3; font-weight: 850; }
.bw-panel-head h3:focus { outline: none; }
.bw-panel-head p { margin: 4px 0 0; color: #68705c; font-size: 13px; line-height: 1.55; }
.bw-options { display: grid; gap: 8px; }
.bw-option { display: grid; grid-template-columns: 54px minmax(0,1fr) 16px; gap: 10px; align-items: center; width: 100%; min-height: 60px; padding: 5px 10px 5px 5px; text-align: left; color: #394938; background: #fffdf1; border: 1.5px solid #9da58b; border-radius: 4px; box-shadow: 2px 2px 0 #b6b79c; }
.bw-option:hover:not(:disabled) { border-color: #687b55; background: #f7f7e5; }
.bw-option[aria-pressed="true"] { border-color: #5c744a; background: #e7efd5; box-shadow: 2px 2px 0 #818c68; }
.bw-sample, .bw-swab { position: relative; display: grid; place-items: center; width: 100%; height: 47px; overflow: hidden; border: 1px solid #d4d4ba; border-radius: 2px; background-color: #e9e8d6; background-image: radial-gradient(#c8c8ad .75px,transparent .9px); background-size: 6px 6px; }
.bw-sample img { display: block; width: 100%; height: 100%; min-height: 0; padding: 3px; object-fit: contain; }
.bw-sample-substrate img { height: 85%; padding: 0; object-fit: cover; }
.bw-swab { --swab-light: #bdeddb; --swab-base: #67b5aa; --swab-dark: #388b85; background: linear-gradient(161deg,var(--swab-light) 8%,var(--swab-base) 60%,var(--swab-dark)); }
.bw-swab-tea { --swab-light: #ffe4a9; --swab-base: #d3a55a; --swab-dark: #ac7a43; }
.bw-swab i { width: 54%; height: 3px; border-radius: 60%; align-self: start; margin-top: 27%; background: #fff9dcb8; box-shadow: -6px 9px 0 -1px #fffde4c9,5px 14px 0 -1px #ffffe4a9; transform: rotate(-7deg); }
.bw-option-text { display: grid; gap: 2px; }
.bw-option-text strong { font-size: 15px; line-height: 1.3; }
.bw-option-text small { font-size: 12px; color: #657059; line-height: 1.3; }
.bw-dense { grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.bw-dense .bw-option { position:relative; display:flex; flex-direction:column; justify-content:flex-start; gap:4px; padding:5px; text-align:center; }
.bw-dense .bw-sample,.bw-size-icon { width:100%; height:48px; }
.bw-size-icon { display:grid; place-items:center; background:#e8edda; color:#637b59; border:1px solid #ced7bd; border-radius:2px; }
#builder-dialog .bw-size-icon svg { width:45px; height:39px; }
.bw-dense .bw-option-text { padding:1px 0; }
.bw-dense .bw-option-text strong { font-size:13px; }
.bw-dense .bw-option-text small { font-size:10px; }
.bw-dense .bw-select-dot { display:none; position:absolute; top:5px; right:5px; }
.bw-dense .bw-option[aria-pressed="true"] .bw-select-dot { display:grid; }
.bw-dense .bw-option:disabled[aria-pressed="false"] { opacity:.65; }
.bw-settings { min-width:0; margin:12px 0 0; padding:6px 10px 10px; border:1px solid #acb699; border-radius:3px; background:#eef1dd; }
.bw-settings legend { padding:0 4px; color:#455b3e; font-size:13px; font-weight:750; }
.bw-settings legend small,.bw-settings>small,.bw-settings label small,.bw-settings button small { color:#647456; font-size:11px; font-weight:500; }
.bw-settings > div { display:flex; gap:7px; align-items:center; }
.bw-dimensions label { display:grid; flex:1; min-width:0; gap:3px; color:#56674b; font-size:12px; }
.bw-settings input[type="number"] { box-sizing:border-box; min-width:0; width:100%; border:1px solid #9da88b; border-radius:3px; background:#fffcf0; padding:5px; color:#344b36; font:700 14px/1.3 var(--mono); }
.bw-settings input[aria-invalid="true"] { border-color:#ad6b33; }
.bw-depth input[type="range"] { flex:1; min-width:0; width:100%; accent-color:#5e794b; }
.bw-depth label { display:flex; align-items:center; gap:3px; font-size:12px; }
.bw-depth input[type="number"] { width:50px; }
.bw-models button { flex:1; min-width:0; min-height:37px; display:grid; gap:2px; padding:4px; border:1px solid #a1ae8a; border-radius:3px; background:#fffced; color:#4b5f42; font-size:13px; }
.bw-models button[aria-pressed="true"] { background:#dce9c5; border-color:#5c774b; box-shadow:inset 0 0 0 1px #82986e; }
.bw-pick-total { display:flex; justify-content:space-between; align-items:center; gap:6px; margin-top:10px; color:#5b6c50; font-size:12px; }
.bw-pick-total button { color:#4f6845; border:1px solid #b5bd9f; border-radius:3px; padding:4px 7px; background:#f0f1dd; }
.bw-select-dot { display: grid; place-items: center; width: 15px; height: 15px; border: 1px solid #a9b29b; border-radius: 3px; }
#builder-dialog .bw-select-dot svg { width: 12px; height: 12px; visibility: hidden; }
[aria-pressed="true"] > .bw-select-dot { background: #617d4c; border-color: #587347; color: #fffde6; }
#builder-dialog [aria-pressed="true"] > .bw-select-dot svg { visibility: visible; }
.bw-positions { display: flex; gap: 5px; margin-top: 10px; }
.bw-positions button { display: flex; justify-content: center; align-items: center; gap: 4px; flex: 1; min-height: 34px; padding: 3px; border: 1px solid #98a188; border-radius: 3px; background: #f2f1df; color: #53614b; font-size: 12px; }
.bw-positions button[aria-pressed="true"]:enabled { border-color: #6a7d55; background: #dfe9c6; color: #374d34; font-weight: 750; }
.bw-positions i { display: inline-block; width: 19px; height: 10px; border: 1px solid currentColor; border-radius: 1px; background: linear-gradient(currentColor,currentColor) 2px 50% / 4px 4px no-repeat; }
.bw-positions [data-bw-slot="center"] i { background-position: center; }
.bw-positions [data-bw-slot="right"] i { background-position: calc(100% - 2px); }
.bw-recipe { margin: 0; padding: 4px 10px; border: 1px solid #aab696; border-radius: 3px; background: #eef1dd; }
.bw-recipe > div { display: flex; justify-content: space-between; align-items: baseline; gap: 7px; padding: 7px 0; border-bottom: 1px dotted #b4c09c; font-size: 13px; }
.bw-recipe > div:last-child { border-bottom: none; }
.bw-recipe dt { gap: 4px; color: #607650; white-space: nowrap; }
.bw-recipe dd { margin: 0; text-align: right; color: #40523a; font-weight: 750; }
.bw-installed { margin-top: 10px; padding: 7px 10px; border: 1px solid #c8c8aa; border-left: 3px solid #b6bea0; background: #f3f0dd; }
.bw-installed > summary { font-size: 12px; font-weight:750; color: #5e6b52; cursor:pointer; }
.bw-installed summary small { margin-left:4px; color:#718065; font-weight:500; }
.bw-installed dl { display: grid; grid-template-columns:repeat(2,minmax(0,1fr)); margin: 6px 0 0; gap: 4px 13px; }
.bw-installed dl > div { display: flex; align-items: baseline; gap: 6px; color: #607055; font-size: 12px; }
.bw-installed dt { display: flex; align-items: baseline; gap: 6px; flex: 1; white-space:nowrap; }
.bw-installed dt::after { content: ""; flex: 1; border-bottom: 1px dotted #c0c6a9; }
.bw-installed dd { margin: 0; color: #485a3c; text-align:right; }
.bw-foot { position: sticky; bottom: 0; z-index: 3; gap: 11px; padding: 11px clamp(13px,1.75vw,20px); border-top: 1px solid #a9ad91; background: #f3f0de; }
.bw-back, .bw-primary { min-height: 39px; gap: 7px; padding: 6px 11px; border: 1.5px solid #68745b; border-radius: 4px; color: #394731; font-size: 14px; font-weight: 750; }
.bw-back { background: #faf8e9; }
.bw-back:disabled { opacity: .48; }
.bw-count { margin-left: auto; color: #68745f; font-size: 12px; white-space: nowrap; }
.bw-primary { justify-content: center; min-width: 135px; background: #f3d17e; box-shadow: 2px 2px 0 #697351; border-color: #526346; }
.bw-primary:disabled { opacity: 1; color: #727761; background: #e4e3ce; border-color: #a5ab8f; box-shadow: 1px 1px 0 #b0b597; }
.bw-primary:enabled:hover { background: #ffdb86; }
.bw-error { padding: 7px 15px; color: #805224; background: #fff0c9; border-top: 1px solid #c6a366; font-size: 13px; }
.bw-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 700px) {
  #builder-dialog { width: calc(100% - 14px); max-height: 96dvh; }
  .bw-head { padding: 6px 10px; min-height: 44px; }
  .bw-route { display:grid; grid-template-columns:repeat(8,minmax(0,1fr)); padding: 5px 4px; }
  .bw-route li { flex-direction:column; gap:2px; font-size: 11px; }
  .bw-step-link { flex-direction:column; gap:2px; width:100%; min-height:37px; }
  .bw-route li:not(:last-child)::after { display:none; }
  .bw-stop { width: 18px; height: 18px; font-size: 11px; }
  .bw-workbench { grid-template-columns: minmax(0,1fr); gap: 11px; padding: 9px; }
  .bw-stage { height:clamp(154px,52vw,295px); }
  .bw-view figcaption { padding: 4px 7px; min-height: 27px; font-size: 11px; }
  .bw-panel-head { margin-bottom: 7px; }
  .bw-panel-head h3 { font-size: 18px; }
  .bw-panel-head p { margin-top: 2px; font-size: 12px; }
  .bw-options { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .bw-options.bw-dense { grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
  .bw-dense .bw-option { min-height:52px; gap:2px; padding:3px; }
  .bw-dense .bw-sample,.bw-size-icon { height:34px; }
  #builder-dialog .bw-size-icon svg { height:29px; }
  .bw-option { position: relative; grid-template-columns: 39px minmax(0,1fr); min-height: 51px; gap: 5px; padding: 4px; }
  .bw-sample,.bw-swab { height: 40px; }
  .bw-option-text strong { font-size: 13px; }
  .bw-option-text small { font-size: 10px; }
  .bw-select-dot { display: none; }
  .bw-option[aria-pressed="true"] { box-shadow: inset 0 0 0 1px #6c8059,1px 1px 0 #818c68; }
  .bw-dense:not(.bw-group-size) .bw-option-text small { display:none; }
  .bw-settings { margin-top:7px; }
  .bw-positions { margin-top: 7px; }
  .bw-installed { margin-top:6px; padding:4px 7px; }
  .bw-installed dl { grid-template-columns:1fr; }
  .bw-foot { padding: 8px 9px; gap: 6px; }
  .bw-back,.bw-primary { min-height: 37px; font-size: 13px; }
  .bw-primary { min-width: 114px; }
  .bw-count { font-size: 11px; }
  .bw-recipe > div { padding: 5px 0; }
}
@media (max-width: 345px) {
  .bw-option { grid-template-columns: 33px minmax(0,1fr); }
  .bw-route li { font-size: 11px; }
  .bw-option-text small { display: none; }
  .bw-count { margin-right: 0; }
}
@media (prefers-reduced-motion: reduce) { .bw-stamp { animation: none; } }
