/* ScanPlano. Mobile first: every screen fits the viewport, with its main action
   in a bar pinned to the bottom. Tap targets are at least 48px tall. */
:root {
  --bg:#f6f7f9; --panel:#ffffff; --line:#e2e5ea; --text:#14181f; --dim:#667085;
  --accent:#0f9d6b; --accent-ink:#ffffff; --danger:#c0392b; --radius:14px;
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
[hidden] { display:none !important; }
html, body { margin:0; height:100%; }
body { background:var(--bg); color:var(--text); display:flex; flex-direction:column; overflow:hidden;
  font:16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color:inherit; }
h1 { font-size:22px; line-height:1.2; margin:0; letter-spacing:-.01em; }
p { margin:0 0 12px; color:var(--dim); }

/* header */
.top { flex:none; display:flex; align-items:center; gap:10px; height:50px; padding:0 16px; padding-top:env(safe-area-inset-top);
  box-sizing:content-box; background:var(--panel); border-bottom:1px solid var(--line); }
.brand { font-weight:700; font-size:18px; text-decoration:none; letter-spacing:-.01em; }
.spacer { flex:1; }
.badge { display:none; font-size:12px; color:var(--dim); border:1px solid var(--line); border-radius:999px; padding:4px 10px; white-space:nowrap; }

/* page frame */
main { flex:1; min-height:0; overflow-y:auto; display:flex; flex-direction:column; width:100%; max-width:1100px; margin:0 auto; padding:0 16px; }
.screen { flex:1 0 auto; display:flex; flex-direction:column; min-height:100%; padding-top:14px; }
.col, section.col { flex:1 1 auto; display:flex; flex-direction:column; min-height:0; }
.fill { flex:1 1 auto; min-height:260px; }
.bar { position:sticky; bottom:0; z-index:4; margin-top:auto; display:flex; gap:10px; background:var(--bg);
  padding:12px 0 calc(12px + env(safe-area-inset-bottom)); }
.bar > * { flex:1; text-align:center; }
.bar > .primary { flex:2; }

/* buttons and fields */
button, .btn { font:inherit; font-weight:600; font-size:16px; min-height:50px; padding:12px 18px; border-radius:12px; border:1px solid var(--line);
  background:var(--panel); color:var(--text); cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; justify-content:center; }
button.primary, .btn.primary { background:var(--accent); color:var(--accent-ink); border-color:transparent; }
button.danger { color:var(--danger); }
button.ghost { background:transparent; }
button.small { min-height:42px; padding:8px 14px; font-size:15px; }
button:disabled { opacity:.45; cursor:default; }
input[type=text], input[type=number], input[type=search], select { font:inherit; font-size:16px; width:100%; min-height:50px; padding:12px 14px;
  border-radius:12px; border:1px solid var(--line); background:#fff; color:var(--text); }
input:focus, select:focus { outline:2px solid #0f9d6b55; border-color:var(--accent); }
label { display:block; font-size:14px; color:var(--dim); margin:0 0 6px; }
.row { display:flex; gap:10px; align-items:center; }
.grow { flex:1; min-width:0; }

/* screen heading */
.shead { display:flex; align-items:center; gap:10px; margin-bottom:12px; min-height:44px; }
.back { flex:none; width:44px; height:44px; border-radius:50%; display:grid; place-items:center; font-size:22px; text-decoration:none;
  background:var(--panel); border:1px solid var(--line); }
.eyebrow { display:block; font-size:12px; font-weight:700; color:var(--accent); text-transform:uppercase; letter-spacing:.06em; }
input.title-input { font-size:20px; font-weight:700; border-color:transparent; background:transparent; padding:6px 8px; min-height:44px; letter-spacing:-.01em; }
input.title-input:focus { background:#fff; }

/* hints */
.hint { font-size:14px; color:var(--dim); margin:8px 0; min-height:20px; }
.hint.warn { color:#9a5b00; }
.hint.big { font-size:16px; color:var(--text); font-weight:600; margin:0 0 10px; min-height:22px; }
.hint.big.warn { color:#9a5b00; }
.caption { font-size:13px; color:var(--dim); margin:8px 0 0; }

/* projects */
.grid { display:grid; grid-template-columns:1fr; gap:10px; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:12px; text-decoration:none;
  display:flex; align-items:center; gap:14px; min-height:88px; }
.card svg { flex:none; width:96px; height:64px; background:#eef1f4; border-radius:8px; }
.card b { display:block; font-size:17px; }
.card span { display:block; font-size:13px; color:var(--dim); margin-top:2px; }
.empty { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:30px 20px; }
.empty b { font-size:18px; margin-bottom:6px; }

/* address results */
.results { list-style:none; margin:0; padding:0; }
.results li { padding:14px; border:1px solid var(--line); border-radius:12px; margin-top:8px; cursor:pointer; font-size:15px; background:#fff; min-height:50px; }

/* map */
.mapwrap { position:relative; border-radius:var(--radius); overflow:hidden; border:1px solid var(--line); background:#dfe3e8; }
.mapwrap .map { position:absolute; inset:0; }
.maptools { position:absolute; left:10px; top:10px; z-index:2; display:flex; gap:8px; }
.maptools button { box-shadow:0 1px 6px #0004; }
.vtx { width:22px; height:22px; border-radius:50%; background:#fff; border:4px solid var(--accent); cursor:grab; box-shadow:0 1px 4px #0006; }
.maplibregl-ctrl-group button { width:40px; height:40px; }

/* steps of a project */
.seg { display:grid; grid-template-columns:repeat(5, 1fr); gap:5px; margin-bottom:12px; }
.seg a { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; min-height:52px; border-radius:12px;
  border:1px solid var(--line); background:var(--panel); text-decoration:none; font-size:12px; font-weight:600; color:var(--dim); }
.seg a i { font-style:normal; font-size:13px; font-weight:700; }
.seg a.on { background:var(--text); border-color:var(--text); color:#fff; }

.strip { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:10px; font-size:15px; font-weight:600; }
.hfield { display:flex; align-items:center; gap:8px; margin:0; font-size:14px; color:var(--dim); font-weight:400; white-space:nowrap; }
input.inline { width:84px; min-height:42px; padding:6px 10px; font-weight:700; text-align:right; }
input.inline.unset { border-color:#e0a800; background:#fffbea; }

.panel { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:16px; }
.stack > * + * { margin-top:8px; }
.todo { margin:0; padding-left:20px; color:var(--text); }
.todo li { margin:8px 0; }
.tips { margin-top:12px; background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:0 16px; }
.tips summary { cursor:pointer; font-weight:600; min-height:50px; display:flex; align-items:center; }
.tips[open] { padding-bottom:14px; }
.rowcard { display:flex; align-items:center; gap:12px; background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:10px 12px; min-height:72px; }
.rowcard img { width:52px; height:52px; object-fit:cover; border-radius:8px; background:#e7eaee; flex:none; }
.rowcard .num { width:26px; height:26px; border-radius:50%; background:var(--text); color:#fff; display:grid; place-items:center; font-size:13px; font-weight:700; flex:none; }
.rowcard .meta { flex:1; min-width:0; }
.rowcard .meta b { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rowcard .meta em { font-style:normal; font-size:13px; color:var(--dim); }

/* floor plan */
.drop { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; border:2px dashed #c9ced6; border-radius:var(--radius);
  padding:24px 16px; text-align:center; cursor:pointer; margin:0; background:var(--panel); }
.drop b { color:var(--text); font-size:17px; }
.drop span { font-size:13px; }
.fpwrap { margin-top:10px; overflow:auto; }
.fpimg { width:100%; border-radius:10px; border:1px solid var(--line); }

/* model */
.toggle { display:grid; grid-template-columns:1fr 1fr; gap:4px; background:#e7eaee; border-radius:12px; padding:4px; margin-bottom:10px; }
.toggle button { min-height:40px; border:0; background:transparent; font-size:15px; padding:6px; }
.toggle button.on { background:#fff; box-shadow:0 1px 3px #0002; }
.views { position:relative; min-height:220px; }
.pane { position:absolute; inset:0; border-radius:var(--radius); overflow:hidden; border:1px solid var(--line); background:#fff; }
.views[data-v=plan] .three-pane, .views[data-v=three] .plan-pane { visibility:hidden; pointer-events:none; }
.three { width:100%; height:100%; background:#eef1f4; }
svg.plan { width:100%; height:100%; display:block; touch-action:none; user-select:none; -webkit-user-select:none; }
svg.plan .wlabel { font:700 12px -apple-system, "Segoe UI", sans-serif; fill:#14181f; paint-order:stroke; stroke:#fff; stroke-width:3px; stroke-linejoin:round; }
svg.plan .slabel { font:700 11px -apple-system, "Segoe UI", sans-serif; fill:#fff; pointer-events:none; }
svg.plan .op { cursor:grab; }
.sheet { position:fixed; left:0; right:0; bottom:0; z-index:20; max-width:560px; margin:0 auto; background:var(--panel);
  border-radius:18px 18px 0 0; box-shadow:0 -6px 30px #0003; padding:16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet .caption { margin:6px 0 0; }
.fields { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:12px; }
.fields label { margin:0; }
.fields input, .fields select { margin-top:4px; min-height:46px; padding:8px 12px; }
.sheetbar { margin-top:14px; }
.chip { font-size:12px; font-weight:600; border-radius:999px; padding:4px 10px; background:#fff3d6; color:#8a5a00; white-space:nowrap; }
.chip.ok { background:#dff5ea; color:#0b6b48; }
.chip.bad { background:#fde3e1; color:#a1271c; }
.setup { margin-bottom:10px; padding:12px 14px; border-radius:12px; background:#fff8e6; border:1px solid #f1dca6; font-size:14px; line-height:1.5; }
#aiExtra input { margin-bottom:10px; }
code { background:#eef1f4; padding:1px 5px; border-radius:5px; font-size:.92em; }
.note { padding:12px 0; border-top:1px solid var(--line); }
.note p { color:var(--text); margin:4px 0 8px; }
.note ul { margin:4px 0 8px; padding-left:20px; font-size:14px; }
.note li { margin:4px 0; }

/* wider screens */
@media (min-width: 720px) {
  .badge { display:inline-block; }
  .grid { grid-template-columns:repeat(auto-fill, minmax(320px, 1fr)); }
  .bar { justify-content:flex-end; }
  .bar > *, .bar > .primary { flex:0 1 220px; }
  .seg a { flex-direction:row; gap:8px; font-size:14px; }
  #w1, #w3 { max-width:560px; }
}
@media (min-width: 900px) {
  .toggle { display:none; }
  .views .pane { visibility:visible !important; pointer-events:auto !important; }
  .views .plan-pane { right:calc(50% + 8px); }
  .views .three-pane { left:calc(50% + 8px); }
}

/* rooms step */
.chips { display:flex; gap:6px; overflow-x:auto; margin-bottom:10px; padding-bottom:2px; }
.chipbtn { flex:none; min-height:40px; padding:6px 14px; border-radius:999px; font-size:14px; }
.chipbtn.on { background:var(--text); color:#fff; border-color:var(--text); }
.chipbtn.add { color:var(--dim); border-style:dashed; }
.planwrap { position:relative; border-radius:var(--radius); overflow:hidden; border:1px solid var(--line); background:#fff; min-height:260px; }
.planwrap svg { position:absolute; inset:0; }
svg.plan .room { cursor:grab; }
svg.plan .handle { cursor:grab; }
svg.plan .rlabel { font:700 12px -apple-system, "Segoe UI", sans-serif; fill:#14181f; paint-order:stroke; stroke:#fff; stroke-width:3px; stroke-linejoin:round; }
.row.wrap { flex-wrap:wrap; margin-top:10px; }
.sheet select.small { width:auto; min-height:42px; padding:6px 10px; }
.bar .narrowbtn { flex:0 0 auto; padding:12px 14px; }
#histBox .note { padding:8px 0; font-size:14px; }

/* plan: zoom buttons and the "Done moving" button sit on top of the drawing */
.planwrap { position: relative; }
.planctl { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 8px; }
.planctl button { width: 46px; height: 46px; min-height: 0; padding: 0; border-radius: 23px; font-size: 20px; font-weight: 700; box-shadow: 0 1px 4px #0003; }
.planctl #zFit { font-size: 13px; }
#moveDone { position: absolute; left: 8px; top: 8px; width: auto; padding: 10px 16px; box-shadow: 0 1px 4px #0003; }

#rStatus { min-height: 3.1em; }   /* two lines reserved so the plan does not jump under the finger when the message changes */
