/* Beit: warm limestone + concrete, one deep olive accent (the hillside). Arabic-first, works RTL and LTR. */
:root {
  --bg: #efe9df;          /* limestone */
  --panel: rgba(251, 248, 243, 0.94);
  --ink: #23201b;
  --muted: #6d655a;
  --line: #d9d0c2;
  --accent: #4f5d2f;      /* olive */
  --accent-ink: #ffffff;
  --warn: #a4462b;
  --pin-note: #4f5d2f; --pin-wall: #7a5a3a; --pin-window: #2f6a86; --pin-door: #8a6a1f; --pin-room: #6b3f6b; --pin-question: #a4462b;
  --r: 12px;
  --font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); overflow: hidden; touch-action: none; -webkit-tap-highlight-color: transparent; }
.drawer, .sheet .card, .screen { touch-action: pan-y; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

button, input, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 14px; min-height: 42px; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: var(--panel); }
button.danger { color: var(--warn); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; min-height: 0; padding: 4px; }
button.icon { width: 42px; padding: 0; }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
textarea { resize: vertical; }
label { font-weight: 500; font-size: 14px; }
h1, h2 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 24px; } h2 { font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.err { color: var(--warn); min-height: 1.2em; margin: 0; font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }
.col { display: grid; gap: 6px; }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #e4dccf; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; box-shadow: 0 8px 30px rgba(40, 30, 15, .12); backdrop-filter: blur(6px); }

.screen { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 20; padding: 16px; }
.login { width: min(360px, 100%); }

.bar { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); inset-inline: max(10px, env(safe-area-inset-left, 0px)) max(10px, env(safe-area-inset-right, 0px));
  display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; pointer-events: none; }
.bar > * { pointer-events: auto; }
.brand { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-height: 42px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; border-radius: 0; }
.seg.small button { min-height: 34px; padding: 6px 10px; font-size: 13px; }

.floors { position: fixed; inset-inline-start: max(10px, env(safe-area-inset-left, 0px)); top: calc(env(safe-area-inset-top, 0px) + 66px); width: 190px; padding: 10px; gap: 8px; }
.floors button { text-align: start; min-height: 38px; padding: 6px 10px; }
.check { display: flex; gap: 6px; align-items: center; font-weight: 400; font-size: 13px; }
.check input { width: auto; }

.actions { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); inset-inline-end: max(12px, env(safe-area-inset-right, 0px)); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.actions .primary { min-height: 50px; padding: 0 20px; font-size: 16px; }
.hint { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 66px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 99px; font-size: 14px; max-width: calc(100vw - 32px); text-align: center; }
.toast { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100vw - 32px); }

.sheet { position: fixed; inset-inline: 0; bottom: 0; display: grid; place-items: end center; padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 12px) max(12px, env(safe-area-inset-left, 0px)); z-index: 10; pointer-events: none; }
.sheet .card { width: min(460px, 100%); max-height: 78vh; overflow: auto; pointer-events: auto; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kinds button { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.body { white-space: pre-wrap; margin: 0; font-size: 16px; }
.replies { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.replies li { background: #f3eee6; border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; }
.replies li b { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.reply { display: grid; gap: 8px; }

.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(380px, 100vw); background: var(--panel); border-inline-start: 1px solid var(--line); padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 14px; display: grid; grid-template-rows: auto auto 1fr; gap: 10px; z-index: 12; backdrop-filter: blur(8px); }
#lItems { overflow: auto; display: grid; gap: 14px; align-content: start; }
#lItems h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.item { display: grid; grid-template-columns: 28px 1fr; gap: 8px; text-align: start; width: 100%; padding: 8px; min-height: 0; background: #fff; }
.item .n { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font: 600 12px var(--mono); }
.item p { margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item small { color: var(--muted); }
.item.done { opacity: .6; }

.menu { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 60px); inset-inline-end: max(10px, env(safe-area-inset-right, 0px)); padding: 8px; gap: 6px; z-index: 13; min-width: 180px; }
.menu button { text-align: start; }
.card.flat { box-shadow: none; background: #fff; }
.card h3 { margin: 0; font-size: 15px; }
.notice { background: #e9eedd; border: 1px solid #c9d3ae; border-radius: 10px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; }
.notice code { font: 600 15px var(--mono); background: #fff; padding: 2px 6px; border-radius: 6px; user-select: all; -webkit-user-select: all; }
.acct { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.acct small { color: var(--muted); display: block; }
.acct .row button { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.acct.off { opacity: .55; }
#accounts { grid-template-rows: auto auto auto 1fr; overflow: auto; }
.joy { position: fixed; inset-inline-start: max(18px, calc(env(safe-area-inset-left, 0px) + 12px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); width: 120px; height: 120px; border-radius: 50%; background: rgba(35, 32, 27, .18); border: 1px solid rgba(35, 32, 27, .25); touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: var(--accent); opacity: .9; }

@media (max-width: 640px) {
  .floors { width: auto; top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 74px); padding: 8px; }
  .floors .col { display: flex; flex-wrap: wrap; }
  .floors .check:last-child { display: none; }
  body.walking .floors { bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); }
  .actions .ghost { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
