/* Test Pattern — charcoal theme: lighter than black, never bright white surfaces.
   Brand (BRAND_CORE §5): black/white base, Poppins, colour only as a light accent. */
:root {
  --bg: #1d1e22;
  --panel: #25262b;
  --panel-2: #2b2d33;
  --line: #383a41;
  --field: #2f3137;
  --field-h: #353840;
  --fg: #f1f1f3;
  --dim: rgba(241, 241, 243, .66);
  --faint: rgba(241, 241, 243, .42);
  --accent: #9b3cff;
  --grad: linear-gradient(90deg, #2a2a9a, #8a1f8f);
  --warn: #FFAA3B;
  --err: #FF5A5A;
  --ok: #3BE8B0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font: 300 13px/1.45 Poppins, system-ui, sans-serif; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.app { display: grid; grid-template-rows: 52px 1fr; height: 100vh; }

/* top bar */
.top { display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; }
.top::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--grad); }
.brand { font-size: 17px; font-weight: 200; letter-spacing: -.01em; white-space: nowrap; }
.brand b { font-weight: 600; }
.brand small { font-size: 11px; color: var(--faint); margin-left: 10px; }
.brand small b { color: var(--dim); }
.top .sp { flex: 1; }
.note { color: var(--faint); font-size: 11px; }
.note.bad { color: var(--err); }

.btn { background: #ececf0; color: #17181b; border: 0; border-radius: 999px; padding: 7px 16px; font-weight: 600; cursor: pointer; font-size: 12px; transition: background .15s; }
.btn:hover { background: #fff; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 300; }
.btn.ghost:hover { border-color: #5a5d66; background: var(--field); }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.btn.wide { width: 100%; }
.btn.sm { padding: 5px 12px; font-size: 11.5px; }

/* layout */
.main { display: grid; grid-template-columns: 236px 1fr 352px; min-height: 0; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 10px; }
.side-h { display: flex; align-items: center; justify-content: space-between; margin: 2px 4px 12px 6px; }
.side h2, .insp h3 { font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.insp h3 { margin-bottom: 10px; }
.insp { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; }
#viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#viewport > canvas { display: block; width: 100%; height: 100%; }

/* list */
.item { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; margin-bottom: 2px; }
.item:hover { background: var(--field); }
.item.on { background: var(--field-h); box-shadow: inset 2px 0 0 var(--accent); }
.item .nm { display: block; font-weight: 600; font-size: 12.5px; }
.item .sub { display: block; color: var(--dim); font-size: 11.5px; }
.item.person .nm { font-weight: 300; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--err); margin-right: 6px; vertical-align: middle; }
.empty { color: var(--faint); padding: 6px; }

/* menus */
.dd { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; min-width: 260px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, .45); }
.side .menu { left: auto; right: -170px; }
.menu[hidden] { display: none; }
.menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.menu button:hover { background: var(--field-h); }
.menu b { display: block; font-weight: 600; font-size: 12.5px; }
.menu span { display: block; color: var(--dim); font-size: 11.5px; }

/* inspector */
.insp section { padding: 16px 16px 18px; border-bottom: 1px solid var(--line); }
.insp section.head { padding-bottom: 14px; }
.insp section.foot { display: flex; gap: 8px; border-bottom: 0; }
.insp section.foot .btn { flex: 1; }
.ph { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.f { display: block; margin-bottom: 10px; }
.f > span { display: block; font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.f input, .f select { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; outline: none; font-variant-numeric: tabular-nums; }
.f input:hover, .f select:hover { background: var(--field-h); }
.f input:focus, .f select:focus { border-color: var(--accent); }
.f select { appearance: none; cursor: pointer; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, #aaa 50%), linear-gradient(135deg, #aaa 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.f select option { background: #2b2d33; color: var(--fg); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row2.tight { gap: 8px; margin: 4px 0 12px; }
.tag { font-size: 11px; color: var(--faint); margin-top: 2px; }
.tag a { color: var(--fg); }
.tag.okay { color: var(--ok); }
.stack { display: grid; gap: 8px; margin-bottom: 8px; }

.sum { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-top: -2px; font-variant-numeric: tabular-nums; }
.sum .k { width: 100%; font-size: 11px; color: var(--faint); }
.sum b { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.sum b.bad { color: var(--err); font-size: 14px; }
.sum span:not(.k) { color: var(--dim); font-size: 12px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-variant-numeric: tabular-nums; }
.stats dt { color: var(--dim); }
.stats dd { text-align: right; }
.msgs { list-style: none; margin-top: 12px; font-size: 12px; }
.msgs li { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; }
.msgs.warn li { color: var(--warn); background: rgba(255, 170, 59, .09); }
.msgs.err li { color: var(--err); background: rgba(255, 90, 90, .09); }
.how { margin-top: 12px; font-size: 11.5px; color: var(--dim); }
.how summary { cursor: pointer; color: var(--fg); }
.how ol { margin: 8px 0 0 18px; }
.how li { margin-bottom: 3px; }
.pill { font-style: normal; display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .04em; padding: 1px 7px; margin-right: 6px; border-radius: 999px; border: 1px solid var(--warn); color: var(--warn); }
.pill.ok { border-color: var(--ok); color: var(--ok); }

.spec { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 2px; }
.spec-h { display: flex; align-items: center; margin-bottom: 8px; }
.spec-h b { font-weight: 600; }
.spec .stats { font-size: 12px; margin-bottom: 6px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.links a { font-size: 12px; text-underline-offset: 3px; }
.links a.dl { font-weight: 600; }

.checks { display: grid; gap: 8px; margin-bottom: 12px; }
.ck { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; }
.ck input { accent-color: var(--accent); width: 15px; height: 15px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px var(--panel); }
.sw.on { border-color: var(--fg); }
.logo-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.logo-name { color: var(--dim); font-size: 12px; margin-right: auto; }
.link { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--fg); }
.group { border: 1px solid var(--line); border-radius: 8px; padding: 10px 10px 0; margin: 4px 0 10px; }
.ghead { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-bottom: 6px; }
.faces { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 8px; }
.faces .link { margin-left: 4px; text-decoration: none; }
.ct { margin: 4px 0 10px; }
.ct .nm { display: block; font-weight: 600; word-break: break-all; }
.ct .sub { display: block; color: var(--dim); font-size: 11.5px; }
.video { margin-top: 16px; }
.edit-cta .btn { background: var(--accent); color: #fff; }
.edit-cta .btn:hover { background: #ab55ff; }
.hint { padding: 40px 20px; color: var(--faint); text-align: center; }
.views { display: grid; gap: 4px; margin-bottom: 10px; }
.vrow { display: flex; align-items: center; gap: 8px; }
.vgo { flex: 1; text-align: left; background: var(--field); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; cursor: pointer; }
.vgo:hover { background: var(--field-h); border-color: #5a5d66; }
.vrow .link { text-decoration: none; font-size: 16px; padding: 0 4px; }

/* viewport overlays */
#empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: var(--faint); }
#empty[hidden] { display: none; }
.vbtn { position: absolute; top: 12px; right: 12px; background: rgba(37, 38, 43, .8); }
.vhint { position: absolute; left: 12px; bottom: 10px; color: var(--faint); font-size: 11px; pointer-events: none; }
.editicon { position: absolute; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 600; cursor: pointer; box-shadow: 0 0 0 4px rgba(155, 60, 255, .25), 0 8px 24px rgba(0,0,0,.4); animation: pop .25s ease-out; }
.editicon:hover { background: #ab55ff; }
.editicon[hidden] { display: none; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 2D editor */
.editor { position: absolute; inset: 0; z-index: 4; }
.ed-back { position: absolute; inset: 0; background: #1d1e22; opacity: 0; transition: opacity .48s ease; }
.editor.on .ed-back { opacity: .97; }
.ed-head { position: absolute; left: 0; right: 0; top: 0; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 16px; opacity: 0; transform: translateY(-8px); transition: opacity .3s ease .15s, transform .3s ease .15s; }
.editor.on .ed-head { opacity: 1; transform: none; }
.ed-title { flex: 1; font-size: 13px; color: var(--dim); }
.ed-title b { color: var(--fg); font-weight: 600; }
.ed-hint { color: var(--faint); font-size: 11px; }
.ed-frame { position: absolute; display: flex; gap: 14px; align-items: flex-start; justify-content: center; }
.ed-frame.anim { transition: left .48s cubic-bezier(.2,.8,.2,1), top .48s cubic-bezier(.2,.8,.2,1), width .48s cubic-bezier(.2,.8,.2,1), height .48s cubic-bezier(.2,.8,.2,1), opacity .48s ease; }
.ed-frame figure { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ed-frame canvas { display: block; width: 100%; height: auto; box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 20px 60px rgba(0,0,0,.5); background: #000; }
.ed-frame figcaption { font-size: 11px; color: var(--dim); text-align: center; }
body.editing .vhint, body.editing .vbtn { display: none; }
body.editing .side { pointer-events: none; opacity: .55; }

/* projects drawer */
#pname { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; width: 220px; font-weight: 600; outline: none; }
#pname:hover { border-color: var(--line); }
#pname:focus { border-color: var(--accent); background: var(--field); }
.proj { display: flex; align-items: center; gap: 6px; }
.drawer { position: fixed; inset: 0; background: rgba(20, 21, 24, .6); display: flex; justify-content: center; align-items: flex-start; padding-top: 80px; z-index: 10; }
.drawer[hidden] { display: none; }
.dpanel { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 140px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.dhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dhead h2 { font-size: 16px; font-weight: 600; margin-right: 8px; }
.dhead .sp { flex: 1; }
#plist { margin-top: 12px; }
.prow { display: flex; align-items: center; gap: 6px; border-radius: 8px; padding: 2px; }
.prow:hover { background: var(--field); }
.prow.on { box-shadow: inset 2px 0 0 var(--accent); background: var(--field-h); }
.pmain { flex: 1; text-align: left; background: transparent; border: 0; padding: 8px 10px; cursor: pointer; }
.pmain .nm { display: block; font-weight: 600; }
.pmain .sub { display: block; color: var(--dim); font-size: 11.5px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px 8px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.toast[hidden] { display: none; }

/* desktop only */
.gate { display: none; }
@media (max-width: 1023px) {
  .app { display: none; }
  .gate { display: grid; place-items: center; height: 100vh; text-align: center; padding: 0 16px; }
}
body.touch .app { display: none; }
body.touch .gate { display: grid; place-items: center; height: 100vh; text-align: center; padding: 0 16px; }
.gate h1 { font-weight: 200; font-size: 34px; } .gate h1 b { font-weight: 600; }
.gate p { color: var(--dim); margin-top: 8px; }

/* print: pixel map table only */
#print { display: none; }
@media print {
  body.printing { background: #fff; color: #000; overflow: visible; }
  body.printing .app, body.printing .drawer, body.printing .gate, body.printing .toast { display: none !important; }
  body.printing #print { display: block; font: 9pt/1.35 Poppins, system-ui, sans-serif; }
  #print h1 { font-weight: 200; font-size: 16pt; } #print h1 b { font-weight: 600; }
  #print p { color: #555; margin: 2pt 0 10pt; }
  #print table { border-collapse: collapse; width: 100%; }
  #print th, #print td { border-bottom: .5pt solid #bbb; padding: 3pt 4pt; text-align: left; vertical-align: top; }
  #print th { font-weight: 600; }
  @page { size: A4 landscape; margin: 12mm; }
}

/* ---- v1.3: cameras bar, viewport tools, view cube, render frame, setup draft ---- */
.camsbar { display: flex; align-items: center; gap: 8px; min-width: 0; margin-left: 12px; padding-left: 16px; border-left: 1px solid var(--line); }
.camsbar .lbl { font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.cams { display: flex; align-items: center; gap: 6px; overflow-x: auto; max-width: 46vw; scrollbar-width: thin; }
.cam { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--field); flex: 0 0 auto; }
.cam.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(155, 60, 255, .25); }
.cam .cgo { background: none; border: 0; padding: 4px 4px 4px 12px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.cam .cic { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 4px 6px; display: grid; place-items: center; }
.cam .cic:hover { color: var(--fg); }
.cam .cx { padding-right: 10px; font-size: 14px; display: none; }
.cam:hover .cx { display: grid; }
.iconbtn { width: 30px; height: 28px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--dim); }
.iconbtn:hover { color: var(--fg); background: var(--field); }
.iconbtn.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.iconbtn:not(.on) .shackle { transform: translateY(-2px) rotate(-12deg); transform-origin: 16px 11px; }
.btn.busy { opacity: .6; }
.mt8 { margin-top: 8px; }

.vtools { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(37, 38, 43, .88); border: 1px solid var(--line); }
.tool { display: flex; align-items: center; gap: 6px; background: transparent; border: 0; border-radius: 7px; padding: 5px 9px; cursor: pointer; color: var(--dim); font-size: 11.5px; }
.tool:hover { color: var(--fg); background: var(--field); }
.tool.on { color: #fff; background: var(--accent); }
.vtools .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.viewcube { position: absolute; top: 8px; right: 8px; z-index: 3; width: 104px; height: 104px; }
.rframe { position: absolute; z-index: 1; pointer-events: none; border: 1px dashed rgba(255, 255, 255, .45); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .22); }
.rframe::after { content: attr(data-label); position: absolute; left: 6px; bottom: 6px; font-size: 10.5px; color: rgba(255, 255, 255, .6); }
.rframe[hidden] { display: none; }
body.editing .vtools, body.editing .viewcube { display: none; }

.draftbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: #3a2160; border-bottom: 1px solid var(--accent); font-size: 12px; }
.draftbar span { flex: 1; }
.draftbar b { font-weight: 600; }
.draftbar[hidden] { display: none; }
.viewmode { display: flex; background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-left: 8px; }
.viewmode button { display: flex; align-items: center; gap: 6px; background: transparent; border: 0; border-radius: 999px; padding: 4px 12px; cursor: pointer; color: var(--dim); font-size: 12px; }
.viewmode button.on { background: #ececf0; color: #17181b; font-weight: 600; }
.orthobadge { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 12px; padding: 5px 6px 5px 14px; border-radius: 999px; background: rgba(37, 38, 43, .92); border: 1px solid var(--accent); box-shadow: 0 0 0 3px rgba(155, 60, 255, .2); font-size: 12px; }
.orthobadge b { font-weight: 600; }
.orthobadge .dim { color: var(--faint); font-size: 11px; }
.orthobadge[hidden] { display: none; }
body.ortho .rframe { border-color: rgba(155, 60, 255, .6); }

/* ---- v1.5: pinned Content button, canvas layers, colour pickers, video tab ---- */
.editicon { transform: translate(-50%, calc(-100% - 10px)); }
.editicon::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; background: var(--accent); transform: translateX(-50%) rotate(45deg); border-right: 1px solid rgba(255,255,255,.25); border-bottom: 1px solid rgba(255,255,255,.25); }
@keyframes pop { from { opacity: 0; } to { opacity: 1; } }
.side-h.ed-only { display: none; }
body.editing .side-h.ed-only { display: flex; }
body.editing .side-h.scene-only { display: none; }
body.editing .side { pointer-events: auto; opacity: 1; }
.item.layer { position: relative; padding-right: 34px; }
.item.layer.off .nm, .item.layer.off .sub { opacity: .45; }
.item.layer.base { margin-top: 10px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.kind { font-style: normal; font-size: 9.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; margin-right: 7px; background: var(--field-h); color: var(--dim); }
.k-video { color: #ff8ad8; } .k-logo { color: #ffd36b; } .k-image { color: #7fd8ff; } .k-base { color: var(--accent); }
.eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 15px; padding: 4px; }
.eye:hover { color: var(--fg); }
.colour .cin { display: flex; align-items: center; gap: 8px; }
.colour input[type=color] { width: 40px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--field); cursor: pointer; }
.colour input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.colour input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.colour code { font: 11.5px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--dim); }
.gprev { height: 18px; border-radius: 6px; border: 1px solid var(--line); margin: -2px 0 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.align { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 8px; }
.align .btn { padding: 6px 0; font-size: 14px; }
.tag.warn-t { color: var(--warn); }
.vprog { height: 4px; border-radius: 4px; background: var(--field); overflow: hidden; margin: 10px 0 6px; }
.vprog i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }
.insp section.foot { flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: 0; padding: 10px 10px 9px; cursor: pointer; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 12.5px; }
.tabs button:hover { color: var(--fg); }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
