/* Copyright (c) 2026 Spacetech-KW. All rights reserved. See LICENSE. */
:root {
  --bg: #f3f4f6; --panel: #ffffff; --ink: #1c2230; --mut: #667085; --line: #dfe3ea; --acc: #1d6fd6; --acc-ink: #ffffff; --acc-soft: #e5effc; --warn: #e8590c; --ok: #2e9e5b; --shadow: 0 4px 18px rgba(20, 30, 50, .14);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="dark"] { --bg: #12151b; --panel: #1b2029; --ink: #e8ebf1; --mut: #98a2b3; --line: #2b323f; --acc: #5b9cf0; --acc-ink: #0b1220; --acc-soft: #22324c; --shadow: 0 4px 18px rgba(0, 0, 0, .5); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { display: flex; flex-direction: column; height: 100%; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- top bar */
#top { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; min-height: 52px; overflow-x: auto; scrollbar-width: none; }
#top::-webkit-scrollbar { display: none; }
#top .ttl { font-weight: 800; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-inline-end: 6px; }
#top .sp { flex: 1; }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; flex: none; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; color: var(--mut); font-weight: 600; white-space: nowrap; }
.seg button.on { background: var(--panel); color: var(--acc); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.ibtn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; height: 36px; min-width: 36px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; flex: none; white-space: nowrap; }
.ibtn:hover { background: var(--bg); }
.ibtn[disabled] { opacity: .4; cursor: default; }
.ibtn.pri { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); font-weight: 700; }
.ibtn.on { background: var(--acc-soft); border-color: var(--acc); color: var(--acc); }
.ibtn.danger { color: #c0392b; }
.state { font-size: 12px; color: var(--mut); white-space: nowrap; padding: 0 4px; }
.state.err { color: #c0392b; font-weight: 700; }
.chips { display: inline-flex; gap: 4px; flex: none; }
.chip { border: 1px solid var(--line); background: var(--panel); padding: 5px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 13px; }
.chip.on { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }

/* ---- stage */
#stage { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; display: none; }
.view.on { display: block; }
#planHost, #v3host { position: absolute; inset: 0; overflow: hidden; }
#planHost canvas, #v3host canvas { display: block; }
#v3host { background: #cfe0f0; }

/* ---- plan tools + properties */
#tools { position: absolute; inset-inline-start: 8px; top: 8px; bottom: 8px; width: 62px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; scrollbar-width: none; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 3; }
.tool { border: 0; background: transparent; border-radius: 10px; padding: 7px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-size: 10.5px; line-height: 1.15; color: var(--ink); text-align: center; }
.tool:hover { background: var(--bg); }
.tool.on { background: var(--acc); color: var(--acc-ink); }
.tool svg { width: 22px; height: 22px; }
.tool.sep { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; padding-top: 10px; }
#props { position: absolute; inset-inline-end: 8px; top: 8px; bottom: 8px; width: 292px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; z-index: 3; }
#props h3 { margin: 2px 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
#props h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--mut); }
.row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.row > label { flex: 0 0 104px; color: var(--mut); font-size: 12.5px; }
.row > .v { flex: 1; min-width: 0; }
.row input[type=text], .row input[type=number], .row select { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 8px; min-height: 34px; }
.row input[type=color] { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--bg); }
.row input[type=range] { width: 100%; }
.sw { display: flex; flex-wrap: wrap; gap: 6px; }
.sw button { width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; outline: 1px solid var(--line); cursor: pointer; padding: 0; }
.sw button.on { border-color: var(--acc); outline-color: var(--acc); }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.btnrow .ibtn { flex: 1 1 auto; }
.note { color: var(--mut); font-size: 12.5px; margin: 8px 0; white-space: pre-line; }
#hud { position: absolute; inset-inline: 0; bottom: 12px; display: flex; justify-content: center; pointer-events: none; z-index: 2; }
#hud .box { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 12px; display: flex; gap: 8px; align-items: center; }
#hud input { width: 90px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 8px; }

/* ---- 3D overlays */
#ov3d { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#ov3d .bar { position: absolute; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: auto; }
#ov3d .tl { top: 10px; inset-inline-start: 10px; max-width: calc(100% - 20px); }
#ov3d .tr { top: 10px; inset-inline-end: 10px; }
#ov3d .bl { bottom: calc(12px + var(--safe-b)); inset-inline-start: 10px; }
#ov3d .bc { bottom: calc(12px + var(--safe-b)); left: 50%; transform: translateX(-50%); }
#ov3d .hint { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); background: rgba(15, 20, 30, .72); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; pointer-events: none; max-width: 92%; text-align: center; transition: opacity .6s; }
#ov3d .ibtn, #ov3d .chip { box-shadow: var(--shadow); }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; background: rgba(255, 255, 255, .88); color: #1c2230; border-radius: 8px; padding: 2px 8px; text-align: center; font-size: 11px; line-height: 1.25; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); white-space: nowrap; }
.lbl b { display: block; font-size: 12px; }
.lbl i { font-style: normal; color: #667085; }
.fade { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity .4s; pointer-events: none; z-index: 2; }
#joy { position: absolute; bottom: calc(26px + var(--safe-b)); inset-inline-start: 26px; width: 116px; height: 116px; border-radius: 50%; background: rgba(255, 255, 255, .22); border: 2px solid rgba(255, 255, 255, .55); z-index: 4; touch-action: none; backdrop-filter: blur(4px); }
#joy i { position: absolute; width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, .8); left: 34px; top: 34px; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
#tourcap { position: absolute; bottom: calc(80px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: rgba(15, 20, 30, .78); color: #fff; padding: 10px 18px; border-radius: 14px; text-align: center; z-index: 4; }
#tourcap b { display: block; font-size: 18px; }
#roomBadge { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); background: rgba(15, 20, 30, .72); color: #fff; padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; z-index: 4; pointer-events: none; white-space: nowrap; }
#roomBadge[hidden] { display: none !important; }
#notes { position: absolute; inset-inline-end: 8px; top: 8px; bottom: 8px; width: 320px; max-width: calc(100% - 16px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 6; display: flex; flex-direction: column; overflow: hidden; }
#notes header { padding: 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); font-weight: 800; }
#notes .list { flex: 1; overflow-y: auto; padding: 8px; }
.pin { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; cursor: pointer; background: var(--bg); }
.pin.on { border-color: var(--acc); background: var(--acc-soft); }
.pin .n { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; background: var(--warn); color: #fff; font-weight: 800; font-size: 12px; margin-inline-end: 8px; flex: none; }
.pin.done .n { background: var(--ok); }
.pin .meta { color: var(--mut); font-size: 11.5px; margin-top: 4px; }
.pin .cm { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 13px; }
.pin .cm small { color: var(--mut); display: block; }
.pin textarea, .pin input[type=text] { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 8px; margin-top: 6px; }

/* ---- modal, toast, empty */
#modal { position: absolute; inset: 0; background: rgba(10, 14, 22, .5); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal[hidden], #toast[hidden], #empty[hidden], #joy[hidden], #notes[hidden], #tourcap[hidden] { display: none !important; }
#modal .card { background: var(--panel); border-radius: 16px; padding: 18px; width: 440px; max-width: 100%; max-height: 90%; overflow: auto; box-shadow: var(--shadow); }
#modal h3 { margin: 0 0 10px; }
#modal textarea { width: 100%; min-height: 90px; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px; }
#modal .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
#modal .gi { border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; background: var(--bg); cursor: pointer; font-size: 12.5px; }
#modal .gi:hover { border-color: var(--acc); }
#toast { position: absolute; bottom: calc(22px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: #1c2230; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: 90%; box-shadow: var(--shadow); }
#empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 5; pointer-events: none; }
#empty .card { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; max-width: 380px; text-align: center; }
#empty h2 { margin: 0 0 6px; }

/* ---- phones */
@media (max-width: 800px) {
  #tools { inset: auto 8px calc(8px + var(--safe-b)) 8px; width: auto; height: 62px; flex-direction: row; top: auto; overflow-x: auto; overflow-y: hidden; padding: 3px 4px; }
  .tool { flex: 0 0 58px; }
  .tool.sep { margin: 0 0 0 4px; border-top: 0; border-inline-start: 1px solid var(--line); padding-top: 7px; }
  #props { inset: auto 8px calc(78px + var(--safe-b)) 8px; width: auto; top: auto; max-height: 44%; }
  #props:empty { display: none; }
  #top .ttl { display: none; }
  .seg button { padding: 6px 9px; }
  .seg button span { display: none; }
  .seg button.on span { display: inline; }
  #notes { inset: auto 0 0 0; width: auto; max-width: none; top: 38%; border-radius: 16px 16px 0 0; }
  #ov3d .bc { bottom: calc(150px + var(--safe-b)); }
}
