/* Size the editing workspace from its actual headers, not fixed viewport offsets.
   Preview, editing controls and messages each own their scrolling. */
body:has(#app:not([hidden]) .editor-layout) {
  overflow: hidden;
}
body:has(.editor-layout) .rail {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.shell:has(.editor-layout) {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.shell:has(.editor-layout) .topbar {
  flex-shrink: 0;
}
#workspace:has(.editor-layout) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  min-width: 0;
}
.editor-layout,
.editor-layout .preview-area {
  min-height: 0;
  overflow: hidden;
}
.editor-layout .preview-caption {
  flex-shrink: 0;
}
.editor-layout .selection-tools {
  max-height: 35%;
  overflow: auto;
}
.editor-layout .frame-wrap {
  flex: 1;
  min-height: 0;
}
.editor-layout #preview {
  height: 100%;
  min-height: 0;
}
.editor-layout .inspector {
  padding: 0;
  height: 100%;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.inspector-controls {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 16px;
}
.inspector-controls #page-details {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}
.inspector:has(#assistant-panel[hidden]) .inspector-controls {
  flex: 1;
  max-height: none;
}
.chat-focus .inspector-controls {
  display: none;
}
.editor-layout #assistant-panel {
  container-type: size;
  display: flex;
  flex-direction: column;
  flex: 1;
  height: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
}
.editor-layout:not(.chat-focus) #assistant-panel {
  display: none;
}
.editor-layout .assistant-header {
  padding: 6px 12px;
  min-height: 44px;
  gap: 8px;
}
.pane-tabs {
  display: flex;
  gap: 4px;
}
.pane-tabs button {
  padding: 6px 12px;
  border: 0;
  background: transparent;
  font-size: 12px;
}
.pane-tabs [aria-selected='true'] {
  background: #eee8f6;
  color: var(--accent);
  font-weight: 600;
}
.editor-layout .assistant-welcome {
  padding: 4px 0;
  margin: 0;
  max-width: none;
}
.editor-layout .assistant-welcome h4 {
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0;
  margin: 0 0 12px;
}
.editor-layout .assistant-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.editor-layout .assistant-starters button {
  padding: 7px 10px;
  font-size: 11px;
  border-radius: 7px;
}
.editor-layout #assistant-message {
  min-height: 44px;
  max-height: 120px;
}
.editor-layout .assistant-log {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
}
.editor-layout .assistant-attachments {
  max-height: 76px;
  overflow: auto;
}
.editor-layout .assistant-error {
  max-height: 15%;
}
/* Keep the composer compact in short windows. */
@container (max-height: 480px) {
  .assistant-header {
    padding: 8px 12px;
  }
  .assistant-compose-area {
    padding: 6px 10px;
  }
  #assistant-message {
    min-height: 36px;
    max-height: 60px;
  }
  .attachment-note,
  .assistant-draft-note {
    display: none;
  }
  .assistant-attachments {
    max-height: 42px;
  }
  .assistant-log {
    padding: 10px 12px;
  }
}
@media (max-height: 700px) {
  .shell:has(.editor-layout) .topbar {
    height: 60px;
    padding: 8px 18px;
  }
  .shell:has(.editor-layout) .toolbar {
    padding: 8px 12px;
    gap: 6px;
  }
  .editor-layout .preview-area {
    padding: 10px;
  }
  .editor-layout .assistant-header {
    padding: 8px 12px;
  }
  .editor-layout .assistant-compose-area {
    padding: 6px 10px;
  }
  .editor-layout #assistant-message {
    min-height: 36px;
    max-height: 60px;
  }
  .editor-layout .attachment-note,
  .editor-layout .assistant-draft-note {
    display: none;
  }
  .editor-layout .assistant-attachments {
    max-height: 42px;
  }
  .editor-layout .assistant-log {
    padding: 10px 12px;
  }
}
@media (max-width: 760px) {
  /* On phones Chat switches the workspace to chat; Editing controls returns
     to the page. Keep navigation outside the message scroller. */
  .editor-layout.chat-focus .preview-area {
    display: none;
  }
  .editor-layout.chat-focus .inspector {
    flex: 1;
  }
  body:has(.editor-layout:not(.chat-focus)) {
    overflow: auto;
  }
  .shell:has(.editor-layout:not(.chat-focus)) {
    height: auto;
    display: block;
  }
  #workspace:has(.editor-layout:not(.chat-focus)) {
    display: block;
  }
  .editor-layout:not(.chat-focus) .frame-wrap {
    flex: none;
    height: 560px;
  }
  .editor-layout:not(.chat-focus) .inspector {
    height: auto;
  }
  .editor-layout:not(.chat-focus) .inspector-controls {
    max-height: none;
    overflow: visible;
  }
}
