:root {
  --ink: #f5f3ef;
  --ink-dim: #c9c4bb;
  --glass: rgba(24, 23, 21, .72);
  --glass-strong: rgba(24, 23, 21, .86);
  --accent: #e8c17a;
  --line: rgba(255, 255, 255, .14);
  --bg: #e7e3dc;
  --radius: 14px;
  font-family: "Segoe UI", "Arial Hebrew", "Noto Sans Hebrew", Arial, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#stage canvas { cursor: grab; }
body.dragging #stage canvas { cursor: grabbing; }
body.measuring #stage canvas { cursor: crosshair; }

#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-size: 13px; line-height: 1.25; text-align: center; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 6px rgba(0,0,0,.7); font-weight: 600; }
.label small { display: block; font-weight: 400; font-size: 11px; color: #e6e1d8; }
.label.measure { background: var(--glass-strong); color: #fff; text-shadow: none; padding: 3px 9px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--accent); direction: rtl; }

#top { position: fixed; top: max(12px, env(safe-area-inset-top)); inset-inline-start: 12px; inset-inline-end: 12px; display: flex; pointer-events: none; }
.chip { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; display: flex; gap: 8px; align-items: center; max-width: 100%; }
.chip #house-name { font-weight: 600; white-space: nowrap; }
.chip #room-name { color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .sep { color: var(--ink-dim); }

#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--glass);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--ink); pointer-events: none;
  opacity: 0; transition: opacity .4s; max-width: calc(100% - 24px); text-align: center; }
#hint.show { opacity: 1; }

#bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 4px;
  background: var(--glass-strong); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line);
  border-radius: 18px; padding: 6px; }
#bar button { appearance: none; border: 0; background: transparent; color: var(--ink-dim); font: inherit; font-size: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 74px; padding: 7px 8px 6px; border-radius: 12px; }
#bar button svg { width: 24px; height: 24px; fill: currentColor; }
#bar button:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }
#bar button.active { color: #1d1b18; background: var(--accent); }
#bar button:focus-visible, #measure-tools button:focus-visible, #enter:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

#measure-tools { position: fixed; top: calc(60px + env(safe-area-inset-top)); inset-inline-start: 12px; }
#measure-tools button { appearance: none; border: 1px solid var(--line); background: var(--glass-strong); color: var(--ink); font: inherit;
  font-size: 13px; padding: 7px 14px; border-radius: 999px; cursor: pointer; }

#intro { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(20, 19, 17, .25), rgba(20, 19, 17, .55)); transition: opacity .5s; }
#intro.gone { opacity: 0; pointer-events: none; }
#intro .card { width: min(440px, 100%); background: var(--glass-strong); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 20px; padding: 26px 24px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
#intro .kicker { margin: 0 0 6px; color: var(--accent); font-size: 13px; letter-spacing: .02em; }
#intro h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.2; font-weight: 650; }
#intro #intro-sub { margin: 0 0 16px; color: var(--ink-dim); font-size: 15px; }
#intro ul { margin: 0 0 20px; padding: 0 18px 0 0; color: var(--ink); font-size: 14px; line-height: 1.6; }
#enter { width: 100%; appearance: none; border: 0; border-radius: 12px; background: var(--accent); color: #1d1b18; font: inherit; font-size: 16px;
  font-weight: 650; padding: 12px; cursor: pointer; }
#enter:disabled { opacity: .6; cursor: progress; }

#busy { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#error { position: fixed; inset: auto 12px 100px 12px; background: #7a2a1d; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; }

@media (max-width: 480px) {
  #bar { gap: 2px; padding: 5px; border-radius: 16px; }
  #bar button { min-width: 0; width: 76px; font-size: 11px; padding: 6px 4px 5px; }
  .chip { font-size: 13px; padding: 6px 12px; }
  #intro h1 { font-size: 22px; }
  #hint { bottom: calc(88px + env(safe-area-inset-bottom)); font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { #intro, #hint { transition: none; } }
[hidden] { display: none !important; }
@media (max-width: 480px) { .label { font-size: 11px; } .label small { font-size: 10px; } }

/* measure: the snap marker (a corner: gold ring with a dot; an edge: gold ring; free: a small white ring) */
.snap { position: absolute; left: 0; top: 0; width: 22px; height: 22px; margin: 0; border-radius: 50%; pointer-events: none;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.5); transform: translate(-50%, -50%); }
.snap.free { width: 14px; height: 14px; border-width: 2px; background: rgba(255,255,255,.18); }
.snap.edge { border-color: var(--accent); background: rgba(232,193,122,.18); }
.snap.corner { width: 26px; height: 26px; border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 3.5px, rgba(232,193,122,.22) 4.5px); }
.snap.axis { border-color: #6fd38a; }
.label.measure.edge { background: rgba(24,23,21,.72); border-color: rgba(232,193,122,.6); font-size: 12px; padding: 2px 8px; }
