/* BRO Builder brand (dark, matches brobuilder.llc in every theme) */
:root {
  --bg: #222429; --header: #171717; --surface: #282a2f; --panel: #1c1d21; --panel-text: #ffffff; --muted: #999b9f; --border: #2f2f2f;
  --btn: #282a2f; --btn-hover: #31343a; --accent: #ffaa17; --accent-text: #111111; --live: #198754;
  --spider-legs: #111111; --spider-head: #ffaa17; --title: #ffffff; --spider: #ffaa17;
  --c-room: #ffaa17; --c-type: #5ab8ff; --c-dimension: #6fe0c8; --c-ref: #c3a6ff; --c-note: #ff6b6b;
  --c-label: #ff9f5a; --c-tag: #d6dbe1; --c-sheet: #999b9f; --c-material: #7fdbca;
  --flash: rgba(255,170,23,.28); --plan-filter: invert(0.88) hue-rotate(180deg);
  --head-font: "Oswald", "Arial Narrow", system-ui, sans-serif; --body-font: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #222429; --header: #171717; --surface: #282a2f; --panel: #1c1d21; --panel-text: #ffffff; --muted: #999b9f; --border: #2f2f2f;
  --btn: #282a2f; --btn-hover: #31343a; --accent: #ffaa17; --accent-text: #111111; --live: #198754;
  --spider-legs: #111111; --spider-head: #ffaa17; --title: #ffffff; --spider: #ffaa17;
  --c-room: #ffaa17; --c-type: #5ab8ff; --c-dimension: #6fe0c8; --c-ref: #c3a6ff; --c-note: #ff6b6b;
  --c-label: #ff9f5a; --c-tag: #d6dbe1; --c-sheet: #999b9f; --c-material: #7fdbca;
  --flash: rgba(255,170,23,.28); --plan-filter: invert(0.88) hue-rotate(180deg);
  --head-font: "Oswald", "Arial Narrow", system-ui, sans-serif; --body-font: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  }
}
:root[data-theme="dark"] {
  --bg: #222429; --header: #171717; --surface: #282a2f; --panel: #1c1d21; --panel-text: #ffffff; --muted: #999b9f; --border: #2f2f2f;
  --btn: #282a2f; --btn-hover: #31343a; --accent: #ffaa17; --accent-text: #111111; --live: #198754;
  --spider-legs: #111111; --spider-head: #ffaa17; --title: #ffffff; --spider: #ffaa17;
  --c-room: #ffaa17; --c-type: #5ab8ff; --c-dimension: #6fe0c8; --c-ref: #c3a6ff; --c-note: #ff6b6b;
  --c-label: #ff9f5a; --c-tag: #d6dbe1; --c-sheet: #999b9f; --c-material: #7fdbca;
  --flash: rgba(255,170,23,.28); --plan-filter: invert(0.88) hue-rotate(180deg);
  --head-font: "Oswald", "Arial Narrow", system-ui, sans-serif; --body-font: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--panel-text); font: 13px/1.5 var(--body-font); }
*, *::before, *::after { box-sizing: border-box; }

#stage { position: fixed; top: 0; left: 0; right: 0; bottom: 0; cursor: grab; touch-action: none; }
#stage.panning { cursor: grabbing; }
body.tracing #stage { cursor: crosshair; }
#stage canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
#plan { filter: var(--plan-filter); }

.toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px 10px 18px; background: var(--header); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 14px; }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.brand b { font: 600 20px/1 var(--head-font); text-transform: uppercase; letter-spacing: .03em; color: var(--title); }
.beta { font: 500 11px/1 var(--body-font); color: var(--accent-text); background: var(--accent); border-radius: 4px; padding: 4px 7px; }
button, .filebtn, select {
  appearance: none; border: 1px solid var(--border); background: var(--btn); color: var(--panel-text);
  font: 500 14px/1 var(--head-font); text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; border-radius: 4px; cursor: pointer;
}
button:hover, .filebtn:hover { color: var(--accent); }
.filebtn { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.filebtn:hover { background: #ffb83d; color: var(--accent-text); }
select { font: 400 13px/1.2 var(--body-font); text-transform: none; letter-spacing: 0; }
select { max-width: 260px; padding-right: 24px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
button:hover, select:hover { background-color: var(--btn-hover); }
button:focus-visible, .filebtn:focus-within, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filebtn { position: relative; }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.status { color: var(--muted); font: 400 12px var(--body-font); }
.colors { display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
.colors span { font: 500 13px var(--head-font); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.colors input[type="color"] { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: none; cursor: pointer; }
.colors input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.colors input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.colors input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }
.colors input[type="color"]:focus-visible { outline: 2px solid var(--spider); outline-offset: 1px; }
.colors button { padding: 4px 8px; font-size: 12px; }

.empty {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; text-align: center;
  pointer-events: none; color: var(--muted); max-width: 360px; padding: 0 16px;
}
.empty strong { display: block; color: var(--panel-text); font: 600 28px/1.2 var(--head-font); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
body.dragging .empty strong { color: var(--accent); }
.empty { transition: opacity .6s; }
.empty.sketching { opacity: 0; }
.msg { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); z-index: 4;
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 6px; max-width: min(520px, 90vw); }

.panel {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 74px); right: 12px; width: 320px; z-index: 3;
  max-height: calc(100% - 86px - env(safe-area-inset-top, 0px)); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.45); overflow: hidden;
}
.hdr, .file, .cats, .waiting, .btns { flex: none; }
.hdr { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px 6px; }
.title { font: 600 20px/1.1 var(--head-font); text-transform: uppercase; letter-spacing: .03em; color: var(--title); }
.count { font: 500 13px var(--body-font); color: var(--accent); }
.file { padding: 0 12px 8px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 3px; background: var(--border); flex: none; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.cats { list-style: none; margin: 0; padding: 8px 12px 4px; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
.cats li { display: contents; }
.cats .name { display: flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cats .num { font: 400 12px var(--body-font); font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.cats .done .num { color: var(--panel-text); }
.found { list-style: none; margin: 4px 0 0; padding: 4px 8px 8px; max-height: 260px; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--border); flex: 0 1 auto; }
.found:empty { display: none; }
.found li { display: flex; gap: 8px; align-items: baseline; padding: 3px 4px; border-radius: 4px; }
.found li .dot { width: 7px; height: 7px; transform: translateY(-1px); }
.found li .lbl { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.found li.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: var(--flash); } 100% { background: transparent; } }
.waiting { padding: 8px 12px; color: var(--muted); }
.btns { display: flex; gap: 6px; padding: 8px 12px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.btns button { background: var(--btn); }
.btns button:first-child { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btns button:first-child:hover { background: #ffb83d; }
.btns button.armed { background: #c0392b; border-color: #c0392b; color: #fff; }
.tabs { display: flex; gap: 4px; padding: 0 12px 8px; flex: none; }
.tabs { gap: 18px; }
.tabs button { padding: 4px 0 6px; background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); font-size: 16px; }
.tabs button:hover { background: transparent; color: var(--panel-text); }
.tabs button.on { color: var(--panel-text); border-bottom-color: var(--accent); }
.panel.wide { width: 490px; }
#sheetView, #takeoffView { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.tk-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--border); flex: none; }
.tk-tools label { font-size: 12px; color: var(--muted); }
.tk-tools select { max-width: 150px; }
button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tk-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 10px; flex: 1 1 auto; min-height: 120px; }
.tk-body h4 { margin: 14px 0 6px; font: 600 16px/1.2 var(--head-font); text-transform: uppercase; letter-spacing: .04em; color: var(--title); }
.tk-body .sum { color: var(--muted); font-size: 12px; margin: 6px 0 2px; }
.tk-body .sum b { color: var(--panel-text); }
.tk-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tk-body th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); padding: 3px 4px; white-space: nowrap; }
.tk-body td { border-bottom: 1px solid var(--border); padding: 3px 4px; vertical-align: top; }
.tk-body td:nth-child(5) { white-space: nowrap; }
.tk-body td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-body td.muted, .tk-body .muted { color: var(--muted); }
.tk-body select { font-size: 12px; padding: 3px 18px 3px 6px; max-width: 110px; }
.tk-body button { padding: 2px 6px; font-size: 13px; }
.tk-body .empty-note { color: var(--muted); padding: 6px 0; }
.st-ok { color: #fff; } td.st-ok { white-space: nowrap; } td.st-ok::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--live); margin-right: 6px; }
.st-unsure { color: var(--c-note); }
.tk-form { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin: 8px 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; font-size: 12px; }
.tk-form input, .tk-form select { font: 13px var(--body-font); padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--panel); color: var(--panel-text); max-width: none; }
.tk-form .row { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }
.social-share { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.social-share-label { font: 500 13px/1 var(--head-font); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 4px; }
.social-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  background: var(--btn); border: 1px solid var(--border); color: var(--panel-text);
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s;
}
.social-btn svg { width: 16px; height: 16px; fill: currentColor; }
.social-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.social-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.social-copy.copied { background: var(--live); border-color: var(--live); color: #fff; }
@media (max-width: 1700px) { .toolbar .status { display: none; } }
@media (max-width: 1350px) { .social-share-label { display: none; } }
[hidden] { display: none !important; }

@media (max-width: 680px) {
  .panel.wide { width: auto; }
  .toolbar { gap: 6px; padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px; }
  .brand b { font-size: 17px; }
  .colors { display: none; }
  .social-share-label { display: none; }
  .social-share { gap: 6px; }
  .social-btn { width: 30px; height: 30px; }
  .toolbar button, .toolbar .filebtn { padding: 7px 9px; font-size: 13px; }
  .toolbar select { max-width: 60vw; }
  .status { display: none; }
  select { max-width: 100%; }
  .panel { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); left: 8px; right: 8px; width: auto; max-height: 45%; overflow-y: auto; }
  .cats { grid-template-columns: 1fr auto 1fr auto; }
  .found { max-height: 18vh; }
  .msg { bottom: calc(env(safe-area-inset-bottom, 0px) + 48%); }
}
@media (prefers-reduced-motion: reduce) {
  .found li.flash { animation: none; background: var(--flash); }
  .fill { transition: none; }
}
.sketch-pdf {
  position: fixed; left: 190px; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); z-index: 3;
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  font-size: 13px; padding: 7px 10px; white-space: nowrap;   /* same size as the CALL THE CRANE button */
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.sketch-pdf:hover { background: #ffb83d; color: var(--accent-text); }
.sketch-pdf[disabled] { opacity: .7; cursor: default; }
.fly-capsule {
  position: fixed; left: 20px; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); z-index: 2;   /* under the header: the jar comes down from behind it */
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.capsule-jar { display: block; filter: drop-shadow(0 8px 18px rgba(0,0,0,.5)); }
.capsule-btn {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  font-size: 13px; padding: 7px 10px; white-space: nowrap; box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
.capsule-btn:hover { background: #ffb83d; color: var(--accent-text); }
@media (max-width: 680px) {
  .capsule-jar { width: 64px !important; height: 112px !important; }
  .capsule-btn { font-size: 11px; padding: 5px 8px; }
  .empty { top: 40%; font-size: 0; }            /* phones: headline only (it keeps its own size), so it clears the capsule */
}
/* the analysis panel stays off-screen in play mode and slides in when a plan is opened */
.panel { transition: transform .55s cubic-bezier(.2,.8,.2,1), opacity .4s ease; }
.panel.offstage { transform: translateX(calc(100% + 32px)); opacity: 0; pointer-events: none; }
@media (max-width: 680px) { .panel.offstage { transform: translateY(calc(100% + 32px)); } }
/* tab on the right edge to show or hide the analysis panel */
.panel-tab {
  position: fixed; z-index: 3; right: 0; top: 90px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 5px; border-radius: 6px 0 0 6px; border: 1px solid var(--border); border-right: 0;
  background: var(--panel); color: var(--panel-text); box-shadow: -6px 6px 18px rgba(0,0,0,.35);
  font: 500 12px/1 var(--head-font); text-transform: uppercase; letter-spacing: .08em;
}
.panel-tab:hover { color: var(--accent); background: var(--panel); }
.panel-tab .lbl { writing-mode: vertical-rl; transform: rotate(180deg); }
.panel-tab .chev::before { content: '‹'; font-size: 18px; line-height: .8; color: var(--accent); }
.panel-tab.open .chev::before { content: '›'; }
.panel-tab.phone { flex-direction: row; padding: 6px 10px; border-radius: 6px 6px 0 0; border: 1px solid var(--border); border-bottom: 0; box-shadow: 0 -6px 18px rgba(0,0,0,.35); }
.panel-tab.phone .lbl { writing-mode: horizontal-tb; transform: none; }
.panel-tab.phone .chev::before { content: '⌃'; }
.panel-tab.phone.open .chev::before { content: '⌄'; }