: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; }

#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; }

#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; }

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; }

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