/* Shared look for the three Creator Hub tools: a dark pro-app shell with a top bar, side panels,
   the 3D viewport in the middle and a status bar. Each app sets --accent on <body>. */
:root {
  --bg: #15171c;
  --panel: #1d2027;
  --panel-2: #252932;
  --panel-3: #2d323d;
  --line: #343a46;
  --text: #e8e6e1;
  --muted: #9a9ea8;
  --accent: #ff6a3d;
  --good: #59d38c;
  --bad: #ff5c5c;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: 290px 1fr 300px;
  grid-template-rows: 46px 1fr 26px;
  grid-template-areas: "top top top" "left view right" "status status status";
  height: 100vh;
}
.top {
  grid-area: top;
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: #101216;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: 10px; text-decoration: none; color: var(--text); }
.brand .logo {
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--accent); color: #111; font: 800 12px var(--mono);
}
.brand b { font-size: 14px; letter-spacing: .01em; }
.brand small { display: block; color: var(--muted); font: 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.top .spacer { flex: 1; }
.top .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.left { grid-area: left; border-right: 1px solid var(--line); }
.right { grid-area: right; border-left: 1px solid var(--line); }
.left, .right { background: var(--panel); overflow-y: auto; overflow-x: hidden; }
.viewport { grid-area: view; position: relative; overflow: hidden; background: #0d0f13; }
.viewport canvas.stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; will-change: transform; outline: none; }
.status {
  grid-area: status;
  display: flex; align-items: center; gap: 16px;
  padding: 0 12px;
  background: #101216; border-top: 1px solid var(--line);
  font: 11px var(--mono); color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.status .mode { color: var(--accent); }
.status .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { background: var(--panel-3); }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 5px; }
.btn-row.tight .btn { flex: 1; justify-content: center; }

.section { border-bottom: 1px solid var(--line); }
.section > h3 {
  margin: 0; padding: 9px 12px;
  display: flex; align-items: center; gap: 8px;
  font: 600 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  cursor: pointer; user-select: none;
}
.section > h3::before { content: "\25BE"; font-size: 10px; }
.section.closed > h3::before { content: "\25B8"; }
.section.closed > .body { display: none; }
.section > h3 .act { margin-left: auto; display: flex; gap: 4px; }
.section > .body { padding: 2px 12px 12px; }

.row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 8px; min-height: 28px; }
.row > label { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row > output { font: 11px var(--mono); color: var(--muted); min-width: 34px; text-align: right; }
.row input[type=range] { width: 100%; accent-color: var(--accent); }
.row select, .row input[type=text], .row input[type=number], .field {
  width: 100%; height: 26px; padding: 0 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px;
}
textarea.field { height: 64px; padding: 6px; resize: vertical; }
.row input[type=color] { width: 100%; height: 26px; padding: 0 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; }
.row.two { grid-template-columns: 92px 1fr 1fr; }
.hint { color: var(--muted); font-size: 11.5px; margin: 6px 0; }
.kbd { font: 10px var(--mono); padding: 1px 4px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 3px; }
.item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px;
  background: var(--panel-2); border: 1px solid transparent; border-radius: 4px;
  cursor: pointer; user-select: none;
}
.item:hover { background: var(--panel-3); }
.item.sel { border-color: var(--accent); }
.item .sw { width: 26px; height: 26px; border-radius: 3px; flex: none; background: #555 center/cover; border: 1px solid rgba(255,255,255,.1); }
.item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font: 10px var(--mono); color: var(--muted); }
.item .x { opacity: .5; padding: 0 3px; }
.item .x:hover { opacity: 1; color: var(--bad); }
.item .eye { opacity: .8; width: 16px; text-align: center; }
.item.off .name, .item.off .sw { opacity: .4; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.card {
  position: relative; aspect-ratio: 1; border-radius: 5px; overflow: hidden; cursor: pointer;
  background: var(--panel-2) center/cover; border: 1px solid var(--line);
}
.card:hover { border-color: var(--muted); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); background: #191b21; position: sticky; top: 0; z-index: 2; }
.tabs button {
  flex: 1; height: 34px; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--muted); font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- overlays in the viewport (kept off the canvas edges so the 3D stays clean) ---------- */
.vp-tools {
  position: absolute; left: 10px; top: 10px; z-index: 3;
  display: flex; flex-direction: column; gap: 4px;
}
.vp-tools .btn { background: rgba(29,32,39,.92); }
.vp-chip {
  position: absolute; right: 10px; top: 10px; z-index: 3;
  padding: 5px 9px; border-radius: 4px;
  background: rgba(16,18,22,.86); font: 11px var(--mono); color: var(--muted);
}
.vp-chip b { color: var(--accent); font-weight: 600; }
.vp-depth { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.vp-depth input { width: 110px; accent-color: var(--accent); }

/* ---------- modal + toast ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(5,6,9,.7);
}
.modal {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 15px; flex: 1; }
.modal .content { padding: 14px 16px; display: grid; gap: 10px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal .thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #0d0f13; border: 1px solid var(--line); }
.modal label.f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.modal .ok { color: var(--good); }

.toast {
  position: fixed; left: 50%; bottom: 40px; z-index: 60;
  translate: -50% 0;
  padding: 9px 16px; border-radius: 6px;
  background: #0f1115; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toast .25s ease-out;
}
.toast.bad { border-color: var(--bad); }
@keyframes toast { from { opacity: 0; translate: -50% 10px; } }

.busy {
  position: absolute; left: 50%; top: 50%; z-index: 4; translate: -50% -50%;
  padding: 10px 18px; border-radius: 6px;
  background: rgba(13,15,19,.86);
  font: 600 12px var(--mono); letter-spacing: .12em; color: var(--text);
  pointer-events: none;
}

.drop-hint {
  position: absolute; inset: 12px; z-index: 5; border: 2px dashed var(--accent); border-radius: 10px;
  display: grid; place-items: center; background: rgba(0,0,0,.45); font-size: 16px; pointer-events: none;
}

@media (max-width: 1100px) {
  .app { grid-template-columns: 250px 1fr 260px; }
  .brand small { display: none; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .app {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto 60vh auto auto 26px;
    grid-template-areas: "top" "view" "left" "right" "status";
  }
  .top { flex-wrap: wrap; height: auto; padding: 6px 10px; }
  .left, .right { border: 0; border-top: 1px solid var(--line); overflow: visible; }
}

/* Woven-canvas rule 5: an opaque cover ON TOP of the canvas until the first woven frame, removed
   with a hard cut (never faded). Not an overlay: it is meant to hide the tile. */
.stage-cover {
  position: absolute; inset: 0; z-index: 6;
  display: grid; place-items: center;
  background: #0d0f13;
  font: 600 12px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
