:root {
  --bg: #14171a;
  --panel: #1c2024;
  --line: #2f353b;
  --text: #e4e7ea;
  --muted: #8b949c;
  --accent: #f5a524;
  --room: #3fa7d6;
  --wall: #e8594f;
  --ok: #5cb85c;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, "Segoe UI", sans-serif;
  display: flex; flex-direction: column;
}
button, .btn {
  background: #272c31; color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; padding: 6px 10px; font: inherit; cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.active { background: var(--accent); color: #111; border-color: var(--accent); }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
kbd { opacity: .6; font: 11px monospace; margin-left: 4px; }
input, select {
  background: #101316; color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 5px 7px; font: inherit; width: 100%;
}
#topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { margin-right: 8px; }
/* the tools wrap: in one row they were wider than a phone, which made the whole page wider than the screen (owner 2026-11-19) */
#tools { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
/* a button per kind of work, its tools and actions in a list under it (owner 2026-11-19) */
.tm { position: relative; }
.tmBtn::after { content: ' \25BE'; color: var(--muted); }
.tmList { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 210px; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.5); }
.tmList[hidden] { display: none; }
.tmList button { text-align: left; display: flex; justify-content: space-between; gap: 12px; white-space: nowrap; }
.tmList button[hidden] { display: none; }
.tmList hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; width: 100%; }
.tmPin { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; padding: 4px 2px 0; border-top: 1px solid var(--line); margin-top: 3px; cursor: pointer; }
.tmPin input { width: auto; }
.spacer { flex: 1; }
main { flex: 1; display: flex; min-height: 0; }
#stageWrap { flex: 1; position: relative; min-width: 0; }
#stage { width: 100%; height: 100%; display: block; background: #0d0f11; touch-action: none; }
#stage.tool-select { cursor: default; }
#stage.tool-wall, #stage.tool-room, #stage.tool-scale, #stage.tool-area, #stage.tool-door, #stage.tool-window, #stage.tool-point, #stage.tool-cable, #stage.tool-dim, #stage.tool-outer, #stage.tool-box { cursor: crosshair; }
#stage.tool-pan, #stage.panning { cursor: grab; }
#empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); pointer-events: none; text-align: center;
}
#stageWrap.dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }
#hint {
  position: absolute; left: 10px; bottom: 10px; background: rgba(20,23,26,.85);
  border: 1px solid var(--line); border-radius: 5px; padding: 5px 9px; color: var(--muted);
  pointer-events: none; max-width: calc(100% - 20px);
}
#panel {
  width: 300px; background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 12px;
}
#panel h4 {
  margin: 16px 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
#panel h4:first-child { margin-top: 0; }
#panel label.f { display: block; margin: 6px 0; color: var(--muted); font-size: 12px; }
#panel label.f input, #panel label.f select { margin-top: 2px; color: var(--text); font-size: 14px; }
.row { display: flex; gap: 8px; margin-top: 8px; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.good { color: var(--ok); }
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; justify-content: space-between; padding: 4px 6px; border-radius: 4px; cursor: pointer;
}
.list li:hover { background: #262b30; }
#pointList li { cursor: pointer; }
.list li.sel { background: #3a2f17; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin-top: 0; }
/* the rooms of a lead that wait to be put on the plan: a small window over the plan's corner */
#leadWait { position: absolute; top: 10px; right: 10px; width: 200px; max-height: calc(100% - 20px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
#leadWait[hidden] { display: none; }
#leadWait .lw-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
#leadWait #lwClose { padding: 0 7px; }
#leadWait button.lw { text-align: left; touch-action: none; cursor: grab; }
#leadWait button.lw small { display: block; color: var(--muted); pointer-events: none; }
#leadWait button.lw.on { border-color: var(--accent); background: #3a2f17; }
#lwGhost { position: fixed; z-index: 50; transform: translate(-50%, -130%); pointer-events: none; background: var(--accent); color: #111; border-radius: 4px; padding: 3px 8px; font-size: 13px; }
#leadDlg { width: min(640px, 94vw); }
#leadDlg textarea { width: 100%; font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 6px; }
#leadDlg pre.lead { white-space: pre-wrap; font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--bg); padding: 8px; border-radius: 4px; max-height: 50vh; overflow: auto; }
@media (max-width: 800px) {
  main { flex-direction: column; }
  /* phone: the whole page scrolls (plan on top, panel below) instead of two squeezed scroll areas */
  html, body { height: auto; min-height: 100%; }
  main { flex: none; }
  #stageWrap { flex: none; height: 62vh; min-height: 320px; }
  #panel { width: 100%; max-height: none; overflow-y: visible; border-left: 0; border-top: 1px solid var(--line); }
  #hint { max-height: 5.5em; overflow: hidden; font-size: 12px; }
  /* no keyboard on a phone: without the key hints the tools take a row less */
  #tools kbd { display: none; }
  /* the waiting rooms take less of a narrow plan */
  #leadWait { width: 150px; top: 6px; right: 6px; padding: 6px; }
  #leadWait .muted { display: none; }
  #empty { padding: 0 12px 6em; }
}

.palgroup { margin: 6px 0; }
.palgroup > summary { cursor: pointer; user-select: none; padding: 3px 0; }
.palgroup > summary:hover { color: var(--text); }
.palgroup button.pal { display: block; width: 100%; text-align: left; margin: 2px 0; padding: 4px 8px; font-size: 13px; }
.palgroup button.pal b { display: inline-block; min-width: 26px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; color: #fff; text-shadow: 0 0 2px #000; border: 1px solid rgba(255,255,255,.25); }
.chip.dark { color: #111; text-shadow: none; }
details.wiresel { margin: 4px 0; }
details.wiresel summary { cursor: pointer; font-size: 12px; color: #9aa5ad; }
.wrow { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0; }
.wrow > span:first-of-type { flex: 1; }
.wrow select { width: auto; max-width: 150px; font-size: 11px; padding: 1px 4px; }
.wrow select.off { opacity: .5; }

.strip { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; margin: 2px 0 6px; background: #111; }
.strip img { display: block; max-width: none; height: 70px; }

.figcard { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 8px 0; background: #14181b; }
.figcard img { display: block; max-width: 100%; background: #fff; border-radius: 3px; margin-bottom: 6px; }

dialog.wide { width: min(900px, 94vw); max-height: 90vh; overflow-y: auto; }
/* the board view: the drawing fills the screen like the plan, the controls are a column on its right */
#boardDlg[open] { display: grid; grid-template-columns: minmax(0, 1fr) 400px; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0; padding: 0; border: 0; border-radius: 0; overflow: hidden; }
#boardMain { position: relative; overflow: auto; min-width: 0; min-height: 0; background: #14181b; }
#boardMain > svg { margin: 14px; }
#boardSide { overflow-y: auto; min-height: 0; padding: 12px 14px 24px; border-left: 1px solid var(--line); }
#boardSide .row { flex-wrap: wrap; align-items: flex-end; }
#boardSide .row > * { flex: 1 1 120px; min-width: 0; }
#boardSide label.f { display: block; margin: 0; color: var(--muted); font-size: 12px; }
#boardSide label.f input:not([type=checkbox]), #boardSide label.f select { display: block; width: 100%; margin-top: 2px; color: var(--text); font-size: 14px; }
#boardSide select { max-width: 100%; }
#boardSide details { margin-top: 6px; }
#boardSide details svg { max-width: 100%; height: auto; }
#freeWrap, #b3d { width: 100%; height: 100%; }
.btabs { display: flex; gap: 4px; margin-bottom: 12px; }
.btabs button { flex: 1; }
.btabs button.on { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.btabs #boardClose { flex: 0 0 40px; }
#pTree { max-height: 300px; overflow-y: auto; margin: 4px 0 8px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
#pTree details { margin: 0; }
#pTree details details { margin-left: 12px; }
#pTree summary { cursor: pointer; padding: 4px 2px; font-size: 13px; }
#pTree button { display: block; width: calc(100% - 14px); margin: 2px 0 2px 14px; padding: 4px 8px; text-align: left; font-size: 13px; }
#pTree button.on { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.bsec { margin: 16px 0 2px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
#swapPop { position: absolute; top: 10px; left: 10px; width: min(420px, calc(100% - 70px)); max-height: calc(100% - 20px); display: flex; flex-direction: column; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
#swapPop input { width: 100%; margin-bottom: 6px; }
#swapList { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 3px; }
#swapList button { text-align: left; }
.zoomBar { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; }
.zoomBar button { width: 38px; height: 38px; padding: 0; font-size: 18px; }
@media (max-width: 820px) {
  #boardDlg[open] { grid-template-columns: minmax(0, 1fr); grid-template-rows: 52vh minmax(0, 1fr); }
  #boardSide { border-left: 0; border-top: 1px solid var(--line); }
}
.estopts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 8px; }
.estopts select { width: auto; }
.estopts .chk { display: flex; gap: 6px; align-items: center; }
.estopts .chk input { width: auto; }
.pkgs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.pkg { border: 1px solid var(--line); border-radius: 6px; padding: 8px; cursor: pointer; }
.pkg.on { border-color: var(--accent); background: #2a2417; }
table.est { width: 100%; border-collapse: collapse; }
table.est th, table.est td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.est td.num { text-align: right; white-space: nowrap; }
table.est input { width: 100px; }
.esttotal { margin: 10px 0; font-size: 16px; }
.assump { color: var(--muted); padding-left: 18px; }
@media print { body > *:not(dialog) { display: none; } dialog { position: static; border: 0; color: #000; background: #fff; } button { display: none; } }

.glyphs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.gl { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 4px; padding: 4px; background: #1b1f23; }
.gl.skip { opacity: .45; }
.gl img { height: 38px; width: auto; max-width: 56px; background: #fff; }
.gl select { width: 58px; padding: 2px; font-size: 13px; }
.gl label { font-size: 11px; color: var(--muted); display: flex; gap: 3px; align-items: center; }
.gl label input { width: auto; }
.gl button { padding: 1px 6px; font-size: 11px; }
.chips { margin: 4px 0; color: var(--muted); font-size: 12px; }
.chips button { margin-left: 4px; padding: 2px 8px; font-size: 13px; }

.lvtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.lvtabs button { padding: 4px 9px; }

.palgroup button.pal { display: flex; align-items: center; gap: 8px; }
.palgroup button.pal .sym { display: inline-flex; width: 36px; justify-content: center; flex: none; }

.learnmsg { white-space: pre-line; margin-top: 6px; font-size: 12px; }


button.danger { background: #7a2420; border-color: #e8594f; color: #fff; }

#panel h4.sec { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
#panel h4.sec::before { content: '▾'; font-size: 11px; width: 10px; color: var(--accent); }
#panel h4.sec.closed::before { content: '▸'; }
#panel h4.sec:hover { color: var(--text); }
#panel h4.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: rgba(245,165,36,.45); } 100% { background: transparent; } }

.grp { border: 1px solid #2a3036; border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.grphead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; }
.grphead .chk { margin-left: auto; }
.warn { color: #f5a524; }

button.mini { padding: 1px 8px; font-size: 11px; }
/* what stands in the way of saving (houseAlert() in app.js): a bar over the plan until it is over */
#saveAlert { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; font-size: 14px; color: #fff; background: #b3261e; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
#saveAlert.note { background: #2f5d8a; }
#saveAlert[hidden] { display: none; }
#saveAlert span { flex: 1 1 320px; }
#saveAlert button { color: #111; background: #fff; border: 0; border-radius: 4px; padding: 4px 10px; cursor: pointer; }

/* the photographs visitors sent with an enquiry (the owner's server only) */
.photoset { border-top: 1px solid var(--line, #3a3f46); padding: 10px 0; }
.photoset .row { gap: 10px; align-items: center; flex-wrap: wrap; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photos img { width: 150px; height: 150px; object-fit: cover; border-radius: 6px; display: block; }
