:root {
  --bg: #f4f2ee; --card: #fff; --ink: #1f2328; --mute: #6b6f76; --line: #e2ded6; --acc: #e4572e; --acc-ink: #fff;
  --sel: #2350d8; --ok: #2f8a4c; --warn: #b7791f; --bad: #c8382f; --r: 12px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { overscroll-behavior-y: none; }
a { color: inherit; }
h3 { margin: 0 0 10px; font-size: 17px; }
h4 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--mute); }
h4 small, .chk small, summary small { text-transform: none; letter-spacing: 0; font-weight: 400; }
small { color: var(--mute); }
.up { color: var(--acc); }

/* controls — 16px text keeps iPhone from zooming into fields */
button, .btn, input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
button:active, .btn:active { transform: translateY(1px); }
.pri { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.ghost { background: transparent; }
.sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.ico { min-width: 40px; padding: 0; font-size: 18px; }
.danger { color: var(--bad); }
input, select, textarea { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sel); outline-offset: -1px; }
input.len { width: 88px; text-align: center; }
.fld { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.fld > span, .mini > span { font-size: 12px; color: var(--mute); }
.mini { display: flex; flex-direction: column; gap: 2px; }
.mini input.len { width: 74px; min-height: 38px; }
.mini select { min-height: 38px; }
.chk { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 15px; }
.chk input { width: 22px; height: 22px; min-height: 0; accent-color: var(--acc); }
.row { display: flex; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.gap { gap: 8px; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; }
.hint { color: var(--mute); font-size: 14px; margin: 8px 0; }
.empty { color: var(--mute); padding: 18px; text-align: center; }
.err { color: var(--bad); }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 12px 8px; background: rgba(31, 35, 40, .97); color: #fff; }
.top .btn, .top button { border-color: rgba(255, 255, 255, .25); color: #fff; background: transparent; min-height: 36px; }
.top .pri { background: var(--acc); border-color: var(--acc); }
.brand { flex: 1; font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--acc); font-weight: 800; font-size: 14px; }
.back { font-size: 30px; line-height: 1; text-decoration: none; padding: 0 8px 4px 0; }
.ttl { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttl small { display: block; color: #b9bcc2; font-weight: 400; font-size: 12px; }

.page { max-width: 880px; margin: 0 auto; padding: 14px 12px calc(30px + var(--safe-b)); }
.page.narrow { max-width: 620px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 12px 0; }
.list { list-style: none; padding: 0; margin: 12px 0; }
.list li { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; display: flex; align-items: center; }
.list li a { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; text-decoration: none; min-width: 0; }
.list li a span { color: var(--mute); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li.empty { display: block; }
.li-act { display: flex; gap: 4px; padding-right: 8px; }
.card .list li { background: var(--bg); }
.logo-sm { height: 60px; }

/* editor */
.rooms { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: #2a2f35; scrollbar-width: none; }
.rooms .tab { flex: none; min-height: 34px; color: #dfe2e6; border-color: rgba(255, 255, 255, .18); background: transparent; font-size: 14px; }
.rooms .tab.on { background: #fff; color: var(--ink); font-weight: 600; }
.rooms .tab.add { border-style: dashed; }
.ed { display: flex; flex-direction: column; }
.stage { background: #fbfaf8; border-bottom: 1px solid var(--line); position: sticky; top: calc(52px + var(--safe-t)); z-index: 10; }
.seg { display: flex; gap: 4px; padding: 8px 12px 0; }
.seg button { flex: 1; min-height: 34px; font-size: 14px; background: transparent; border-color: transparent; color: var(--mute); }
.seg button.on { background: var(--card); border-color: var(--line); color: var(--ink); font-weight: 600; }
.seg i { font-style: normal; font-size: 11px; color: #fff; border-radius: 9px; padding: 1px 6px; background: var(--mute); }
.seg i.bad { background: var(--bad); } .seg i.warn { background: var(--warn); }
.viewbox { height: 40vh; min-height: 230px; display: flex; align-items: center; justify-content: center; padding: 6px; overflow: hidden; touch-action: manipulation; }
.viewbox svg { width: 100%; height: 100%; }
.v3 { width: 100%; height: 100%; }
.v3 canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.v3-offscreen { position: fixed; left: -3000px; top: 0; width: 700px; height: 450px; }
.wallnav { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 12px 6px; font-size: 14px; font-weight: 600; }
.wallnav .hint { margin: 0; font-weight: 400; }
.panel { padding: 0 0 calc(40px + var(--safe-b)); }
.pn { padding: 6px 12px; }

/* drawing styles */
.e-wall { fill: #fff; stroke: #c9c4bb; stroke-width: .3; }
.e-hl { stroke: #b9b2a6; stroke-width: .25; }
.e-obs { stroke-width: .3; }
.e-bad { stroke: var(--bad) !important; stroke-width: .9 !important; stroke-dasharray: 1.2 .8; }
.e-m { fill: #7a7e85; }
.e-t { fill: #2b2f35; }
.e-dim { stroke: #8b9096; stroke-width: .2; }
.e-floor { stroke: #4a4d52; stroke-width: .5; }
.e-hit { fill: transparent; cursor: pointer; }
.e-hit:hover { fill: rgba(35, 80, 216, .06); }
.e-hit.on { fill: rgba(35, 80, 216, .1); stroke: var(--sel); stroke-width: .6; }
.e-flag { fill: #d0231b; font-weight: 700; }
.p-wall { stroke: #3a3e44; }
.p-wall.off { stroke: #b8b4ac; stroke-dasharray: 3 2; }
.p-wall.on { stroke: var(--sel); }
.p-lab { fill: #4a4e55; font-weight: 600; }
.p-lab.on { fill: var(--sel); }

/* panel pieces */
.picks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.picks button { min-height: 38px; padding: 0 12px; }
.picks button small { font-size: 11px; }
.picks button.on, .segs button.on, .chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.picks button.on small { color: #c7cad0; }
.segs { display: flex; gap: 4px; }
.segs button { flex: 1; min-height: 42px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.sw { position: relative; height: 64px; padding: 0; border-radius: 10px; background-size: cover; background-position: center; overflow: hidden; align-items: flex-end; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.sw span { width: 100%; font-size: 10px; line-height: 1.15; padding: 3px; background: rgba(255, 255, 255, .85); color: var(--ink); white-space: normal; }
.sw.on { border-color: var(--sel); box-shadow: 0 0 0 2px var(--sel); }
.toggles { display: flex; flex-wrap: wrap; gap: 0 18px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips button { flex: none; min-height: 34px; font-size: 14px; }
.chips button.off { opacity: .5; }
.fitbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; background: #eef0f3; font-size: 14px; margin-bottom: 8px; }
.fitbar.ok { background: #e6f3ea; color: var(--ok); }
.fitbar.bad { background: #fbe9e7; color: var(--bad); }
.secs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.sec { flex: none; flex-direction: column; align-items: flex-start; gap: 0; min-height: 52px; padding: 6px 10px; font-size: 14px; }
.sec b { font-size: 11px; color: var(--mute); }
.sec small em { color: #d0231b; font-style: normal; font-weight: 700; }
.sec.on { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel); }
.sec.exact::after { content: "exact"; font-size: 10px; color: var(--ok); }
.sed h4 { margin-top: 10px; }
.sed .row h4 { margin: 0; }
.cnt { min-width: 28px; text-align: center; }
.faces { display: flex; flex-wrap: wrap; gap: 6px; }
.faces select { width: 92px; }
details { margin-top: 12px; }
summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.parts .row { padding: 4px 0; border-bottom: 1px solid var(--line); }
.wcard.on { border-color: var(--sel); }
.wcard .row { margin: 4px 0; flex-wrap: wrap; }
.wcard .row > input:not(.len) { flex: 1; min-width: 110px; }
.num { min-width: 28px; }
.obs { background: var(--bg); border-radius: 10px; padding: 6px; align-items: flex-end; }
.obs select { width: auto; flex: 1; min-width: 120px; }
.issues { list-style: none; padding: 0; margin: 0; }
.issues li button { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; padding: 10px 12px; margin-bottom: 6px; border-left: 4px solid var(--mute); }
.issues li.err button { border-left-color: var(--bad); } .issues li.warn button { border-left-color: var(--warn); } .issues li.info button { border-left-color: var(--sel); }
.ok-msg { color: var(--ok); font-weight: 600; padding: 12px; }
.prow { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.prow > span { flex: 1; }
.prow input:not(.money) { flex: 1; }
input.money { width: 130px; text-align: right; }
.totals .prow b { font-variant-numeric: tabular-nums; }
.totals .big { font-size: 20px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }

/* sheets */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); max-height: 85vh; overflow: auto; }
.shapes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.shapes button { min-height: 52px; }
#toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translate(-50%, 40px); opacity: 0; transition: .2s; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; pointer-events: none; font-size: 15px; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Mac / iPad: drawing on the left, tools on the right */
@media (min-width: 900px) {
  .ed { flex-direction: row; height: calc(100vh - 102px - var(--safe-t)); }
  .stage { position: static; flex: 1; display: flex; flex-direction: column; border-bottom: 0; border-right: 1px solid var(--line); min-width: 0; }
  .viewbox { flex: 1; height: auto; }
  .panel { width: 420px; overflow-y: auto; }
  .sheet-bg { align-items: center; } .sheet { border-radius: 16px; }
}

/* proposal + install sheet */
.doc { max-width: 900px; margin: 0 auto; padding: 16px 12px 40px; }
.pg { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 28px; margin-bottom: 18px; }
.ph { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--acc); padding-bottom: 10px; margin-bottom: 16px; }
.ph img { height: 44px; }
.ph b { display: block; font-size: 20px; }
.ph span { color: var(--mute); font-size: 13px; }
.cover { text-align: center; }
.cv-logo { width: 260px; max-width: 70%; margin: 10px auto 0; }
.cover h1 { font-size: 34px; margin: 16px 0 4px; letter-spacing: .02em; }
.cv-who { font-size: 22px; font-weight: 600; margin: 4px 0; }
.cv-hero { width: 100%; border-radius: 6px; margin-top: 16px; }
.cv-co { color: var(--mute); font-size: 13px; margin-top: 18px; }
.specs { border-collapse: collapse; width: 100%; font-size: 14px; }
.specs th { text-align: left; color: var(--mute); font-weight: 500; padding: 5px 10px 5px 0; vertical-align: top; width: 34%; }
.specs td { padding: 5px 0; border-bottom: 1px solid #f0ede7; }
.specs.cv { max-width: 380px; margin: 14px auto 0; }
.swi { display: inline-block; width: 18px; height: 18px; border-radius: 4px; background-size: cover; vertical-align: -4px; margin-right: 6px; border: 1px solid rgba(0, 0, 0, .15); }
.rm-top { display: grid; grid-template-columns: 1fr 1.3fr; gap: 18px; align-items: start; }
.rm-plan { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 14px; }
.rm-plan svg { width: 100%; max-height: 320px; }
.shot { width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.note { background: #fbf7ee; border-left: 3px solid var(--acc); padding: 8px 10px; font-size: 14px; white-space: pre-wrap; }
.elev-wrap { margin: 6px 0 18px; }
.elev-wrap svg { width: 100%; max-height: 520px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tiles figure { margin: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tiles img { width: 100%; height: 110px; object-fit: cover; display: block; }
.tiles figcaption { font-size: 12px; padding: 6px; }
.tiles figcaption b { display: block; color: var(--acc); font-size: 11px; }
.tiles .chosen { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc); }
.price { width: 100%; border-collapse: collapse; font-size: 16px; }
.price td { padding: 8px 0; border-bottom: 1px solid #f0ede7; }
.price td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.price .disc td:last-child { color: var(--ok); }
.price .tot td { font-weight: 700; font-size: 20px; border-top: 2px solid var(--ink); }
.valid { font-weight: 600; }
.terms { font-size: 13px; color: #44484e; padding-left: 18px; }
.terms li { margin-bottom: 5px; }
.sign { display: grid; grid-template-columns: 2fr 1fr; gap: 26px 24px; margin-top: 36px; font-size: 12px; color: var(--mute); }
.sign span { display: block; border-bottom: 1px solid var(--ink); height: 30px; }
.isheet th { width: 22%; }
@media (max-width: 640px) { .rm-top, .rm-plan { grid-template-columns: 1fr; } .pg { padding: 16px; } }
@media print {
  @page { size: letter; margin: .4in; }
  html, body, :root { background: #fff !important; }
  .elev-wrap svg { max-height: 4.4in; }
  .elev-wrap { break-inside: avoid; }
  .noprint, #toast { display: none !important; }
  .doc { padding: 0; max-width: none; }
  .pg { border: 0; border-radius: 0; padding: 0; margin: 0; break-after: page; }
  .pg:last-child { break-after: auto; }
  .rm-top { grid-template-columns: 1fr 1.3fr; } .rm-plan { grid-template-columns: 1fr 1fr; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* sync */
#syncpill { position: fixed; left: 10px; bottom: calc(10px + var(--safe-b)); z-index: 40; min-height: 28px; padding: 0 10px; font-size: 12px; border-radius: 14px; background: rgba(255, 255, 255, .95); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); color: var(--mute); }
#syncpill.synced { color: var(--ok); } #syncpill.offline { color: var(--warn); } #syncpill.error, #syncpill.login { color: var(--bad); }
#syncpill[hidden] { display: none; }
form.login { display: flex; flex-direction: column; gap: 10px; }
.brand.dark { color: var(--ink); flex: none; }
.mark { color: #fff; }
button.wide { width: 100%; min-height: 46px; }
@media print { #syncpill { display: none !important; } }

/* draw walls */
.viewbox.drawing { touch-action: none; cursor: crosshair; background: #fff; }
.drawsvg { width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }
.drawsvg .g1 { stroke: #eeebe5; } .drawsvg .g2 { stroke: #ddd8cf; }
.drawsvg .dw { stroke: #2b2f35; }
.drawsvg .dp { stroke: var(--sel); }
.drawsvg .dl { fill: #2b2f35; stroke: #fff; font-weight: 600; }
.drawsvg .dpl { fill: var(--sel); stroke: #fff; font-weight: 700; }
.drawsvg .dpt { fill: #2b2f35; } .drawsvg .dstart { fill: var(--acc); }
.drawsvg .dhint { fill: var(--mute); }
.drawtitle { flex: 1; text-align: center; font-weight: 600; padding: 8px 0; }
.dctl { width: 100%; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.dctl .pad { flex-wrap: wrap; }
.dirs { display: grid; grid-template-columns: repeat(8, 40px); gap: 4px; }
.dirs .ico { min-width: 0; min-height: 40px; font-size: 18px; }
#dlen.bad { outline: 2px solid var(--bad); }
.wallnav:has(.dctl) { height: auto; }
@media (max-width: 520px) { .dctl .pad { display: grid; grid-template-columns: 1fr; } .dctl .pad .len { width: 100%; } .dirs { width: 100%; grid-template-columns: repeat(8, 1fr); } .dirs .ico { min-height: 44px; } }
.stage:has(.dctl) { position: static; }
