/* ================================================================
   Leap Arcade Studio — layout additions to ide.css (studio.html loads both).
   Colours come from the ide.css variables only, so both themes work.
   ================================================================ */

/* Left: the project */
.panel-project { flex: 0 0 210px; min-width: 170px; background: var(--bg); }
.project-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0 12px; }
.proj-section { padding: 0 0 6px; }
.proj-title {
  padding: 6px 12px 4px;
  font: 700 10px var(--font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--fg-muted);
}
.proj-list { list-style: none; }
.proj-row {
  display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 12px; cursor: pointer;
  font: 12px var(--font-code); color: var(--fg);
}
.proj-row:hover { background: var(--bg-hover); }
.proj-row.active { background: var(--hover-sel); box-shadow: inset 2px 0 0 var(--amber-fg); }
.proj-row .proj-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-row .proj-meta { color: var(--fg-muted); font-size: 10px; }
.proj-row.has-error .proj-name { color: var(--red-fg); }
.proj-row .proj-act {
  border: none; background: none; color: var(--fg-dim); cursor: pointer; font-size: 11px; padding: 0 2px; visibility: hidden;
}
.proj-row:hover .proj-act { visibility: visible; }
.proj-row .proj-act:hover { color: var(--fg); }
.proj-note { padding: 2px 12px 0; font-size: 10px; line-height: 1.4; color: var(--fg-muted); }
.asset-group-head { display: flex; align-items: center; padding: 4px 8px 2px 12px; color: var(--fg-soft); font: 600 11px var(--font-ui); }
.asset-group-head span.asset-count { margin-left: 4px; color: var(--fg-muted); font-weight: 400; }
.asset-group-head .phbtn { margin-left: auto; }
.asset-empty { padding: 1px 12px 4px 20px; font-size: 10px; color: var(--fg-dim); }

/* Scenes group of the project panel: a name, a start marker, the plan text, the display select */
.proj-section[hidden] { display: none; }
.scene-row { display: block; cursor: default; padding: 4px 8px 6px 12px; }
.scene-row .scene-head { display: flex; align-items: center; gap: 4px; }
.scene-row .scene-start { color: var(--green-hi); font-size: 10px; width: 10px; }
.scene-row .scene-plan { margin: 2px 0 3px; font: 10px/1.4 var(--font-ui); color: var(--fg-muted); overflow-wrap: anywhere; }
.scene-row .scene-select {
  width: 100%; padding: 2px 4px; border-radius: 3px; border: 1px solid var(--border);
  background: var(--bg-panel); color: var(--fg); font: 11px var(--font-ui);
}

.scene-row .scene-ink { display: flex; align-items: center; gap: 4px; margin-top: 3px; font: 10px var(--font-ui); color: var(--fg-muted); }
.scene-row .scene-ink-select {
  flex: 1; padding: 2px 4px; border-radius: 3px; border: 1px solid var(--border);
  background: var(--bg-panel); color: var(--fg); font: 11px var(--font-ui);
}

/* Centre: the editor, with the problems list under it (E3: a drag handle on its top edge, a fold button with the count) */
.studio-root .panel-editor { min-width: 320px; }
.problems {
  flex: 0 0 auto; max-height: 70%; min-height: 0; display: flex; flex-direction: column;
  border-top: 1px solid var(--border); background: var(--bg-panel);
  font: 11px var(--font-code); position: relative;
}
.problems:not([style*="height"]) { max-height: 28%; }      /* the default share until it has been dragged */
.problems[hidden] { display: none; }
.problems-grip { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; z-index: 2; touch-action: none; }
.problems-grip:hover { background: var(--hover-sel); }
.problems.folded .problems-grip { cursor: default; pointer-events: none; }
.problems-head {
  flex: none; text-align: left; border: none; border-bottom: 1px solid var(--border); background: var(--bg-panel);
  color: var(--fg-muted); font: 700 10px var(--font-ui); letter-spacing: .05em; text-transform: uppercase; padding: 4px 12px; cursor: pointer;
}
.problems-head:hover { background: var(--bg-hover); color: var(--fg); }
.problems.folded .problems-head { border-bottom: none; }
.problems.folded .problems-list { display: none; }
.problems-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.problem {
  display: flex; gap: 8px; padding: 3px 12px; cursor: pointer; align-items: baseline;
}
.problem:hover { background: var(--bg-hover); }
.problem .p-sev { font-weight: 700; text-transform: uppercase; font-size: 9px; letter-spacing: .05em; }
.problem.error .p-sev { color: var(--red-fg); }
.problem.warning .p-sev { color: var(--amber-fg); }
.problem .p-where { color: var(--fg-muted); white-space: nowrap; }
.problem .p-msg { color: var(--fg); }
/* R4: the breakpoint gutter is the source debugger's (stage 6) */

/* Right: display, symbols, asset editors */
.panel-right { flex: 0 0 auto; min-width: 340px; background: var(--bg); }
.panel-right .tab-body { flex: 1; min-height: 0; overflow-y: auto; }
.panel-right .tab-body[hidden] { display: none; }
.display-body { display: flex; flex-direction: column; }
.display-body .emulator-body { flex: 0 0 auto; padding-bottom: 8px; overflow: visible; }   /* the tab scrolls, not the screen's own box (E2) */
#display-btns[hidden] { display: none; }
/* E2: the six tab names have the header to themselves and scroll sideways if the panel is narrower still */
.panel-right > .panel-header { padding: 0 6px; }
.panel-right .panel-tabs { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.panel-right .panel-tabs { gap: 0; }
.panel-right .panel-tabs::-webkit-scrollbar { display: none; }
.panel-right .panel-tab { padding: 0 3px; letter-spacing: .03em; white-space: nowrap; flex: none; }      /* (eight names since the Variables tab: tightened to keep them in one row at 1280 px) */
/* sticky: an enlarged screen makes the Display tab taller than the window and it scrolls; the size buttons must not scroll away with it */
.display-tools { display: flex; align-items: center; gap: 4px; padding: 6px 12px 6px; flex: none; position: sticky; top: 0; z-index: 3; background: var(--bg); }
.display-tools-label { margin-right: auto; font: 700 10px var(--font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--fg-muted); }

/* R2: run controls; R1: the budget meter; N3: the first-run line. Colours from the ide.css variables. */
.run-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 0 12px 6px; }
.run-speed { display: inline-flex; gap: 2px; }
.speed-btn.active { background: var(--hover-sel); color: var(--fg); }
.run-meter { margin: 0 12px 8px; padding: 4px 8px; border-radius: 4px; background: var(--bg-surface); border: 1px solid var(--border);
  font: 11px/1.4 var(--font-code); color: var(--fg); overflow-wrap: anywhere; }
.run-meter.over { border-color: var(--amber-fg); }
.run-meter.behind { color: var(--amber-fg); }
.run-meter[hidden], .first-run[hidden] { display: none; }
.first-run { margin: 0 12px 8px; font: 12px var(--font-ui); color: var(--fg-muted); text-align: center; }
.asset-tool { padding: 0; }
.asset-tool .tool-note { padding: 12px; }

/* Size and budget */
.sizes { padding: 8px 14px 14px; border-top: 1px solid var(--border); font: 11px var(--font-code); }
.sizes-title { font: 700 10px var(--font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 6px; }
.size-bar { height: 8px; border-radius: 4px; background: var(--bg-surface); border: 1px solid var(--border); overflow: hidden; }
.size-fill { height: 100%; width: 0; background: var(--green-hi); transition: width .2s; }
.size-fill.warn { background: var(--amber-fg); }
.size-fill.over { background: var(--red-fg); }
.size-total { margin: 4px 0 6px; color: var(--fg); }
.bank-fill { background: var(--blue-fg); }
.bank-fill.warn { background: var(--amber-fg); }
.bank-fill.over { background: var(--red-fg); }
#bank-block { margin-top: 8px; }
.bank-list { margin: 0 0 6px; color: var(--fg-muted); }
.bank-row { padding: 1px 0; overflow-wrap: anywhere; }
.bank-row b { font-weight: 600; color: var(--fg); }
.size-table { width: 100%; border-collapse: collapse; }
.size-table td { padding: 1px 0; color: var(--fg-muted); }
.size-table td:last-child { text-align: right; color: var(--fg); font-variant-numeric: tabular-nums; }

/* Status bar: the first error is a link */
.statusbar #sb-state.has-error { cursor: pointer; text-decoration: underline; }

@media (max-width: 1100px) {
  .panel-project { flex-basis: 170px; }
}
@media (max-width: 700px) {
  .panel-project, .panel-right { flex: none; min-width: 0; }
  .studio-root .panel-editor { height: 45vh; }
}

/* Model previews: a small turning wireframe on each model row (studio.js paintPreviews); the line colour comes from --blue-fg */
.proj-row .model-preview { width: 28px; height: 28px; flex: none; margin: -2px 4px -2px 0; }
.proj-row[data-asset^="models/"] .proj-meta { white-space: nowrap; }

/* Asset rows (E1): the name takes the room, the details sit on a second line (and in the row's tooltip); the buttons float over the right end on hover */
.proj-row.asset-row { position: relative; }
.proj-row.asset-row .proj-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.proj-row.asset-row .proj-name { flex: none; }
.proj-row.asset-row .proj-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-row.asset-row .proj-acts { display: none; position: absolute; right: 4px; top: 2px; gap: 2px; padding: 0 2px; border-radius: 3px; background: var(--bg-hover); }
.proj-row.asset-row:hover .proj-acts, .proj-row.asset-row:focus-within .proj-acts { display: flex; }
.proj-row.asset-row .proj-act { visibility: visible; }

/* New project dialog (N1): a grid of starter cards */
.new-dialog { max-width: min(860px, 94vw); width: 94vw; padding: 0; border: 1px solid var(--border-hi); border-radius: 8px; background: var(--bg-panel); color: var(--fg); }
.new-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.new-dialog-form { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; max-height: 88vh; overflow: auto; }
.new-dialog-head { display: flex; align-items: center; justify-content: space-between; }
.new-dialog-head h2 { margin: 0; font: 600 15px var(--font-ui); }
.new-dialog-note { margin: 0; font: 12px var(--font-ui); color: var(--fg-muted); }
.new-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.new-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: left; font: 12px var(--font-ui); color: var(--fg); background: var(--bg-surface); border: 1px solid var(--border-hi); border-radius: 6px; cursor: pointer; }
.new-card:hover, .new-card:focus-visible { background: var(--hover-sel); border-color: var(--amber-fg); outline: none; }
.new-card img, .new-card .new-pic { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; image-rendering: pixelated; background: #000; border-radius: 3px; }
.new-card .new-pic { display: flex; align-items: center; justify-content: center; color: var(--fg-muted); font-size: 11px; }
.new-card-title { font-weight: 600; font-size: 13px; }
.new-card-about { color: var(--fg-muted); white-space: normal; }
.new-card-rt { align-self: flex-start; font-size: 10px; padding: 0 6px; border: 1px solid var(--border-hi); border-radius: 8px; color: var(--fg-muted); }
