/* Design by Scale – floor plan editor. Blueprint navy + teal, light and dark. */
:root {
  --navy: #0b2545; --teal: #67e8d0; --acc: #0a7d8c; --acc-ink: #fff;
  --bg: #eef3f9; --panel: #ffffff; --panel2: #f4f7fb; --ink: #1d2330; --muted: #5a6275; --line: #d5dde8; --canvas: #ffffff; --gridc: #e3e9f2; --gridm: #c9d3e1;
  --sel: #0a84ff; --danger: #c2392f; --ok: #2a8a4f;
  --disp: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif; --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 44px; color-scheme: light;
}
:root[data-theme="dark"] {
  --acc: #67e8d0; --acc-ink: #06223a; --bg: #081426; --panel: #0f1e36; --panel2: #13264a; --ink: #eef4ff; --muted: #a9bedf; --line: #26395a;
  --canvas: #0e1a2e; --gridc: #16263f; --gridm: #22385a; --sel: #5cb8ff; --danger: #ff6b61; --ok: #4fd27b; color-scheme: dark;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { height: 100%; margin: 0; overflow: hidden }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); display: flex; flex-direction: column; overscroll-behavior: none }
.skip { position: absolute; left: -9999px } .skip:focus { left: 12px; top: 12px; z-index: 90; background: #fff; color: #000; padding: 8px 12px; border-radius: 8px }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0) }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
.btn, .ib, .chip { min-height: var(--tap); border-radius: 10px; border: 1px solid var(--line); background: var(--panel); padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap }
.ib { min-width: var(--tap); padding: 0; font-size: 18px }
.btn:hover, .ib:hover { border-color: var(--acc) }
.btn.acc { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); font-weight: 600 }
.btn.danger { color: var(--danger) }
.btn.sm { min-height: 44px; padding: 0 12px; font-size: 14px }
.btn:disabled, .ib:disabled { opacity: .45; cursor: default }
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0 10px; max-width: 100% }
textarea { padding: 8px 10px; width: 100% }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--acc) }

/* top bar */
.bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--navy); color: #eef4ff; min-height: 58px }
.bar .btn, .bar .ib { background: rgba(255,255,255,.08); border-color: rgba(207,227,255,.25); color: #eef4ff }
.bar .btn.acc { background: var(--teal); color: #06223a; border-color: var(--teal) }
.bar select, .bar input:not([type=checkbox]) { background: rgba(255,255,255,.08); border-color: rgba(207,227,255,.25); color: #eef4ff }
.bar select option { color: #1d2330; background: #fff }
.brand { font: 700 1.15rem var(--disp); color: #eef4ff; text-decoration: none; white-space: nowrap; min-height: var(--tap); display: inline-flex; align-items: center }
.brand .acc { color: var(--teal) }
#bar .pname { width: 190px; font-weight: 600; background: rgba(255,255,255,.08); color: #eef4ff; border-color: rgba(207,227,255,.25) }
body.embed #bar .pname { background: var(--panel2); color: var(--ink); border-color: var(--line) }
.grow { flex: 1 }
.variants { display: flex; gap: 4px; align-items: center; overflow-x: auto; max-width: 40vw; scrollbar-width: none }
.variants button { min-height: 44px; border-radius: 999px; border: 1px solid rgba(207,227,255,.3); background: transparent; color: #cfe3ff; padding: 0 12px; white-space: nowrap }
.variants button[aria-current="true"] { background: #eef4ff; color: var(--navy); font-weight: 700 }
.lvl { max-width: 150px }
.menuwrap { position: relative }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 34px rgba(0,0,0,.25); padding: 6px; width: 290px; max-height: 75vh; overflow: auto }
.menu button { display: flex; width: 100%; min-height: var(--tap); align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 0 10px; border-radius: 10px }
.menu button:hover, .menu button:focus-visible { background: var(--panel2) }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px }
.menu .mh { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 2px }

/* main area */
.main { flex: 1; display: flex; min-height: 0; position: relative }
.tools { flex: none; width: 76px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; padding: 6px; overflow-y: auto }
.tools button { min-height: 52px; border: 1px solid transparent; border-radius: 12px; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; gap: 1px; padding: 2px; color: var(--ink) }
.tools button .ic { font-size: 20px; line-height: 1 }
.tools button[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); }
.tools button:hover { border-color: var(--line) }
.tools .sep { height: 1px; background: var(--line); margin: 4px 2px; flex: none }
.stage { flex: 1; position: relative; min-width: 0; background: var(--canvas); overflow: hidden }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; display: block }
#cv:focus { outline: none } #cv:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px }
#cv text { font-family: var(--body); pointer-events: auto }
#cv .o { cursor: pointer }
#cv .o.locked, #cv .lk { pointer-events: none }
#cv .o.zone polygon:not(.hit) { pointer-events: none }
#cv .hit { fill: none; stroke: transparent; pointer-events: stroke }
#cv #gGrid, #cv #gUnder, #cv #gCad, #cv #gChk { pointer-events: none }
#cv .h { fill: #fff; stroke: var(--sel); stroke-width: 2; cursor: pointer }
#cv .h.rot { fill: var(--sel) }
#cv .selo { fill: none; stroke: var(--sel); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none }
#cv .ov text { font: 600 13px var(--body); paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; fill: var(--ink); pointer-events: none }
#cv .ov .pen { fill: none; stroke: var(--sel); stroke-width: 2 }
#cv .ov .pen.rub { stroke-dasharray: 6 4 }
#cv .ov .snap { fill: none; stroke: #ff7a00; stroke-width: 2 }
#cv .ov .mq { fill: rgba(10,132,255,.08); stroke: var(--sel); stroke-dasharray: 4 3 }
#cv .ov .meas { stroke: #ff7a00; stroke-width: 2.5 }
#cv .ov, #cv .ov * { pointer-events: none }
#cv .ov .h { pointer-events: all }
.stage.panning #cv { cursor: grabbing }
.stage.t-pan #cv { cursor: grab }
.stage.t-draw #cv { cursor: crosshair }

.banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 8; background: var(--navy); color: #fff; padding: 6px 8px 6px 14px; border-radius: 999px; display: flex; gap: 10px; align-items: center; max-width: calc(100% - 20px); box-shadow: 0 6px 20px rgba(0,0,0,.2) }
.banner .btn { min-height: 44px; background: var(--teal); color: #06223a; border: 0 }
.drawbar { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 6; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); max-width: 760px }
.drawbar label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px }
.drawbar input { width: 90px }
.drawbar .dirs { display: inline-flex; gap: 2px }
.drawbar .dirs button { min-width: 40px; min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; background: var(--panel2) }
.hint { position: absolute; left: 10px; bottom: 54px; z-index: 5; max-width: min(520px, calc(100% - 20px)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.1) }
.hint:empty { display: none }
.hint .btn { min-height: 44px; margin-left: 6px }
.legend { position: absolute; right: 10px; top: 10px; z-index: 4; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 4px 14px rgba(0,0,0,.08) }
.legend span { display: flex; align-items: center; gap: 6px }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid; flex: none }
.zoom { position: absolute; right: 10px; bottom: 54px; z-index: 5; display: flex; gap: 4px }
.zoom .ib { background: var(--panel); box-shadow: 0 2px 8px rgba(0,0,0,.1) }
.zpct { min-width: 64px !important; font-size: 13px !important }
.status { position: absolute; left: 0; right: 0; bottom: 0; height: 46px; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 0 10px; background: var(--panel); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted) }
.status .chip { min-height: 34px; padding: 0 10px; font-size: 13px }
.chip[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); border-color: var(--acc) }
.status .ver { margin-left: auto }
.chip.acc { background: var(--panel2); color: var(--ink); max-width: 260px; overflow: hidden; text-overflow: ellipsis }
.nudge { border: 1px solid #f0b36b; background: rgba(240,179,107,.14); border-radius: 12px; padding: 8px 10px; font-size: 13px; margin: 0 0 12px }
@media (max-width: 760px) { #gridBtn, .status .ver { display: none } .chip.acc { max-width: 150px } }
#coords { min-width: 140px; font-variant-numeric: tabular-nums }

/* side panel */
.side { flex: none; width: 340px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0 }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; scrollbar-width: none }
.tabs button { flex: 1; min-height: var(--tap); border: 0; background: none; border-bottom: 3px solid transparent; font-size: 13px; padding: 0 8px; white-space: nowrap; color: var(--muted) }
.tabs button[aria-selected="true"] { border-bottom-color: var(--acc); color: var(--ink); font-weight: 700 }
.panel { flex: 1; overflow-y: auto; padding: 12px; overscroll-behavior: contain }
.panel h3 { font: 700 15px var(--disp); margin: 4px 0 10px }
.panel h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 6px }
.fld { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; min-height: 44px }
#ebeSites .ebes > button { width: 44px; height: 44px }
.fld > span { font-size: 13px; color: var(--muted) }
.fld input, .fld select, .fld textarea { width: 100% }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
.row2 .fld { grid-template-columns: 1fr; gap: 2px }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 }
.big { font: 700 22px var(--disp) }
.muted { color: var(--muted) } .small { font-size: 13px }
.seg { width: 100%; border-collapse: collapse; font-size: 14px }
.seg td, .seg th { padding: 3px 4px; text-align: left } .seg input { width: 100%; min-height: 38px !important }
.list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px }
.list li button { width: 100%; min-height: var(--tap); display: grid; grid-template-columns: 18px 64px 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 4px 10px; text-align: left }
.list li button[aria-current="true"] { border-color: var(--sel); box-shadow: 0 0 0 2px var(--sel) inset }
.list .co { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.filt { display: grid; grid-template-columns: 1fr 1fr; gap: 6px }
.filt input { grid-column: 1 / -1 }
.lib { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px }
.lib button { min-height: 54px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-align: left; padding: 6px 10px; font-size: 13px }
.lib button b { display: block; font-size: 14px }
.lyr { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; padding: 2px 0 }
.lyr .ib { min-width: 40px; min-height: 40px; font-size: 15px }
.lyr .ib[aria-pressed="false"] { opacity: .45 }
.cadl { display: grid; grid-template-columns: 26px 1fr 120px; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 13px }
.cadl select { min-height: 38px !important; font-size: 13px }
.tot { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px }
.tot b { text-align: right; font-variant-numeric: tabular-nums }
.flag { color: var(--danger); font-weight: 600 }
.okc { color: var(--ok); font-weight: 600 }

dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.35) }
dialog::backdrop { background: rgba(5,15,30,.55) }
dialog form { padding: 18px; display: flex; flex-direction: column; max-height: calc(100vh - 26px) }
dialog h2 { font: 700 1.15rem var(--disp); margin: 0 0 12px }
#dlgBody { overflow-y: auto; flex: 1; min-height: 0 }
.dlgbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap }
dialog.wide { width: min(1200px, calc(100vw - 24px)) }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
.cmp svg { width: 100%; height: 50vh; background: var(--canvas); border: 1px solid var(--line); border-radius: 12px }
.choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px }
.choice button { min-height: 110px; border: 2px solid var(--line); border-radius: 14px; background: var(--panel2); padding: 12px; text-align: left }
.choice button[aria-pressed="true"] { border-color: var(--acc) }
.choice b { display: block; font: 700 1.05rem var(--disp) }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; background: var(--panel2); font: 600 13px var(--body) }
.toast { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 99; background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); text-align: center }
.toast.on { opacity: 1 }
.dropping .stage::after { content: "Drop a DXF, PDF, image or plan file"; position: absolute; inset: 10px; border: 3px dashed var(--acc); border-radius: 16px; display: grid; place-items: center; font: 700 1.2rem var(--disp); background: rgba(103,232,208,.12); z-index: 20 }

/* embed: minimal chrome */
body.embed .brand, body.embed #ebeSites, body.embed #helpBtn .x { display: none }
body.embed .bar { min-height: 50px; background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line) }
body.embed .bar .btn, body.embed .bar .ib, body.embed .bar select, body.embed .bar input { background: var(--panel2); color: var(--ink); border-color: var(--line) }
body.embed .variants button { color: var(--ink); border-color: var(--line) }
body.embed .variants button[aria-current="true"] { background: var(--acc); color: var(--acc-ink) }

/* tablet */
@media (max-width: 1100px) { .side { width: 300px } .pname { width: 140px } }
/* phone: view + simple edit. Tools along the bottom, panel as a sheet */
@media (max-width: 760px) {
  .long { display: none }
  .bar { gap: 4px; padding: 4px 6px; flex-wrap: wrap; min-height: 0 }
  .pname { width: 0; flex: 1; min-width: 80px }
  .variants { order: 10; max-width: 100%; width: 100%; padding-bottom: 2px }
  .lvl { max-width: 96px }
  #ebeSites, #themeBtn, #helpBtn { display: none }
  .main { flex-direction: column }
  .tools { order: 3; width: 100%; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; padding: 4px; flex: none }
  .tools button { min-width: 58px; min-height: 52px; flex: none }
  .tools .sep { width: 1px; height: auto; margin: 4px 2px }
  .side { position: absolute; left: 0; right: 0; bottom: 61px; width: auto; max-height: 55%; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; z-index: 30; box-shadow: 0 -10px 30px rgba(0,0,0,.2); transform: translateY(110%); transition: transform .2s; visibility: hidden }
  .side.open { transform: none; visibility: visible }
  .drawbar { top: 6px; left: 6px; right: 6px; gap: 4px }
  .drawbar input { width: 70px }
  .legend { top: auto; bottom: 100px; font-size: 12px }
  .zoom { bottom: 52px }
  .hint { bottom: 100px; right: 10px }
  #coords { min-width: 0 }
  .choice { grid-template-columns: 1fr } .cmp { grid-template-columns: 1fr } .cmp svg { height: 32vh }
  .fld { grid-template-columns: 96px 1fr }
}
@media (min-width: 761px) { .only-phone { display: none !important } }
@media (pointer: coarse) { .btn.sm, .status .chip, .lyr .ib, .cadl select, .seg input, .variants button { min-height: 44px !important } .lyr .ib { min-width: 44px } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important } }
/* v1.6 DBS_ACCOUNTS: on a phone the 🔑 / ☁️ account button sits at the end of the second row (beside the versions) */
@media (max-width: 760px) { .bar .variants { width: auto; flex: 1 1 calc(100% - 150px); min-width: 0 } .bar #dbsAcct { order: 11; margin-left: 0 } }
