/* Chat boundaries allow normal document scrolling on small screens. */
.workspace .messages{overscroll-behavior-y:auto}
.chat-composer .composer-bottom{flex-wrap:wrap;row-gap:10px}
.chat-composer .composer-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-left:auto;flex-shrink:0}
:root body .shell-workspace .chat-composer .composer-actions .end-chat{min-height:30px;padding:5px 9px;font-size:12px;line-height:1.5;white-space:nowrap}
.chat-composer .composer-actions .end-chat svg{width:14px;height:14px}
@media(max-width:540px){.chat-composer .composer-actions{gap:8px}.chat-composer .composer-actions .composer-hint{display:none}}

/* Give the writing area and inspiration canvas clear, separate frames. */
.workspace{--workspace-edge:var(--theme-line,var(--border));--workspace-heading:var(--theme-control,var(--panel));--workspace-composer:var(--theme-secondary,var(--panel))}
:root:is([data-theme="white"],[data-theme="light"]) .workspace{--workspace-edge:#73877b;--workspace-heading:#edf3ef;--workspace-composer:#f1f5f2}
:root[data-theme] body .workspace>:is(.chat-panel,.plan-panel){border:2px solid var(--workspace-edge);border-radius:12px;box-shadow:0 3px 0 var(--workspace-edge),0 9px 20px #10271b24}
:root[data-theme] body .workspace>:is(.chat-panel,.plan-panel)>.panel-heading{background:var(--workspace-heading);border-bottom:1px solid var(--workspace-edge)}
:root[data-theme] body .workspace>.chat-panel>.chat-composer{background:var(--workspace-composer);border-top:2px solid var(--workspace-edge)}
:root[data-theme] body .workspace .chat-composer .create-box{border:2px solid var(--workspace-edge);background:var(--theme-surface,var(--panel));box-shadow:0 2px 6px #10271b14;transition:border-color .16s ease,box-shadow .16s ease}
:root[data-theme] body .workspace .chat-composer .create-box:focus-within{border-color:var(--theme-accent,#a3e4bb);box-shadow:0 0 0 3px var(--workspace-heading)}

.workbench-current{padding:16px;min-width:0}
.workbench-current>header{display:flex;justify-content:space-between;gap:12px;font-size:13px}
.workbench-current>header small,.workbench-current small{color:var(--theme-muted,var(--muted));font-size:12px}
.workbench-current h2{font-size:19px;margin:12px 0 8px;overflow-wrap:anywhere}
.workbench-request{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.75;font-size:13px;margin:8px 0 16px;max-height:8.75em;overflow:auto}
.workbench-result{border-top:1px solid var(--theme-line,var(--border));padding-top:12px;margin-top:16px;min-width:0}
.workbench-result h3{font-size:13px;margin:0 0 10px}
.workbench-result ul{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.workbench-result li{display:flex;justify-content:space-between;gap:8px;font-size:12px;line-height:1.6}
.workbench-result li>span{min-width:0;overflow-wrap:anywhere}
.workbench-result li>small{flex-shrink:0}
.workbench-history{border-top:1px solid var(--theme-line,var(--border));margin:0 14px 14px}
.workbench-history>summary,.workbench-source>summary{padding:12px 0;cursor:pointer;font-size:12px;overflow-wrap:anywhere}
.workbench-history>.plan-panel{border:0;box-shadow:none;margin:0;max-height:none;overflow:visible;background:transparent}
.workbench-history .panel-heading{position:static!important}
.workbench-source{margin-top:14px;min-width:0}
.workbench-source pre{max-height:280px;overflow:auto;max-width:100%;font-size:11px;line-height:1.6;padding:10px;background:var(--theme-control,transparent);border:1px solid var(--theme-line,var(--border));border-radius:6px}
.workbench-compile{font-size:12px;margin-top:14px}
.workbench-weapon{display:grid;justify-items:center;gap:10px;padding:14px 0}
.workbench-weapon img{max-width:100%;max-height:220px;object-fit:contain}
.workbench-current .texture-panel{padding:0!important}
.workbench-current .material-list{width:100%;max-width:none}

/* Flex sizing includes the optional time notice without fixed offsets. */
@media(min-width:901px) and (min-height:640px){
  .shell-workspace{height:100vh;height:100dvh;display:flex;flex-direction:column}
  .shell-workspace>.topbar{height:52px;min-height:52px;padding-inline:24px;flex:0 0 auto}
  .shell-workspace>.time-notice{flex:0 0 auto;min-height:34px;padding:3px 20px;font-size:12px}
  .shell-workspace>.world-stage{
    flex:1 1 0;min-height:0;display:flex;flex-direction:column;
    padding-bottom:clamp(88px,13dvh,128px);overflow:hidden;
  }
  :root[data-theme] .shell-workspace .world-stage>main{
    width:100%;flex:1 1 0;min-height:0;margin:0 auto;padding:10px 24px 0;
    display:flex;flex-direction:column;
  }
  .shell-workspace .workspace-head{flex:0 0 auto;margin-bottom:8px;gap:12px}
  :root body .shell-workspace .workspace-head h1{font-size:20px;margin:0 0 2px}
  :root body .shell-workspace .workspace-head p{font-size:12px;line-height:1.6}
  :root body .shell-workspace .saved-label-row .secondary{font-size:12px;padding:6px 10px}
  .shell-workspace .workflow{flex:0 0 auto;margin-bottom:10px;padding:7px 12px}
  .shell-workspace .workspace{flex:1 1 0;min-height:0;gap:16px;align-items:stretch;grid-template-columns:minmax(0,1fr)}
  .shell-workspace .workspace>.chat-panel{
    min-width:0;min-height:0;display:flex;flex-direction:column;
  }
  :root body .shell-workspace .panel-heading{padding:9px 13px;font-size:14px;flex:0 0 auto}
  :root body .shell-workspace .panel-heading .mode-badge{padding:3px 8px;font-size:11px;line-height:1.5;min-height:0}
  .shell-workspace .workspace>.chat-panel>.messages{
    flex:1 1 0;min-height:0;max-height:none;overflow-y:auto;
    padding:14px;scrollbar-gutter:stable;
  }
  :root body .shell-workspace :is(.message-text,.message.user .message-text){font-size:14px;line-height:1.8}
  .shell-workspace .chat-composer{flex:0 0 auto;padding:10px 12px}
  .shell-workspace .chat-composer .idea-chips{gap:6px;margin:0 0 7px}
  :root body .shell-workspace .chat-composer .chip{font-size:12px;padding:4px 8px}
  .shell-workspace .chat-composer .create-box{padding:7px 10px}
  :root body .shell-workspace .chat-composer .create-box textarea{
    font-size:14px;line-height:1.7;min-height:52px;height:52px;max-height:104px;resize:vertical;
  }
  .shell-workspace .workspace>.plan-panel{
    min-height:0;max-height:100%;overflow-y:auto;overscroll-behavior-y:auto;scrollbar-gutter:stable;
  }
  .shell-workspace .workspace>.plan-panel>.panel-heading{position:sticky;top:0;z-index:2;background:inherit}
  .shell-workspace .texture-panel{padding:12px 14px}
  .shell-workspace .texture-panel .texture-grid{width:min(100%,224px);height:clamp(144px,24dvh,216px);aspect-ratio:auto;margin:10px auto 12px}
  .shell-workspace .texture-panel .texture-sprite{object-fit:contain}
  .shell-workspace .texture-panel p{margin:8px 0}
  .shell-workspace .texture-panel-actions{margin-top:10px}
  .shell-workspace .plan-visual{height:96px;min-height:96px}
  .shell-workspace .plan-fields{padding:12px}
  :root body .shell-workspace .world-stage footer{
    flex:0 0 auto;margin-top:8px;padding:3px 10px;font-size:11px;line-height:1.4;
  }
  /* Preserve floor, water, prop and actor coordinates in one native space. */
  :root[data-theme] .shell-workspace .world-stage>.marble-scene{
    inset:auto auto 0 0;width:133.333333%;height:133.333333%;
    transform:scale(.75);transform-origin:left bottom;
  }
  :root:is([data-theme="white"],[data-theme="black"]) .shell-workspace>.world-stage{padding-bottom:16px}
}

@media(max-width:900px),(max-height:639px){
  .workspace>.chat-panel{display:flex;flex-direction:column;min-width:0}
  .workspace .messages{min-height:260px;max-height:60dvh}
  .workspace .chat-composer{padding:12px}
  .workspace .plan-panel{min-width:0}
  .workspace .texture-panel .texture-grid{width:min(100%,224px);height:192px;aspect-ratio:auto}
}

/* Keep naming available in the editor and in saved project cards. */
.workspace-head>div:first-child{min-width:0}
.workspace-head h1,.library-info h3{overflow-wrap:anywhere}
.workspace-head-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.workspace-head .project-rename{flex-shrink:0;white-space:nowrap}
.library-actions{flex-wrap:wrap}
.project-name-dialog{max-width:440px}
.project-name-modal .field-label{display:block;margin:20px 0 8px}
.project-name-modal input{width:100%;min-height:44px;padding:10px 12px;border:1px solid var(--theme-line,var(--border));border-radius:7px;background:var(--theme-control,var(--panel));color:var(--theme-ink,var(--text));font:inherit;box-sizing:border-box}
.project-name-modal input:focus{outline:2px solid var(--theme-accent,var(--mint));outline-offset:2px}
.project-name-error{min-height:1.5em;color:var(--theme-ink,var(--text));font-size:12px}
@media(max-width:540px){.workspace-head{flex-wrap:wrap;gap:12px}.workspace-head>.project-rename,.workspace-head-actions{margin-left:auto}.library-actions .project-rename{font-size:11px}}

:root body .workspace .message-next-step{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;margin:10px 0 0;padding:10px 12px;border:1px solid var(--theme-line,var(--border));border-radius:8px;background:var(--theme-control,var(--panel));color:var(--theme-ink,var(--text));font-size:12px;line-height:1.8;overflow-wrap:anywhere}
.message-next-step>strong{white-space:nowrap}
.message-next-step>span{flex:1 1 220px;min-width:0}

/* One conversation column uses the entire editing area. */
.workspace.workspace-chat-only{grid-template-columns:minmax(0,1fr);gap:0;min-width:0}
.workspace-chat-only>.chat-panel{width:100%;min-width:0;box-sizing:border-box}
.chat-composer .composer-tools{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}
:root body .shell-workspace .chat-composer .composer-start{padding:7px 12px;min-height:34px;font-size:12px;line-height:1.5;white-space:nowrap}
.chat-composer .composer-start svg{width:15px;height:15px}
.chat-composer .composer-start:disabled{opacity:.6;cursor:not-allowed}
.chat-composer .composer-actions{min-width:0;max-width:100%;flex-wrap:wrap}
.chat-composer .composer-files{font-size:12px;white-space:nowrap}
@media(max-width:540px){
  .chat-composer .composer-tools{flex-basis:100%;gap:6px 12px}
  .chat-composer .composer-actions{flex-basis:100%;width:100%;gap:8px}
  .chat-composer .composer-start{margin-right:auto}
  :root body .shell-workspace .chat-composer .composer-actions .end-chat{font-size:11px;padding-inline:7px}
}
