/* Conversation-first workspaces. */
.content > :is(#tab-system, #tab-moyue) { max-width: none; }
.content > #tab-system { padding-bottom: 88px; }
.content:has(> :is(#tab-system, #tab-moyue).active) > .editor-location { max-width: none; }
.content :is(.system-heading, .moyue-heading) { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; padding: 0 0 10px; }
.content :is(.system-heading, .moyue-heading) h2 { margin: 0; font-size: 21px; }
.content :is(.system-heading, .moyue-heading) :is(.page-eyebrow, .system-heading-badge) { display: none; }
.content .system-heading-actions { display: none; }
.content :is(.system-heading, .moyue-heading) > .creation-rail-group { margin: 0 0 0 auto; border: 0; padding: 0; background: transparent; }
.content :is(.system-heading, .moyue-heading) > .creation-rail-group[open] { flex-basis: 100%; }
.system-columns, .moyue-workspace.moyue-columns {
  display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 16px; align-items: start;
}

.creation-navigation, .creation-stage, .moyue-columns > * { min-width: 0; }
.creation-navigation { position: sticky; top: 0; max-height: calc(var(--editor-viewport-height, 100dvh) - 140px); overflow-y: auto; scrollbar-width: thin; }
.creation-navigation > h3 { margin: 0 0 10px; color: var(--muted); font-size: 12px !important; letter-spacing: .04em; }
.creation-navigation > .steps-nav { display: flex; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 6px; padding: 0; margin: 0; background: none; border: none; counter-reset: wf-main-step; }
.creation-navigation .wf-dot { display: flex; align-items: flex-start; gap: 8px; white-space: normal; padding: 8px 10px; font-size: 12px; cursor: pointer; text-align: left; }
.creation-navigation .wf-dot[hidden] { display: none; }
.creation-navigation .wf-dot:not([hidden]) { counter-increment: wf-main-step; }
.creation-navigation .wf-dot:not([hidden])::before {
  content: counter(wf-main-step); display: inline-grid; place-items: center; flex: 0 0 20px; height: 20px; margin-top: 1px;
  border-radius: 6px; background: color-mix(in srgb, var(--border) 65%, transparent); color: var(--muted);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.creation-navigation .wf-dot.active::before { background: rgba(255, 255, 255, .22); color: #fff; }
.creation-navigation .wf-dot.done:not(.active)::before { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.creation-navigation .wf-dot[data-optional="true"]:not(.active):not(.done) { border-style: dashed; opacity: .9; }
.creation-navigation .wf-dot-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.creation-navigation .wf-dot-title { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.creation-navigation .wf-dot-meta { font-size: 10.5px; line-height: 1.3; color: var(--muted); font-weight: 400; }
.creation-navigation .wf-dot.active .wf-dot-meta { color: rgba(255, 255, 255, .85); }
.creation-navigation .wf-dot.done:not(.active) .wf-dot-meta { color: var(--ok); }
.creation-navigation .wf-restart {
  margin: 14px 0 0; padding-top: 10px; font-size: 11px; white-space: normal; color: var(--muted);
  border-color: color-mix(in srgb, var(--border) 75%, transparent);
}
.creation-navigation .wf-restart:hover, .creation-navigation .wf-restart:focus-visible {
  color: var(--err); border-color: color-mix(in srgb, var(--err) 55%, var(--border));
  background: color-mix(in srgb, var(--err) 8%, var(--panel));
}
.creation-rail-group { margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--editor-surface); padding: 12px; min-width: 0; }
.creation-rail-group > summary { color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.6; }
.creation-rail-group[open] > summary { color: var(--text); margin-bottom: 12px; }
.creation-rail-group > .card { padding: 0; border: 0; margin: 0; background: transparent; }
#wfWorldBuildGrid { grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
#wvPreviewDock[hidden] { display: none; }
@media (min-width: 1200px) {
  #wfWorldBuildGrid:has(> #wvPreviewDock:not([hidden])) {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  }
  #wvPreviewDock > .card { position: sticky; top: 10px; margin: 0; }
  #wvPreviewDock #wvPreview { max-height: calc(100dvh - 280px); overflow-y: auto; }
}
#wfstep-0:has(#wvMultiDock:not([hidden]) #wvMultiMode:checked) #wfWorldBuildGrid { display: none; }
#wfStandardWorldComposer { display: flex; flex-direction: column; min-height: min(410px, calc(100dvh - 370px)); padding: 14px 16px; margin: 0; }
#wfStandardWorldComposer[hidden] { display: none; }
#wfStandardWorldComposer > .wf-panel-head { padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
#wfStandardWorldComposer > .creation-rail-group { border: 0; padding: 0; background: transparent; margin: 0 0 6px; }
#wfStandardWorldComposer .wv-concise-toggle { padding: 7px 10px; margin: 0 0 8px; }
#wfStandardWorldComposer #wvChat { flex: 1; min-height: 96px; height: clamp(96px, 14dvh, 190px); max-height: 48dvh; border: 0; background: transparent; margin: 0 0 10px; }
#wfStandardWorldComposer .chat-input-row { margin-top: auto; }
.creation-stage .wv-input-highlight { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px; border: 1px solid var(--border); box-shadow: none; background: var(--input-bg); border-radius: 10px; }
.creation-stage .wv-input-highlight::before { grid-column: 1 / -1; font-size: 11px; }
.creation-stage .wv-input-highlight textarea { min-width: 0; width: 100%; }
.creation-stage .wv-input-highlight > .btn { align-self: end; }
#wfStandardWorldComposer > .creation-rail-group:last-child { margin: 12px 0 0; }
.creation-stage > .wf-step > .btn-row.end { margin-top: 12px; }
.creation-stage .creation-start-guide { gap: 8px; margin-block: 12px; }
.creation-stage .creation-start-guide small { font-size: 11px; }
.creation-stage #wfstep-1 > .hint { margin-block: 8px; font-size: 12px; }
.moyue-workspace.moyue-columns { grid-template-columns: 190px minmax(0, 1fr) 280px; }
.moyue-columns .moyue-todo-shell { padding: 12px; border-radius: 10px; box-shadow: none; }
.moyue-columns :is(.moyue-todo-head, .moyue-step-head, .moyue-mode-guide-head) { flex-direction: column; align-items: stretch; gap: 8px; }
.moyue-columns .moyue-todo-actions { gap: 5px; }
.moyue-columns .moyue-todo-actions .btn { font-size: 11px; padding: 5px 7px; }
.moyue-columns .moyue-todo { grid-template-columns: minmax(0, 1fr); }
.moyue-columns .moyue-todo-group { min-width: 0; }
.moyue-columns :is(.moyue-step-grid, .moyue-mode-options, .moyue-character-workspace) { grid-template-columns: minmax(0, 1fr); }
.moyue-columns :is(.moyue-step, .moyue-mode-guide) { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
.moyue-columns :is(.moyue-conversation-card, .moyue-review-card) { border-radius: 12px; padding: 16px; box-shadow: none; background: var(--editor-surface); }
.moyue-columns .moyue-conversation-card { min-height: min(730px, calc(100dvh - 160px)); display: flex; flex-direction: column; }
.moyue-columns .moyue-chat { flex: 1; min-height: 260px; max-height: 50dvh; }
.moyue-columns .moyue-active-head { padding-bottom: 12px; }
.moyue-columns .moyue-active-head h3 { font-size: 16px; }
.moyue-columns .moyue-composer { margin-top: auto; }
.moyue-columns .moyue-composer > .creation-rail-group { border: 0; padding: 0; margin: 10px 0 0; background: none; }
.moyue-columns .moyue-composer-foot { flex-direction: column; align-items: stretch; gap: 8px; }
.moyue-columns .moyue-composer-foot > div { justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.moyue-columns .moyue-composer-foot .creation-rail-group { margin: 0 auto 0 0; border: 0; padding: 0; background: none; }
.moyue-columns .moyue-composer-foot .creation-rail-group[open] { flex-basis: 100%; }
.moyue-columns .moyue-review-card { position: sticky; top: 0; max-height: calc(100dvh - 140px); overflow-y: auto; }
.moyue-columns .moyue-live-artifact { min-height: 140px; max-height: 38dvh; }
.moyue-columns :is(.moyue-write-receipt, .moyue-artifact-library) { padding: 12px; box-shadow: none; border-radius: 10px; }
.moyue-columns .moyue-review-card > .creation-rail-group { margin-top: 12px; }
/* The review is a task dialog, not a page-sized card. Actions stay reachable. */
.moyue-approval-dialog { padding: 0; width: min(820px, calc(100vw - 24px)); max-height: calc(var(--editor-viewport-height, 100dvh) - 24px); overflow: hidden; }
.moyue-approval-shell { display: flex; flex-direction: column; max-height: calc(var(--editor-viewport-height, 100dvh) - 28px); min-height: 0; }
.moyue-approval-shell > .btn-row { flex: none; margin: 0; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.moyue-approval-shell > .moyue-approval-body { min-height: 0; padding: 18px; overflow-y: auto; overscroll-behavior: contain; }
.moyue-approval-footer { flex: none; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--panel); }
.moyue-approval-footer .status-line { margin-top: 0; min-height: 0; overflow-wrap: anywhere; font-size: 12px; }
.moyue-approval-footer .btn-row { margin-top: 8px; }
.moyue-approval-dialog[aria-busy="true"] .status-line.running { color: var(--accent2); }
@media (max-width: 1279px) {
  .system-columns { grid-template-columns: minmax(0, 1fr); }
  .moyue-workspace.moyue-columns { grid-template-columns: minmax(0, 1fr) 240px; }
  .creation-navigation { grid-column: 1 / -1; position: static; max-height: none; }
  .creation-navigation > h3 { display: none; }
  .creation-navigation > .steps-nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .creation-navigation .wf-dot { flex: 0 0 auto; align-items: center; white-space: nowrap; padding: 7px 10px; }
  .creation-navigation .wf-dot-meta { display: none; }
  .creation-navigation .wf-restart { flex: none; margin: 0; padding-top: 6px; }
  .moyue-columns .creation-navigation { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .moyue-columns .moyue-todo-shell { max-height: 170px; overflow-y: auto; margin: 0; }
  .moyue-columns .moyue-todo { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .system-columns, .moyue-workspace.moyue-columns { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .moyue-columns .creation-navigation { display: block; }
  .moyue-columns .creation-navigation > .creation-rail-group { margin-top: 8px; }
  .moyue-columns .moyue-todo-shell { max-height: 150px; }
  .content :is(.system-heading, .moyue-heading) { padding: 0 0 10px; }
  #wfStandardWorldComposer, .moyue-columns .moyue-conversation-card { min-height: 520px; }
}
@media (max-width: 600px) {
  .content:has(> :is(#tab-system, #tab-moyue).active) .editor-location-title { display: none; }
  .moyue-columns .moyue-todo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .moyue-columns :is(.moyue-conversation-card, .moyue-review-card) { padding: 12px; }
  .moyue-approval-shell > .moyue-approval-body { padding: 12px; }
  .moyue-approval-footer { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .content .moyue-approval-footer .btn { min-height: 44px; }
  .moyue-approval-footer .status-line { max-height: 4.5em; overflow: auto; }
  .creation-stage .wv-input-highlight { grid-template-columns: minmax(0, 1fr); }
  .creation-stage .wv-input-highlight::before { display: none; }
  #wfStandardWorldComposer #wvChat { min-height: 180px; }
  body:has(:is(#tab-system, #tab-moyue).active) .pen-pet:not([style*="left"]) { right: 8px; bottom: 12px; }
  body:has(:is(#tab-system, #tab-moyue).active) .pen-pet-orb { width: 48px; height: 48px; }
  body:has(:is(#tab-system, #tab-moyue).active) .pen-pet-orb img { width: 58px; height: 58px; }
}

/* Moyue keeps navigation and primary actions in the main reading path. */
.content > #tab-moyue { max-width: 1560px; margin-inline: auto; }
.moyue-workspace.moyue-columns { grid-template-columns: minmax(0, 1fr) minmax(360px, .62fr); gap: 18px; }
.moyue-columns > .moyue-navigation { grid-column: 1 / -1; display: block; position: static; max-height: none; overflow: visible; }
.moyue-navigation .moyue-todo-shell { padding: 14px 16px; margin: 0; max-height: none; overflow: visible; }
.moyue-navigation .moyue-todo-head { flex-direction: row; align-items: center; flex-wrap: wrap; }
.moyue-navigation > .creation-rail-group { margin: 8px 0 0; padding: 8px 12px; }
.moyue-navigation .moyue-auto-summary { display: none; }
.moyue-navigation .moyue-todo { display: flex; flex-flow: row wrap; gap: 8px; }
.moyue-navigation .moyue-todo-group { display: contents; }
.moyue-columns .moyue-navigation .moyue-todo-group-toggle { flex: 0 0 auto; width: auto; padding: 9px 12px; border: 1px solid transparent; border-radius: 8px; background: var(--input-bg); }
.moyue-navigation .moyue-todo-group-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.moyue-navigation .moyue-todo-items { order: 2; flex: 0 0 100%; padding-top: 10px; gap: 8px; }
.moyue-navigation .moyue-todo-item { padding: 8px 12px; }
.moyue-task-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; padding: 14px 16px; }
.moyue-task-toolbar > label { display: grid; gap: 6px; flex: 1 1 220px; color: var(--muted); font-size: 12px; }
.moyue-task-toolbar select { width: 100%; min-width: 0; }
.moyue-task-toolbar .btn { flex: 0 0 auto; min-height: 38px; }
.moyue-conversation-card > .moyue-character-workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(110px, .7fr) auto; }
.moyue-conversation-card > .moyue-character-workspace[hidden], .moyue-conversation-card > .moyue-written-artifacts[hidden] { display: none; }
.moyue-columns .moyue-chat { min-height: 220px; background: transparent; }
.moyue-columns .moyue-review-card { padding: 0; border: 0; background: transparent; max-height: calc(100dvh - 125px); }
.moyue-columns .moyue-artifact-library { margin-top: 0; padding: 0; }
.moyue-columns .moyue-composer-foot > div { justify-content: flex-start; }
.moyue-columns .moyue-composer-foot #moyueSend { margin-left: auto; }
.moyue-message-retry { display: block; margin-top: 12px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.moyue-message-retry:hover { color: var(--text); border-color: var(--accent); }
.moyue-artifact-view-switch { display: flex; gap: 6px; }
.moyue-artifact-view-switch [aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.moyue-artifact-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.moyue-artifact-fields:empty { display: none; }
.moyue-artifact-fields label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 12px; }
.moyue-artifact-fields :is(input:not([type="checkbox"]), textarea, select) { width: 100%; min-width: 0; }
.moyue-artifact-parameters { grid-column: 1 / -1; }
.moyue-artifact-parameters[open] { display: grid; gap: 10px; }
.moyue-artifact-editor-label { color: var(--muted); font-size: 12px; }
.moyue-columns #moyueArtifactEditor { min-height: 360px; padding: 14px; font: 14px/1.85 var(--font-family, system-ui, sans-serif); border-radius: 10px; white-space: pre-wrap; }
.moyue-columns #moyueArtifactEditor[hidden], .moyue-artifact-editor-label[hidden], .moyue-artifact-view-switch .btn[hidden] { display: none; }
.moyue-artifact-actions { position: sticky; bottom: 0; padding-top: 8px; background: var(--panel); }
.moyue-navigation .moyue-todo-group-toggle, .moyue-message-retry { transition: border-color .16s ease, background-color .16s ease, color .16s ease; }
.moyue-auto-toggle { position: relative; }
.moyue-auto-toggle input { width: 1px; height: 1px; left: 0; top: 0; margin: 0; clip-path: inset(50%); }
@media (max-width: 1100px) {
  .moyue-workspace.moyue-columns { grid-template-columns: minmax(0, 1fr); }
  .moyue-columns .moyue-review-card { position: static; max-height: none; }
  .moyue-columns .moyue-conversation-card { min-height: 0; }
}
@media (max-width: 600px) {
  .moyue-navigation .moyue-todo-shell { padding: 12px; }
  .moyue-navigation .moyue-todo-group-toggle { padding: 7px 9px; font-size: 12px; }
  .moyue-task-toolbar { padding: 12px 0; }
  .moyue-task-toolbar > label { flex-basis: 100%; }
  .moyue-task-toolbar .btn { flex: 1 1 140px; }
  .moyue-conversation-card > .moyue-character-workspace { grid-template-columns: minmax(0, 1fr); }
  .moyue-columns .moyue-composer-foot .btn { flex: 1 1 140px; }
  .moyue-columns .moyue-composer-foot #moyueClearDrafts { flex-basis: auto; order: 0; }
  .moyue-columns .moyue-composer-foot #moyueSend { margin-left: 0; flex-basis: 100%; }
  .moyue-columns #moyueArtifactEditor { min-height: 280px; }
}
@media (prefers-reduced-motion: reduce) { .moyue-navigation .moyue-todo-group-toggle, .moyue-message-retry { transition: none; } }
/* Project tools open inline and leave the running conversation mounted. */
.creation-tool-row, .script-composer-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.system-project-tools, .script-project-tools {
  margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--editor-line);
  border-radius: var(--radius-s); background: var(--editor-surface);
}
[data-creation-toolset] > [hidden] { display: none; }
[data-creation-toolset] > div[id]:not([hidden]) { margin-top: 12px; }
[data-creation-toolset] > div[id] > .card { margin: 0; }
.creation-tool-row [aria-expanded="true"] {
  border-color: var(--accent); color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}
.creation-tool-row [data-creation-tool]::after {
  content: ''; width: 5px; height: 5px; flex: none;
  border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(45deg);
}
.creation-tool-row [aria-expanded="true"]::after { transform: rotate(225deg); }
.system-project-tools .workflow-mode-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 auto 0 0; }
.system-project-tools .workflow-mode-card,
.world-creation-tools .workflow-mode-card { padding: 5px 8px; gap: 6px; border-radius: 8px; }
.system-project-tools .workflow-world-mode-choice,
.world-creation-tools .workflow-world-mode-choice { display: inline-flex; flex-wrap: wrap; padding: 2px; gap: 2px; margin: 0; }
.system-project-tools .workflow-world-mode-choice > label,
.world-creation-tools .workflow-world-mode-choice > label { margin: 0; padding: 5px 9px; gap: 5px; border-radius: 6px; }
.system-project-tools .workflow-mode-card small,
.world-creation-tools .workflow-mode-card small { display: none; }
.wf-global-summary {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg);
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.wf-global-summary i { opacity: .45; font-style: normal; }
.wf-tool-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 999px; background: color-mix(in srgb, var(--accent2) 18%, var(--panel)); color: var(--accent2);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.wf-tool-badge[hidden] { display: none; }
#wvPreviewStateBadge[data-state="saved"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
#wvPreviewStateBadge[data-state="draft"] { color: var(--accent2); border-color: color-mix(in srgb, var(--accent2) 45%, var(--border)); }
.world-creation-tools { margin-bottom: 10px; }
.world-creation-tools > .creation-tool-row { gap: 6px; }
.world-creation-tools > .creation-tool-row > .btn.small { padding-inline: 9px; font-size: 12px; }
#wvSave { margin-inline-start: auto; padding-inline: 12px; }
.world-result-feedback .status-line:empty, .script-feedback .status-line:empty,
.script-conversation .status-line:empty { display: none; }
#tab-script > .script-creator-heading { flex-direction: row; align-items: baseline; justify-content: flex-start; padding: 0 0 10px; }
#tab-script > .script-creator-heading h2 { margin: 0; }
.script-project-tools > .creation-tool-row + .creation-tool-row { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
#scriptWorkspaceSelect { flex: 1 1 200px; min-width: 0; width: auto; }
.script-feedback > :not(:empty):not([hidden]) { margin-bottom: 10px; }
.creation-history { min-width: 0; border: 1px solid var(--editor-line); border-radius: var(--radius-s); overflow: hidden; background: var(--editor-surface); }
.creation-history-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.creation-history-head h4 { display: flex; align-items: center; gap: 7px; margin: 0 auto 0 0; font-size: 13px; }
.creation-history-head .ic { width: 15px; height: 15px; color: var(--accent); }
.creation-history-head .chat-history-tools { margin: 0; }
.creation-history-head button[hidden], .creation-history:has(.chat-window:empty) .chat-history-tools,
.creation-history:has(.chat-window:empty) .history-latest { display: none; }
.creation-history-body { position: relative; }
.creation-history .agent-workspace { display: block; }
.creation-history .agent-observer:not(:has(.agent-event)) { display: none; }
.creation-history .history-empty { position: absolute; inset: 0; display: grid; place-content: center; margin: 0; padding: 20px; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.creation-history:has(.bubble) .history-empty { display: none; }
.creation-history :is(#scriptCreatorChat, #mvuFeChat), #frontendWorkspacePanels .creation-history #mvuFeChat {
  display: flex; height: clamp(230px, 37dvh, 400px); min-height: 0; max-height: none; min-width: 0;
  border: 0; border-radius: 0; margin: 0; padding: 14px; gap: 12px; overscroll-behavior: contain;
}
.creation-history:has(.chat-window:empty) :is(#scriptCreatorChat, #mvuFeChat),
#frontendWorkspacePanels .creation-history #mvuFeChat:empty { height: clamp(108px, 17dvh, 165px); }
.creation-history .chat-window:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.creation-history .bubble { flex: none; min-width: 0; max-width: 90%; overflow-wrap: anywhere; }
.history-message-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; font-size: 11px; }
.history-message-meta time { font-variant-numeric: tabular-nums; }
.creation-history .history-tool { align-self: flex-start; border-inline-start: 2px solid var(--accent); border-radius: 0; padding: 2px 10px; color: var(--muted); }
.history-tool .history-message-text { font-family: var(--mono, monospace); font-size: 12px; }
.creation-history .history-tool[data-failed] { border-color: var(--err); }
@media (prefers-reduced-motion: reduce) { .creation-history .bubble { animation: none; } }
.script-conversation #scriptCreatorRequirement { min-height: 100px; }
.script-conversation .agent-workspace { min-width: 0; }
.agent-mode-enabled .script-conversation .agent-workspace { grid-template-columns: minmax(0, 1fr); }
.agent-mode-enabled .script-conversation .agent-observer { height: auto; max-height: 180px; }
.script-composer-actions { justify-content: space-between; margin-top: 10px; }
.script-composer-actions .mvu-fe-req-tools { margin: 0; }
.creation-chat-composer {
  border: 1px solid var(--editor-line); border-radius: var(--radius-s); background: var(--input-bg);
  padding: 10px 12px; margin: 12px 0;
}
.creation-chat-composer:focus-within { border-color: var(--accent); }
.frontend-workspace-mobile[hidden] { display: none !important; }
.creation-chat-composer .composer-head-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px;
  padding-bottom: 6px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.creation-chat-composer .mvu-fe-req-head { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.creation-chat-composer .mvu-fe-req-head label { color: var(--muted); font-size: 12px; margin: 0; }
.creation-chat-composer .frontend-material-entry { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.creation-chat-composer .frontend-material-entry .btn.small { padding-inline: 9px; font-size: 12px; }
.creation-chat-composer .frontend-material-entry #mvuFeMaterialCount { display: none; }
.creation-chat-composer textarea.mvu-fe-requirement { min-height: 72px; padding: 8px 0; background: transparent; border: 0; box-shadow: none; }
.creation-chat-composer .script-composer-actions { border-top: 1px solid var(--border); padding-top: 8px; gap: 8px 12px; }
.agent-generation-option:has([data-agent-option]:disabled) { opacity: .65; }
.creation-chat-composer .creation-tier { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: 12px; color: var(--muted); }
.creation-chat-composer .creation-tier select { width: auto; max-width: 100%; }
.creation-chat-composer .composer-smart-route {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 auto 0 0; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 8px; background: transparent; box-shadow: none;
}
.creation-chat-composer .composer-smart-route strong { font-size: 12px; font-weight: 550; }
.creation-chat-composer .composer-smart-route small { display: none; }
.creation-chat-composer #mvuFeSmartCapabilityResult:not([hidden]) { margin-top: 8px; font-size: 11.5px; }
.creation-chat-composer :is(#mvuFeGen, #scriptCreatorGenerate) { margin: 0 0 0 auto; }
.device-preview-stage:not(.phone-mode) > iframe {
  width: 100%; min-height: 620px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--th-preview-host-background, var(--panel));
}
@media (min-width: 1280px) {
  .frontend-workspace-shell:has(#mvuFeDeviceStage:not(.phone-mode)) {
    grid-template-columns: minmax(380px, .84fr) minmax(520px, 1.16fr);
  }
}
.creation-agent-trace > .agent-observer { display: flex; flex-direction: column; height: auto; max-height: 160px; margin-block: 8px; overflow: auto; }
.script-code-card #scriptCreatorCode { height: clamp(280px, 45dvh, 600px); min-height: 240px; }
@media (max-width: 600px) {
  .content:has(> #tab-script.active) .editor-location-title { display: none; }
  .creation-tool-row .btn, .script-composer-actions .btn, .system-project-tools .workflow-mode-card label,
  .system-project-tools label.workflow-mode-card { min-height: 44px; }
  #scriptWorkspaceSelect { flex-basis: 100%; }
  .script-project-tools > .creation-tool-row { gap: 5px; }
  .script-project-tools .creation-tool-row > .btn { font-size: 12px; padding-inline: 8px; }
  #wvSave { margin-inline-start: 0; }
  .script-agent-grid { grid-template-columns: minmax(0, 1fr); }
  .script-code-card { position: static; }
  #scriptInterfacesDock .script-capabilities, #scriptSettingsDock .script-meta-grid { grid-template-columns: minmax(0, 1fr); }
}
/* Character creation compact toolbar, directory & sub-navigation. */
.rc-mode-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin-bottom: 12px; padding: 8px 10px; border: 1px solid var(--editor-line);
  border-radius: 12px; background: var(--editor-surface);
}
.rc-mode-toolbar :is(.character-creation-method, .role-mode-switch, .char-gender-switch) { margin: 0; }
.rc-mode-toolbar :is(.character-creation-method, .role-mode-switch)[hidden],
.rc-mode-toolbar .char-gender-switch[hidden] { display: none; }
.rc-mode-toolbar .role-mode-btn, .rc-mode-toolbar .gender-btn { white-space: nowrap; }
.rc-mode-help { margin-left: auto; min-width: 0; }
.rc-mode-help > summary {
  cursor: pointer; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 12px; list-style: none; user-select: none; white-space: nowrap;
}
.rc-mode-help > summary::-webkit-details-marker { display: none; }
.rc-mode-help > summary:hover { color: var(--text); border-color: var(--accent); }
.rc-mode-help[open] { flex-basis: 100%; margin-left: 0; }
.rc-mode-help-body {
  margin-top: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--input-bg); display: grid; gap: 4px;
}
.rc-mode-help-body .hint { margin: 0; font-size: 12px; }

/* Role cards wrap across the active step, or collapse to a chip bar. */
#rcDonePanel { padding: 14px 16px; margin-bottom: 12px; }
#rcDonePanel .studio-heading { margin: 0 0 10px; padding: 0; border: 0; }
#rcDonePanel.is-compact .studio-heading { margin-bottom: 8px; }
#rcDonePanel .studio-role-toolbar { display: flex; flex-wrap: wrap; align-items: center; width: auto; margin: 0 0 0 auto; gap: 8px; }
#rcDonePanel .studio-count { padding: 0; border: 0; background: transparent; font-size: 12px; color: var(--muted); }
#rcDonePanel #rcNewChar {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 12px; background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); font-size: 12px;
}
#rcDonePanel #rcNewChar .ic { width: 14px; height: 14px; flex: none; }
#rcDonePanel #rcDoneToggle[hidden], .rc-done-compact-bar[hidden] { display: none; }
.rc-done-compact-bar { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.rc-compact-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; max-width: 100%;
  padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--input-bg); color: var(--text); font: inherit; font-size: 12px; cursor: pointer;
}
.rc-compact-chip strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.rc-compact-chip small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.rc-compact-chip.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.rc-compact-chip.active small { color: var(--accent2); }
.rc-compact-chip.is-complete:not(.active) small { color: var(--ok); }
#rcDoneList { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; max-height: min(600px,60dvh); padding: 1px 3px 8px 1px; overflow: auto; scrollbar-width: thin; }
#rcDoneList .rc-role-card { position: relative; display: block; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--input-bg); box-shadow: none; transform: none; }
#rcDoneList .rc-role-card.active { border-color: color-mix(in srgb,var(--accent) 65%,var(--border)); background: color-mix(in srgb,var(--accent) 7%,var(--panel)); }
.rc-role-heading { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.rc-role-monogram { display: grid; place-items: center; flex: 0 0 36px; height: 40px; border-radius: 8px; color: var(--accent2); background: color-mix(in srgb,var(--accent2) 10%,var(--panel)); font: 600 20px/1 Georgia,'Songti SC',SimSun,serif; }
.rc-role-identity { flex: 1; min-width: 0; display: grid; gap: 5px; }
.rc-role-identity strong { color: var(--text); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.rc-role-identity > span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.rc-role-more { flex: 0 0 28px; }
.rc-role-more > summary { list-style: none; display: grid; place-items: center; width: 28px; height: 32px; border-radius: 6px; cursor: pointer; font-size: 20px; color: var(--muted); }
.rc-role-more > summary::-webkit-details-marker { display: none; }
.rc-role-more > summary:hover { color: var(--text); background: var(--btn-bg); }
.rc-role-more > div { position: absolute; right: 12px; top: 48px; z-index: 3; display: grid; min-width: 140px; padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px #0004; }
.rc-role-more .btn { text-align: left; justify-content: flex-start; border: 0; min-height: 36px; }
.rc-role-more [data-rc-delete] { color: var(--err); }
.rc-role-modules { margin: 12px 0 10px; color: var(--muted); font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.rc-role-track { display: flex; gap: 6px; margin-bottom: 12px; }
.rc-role-track span { display: grid; gap: 6px; flex: 1; font-size: 10px; color: var(--muted); white-space: nowrap; }
.rc-role-track i { display: block; height: 3px; background: var(--border); border-radius: 2px; }
.rc-role-track .done i { background: var(--accent2); }
.rc-role-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.rc-role-footer .rc-role-status { padding: 0; border: 0; border-radius: 0; font-size: 11px; white-space: nowrap; }
.rc-role-footer .btn { min-height: 34px; border-radius: 7px; font-size: 12px; padding: 6px 10px; }
.rc-role-more summary:focus-visible, #rcDonePanel button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 3px; }

.rc-subnav-shell {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 14px; padding: 8px 10px; border: 1px solid var(--editor-line);
  border-radius: 12px; background: var(--editor-inset);
}
.rc-subnav-shell > .wf-subnav { flex: 1 1 560px; margin: 0; padding: 0; border: 0; background: transparent; }
.rc-subnav-shell > .wf-sub-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.wf-subnav .wf-dot[data-optional="true"]:not(.active):not(.done) { border-style: dashed; color: var(--muted); }
.wf-subnav .wf-dot[hidden] { display: none; }

/* Optional MVU & EJS quick gates avoid showing a wall of disabled inputs. */
.mvu-body.mvu-disabled, #ejsBody.opt-disabled { display: none; }
.opt-quick-gate { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.mvu-enable-card:has(#mvuEnabled:checked) #mvuQuickGate,
.ejs-enable-card:has(#ejsEnabled:checked) #ejsQuickGate { display: none; }

/* Step 9 completion readiness checklist. */
.wf-summary-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--input-bg);
}
.wf-summary-banner.is-ready { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: color-mix(in srgb, var(--ok) 7%, var(--panel)); }
.wf-summary-banner.has-warn { border-color: color-mix(in srgb, #e2a849 45%, var(--border)); background: color-mix(in srgb, #e2a849 7%, var(--panel)); }
.wf-summary-banner strong { display: block; font-size: 15px; margin-bottom: 4px; }
.wf-summary-banner .hint { margin: 0; }
.wf-summary-pill {
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border); background: var(--panel);
}
.wf-summary-banner.is-ready .wf-summary-pill { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.wf-summary-banner.has-warn .wf-summary-pill { color: #e2a849; border-color: rgba(226, 168, 73, .45); }
.wf-summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.wf-summary-card {
  display: flex; flex-direction: column; gap: 8px; padding: 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--input-bg);
}
.wf-summary-card.tone-ok { border-color: color-mix(in srgb, var(--ok) 32%, var(--border)); }
.wf-summary-card.tone-warn { border-color: rgba(226, 168, 73, .48); background: color-mix(in srgb, #e2a849 5%, var(--input-bg)); }
.wf-summary-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wf-summary-card-head h4 { margin: 0; font-size: 14px; border: 0; padding: 0; }
.wf-summary-badge {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap;
  color: var(--muted); border: 1px solid var(--border); background: var(--panel);
}
.wf-summary-card.tone-ok .wf-summary-badge { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 38%, var(--border)); }
.wf-summary-card.tone-warn .wf-summary-badge { color: #e2a849; border-color: rgba(226, 168, 73, .45); }
.wf-summary-card p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.65; flex: 1; overflow-wrap: anywhere; }
.wf-summary-card-foot { display: flex; justify-content: flex-end; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent); }

@media (max-width: 640px) {
  .rc-mode-toolbar { padding: 8px; }
  .rc-mode-toolbar .character-creation-method { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rc-mode-toolbar .role-mode-switch:not([hidden]) { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; border-radius: 12px; padding: 5px; }
  .rc-mode-toolbar .role-mode-btn { width: 100%; min-width: 0; padding: 8px 6px; font-size: 12.5px; text-align: center; }
  .rc-mode-toolbar .char-gender-switch:not([hidden]) { width: 100%; justify-content: space-between; }
  .rc-mode-help { width: 100%; margin-left: 0; }
  .rc-mode-help > summary { display: block; text-align: center; min-height: 40px; line-height: 26px; }
  #rcDonePanel .studio-role-toolbar { width: 100%; margin-left: 0; }
}
@media (max-width: 600px) { .rc-role-more > summary, .rc-role-more .btn, #rcDonePanel #rcNewChar, .rc-compact-chip, .rc-role-footer .btn { min-height: 44px; } }
.frontend-direction > label { display: block; margin: 12px 0 8px; font-size: 13px; }
.frontend-direction > summary .hint, .frontend-file-workspace > summary .hint { margin-left: 8px; font-weight: 400; }
.frontend-direction textarea { width: 100%; }
.frontend-file-workspace { margin-top: 12px; min-width: 0; }
.frontend-file-workspace > summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.frontend-file-workspace[open] > summary { margin-bottom: 12px; }
.frontend-file-workspace label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); margin: 10px 0 5px; }
.frontend-file-workspace :is(input:not([type=file]),select,textarea) { width: 100%; min-width: 0; }
.frontend-file-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 12px 0; }
.frontend-file-toolbar > label:not(.btn) { flex: 1 1 160px; margin: 0; }
.frontend-file-workspace .frontend-file-import { position: relative; display: inline-flex; color: var(--text); margin: 0; overflow: hidden; }
.frontend-file-import input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.frontend-file-import:focus-within { outline: 2px solid var(--accent2); outline-offset: 2px; }
.frontend-file-compose { padding: 12px 0; border-bottom: 1px solid var(--border); }
.frontend-file-compose summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.frontend-file-compose button { margin-top: 8px; }
#promptLabProtocol { margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
#promptLabProtocol summary { cursor: pointer; color: var(--muted); font-size: 12px; }
#promptLabProtocol pre { max-height: 220px; overflow: auto; white-space: pre-wrap; }
@media (max-width: 600px) { .frontend-file-toolbar button { min-height: 44px; } .frontend-direction > summary .hint, .frontend-file-workspace > summary .hint { display: block; margin: 4px 0 0; } }
