/* Round 4: the studio replica at the bottom of the page (r4/studio.js). Drawn like the real build studio:
   neutral dark greys around a pale stage, at a fixed design size of 1440 × 860, scaled to fit. */
.studio-frame {
  --k: 1;
  --c-canvas: #171717; --c-surface: #242424; --c-panel: #1d1d1d; --c-ink: #f1f1f1; --c-muted: #aaaaaa;
  --c-secondary: #bbbbbb; --c-subtle: #666666; --c-line: #2c2c2c; --c-stage: #eef0f3; --c-agent: #4d8dff;
  position: relative; height: calc(860px * var(--k));
}
.studio-frame.compact { height: auto; }
.studio { position: absolute; top: 0; left: 0; width: 1440px; height: 860px; transform: scale(var(--k)); transform-origin: 0 0; background: var(--c-canvas); color: var(--c-ink); font-family: 'Geist', system-ui, sans-serif; font-size: 14px; line-height: 1.35; letter-spacing: 0; border-radius: 16px; overflow: hidden; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08), 0 50px 110px -40px rgb(14 22 34 / 0.55); display: grid; grid-template-rows: 48px 46px 1fr 50px; }
.studio svg { width: 16px; height: 16px; flex: none; }
.studio button { cursor: pointer; font: inherit; }
.studio :focus-visible { outline: 2px solid var(--c-agent); outline-offset: 2px; }
.s-head { display: flex; justify-content: space-between; align-items: center; padding: 0 22px; }
.s-left, .s-right { display: flex; align-items: center; gap: 20px; }
.s-left img { width: 64px; margin-right: 12px; }
.s-tab { display: inline-flex; align-items: center; gap: 6px; color: var(--c-muted); }
.s-tab.on { color: var(--c-ink); text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1.2px; }
.s-right span { color: var(--c-secondary); }
.s-right .s-export { background: var(--c-ink); color: var(--c-canvas); padding: 5px 14px; border-radius: 8px; font-weight: 600; }
.s-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 22px; }
.s-toggle { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgb(255 255 255 / 0.04); color: var(--c-secondary); }
.s-toggle:last-child { justify-self: end; }
.s-title { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.s-title button { background: none; border: 0; color: var(--c-muted); padding: 6px 11px; border-radius: 8px; transition: background 0.15s, color 0.15s; }
.s-title button:hover { color: var(--c-ink); background: rgb(255 255 255 / 0.05); }
.s-title button[aria-pressed='true'] { color: var(--c-ink); background: var(--c-surface); }
#s-meta { color: var(--c-muted); font-size: 13px; margin-left: 14px; font-variant-numeric: tabular-nums; min-width: 15em; }
.s-main { display: grid; grid-template-columns: 252px 1fr; padding: 4px 22px 10px; min-height: 0; }
.s-details { padding: 6px 18px 0 0; min-height: 0; overflow: hidden; }
.s-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--c-panel); border-radius: 9px; padding: 3px; }
.s-tabs button { background: none; border: 0; color: var(--c-muted); padding: 6px; border-radius: 7px; font-size: 14px; }
.s-tabs button[aria-selected='true'] { background: var(--c-canvas); color: var(--c-ink); }
.s-label { color: var(--c-secondary); margin: 22px 0 8px; font-size: 13px; }
#s-parts, #s-mats { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
#s-parts li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 4px; padding: 5px 2px; border-radius: 6px; color: var(--c-ink); opacity: 0.35; transition: opacity 0.4s; }
#s-parts li.in { opacity: 1; }
#s-parts li button { background: none; border: 0; color: var(--c-muted); padding: 2px; display: grid; place-items: center; }
#s-parts li button:hover:not(:disabled) { color: var(--c-ink); }
#s-parts li button:disabled { opacity: 0.4; cursor: default; }
#s-parts li.off span { color: var(--c-subtle); text-decoration: line-through; }
#s-parts li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#s-parts li small { color: var(--c-subtle); font-variant-numeric: tabular-nums; }
#s-mats li { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--c-line); font-size: 13px; }
#s-mats li small { color: var(--c-muted); font-variant-numeric: tabular-nums; text-align: right; }
.s-stagebox { display: grid; grid-template-columns: 1fr 318px; border-radius: 12px; overflow: hidden; min-height: 0; }
.s-stage { position: relative; background: var(--c-stage); min-height: 0; }
.s-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; display: block; }
.s-stage canvas.is-dragging { cursor: grabbing; }
.s-stage.marking canvas { cursor: crosshair; }
.s-gizmo { position: absolute; top: 14px; right: 16px; width: 60px; height: 60px; pointer-events: none; }
.s-gizmo svg { width: 60px; height: 60px; }
.s-loading { position: absolute; left: 50%; top: 50%; width: 160px; height: 3px; margin-left: -80px; background: rgb(0 0 0 / 0.08); border-radius: 2px; overflow: hidden; transition: opacity 0.4s; }
.s-loading i { position: absolute; inset: 0; background: #171717; transform-origin: left; transform: scaleX(var(--p, 0)); }
.s-loading.done { opacity: 0; }
.s-hint { position: absolute; left: 16px; top: 14px; margin: 0; color: #6b7078; font-size: 13px; opacity: 0; transition: opacity 0.6s; pointer-events: none; }
.s-hint.on { opacity: 1; }
.s-dock { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; background: var(--c-canvas); border-radius: 12px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
.s-dock button { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: var(--c-secondary); padding: 7px 12px; border-radius: 8px; font-size: 14px; transition: background 0.15s, color 0.15s; }
.s-dock button:hover { background: rgb(255 255 255 / 0.07); color: var(--c-ink); }
.s-dock button[aria-pressed='true'] { background: var(--c-ink); color: var(--c-canvas); }
.s-pill { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); margin: 0; background: var(--c-canvas); color: var(--c-ink); font-size: 13px; padding: 7px 14px; border-radius: 999px; white-space: nowrap; }
.s-slicer { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); display: grid; justify-items: center; gap: 10px; background: var(--c-canvas); padding: 10px 10px 12px; border-radius: 12px; color: var(--c-secondary); font-size: 12px; }
.s-slicer button { background: var(--c-surface); border: 0; color: var(--c-ink); border-radius: 7px; width: 30px; height: 26px; font: 500 12px 'Geist Mono', ui-monospace, monospace; }
.s-slicer input { writing-mode: vertical-lr; direction: rtl; height: 240px; width: 22px; accent-color: #f1f1f1; }
.s-hud { position: absolute; inset: 0; pointer-events: none; }
.s-hud .cross { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px; }
.s-hud .cross::before, .s-hud .cross::after { content: ''; position: absolute; background: #fff; mix-blend-mode: difference; }
.s-hud .cross::before { left: 7px; width: 2px; height: 16px; }
.s-hud .cross::after { top: 7px; height: 2px; width: 16px; }
.s-hud p { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); margin: 0; background: var(--c-canvas); color: var(--c-secondary); padding: 6px 8px 6px 14px; border-radius: 10px; font-size: 13px; pointer-events: auto; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.s-hud button { margin-left: 8px; background: var(--c-surface); border: 0; color: var(--c-ink); border-radius: 7px; padding: 4px 10px; font-size: 13px; }
.studio kbd { font: 500 11px 'Geist', sans-serif; padding: 1px 5px; border-radius: 5px; background: var(--c-surface); color: var(--c-ink); border-bottom: 2px solid #000; box-shadow: none; min-width: 0; margin: 0 1px; }

.s-agent { background: var(--c-panel); display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.s-agent-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px; }
.s-conn { display: inline-flex; align-items: center; gap: 6px; color: var(--c-muted); font-size: 13px; }
.s-conn i { width: 7px; height: 7px; border-radius: 50%; background: #3fb950; box-shadow: 0 0 0 3px rgb(63 185 80 / 0.18); }
.s-feed { overflow: auto; padding: 4px 14px 12px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: none; }
.s-feed::-webkit-scrollbar { display: none; }
.msg-user { align-self: flex-end; max-width: 88%; background: #2a2a2a; padding: 9px 12px; border-radius: 14px 14px 4px 14px; animation: s-pop 0.35s ease-out; }
.msg-user img { display: block; width: 16px; height: 32px; image-rendering: pixelated; border-radius: 2px; margin-bottom: 6px; }
.msg-user small { display: block; color: var(--c-muted); font-size: 11px; margin-top: 4px; }
.msg-agent { color: var(--c-secondary); animation: s-pop 0.35s ease-out; }
.msg-note { color: var(--c-muted); font-size: 13px; border-left: 2px solid var(--c-agent); padding-left: 10px; animation: s-pop 0.35s ease-out; }
.msg-note a { color: var(--c-ink); }
@keyframes s-pop { from { opacity: 0; transform: translateY(6px); } }
.studio .steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.studio .steps li { display: grid; grid-template-columns: 16px 1fr; gap: 9px; align-items: start; padding: 4px 0; color: var(--c-secondary); font-size: 13px; animation: s-pop 0.3s ease-out; }
.studio .steps li code { font: 12.5px 'Geist Mono', ui-monospace, monospace; background: none; padding: 0; color: inherit; }
.studio .steps li::before { content: ''; margin-top: 3px; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--c-agent); border-top-color: transparent; animation: s-spin 0.8s linear infinite; }
.studio .steps li.done { color: var(--c-muted); }
.studio .steps li.done::before { border: 0; background: var(--c-agent); animation: none; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.6 3.6' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.6 3.6' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
@keyframes s-spin { to { transform: rotate(360deg); } }
.s-composer { margin: 0 12px 12px; background: var(--c-canvas); border-radius: 20px; padding: 12px 12px 8px 16px; display: grid; gap: 4px; }
.s-chip { justify-self: start; display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px; border-radius: 999px; background: rgb(77 141 255 / 0.18); color: #b9d3ff; font-size: 12px; }
.s-chip[hidden] { display: none; }
.s-chip i { width: 8px; height: 8px; border-radius: 2px; background: var(--c-agent); }
.s-composer textarea { background: none; border: 0; resize: none; color: var(--c-ink); font: inherit; font-size: 14px; outline: none; min-height: 40px; }
.s-composer textarea::placeholder { color: var(--c-muted); }
.s-row { display: flex; justify-content: space-between; align-items: center; }
.s-plus { color: var(--c-secondary); font-size: 20px; padding-left: 2px; }
.s-send { width: 30px; height: 30px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--c-surface); color: var(--c-muted); }
.s-composer.has-text .s-send { background: var(--c-ink); color: var(--c-canvas); }

.s-history { display: flex; align-items: center; gap: 12px; padding: 0 22px; border-top: 1px solid #262626; min-width: 0; }
.s-undo { color: var(--c-muted); display: grid; }
.s-replay { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: var(--c-secondary); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.s-replay svg { width: 11px; height: 11px; }
.s-replay:hover { color: var(--c-ink); background: rgb(255 255 255 / 0.06); }
.s-count { color: var(--c-muted); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 18px; }
.s-chips { flex: 1; display: flex; gap: 4px; overflow: hidden; mask-image: linear-gradient(90deg, #000 85%, transparent); }
.s-chips button { flex: none; display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--c-secondary); font-size: 13px; padding: 8px 8px 6px; white-space: nowrap; animation: s-pop 0.3s ease-out; }
.s-chips button svg { width: 13px; height: 13px; color: var(--c-muted); }
.s-chips button:hover { color: var(--c-ink); }
.s-chips button[aria-current='true'] { color: var(--c-ink); border-bottom-color: var(--c-ink); }
.s-chips button.ahead { color: var(--c-subtle); }
.s-pos { color: var(--c-muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* phones: the stage, then the agent column */
.studio.compact { position: relative; width: auto; height: auto; transform: none; display: block; border-radius: 14px; }
.studio.compact .s-head .s-right, .studio.compact .s-details, .studio.compact .s-toggle, .studio.compact .s-history .s-chips, .studio.compact .s-gizmo, .studio.compact #s-meta { display: none; }
.studio.compact .s-head { height: 44px; padding: 0 14px; }
.studio.compact .s-bar { display: flex; justify-content: center; padding: 0 8px 6px; }
.studio.compact .s-title { flex-wrap: wrap; justify-content: center; }
.studio.compact .s-title button { padding: 5px 9px; font-size: 13px; }
.studio.compact .s-main { display: block; padding: 4px 8px 8px; }
.studio.compact .s-stagebox { grid-template-columns: 1fr; }
.studio.compact .s-stage { height: 104vw; max-height: 64vh; }
.studio.compact .s-agent { height: 280px; }
.studio.compact .s-dock button { padding: 7px 9px; font-size: 13px; gap: 5px; }
.studio.compact .s-slicer { right: 10px; }
.studio.compact .s-slicer input { height: 180px; }
.studio.compact .s-history { height: 44px; justify-content: space-between; padding: 0 14px; }
@media (prefers-reduced-motion: reduce) {
  .msg-user, .msg-agent, .msg-note, .studio .steps li, .s-chips button { animation: none; }
  .studio .steps li::before { animation: none; }
}
