:root {
  --bg: #f4f2ee;
  --paper: #ffffff;
  --ink: #1f2328;
  --muted: #6b7076;
  --line: #dedad3;
  --accent: #b6452c;
  --accent-soft: #fbe3dc;
  --sel: #1a73e8;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.topbar { display: flex; justify-content: center; background: var(--ink); padding: 5px 12px; flex-shrink: 0; }
.new-plan { border: 0; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; padding: 6px 22px; border-radius: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.new-plan:hover { background: #9c3a24; }
.map-undo { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 4px; background: #ebe8e2; border-radius: 8px; padding: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.map-undo button { width: 38px; height: 34px; border: 0; border-radius: 6px; background: var(--paper); display: flex; align-items: center; justify-content: center; }
.map-undo button:hover { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.map-undo svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.modal.wizard { width: min(620px, 100%); max-height: 92vh; overflow-y: auto; }
.modal.wizard .hint { margin: 0 0 12px; }
.wz-drop { display: flex; align-items: center; gap: 12px; border: 2px dashed var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.wz-drop.over { background: #f7cdbf; }
.wz-drop.has { border-style: solid; border-color: #2e7d32; background: #e8f5e9; }
.wz-icon { font-size: 28px; }
.wz-body { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.wz-body b { color: var(--ink); font-size: 14.5px; }
.wz-drop.has .wz-file { color: #1b5e20; font-weight: 700; }
.wz-btn { flex-shrink: 0; }
.wz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.wz-full { grid-column: 1 / -1; }
.modal select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; }
.modal .chk-row { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.wz-pc { margin: -4px 0 0; font-size: 12.5px; color: #1b5e20; }
.wz-pc.warn { color: #b3261e; font-weight: 600; }
.wz-end { flex-wrap: wrap; }
.wz-ex { margin-right: auto; }
.top {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo { color: var(--accent); font-size: 20px; }
.proj { font-weight: 400; color: var(--muted); font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 2px; margin-left: auto; }
@media (max-width: 1500px) { .proj { display: none; } }
.tab { border: 0; background: none; padding: 7px 9px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.tab:hover { background: var(--bg); }
.tab.on { background: var(--ink); color: #fff; }
.segs, .floors { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.seg { border: 0; background: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.seg.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
.chk { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.main { flex: 1; display: flex; min-height: 0; }
.app-foot { flex-shrink: 0; display: flex; gap: 6px 16px; flex-wrap: wrap; justify-content: center; padding: 5px 12px; font-size: 12px; background: var(--paper); border-top: 1px solid var(--line); }
.app-foot a { color: var(--muted); text-decoration: none; }
.app-foot a:hover { color: var(--accent); text-decoration: underline; }
body.printing .app-foot { display: none; }
.toolbar {
  width: 74px; background: var(--paper); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: stretch; padding: 8px 6px; gap: 3px; overflow-y: auto;
}
.toolbar hr { border: 0; border-top: 1px solid var(--line); margin: 6px 2px; width: auto; }
.tool {
  border: 1px solid transparent; background: none; border-radius: 8px; padding: 6px 2px 5px;
  display: flex; flex-direction: column; align-items: center; font-size: 18px; line-height: 1.1;
}
.tool span { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.tool:hover { background: var(--bg); }
.tool.on { background: var(--accent-soft); border-color: var(--accent); }
.tool.on span { color: var(--accent); font-weight: 600; }
.tool.small { font-size: 15px; }
.newst { font-size: 10.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; padding: 2px; margin-bottom: 6px; }
.newst select { font-size: 11px; padding: 3px 1px; border: 1px solid var(--line); border-radius: 5px; }

.stage { flex: 1; position: relative; min-width: 0; }
.mix {
  position: absolute; top: 54px; left: 10px; z-index: 2; display: flex; align-items: center; gap: 6px;
  background: #ebe8e2; border-radius: 8px; padding: 4px 6px; box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.mix input[type=range] { width: 140px; accent-color: var(--ink); }
.mix-end { border: 0; background: var(--paper); border-radius: 6px; padding: 4px 9px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.mix-end:hover { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.floors { position: absolute; top: 10px; left: 10px; z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.12); background: #ebe8e2; }
.hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 2;
  background: rgba(31,35,40,.86); color: #fff; font-size: 12.5px; padding: 6px 12px; border-radius: 20px;
  pointer-events: none; max-width: 90%; text-align: center;
}
.view { position: absolute; inset: 0; }
#plan-svg { width: 100%; height: 100%; display: block; background: #fbfaf8; touch-action: none; user-select: none; }
body[data-tool="block"] #plan-svg, body[data-tool="stair"] #plan-svg, body[data-tool="wall"] #plan-svg,
body[data-tool="calibrate"] #plan-svg { cursor: crosshair; }
body[data-tool="backdrop"] #plan-svg { cursor: move; }
body[data-tool="window"] #plan-svg, body[data-tool="door"] #plan-svg, body[data-tool="bifold"] #plan-svg,
body[data-tool="opening"] #plan-svg, body[data-tool="label"] #plan-svg { cursor: copy; }

/* plan drawing */
#plan-svg line, #plan-svg rect, #plan-svg polygon, #plan-svg path, #plan-svg circle { vector-effect: non-scaling-stroke; }
#plan-svg text { font-size: calc(var(--fs) * 1px); font-family: system-ui, Arial, sans-serif; }
.g1 { stroke: #ecebe7; stroke-width: 1; }
.g5 { stroke: #dcdad4; stroke-width: 1; }
.fl { stroke: none; }
.fl-existing { fill: rgba(255,255,255,.35); }
.fl-proposed { fill: rgba(255,214,0,.35); }
.fl-demolish { fill: url(#hatchDemo); }
.nb { fill: #ececec; stroke: #b5b5b5; stroke-width: 1; stroke-dasharray: 4 3; }
.nb-t { fill: #999; text-anchor: middle; dominant-baseline: middle; font-style: italic; }
.ghost { fill: none; stroke: #b9b5ae; stroke-width: 1; stroke-dasharray: 5 4; }
.wst { fill: #111; stroke: #111; stroke-width: 2.2; stroke-linejoin: miter; }
.win { fill: #fff; stroke: #111; stroke-width: 1; }
.glz { stroke: #111; stroke-width: 0.8; }
.jamb { stroke: #111; stroke-width: 1; }
.leaf { stroke: #111; stroke-width: 1.4; fill: none; }
.swing { stroke: #555; stroke-width: 0.8; fill: none; stroke-dasharray: 3 2; }
.head { stroke: #555; stroke-width: 0.8; stroke-dasharray: 4 3; }
.op-proposed .leaf, .op-proposed .win { stroke: var(--accent); }
.stair { fill: rgba(255,255,255,.7); stroke: #333; stroke-width: 1; }
.tread { stroke: #555; stroke-width: 0.8; }
.arrow { stroke: #333; stroke-width: 1; }
.arrowhead { fill: #333; }
.up { fill: #333; text-anchor: middle; }
#plan-svg text.up { font-size: calc(var(--fs) * 0.8px); }
.lbl { fill: #2a2e33; text-anchor: middle; dominant-baseline: middle; font-weight: 600; }
.selbox { fill: rgba(26,115,232,.06); stroke: var(--sel); stroke-width: 1.5; stroke-dasharray: 6 3; }
.selline { stroke: var(--sel); stroke-width: 4; stroke-opacity: .6; }
.selpt { fill: var(--sel); }
.handle { fill: #fff; stroke: var(--sel); stroke-width: 1.5; cursor: crosshair; }
.col { fill: #1b1d1b; stroke: #fff; stroke-width: 0.6; }
.openedge { stroke: #111; stroke-width: 2; stroke-dasharray: 8 5; fill: none; }
.barrel { fill: rgba(255,255,255,.8); stroke: #111; stroke-width: 0.8; stroke-dasharray: 3 2; }
.shutter { stroke: #111; stroke-width: 2; }
.leaf.thick { stroke-width: 3; }
.draw-edge { stroke: #ffd400; stroke-width: 3; }
.units-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.units-pick select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; color: #1f2328; background: #fff; }
.draft { fill: rgba(255,214,0,.35); stroke: var(--accent); stroke-width: 2; cursor: move; }
.rot-stem { stroke: var(--accent); stroke-width: 1.5; }
.rot-knob { fill: #fff; stroke: var(--accent); stroke-width: 2; cursor: crosshair; }
.rot-arrow { fill: none; stroke: var(--accent); stroke-width: 1.3; }
.draft-box { position: absolute; z-index: 20; width: 220px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.draft-box[hidden] { display: none; }
.draft-box label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.draft-box input { width: 90px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.draft-box input.fixed { border-color: var(--accent); background: #fff7f3; font-weight: 600; }
.draft-box .db-in { position: relative; display: inline-flex; }
.draft-box .db-in input { padding-right: 26px; }
.draft-box .db-in i { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 13px; color: var(--muted); pointer-events: none; }
.draft-box .db-in input[type=number] { -moz-appearance: textfield; }
.draft-box .db-in input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.draft-box .db-note { margin: 2px 0; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.draft-box .db-row { display: flex; justify-content: flex-end; gap: 8px; }
.ridge-line { stroke: #b6452c; stroke-width: 2.5; stroke-dasharray: 10 4 2 4; }
.slope-line { stroke: #b6452c; stroke-width: 2.5; }
.slope-head { fill: #b6452c; }
.roof-hit { stroke: transparent; stroke-width: 16; cursor: pointer; }
.roof-box .rb-row { display: flex; gap: 4px; }
.roof-box .rb-four { flex-wrap: wrap; }
.roof-box .rb-four .rb-seg { flex: 1 1 45%; }
.roof-box .rb-seg { flex: 1; padding: 5px 4px; font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.roof-box .rb-seg.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.roof-box .rb-lab { font-size: 11.5px; color: var(--muted); }
.draw-pt { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.snap-pt { fill: none; stroke: #ffd400; stroke-width: 2.5; }
body[data-tool="roller"] #plan-svg, body[data-tool="sliding"] #plan-svg, body[data-tool="boundary"] #plan-svg { cursor: crosshair; }
.preview { fill: rgba(182,69,44,.1); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 3; }
.preview-line { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 3; }
.calline { stroke: #0b8043; stroke-width: 2; }
.hoverside { stroke: var(--sel); stroke-width: 5; stroke-opacity: .5; }
.dim, .dimx { stroke: #0b57d0; stroke-width: 1; }
.dimx { stroke-opacity: .5; }
.dimt { fill: #0b57d0; text-anchor: middle; font-weight: 600; }
.coords { fill: var(--muted); }
.bnd { fill: none; stroke: #d00; stroke-width: 2.5; stroke-linejoin: round; }
.bnd-draft { fill: none; stroke: #d00; stroke-width: 2; stroke-dasharray: 6 4; }
.bnd-pt { fill: #fff; stroke: #d00; stroke-width: 1.5; }
.redline { color: #d00; font-style: normal; }

/* sheets and statement */
.docbar {
  position: absolute; top: 0; left: 0; right: 0; height: 50px; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.docbar-t { font-weight: 600; margin-right: auto; font-size: 14px; }
#view-sheets .cards, #view-statement .st-wrap { top: 50px; }
.cards.sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); grid-auto-rows: max-content; align-content: start; }
.sheet-card .card-body { padding: 8px; background: #e9e7e2; }
.sheet-card .card-body svg { width: 100%; height: auto; max-height: none; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.sheet-card figcaption { text-transform: none; }

.st-wrap { position: absolute; inset: 0; overflow: auto; padding: 16px; display: flex; gap: 16px; align-items: flex-start; }
.st-side { width: 330px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.st-card { padding: 14px 16px; font-size: 13px; line-height: 1.45; }
.st-card h3 { margin: 0 0 10px; font-size: 14px; }
.st-card ul { margin: 6px 0 0; padding-left: 18px; }
.st-card li { margin-bottom: 4px; }
.pd-overall { font-weight: 700; padding: 8px 10px; border-radius: 6px; margin: 0 0 10px; }
.pd-item { border-top: 1px solid var(--line); padding: 8px 0; }
.pd-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.v-ok { background: #e3f4e6; color: #1e6b2f; }
.v-no { background: #fde7e4; color: #a3271a; }
.v-maybe { background: #fff4d6; color: #7a5c00; }
.f-no { color: #a3271a; }
.f-ok { color: #1e6b2f; }
.f-maybe { color: #7a5c00; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.checks { list-style: none; padding: 0 !important; margin: 0; }
.checks li { padding: 7px 0 7px 26px; border-top: 1px solid var(--line); position: relative; display: flex; flex-direction: column; gap: 2px; }
.checks li span { color: var(--muted); font-size: 12px; }
.checks li::before { position: absolute; left: 2px; top: 7px; font-weight: 700; }
.c-ok::before { content: "✓"; color: #1e6b2f; }
.c-no::before { content: "!"; color: #a3271a; background: #fde7e4; border-radius: 50%; width: 16px; text-align: center; }
.c-info::before { content: "i"; color: #0b57d0; font-style: italic; font-family: Georgia, serif; }

.a4 {
  background: #fff; width: 210mm; max-width: 100%; min-height: 297mm; padding: 20mm 18mm; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.15); font-family: Arial, Helvetica, sans-serif; font-size: 11pt; line-height: 1.5; color: #111;
}
.a4:focus { outline: 2px solid var(--sel); }
.a4 h1 { font-size: 22pt; margin: 0 0 4pt; }
.a4 h2 { font-size: 13pt; margin: 18pt 0 6pt; }
.a4 .sub { color: #444; margin: 0 0 12pt; }
.a4 table { border-collapse: collapse; width: 100%; margin: 6pt 0; }
.a4 th, .a4 td { border: 1px solid #bbb; padding: 4pt 7pt; text-align: left; vertical-align: top; font-size: 10pt; }
.a4 .kv th { width: 34%; background: #f4f4f4; }
.a4 .grid th { background: #f4f4f4; }
.a4 mark { background: #fff3a0; }
.a4 ul { padding-left: 18pt; }
.a4 li { margin-bottom: 6pt; }

#view-source .cards { top: 50px; }
.cards.src-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.src-page { width: min(1100px, 100%); flex-shrink: 0; }
.src-page img { width: 100%; height: auto; display: block; border-top: 1px solid var(--line); }
.src-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex-wrap: wrap; }
.src-btns { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.src-loading { padding: 80px 0; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }
.src-empty { padding: 20px 24px; width: min(700px, 100%); }
.src-empty h3 { margin: 0 0 6px; }
.st-wrap .cards.br-sheets { position: static; flex: 1; min-width: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 16px; }
.utab { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.utab th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.utab td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
#br-form select + select { margin-top: 4px; font-size: 12px; color: var(--muted); }
#br-form .btn { width: 100%; margin-top: 4px; }

details.sec { border-top: 1px solid var(--line); padding: 8px 0; }
details.sec summary { font-weight: 700; cursor: pointer; padding: 4px 0; font-size: 13.5px; }
details.sec[open] summary { margin-bottom: 8px; }
.chk-row { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; margin: 4px 0 10px; color: #3b4046; }
.chk-row input { margin-top: 2px; }

/* tour: a ring round each part of the page in turn (the rest dimmed), with a card explaining it */
.tour-btn { margin-left: 0; }
.tourring { position: fixed; z-index: 4500; border: 3px solid #8ab4f8; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); pointer-events: none; transition: top 0.25s, left 0.25s, width 0.25s, height 0.25s; }
.tourbox { position: fixed; z-index: 4600; width: min(330px, calc(100vw - 24px)); background: #fff; color: #1f2a25; border-radius: 16px; padding: 16px 16px 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); font-size: 14px; line-height: 1.5; }
.tourbox h4 { margin: 0 0 6px; font-size: 17px; line-height: 1.2; font-weight: 700; }
.tourbox p { margin: 0 0 12px; }
.tourbox .trow { display: flex; align-items: center; gap: 6px; }
.tourbox .tcount { font-size: 12px; color: #6b6b74; margin-right: auto; font-variant-numeric: tabular-nums; }
.tourbox .btn { padding: 7px 12px; }
.tourbox .btn[hidden] { display: none; }
.tourbox.warn { border: 3px solid #b3261e; }
.tourbox.warn h4 { color: #b3261e; }
.tourbox.warn h4::before { content: "⚠ "; }

/* first building made: the tabs glow, with a note under them */
.tabs.tabs-glow { border-radius: 8px; background: #fff6bf; box-shadow: 0 0 0 3px #f5d000, 0 0 14px 4px rgba(245,208,0,.55); animation: tabs-glow 1.6s ease-in-out infinite; }
@keyframes tabs-glow { 0%, 100% { box-shadow: 0 0 0 3px #f5d000, 0 0 10px 2px rgba(245,208,0,.45); } 50% { box-shadow: 0 0 0 3px #f5d000, 0 0 20px 8px rgba(245,208,0,.7); } }
@media (prefers-reduced-motion: reduce) { .tabs.tabs-glow { animation: none; } }

/* "Start here" upload box */
.add-plan {
  border: 2px dashed var(--accent); background: linear-gradient(180deg, #fff3ee, #fde6dc);
  border-radius: 12px; padding: 16px 14px 12px; text-align: center; margin: 4px 0 16px;
  box-shadow: 0 0 0 4px rgba(182,69,44,.08); animation: ap-glow 2.4s ease-in-out infinite;
}
.add-plan.over { background: #fbd5c7; border-style: solid; }
.ap-icon { font-size: 30px; line-height: 1; }
.ap-title { font-weight: 800; font-size: 16px; color: var(--accent); margin: 6px 0 4px; }
.ap-text { margin: 0 0 12px; font-size: 12.8px; line-height: 1.45; color: #4a3530; }
.add-plan .btn.ap-btn { display: inline-block; position: relative; overflow: hidden; background: var(--accent); border-color: var(--accent); color: #fff; font-size: 14.5px; padding: 10px 18px; }
.add-plan .btn.ap-btn:hover { background: #9e3a24; }
.ap-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ap-drop { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
@keyframes ap-glow { 0%, 100% { box-shadow: 0 0 0 4px rgba(182,69,44,.08); } 50% { box-shadow: 0 0 0 7px rgba(182,69,44,.18); } }
@media (prefers-reduced-motion: reduce) { .add-plan { animation: none; } }

/* guide-only warnings */
.guide-warn { background: #fdecea; border: 1px solid #e8a39c; color: #7a1c14; border-radius: 8px; padding: 10px 12px; font-size: 12.8px; line-height: 1.45; margin: 10px 0; }
.guide-warn b { display: block; margin-bottom: 2px; }
.modal .guide-warn { font-size: 13.5px; }
.chk-row.ack { font-weight: 600; color: #3b4046; }
.docbar-warn { color: #b3261e; font-weight: 700; font-size: 12.5px; background: #fdecea; border: 1px solid #e8a39c; border-radius: 6px; padding: 5px 9px; white-space: nowrap; }
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing { overflow: visible; display: block; height: auto; background: #fff; }
  body.printing #print-root { display: block; }
  .print-sheet { width: 420mm; height: 297mm; overflow: hidden; page-break-after: always; break-after: page; }
  .print-sheet:last-child { page-break-after: auto; break-after: auto; }
  .print-sheet svg { display: block; width: 420mm; height: 297mm; }
  .print-doc { box-shadow: none; padding: 0; width: auto; min-height: 0; }
  .print-doc mark { background: none; }
}

/* drawings */
.cards { position: absolute; inset: 0; overflow: auto; padding: 16px; gap: 16px; }
.cards.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); grid-auto-rows: max-content; align-content: start; }
.cards.single { display: flex; justify-content: center; align-items: flex-start; }
.cards.single .card { width: min(900px, 100%); }
.card { margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-body { padding: 12px; }
.card-body svg { width: 100%; height: auto; max-height: 60vh; display: block; }
.card figcaption { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 600; text-transform: capitalize; }

#three-host { position: absolute; inset: 0; }
#three-host canvas { display: block; }
.three-msg { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); text-align: center; color: #fff; background: rgba(31,35,40,.82); border-radius: 8px; padding: 6px 12px; font-size: 13px; pointer-events: none; z-index: 3; }
.three-msg:empty { display: none; }
.v3d-bar { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 3; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.v3d-bar > * { pointer-events: auto; }
.v3d-bar button, .v3d-bar label { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 18px; padding: 5px 11px; font: inherit; font-size: 12.5px; color: #1f2328; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.v3d-bar button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.v3d-bar input[type=range] { width: 80px; }
.v3d-bar label[hidden] { display: none; }
#view-3d:fullscreen { background: #cfe0ee; }
.face-box { position: absolute; right: 10px; top: 56px; z-index: 4; width: 270px; box-sizing: border-box; max-height: calc(100% - 120px); overflow-y: auto; overflow-x: hidden; background: rgba(255,255,255,.97); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.2); padding: 10px 12px; font-size: 13px; }
.face-box[hidden] { display: none; }
.face-box h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.face-box .fb-head { display: flex; flex-direction: column; margin-bottom: 4px; }
.face-box .fb-head small { color: var(--muted); }
.face-box .fb-chk { display: flex; gap: 6px; align-items: center; }
.face-box .fb-door { display: grid; grid-template-columns: 1fr auto; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.face-box .fb-door select { grid-column: 1; }
.face-box .fb-door .fb-del { grid-column: 2; grid-row: 1; border: none; background: none; color: #b3261e; cursor: pointer; font-size: 15px; }
.face-box .fb-door label { display: flex; align-items: center; justify-content: space-between; gap: 6px; grid-column: 1 / span 2; }
.face-box input[type=text], .face-box select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; max-width: 100%; box-sizing: border-box; }
.face-box .fb-door { min-width: 0; }
.face-box .fb-row select { flex: 0 1 60%; min-width: 0; width: 60%; }
.face-box .fb-door select { min-width: 0; width: 100%; }
.face-box input[type=text] { width: 76px; }
.face-box .fb-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; }
.face-box .fb-add { display: flex; flex-wrap: wrap; gap: 4px; }
.face-box .fb-add button { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 3px 9px; font: inherit; font-size: 12px; cursor: pointer; }
.face-box .fb-add button:hover { border-color: var(--accent); }
.face-box .fb-none, .face-box .fb-tip { color: var(--muted); font-size: 11.5px; margin: 4px 0; }
.face-box .fb-end { display: flex; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 700px) { .face-box { top: auto; bottom: 10px; right: 10px; left: 10px; width: auto; max-height: 45%; } }
.v3d-loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; background: rgba(255,255,255,.96); border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.22); padding: 16px 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 220px; }
.v3d-loading[hidden] { display: none; }
.v3d-loading small { color: var(--muted); font-size: 12px; }
.v3d-spin { width: 30px; height: 30px; border: 3px solid #e3e1da; border-top-color: var(--accent); border-radius: 50%; animation: v3dspin 0.9s linear infinite; margin-bottom: 4px; }
@keyframes v3dspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .v3d-spin { animation-duration: 3s; } }

/* panel */
.panel { width: 300px; background: var(--paper); border-left: 1px solid var(--line); overflow-y: auto; padding: 14px 16px 30px; font-size: 13.5px; }
.panel h2 { font-size: 16px; margin: 2px 0 12px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.f span { font-size: 12px; color: var(--muted); }
.f input, .f select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; }
.f input[type=range] { padding: 0; }
.f input:focus, .f select:focus { outline: 2px solid var(--sel); outline-offset: -1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.note { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 4px 0 10px; }
.row { display: flex; gap: 6px; margin-top: 12px; }
.row.wrap { flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: #fff; padding: 7px 11px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.danger { color: #b3261e; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.small { padding: 4px 9px; font-size: 12px; text-transform: none; }
.btn.file { position: relative; overflow: hidden; display: inline-block; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.steps { padding-left: 18px; margin: 0; line-height: 1.5; color: #3b4046; }
.steps li { margin-bottom: 4px; }

/* dialogs */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 18px 20px; width: min(400px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 12px; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.modal input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }
.modal .hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; position: static; transform: none; background: none; padding: 0; border-radius: 0; max-width: none; text-align: left; pointer-events: auto; }
.modal.wide { width: min(820px, 100%); max-height: 90vh; overflow-y: auto; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.thumb { border: 2px solid var(--line); border-radius: 8px; background: #fff; padding: 6px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.thumb img { width: 100%; height: auto; display: block; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.thumb span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.thumb:hover, .thumb:focus { border-color: var(--sel); outline: none; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; top: 100px; left: 50%; transform: translateX(-50%); max-width: min(560px, 90vw); text-align: center; line-height: 1.45; background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 60; transition: opacity .4s; }
.toast.out { opacity: 0; }
.note.warn-note { color: #b3261e; font-weight: 600; }

/* Phones, and tablets held upright: one column, with the details panel folding away under the drawing. */
.panel-toggle { display: none; }
@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
  html, body { height: 100%; }
  body { height: 100dvh; }
  .top { padding: 6px 8px; gap: 6px 8px; }
  .brand { font-size: 15px; }
  .proj { display: none; }
  .tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 7px 11px; font-size: 14px; flex-shrink: 0; }
  .segs { margin-left: auto; }
  .seg { padding: 6px 10px; }
  .chk { display: none; }
  .tour-btn { padding: 6px 10px; }

  .main { flex-direction: column; min-height: 0; }
  .toolbar { width: auto; flex-direction: row; flex-shrink: 0; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 4px 6px; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar hr { display: none; }
  .tool { min-width: 54px; flex-shrink: 0; padding: 6px 2px; }
  .newst { flex-direction: row; align-items: center; margin: 0 4px; flex-shrink: 0; }
  .stage { flex: 1 1 auto; min-height: 240px; }
  .floors { top: 6px; left: 6px; }
  .mix { top: 48px; left: 6px; padding: 3px 5px; }
  .mix input[type=range] { width: 90px; }
  .hint { display: none; }
  .modal .hint { display: block; }
  .map-undo { top: 6px; right: 6px; }
  .wz-grid { grid-template-columns: 1fr; }
  .wz-drop { flex-wrap: wrap; }
  .wz-ex { margin-right: 0; width: 100%; }

  /* Details panel: a fold-away sheet under the drawing. */
  .panel-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0;
    border: 0; border-top: 1px solid var(--line); background: var(--paper); padding: 10px 14px;
    font-weight: 700; font-size: 14px; text-align: left;
  }
  .panel-toggle .pt-arrow { color: var(--muted); font-size: 12px; }
  .panel { display: none; width: auto; border-left: 0; flex-shrink: 0; max-height: 55dvh; padding: 4px 14px 24px; }
  body.panel-open .panel { display: block; }

  .f input, .f select, .modal input { font-size: 16px; }
  .cards { padding: 10px; }
  .cards.grid, .cards.sheets { grid-template-columns: 1fr; }
  .st-wrap { flex-direction: column; padding: 10px; }
  .st-side { width: 100%; }
  .a4 { padding: 10mm 7mm; min-height: 0; width: 100%; }
  .docbar { overflow-x: auto; padding: 0 10px; gap: 6px; }
  .docbar .btn { flex-shrink: 0; }
  .docbar-t { display: none; }
  .docbar-warn { font-size: 11.5px; padding: 4px 7px; }
  .src-head { padding: 8px 10px; }
  .src-btns { margin-left: 0; width: 100%; }
  .tourbox { font-size: 13.5px; }
}

/* See it on your house (AR): a button over the 3D view, and a full-screen camera viewer */
.ar-btn { position: absolute; right: 12px; bottom: 12px; z-index: 2; padding: 9px 14px; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.ar-btn:disabled { opacity: .7; }
.ar-wrap { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #e9eef2; }
.ar-wrap model-viewer { flex: 1; width: 100%; min-height: 0; background: #e9eef2; }
.ar-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.ar-modes { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.ar-modes .seg { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.ar-modes .seg.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ar-close { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 6px; color: var(--muted); cursor: pointer; }
.ar-go { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 11px 20px; font-size: 15px; border-radius: 22px; }
.ar-note { margin: 0; padding: 10px 14px 14px; background: #fff; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.45; color: var(--ink); }

/* ---- farm buildings ---- */
.findrow { display: flex; gap: 6px; margin: 8px 0 4px; }
.findrow input { flex: 1; min-width: 0; padding: 9px 10px; font-size: 15px; border: 1px solid var(--line); border-radius: 8px; }
.linkish { color: var(--accent); text-decoration: underline; cursor: pointer; }
.add-plan.go { animation: none; }
.credit { font-size: 10.5px; color: var(--muted); margin: 4px 0 0; }
.sizebox { background: #f4f2ec; border-radius: 8px; padding: 7px 10px; font-size: 13px; margin: 6px 0 8px; }
.style-card { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px 6px 6px; margin: 4px 0 10px; cursor: pointer; font: inherit; }
.style-card:hover { border-color: var(--accent); }
.style-card .sc-pic svg { width: 84px; height: 56px; display: block; border-radius: 6px; background: #e8f1f8; }
.style-card .sc-t { display: flex; flex-direction: column; }
.style-card small { color: var(--accent); font-weight: 600; }
.opensides { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 6px 0; font-size: 13px; }
.opensides > span { width: 100%; color: var(--muted); font-size: 12px; }
.styles-modal { width: min(940px, 100%); }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 12px 0; }
.style-pick { display: flex; flex-direction: column; gap: 4px; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; font: inherit; color: inherit; }
.style-pick:hover, .style-pick:focus-visible { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.08); outline: none; }
.style-pick.on { border-color: var(--accent); background: #fff7f3; }
.style-pick .sp-pic svg { width: 100%; height: auto; display: block; border-radius: 8px; background: #e8f1f8; }
.style-pick b { font-size: 14px; }
.ds-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ds-count { font-size: 12px; font-weight: 600; color: var(--accent); }
.ds-dots { display: flex; gap: 5px; }
.ds-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.ds-dots i.past { background: #e3a593; }
.ds-dots i.now { background: var(--accent); }
.ds-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; position: sticky; bottom: -16px; background: #fff; padding: 8px 0; }
.ds-foot [data-nav=skip] { margin-left: auto; }
.style-pick small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.wz-find input { width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; }
.nearby { list-style: none; padding: 0; margin: 4px 0 8px; font-size: 12.5px; }
.nearby li { margin: 2px 0; }
textarea[data-key] { width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.tool.draw-tool { background: #fff3ec; }
