:root {
  --primary: #1f3a5f;
  --accent: #e5a04d;
  --bg: #0e1116;
  --panel-bg: #161c26;
  --text: #f3f1ea;
  --muted: #b9b4a6;
  --border: #2c3547;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif; }
body { display: flex; flex-direction: column; }

header { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px; background: var(--primary); flex-wrap: wrap; }
#brand { display: flex; align-items: baseline; gap: 10px; }
#logo-text { font-weight: 800; font-size: 20px; letter-spacing: 1px; color: var(--accent); }
#brand-name { font-size: 13px; color: var(--text); opacity: .85; }
#header-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
button, .file-btn { font: 12px ui-sans-serif, sans-serif; padding: 6px 10px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--panel-bg);
  color: var(--text); cursor: pointer; }
button:hover, .file-btn:hover { border-color: var(--accent); }
button.on { background: var(--accent); color: #14100a; border-color: var(--accent); font-weight: 700; }
button.active-mode { background: var(--accent); color: #14100a; }
button:focus-visible, .file-btn:focus-visible, input:focus-visible, select:focus-visible,
#view3d:focus-visible, #view2d:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
#view3d:focus-visible, #view2d:focus-visible { outline-offset: -2px; }
.card label.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.card label.check input { width: auto; margin: 0; }

#layout { flex: 1; display: flex; min-height: 0; }
#viewport { flex: 1; position: relative; min-width: 0; }
#view3d, #view2d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#view2d { background: #f7f4ec; cursor: crosshair; }
/* [hidden] must win over the display:block above, else the 2D canvas
   covers the 3D view and swallows its pointer events (real-browser QA) */
#view2d[hidden] { display: none; }
#status { position: absolute; top: 10px; left: 12px; font-size: 12px; color: #ffd9a0;
  background: rgba(14,17,22,.78); padding: 3px 8px; border-radius: 6px;
  pointer-events: none; max-width: 70%; }
#hint { position: absolute; bottom: 10px; left: 12px; font-size: 11px; color: #d8d2c2;
  background: rgba(14,17,22,.78); padding: 3px 8px; border-radius: 6px; pointer-events: none; }
#drop-overlay { position: absolute; inset: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; text-align: center;
  font-size: 18px; font-weight: 700; color: var(--accent);
  border: 3px dashed var(--accent); border-radius: 12px;
  background: rgba(14,17,22,.72); pointer-events: none; z-index: 5; }
#drop-overlay[hidden] { display: none; }
/* Preview-tier watermark (F2): visible, non-interactive, survives embed. */
#watermark { position: absolute; bottom: 10px; right: 12px; font-size: 13px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: #fff; opacity: .55;
  background: rgba(14,17,22,.55); padding: 4px 10px; border-radius: 6px; pointer-events: none; z-index: 4; }
#watermark[hidden] { display: none; }
#drop-overlay .small { color: #d8d2c2; font-weight: 400; }

#panel { width: 300px; overflow-y: auto; background: var(--panel-bg);
  border-left: 1px solid var(--border); padding: 10px; }
.card { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.card h2 { font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent); margin: 0 0 8px; }
.card label { display: block; font-size: 12px; color: var(--muted); margin: 6px 0; }
.card input, .card select { width: 100%; margin-top: 2px; padding: 5px 6px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 5px; }
.card button { margin-top: 6px; }
.row { display: flex; gap: 6px; }
.small { font-size: 11px; color: var(--muted); }
#sel-info { font-size: 12px; line-height: 1.5; word-break: break-word; }
#edits-list { font-size: 11px; margin: 6px 0; padding-left: 18px; }
#edits-list li { margin-bottom: 4px; word-break: break-word; }
#edits-list button { padding: 1px 6px; margin-left: 6px; }
#compare-out { font-size: 12px; line-height: 1.5; }
#compare-out ul { margin: 4px 0 8px; padding-left: 16px; }
.diff-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px;
  color: var(--muted); margin: 6px 0; }
.diff-legend .swatch { display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.swatch.diff-added { background: #2e9e4f; }
.swatch.diff-removed { background: #d64541; }
.swatch.diff-moved { background: #e5a04d; }

footer { padding: 6px 14px; font-size: 11px; color: var(--muted); background: var(--panel-bg); }

/* embed mode (?embed=1): hide all chrome, canvas only */
body.embed .chrome { display: none !important; }
body.embed #hint, body.embed #status { display: none; }

/* client mode (?client=1): clean presentation view — hide the dev
   corrections UI (calibration / role / wall / opening / edits cards and
   the Export edits button); selection, compare, load, and GLB stay. */
body.client .dev-card { display: none !important; }
body.client #btn-export-edits { display: none !important; }

@media (max-width: 800px) {
  #layout { flex-direction: column; }
  #panel { width: 100%; border-left: none; border-top: 1px solid var(--border); }
  #viewport { min-height: 55vh; }
}
