/* studio.css — the creator editor. A fixed three-pane workspace below the app
   topbar: page rail (left), composition canvas (centre), inspector (right).
   The list view reuses the shared card/grid/head components from app.css. */

.editor { position: fixed; inset: 64px 0 0 0; z-index: 30; display: flex; flex-direction: column;
  background: var(--paper-2); }
.editor-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: 9px var(--sp-5); border-bottom: 2px solid var(--work-accent, var(--accent)); background: var(--surface); }
.editor-title { display: flex; align-items: center; gap: 10px; }
.editor-title b { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.editor-body { flex: 1; display: grid; grid-template-columns: 196px 1fr 300px; min-height: 0; }

/* ---- page rail ----------------------------------------------------------- */
.rail { border-right: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0; }
.rail-head { padding: 12px 14px; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  color: var(--muted); border-bottom: 1px solid var(--line); }
.rail-list { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.rail-page { position: relative; border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px; cursor: pointer; background: var(--paper); transition: border-color var(--ease), box-shadow var(--ease); }
.rail-page:hover { border-color: var(--line-strong); }
.rail-page.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.rail-page.dragging { opacity: .4; }
.rail-page.drop-target { border-color: var(--accent); border-style: dashed; }
.rail-num { position: absolute; top: 10px; left: 10px; z-index: 2; font-size: 11px; font-weight: 700;
  background: var(--ink); color: var(--paper); width: 18px; height: 18px; border-radius: 5px;
  display: grid; place-items: center; }
.thumb { width: 100%; border-radius: 4px; overflow: hidden; position: relative; background: var(--surface-2);
  border: 1px solid var(--line); }
.tnode { position: absolute; font-size: 5px; line-height: 1; overflow: hidden; }
.rail-tools { display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px; }
.icon-mini { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; }
.icon-mini:hover { background: var(--surface-2); color: var(--ink); }
.icon-mini.danger:hover { background: color-mix(in srgb, #b23b2a 14%, transparent); color: #b23b2a; }
.add-page { margin: 12px; }

/* ---- canvas -------------------------------------------------------------- */
.canvas-wrap { position: relative; overflow: auto; display: grid; place-items: center;
  min-width: 0; min-height: 0; padding: 24px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 26px 26px,
    var(--paper-2);
  background-blend-mode: normal; }
.stage-holder { position: relative; flex: none; margin: auto; }
.edit-stage { transform-origin: top left; position: absolute; top: 0; left: 0; background: #fff;
  box-shadow: var(--shadow-pop); border-radius: 3px; overflow: visible; }

.enode { position: absolute; cursor: grab; outline: 1px solid transparent; }
.enode:hover { outline-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.enode.selected { outline: 2px solid var(--accent); cursor: move; }
.enode-text { width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.enode-fill { width: 100%; height: 100%; display: grid; place-items: center; pointer-events: none; }
.enode-ph { color: var(--muted); }
.enode-hotspot { width: 100%; height: 100%; display: grid; place-items: center; gap: 4px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 8px; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 12px; font-weight: 600; pointer-events: none; grid-auto-flow: column; }
.handle { position: absolute; width: 14px; height: 14px; background: var(--surface);
  border: 2px solid var(--accent); border-radius: 50%; z-index: 100; pointer-events: auto; box-shadow: 0 1px 8px rgba(0,0,0,.18); }
.handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* ---- inspector ----------------------------------------------------------- */
.inspector { border-left: 1px solid var(--line); background: var(--surface); overflow: auto; padding-bottom: var(--sp-7); }
.insp-section { padding: 14px; border-bottom: 1px solid var(--line); }
.insp-head { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--muted);
  margin: 6px 0 12px; display: flex; align-items: center; }
.insp-head.with-actions { justify-content: space-between; }
.tool-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-btn { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 6px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--paper);
  color: var(--ink-soft); font-size: 12px; font-weight: 600; transition: border-color var(--ease), color var(--ease); }
.tool-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.tool-btn .icon { color: var(--accent); }
.insp-field { margin-bottom: 12px; }
.insp-field.num input { font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-2 .insp-field { margin-bottom: 0; }
.insp-field .input { padding: 8px 10px; font-size: 13.5px; }
.insp-field textarea.input.area { min-height: 70px; }
.btn.dirty { border-color: var(--accent); color: var(--accent-ink); }

@media (max-width: 980px) {
  .editor-body { grid-template-columns: 150px 1fr 260px; }
}
@media (max-width: 760px) {
  .editor-body { grid-template-columns: 1fr; }
  .rail, .inspector { display: none; }
}

/* Rail tabs (Pages / Layers) */
.rail-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.rail-tab { display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 6px; background: var(--surface); border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .04em; cursor: pointer; }
.rail-tab .icon { width: 15px; height: 15px; }
.rail-tab:hover { color: var(--ink); }
.rail-tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); background: var(--paper); }
.rail-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Layers list (lives in the left rail) */
.layer-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.layer-row { display: flex; align-items: center; gap: 4px; border-radius: var(--r-sm); padding: 2px 4px; }
.layer-row.active { background: var(--accent-soft); }
.layer-row:hover { background: var(--surface-2); }
.layer-row.active:hover { background: var(--accent-soft); }
.layer-main { flex: 1; display: flex; align-items: center; gap: 8px; background: none; border: 0;
  color: var(--ink); font: inherit; font-size: 13px; padding: 7px 4px; cursor: pointer; text-align: left; min-width: 0; }
.layer-main .icon { color: var(--muted); flex: none; }
.layer-row.active .layer-main .icon { color: var(--accent-ink); }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-tools { display: flex; gap: 1px; flex: none; }
.rail-empty { padding: var(--sp-4); color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* Empty image node — visible + clickable on the canvas */
.enode-fill.image-empty { display: grid; place-items: center; gap: 6px; pointer-events: auto;
  color: var(--accent-ink); cursor: pointer;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.enode-fill.image-empty .ph-label { font-size: 13px; font-weight: 600; }

/* Active state for tool-btn toggles (used by admin site-mode picker) */
.tool-btn.active { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

/* Theme panel — backdrop preview + range sliders */
.backdrop-preview { display: flex; align-items: center; gap: var(--sp-3); }
.backdrop-thumb { width: 96px; height: 60px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface-2) center / cover no-repeat; flex: none; }
.insp-field.range .range-val { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.range { width: 100%; accent-color: var(--accent); }

/* On-canvas text editing + auto-fit + overflow warning */
.enode.text .enode-text { outline: none; }
.enode.editing { outline: 2px solid var(--accent) !important; cursor: text; }
.enode.editing .enode-text { cursor: text; }
.enode-text[contenteditable] { pointer-events: auto; min-height: 1em; }
.enode.text-overflow { outline: 2px dashed #c0492b; }
.overflow-badge { position: absolute; top: -10px; right: -10px; width: 20px; height: 20px;
  background: #c0492b; color: #fff; border-radius: 50%; display: grid; place-items: center;
  box-shadow: var(--shadow-1); z-index: 12; }
.wrap-exclusion { pointer-events: none; }
textarea.input.area.tall { min-height: 150px; resize: vertical; line-height: 1.5; }
.insp-warn { color: #c0492b; font-size: 12.5px; line-height: 1.5; font-weight: 600;
  background: color-mix(in srgb, #c0492b 8%, transparent); padding: 8px 10px; border-radius: var(--r-sm); }

/* While editing on canvas, let long text scroll so it stays usable */
.enode.editing .enode-text { overflow-y: auto; }

/* SCMA additive fixes: SVGs inside buttons must not capture clicks/drags. */
svg.icon, svg.icon * { pointer-events: none; }

/* Asset picker empty state centered. */
.asset-grid .empty.soft {
  min-height: 180px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  grid-column: 1 / -1;
}
.asset-grid .empty.soft p { margin: 0; }

/* Creator export panel. */
.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.export-preset {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}
.export-preset b { font-family: var(--font-ui); font-size: 14px; }
.export-preset span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.export-preset.active {
  border-color: var(--work-accent, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--work-accent, var(--accent)) 16%, transparent);
  background: var(--surface);
}
@media (max-width: 760px) { .export-grid { grid-template-columns: 1fr; } }

/* SCMA audio module controls: preview and pick without affecting canvas/layers. */
.audio-card { gap: 8px; }
.asset-pick-main {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  width: 100%;
  text-align: left;
  display: grid;
  gap: 6px;
  cursor: pointer;
}
.audio-preview { margin-top: 6px; }
.audio-preview-status { color: var(--muted); font-size: 12px; }

/* SCMA audio/editor usability: inspector access without changing canvas behavior. */
.insp-mini-section { margin: 14px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.inspector-layers { margin-top: 8px; padding-left: 0; padding-right: 0; }
.inspector-layers > .insp-head { padding: 0 14px; }
.inspector-layer-list { max-height: 260px; overflow-y: auto; padding: 0 8px 8px; }
.inspector-layer { border: 1px solid transparent; }
.audio-time-input { font-variant-numeric: tabular-nums; }
.audio-scope-panel { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px; background: var(--paper); margin: 12px 0; }
.audio-scope-panel .insp-head { margin-top: 0; }
.audio-selected-name { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.audio-preview-status { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }

/* SCMA Audio Library Inspector */
.audio-library-inspector { display: grid; gap: 10px; }
.audio-library-inspector .audio-library-upload { width: 100%; font-size: 12px; }
.audio-library-list {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}
.audio-library-item {
  width: 100%;
  border: 1px solid rgba(255,255,255,.11);
  background: rgba(255,255,255,.045);
  color: inherit;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.audio-library-item:hover,
.audio-library-item.active {
  border-color: rgba(255,255,255,.28);
  background: rgba(255,255,255,.09);
}
.audio-library-item small {
  grid-column: 2;
  opacity: .68;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-library-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 12px;
}
.audio-library-selected {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 10px;
  background: rgba(0,0,0,.12);
}
.audio-library-selected audio { width: 100%; }
.audio-scope-toggle .btn.on,
.audio-library-selected .btn.on { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.12); }

/* SCMA image editing: artboard clips image pixels via image module clip-path;
   the selected transform box/handles remain visible outside the canvas like a design app. */
.enode.image.selected { overflow: visible; }
.enode.image .enode-fill { overflow: hidden; }
.enode.image.selected .handle { z-index: 1000; }
