/* App shell: full-height tool layout shared by every tool page (grammar checker + paraphraser have their own shells).
   Adds: document heading on the left of the command bar, all options pushed right, panes scroll internally,
   the page never grows — only the SEO explainer below main scrolls. Loaded after aiwa-tools.css / aiwa-command.css. */
body.aiwa-app-shell { background: #fff; }
.aiwa-app-shell > main { flex: 0 0 auto; display: flex; flex-direction: column; height: calc(100dvh - 64px); min-height: 520px; background: #fff; overflow: hidden; }
.aiwa-app-shell .para-command-bar { position: static; flex: 0 0 auto; top: auto; overflow: visible; border-bottom: 1px solid var(--aiwa-line); background: #fff; }
.aiwa-app-shell .para-command-inner { min-height: 62px; display: flex; flex-wrap: wrap; row-gap: 6px; align-items: center; justify-content: flex-end; gap: 12px; padding: 9px 18px; overflow: visible; }
.aiwa-app-shell .para-command-inner > .para-mode-row, .aiwa-app-shell .para-command-inner > .para-settings-row, .aiwa-app-shell .detector-command-controls { flex: 0 0 auto !important; width: auto !important; justify-content: flex-end !important; margin-left: 0 !important; }
.aiwa-app-shell .para-settings-row .command-language { margin-left: 0; }
.aiwa-app-shell .para-command-inner { overflow: visible !important; }
.aiwa-app-shell .detector-command-inner .detector-command-controls { margin-right: 0; }
.aiwa-app-shell .para-command-label { display: none; }
.aiwa-app-shell .para-mode-row .para-modes legend { display: none; }

/* document heading (AI generated) */
.aiwa-doc-head { flex: 1 1 240px; min-width: 200px; margin-right: auto; display: flex; flex-direction: column; justify-content: center; gap: 1px; line-height: 1.2; }
.aiwa-doc-kicker { color: var(--aiwa-muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.aiwa-doc-title { display: block; min-width: 0; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--aiwa-ink); font-size: 16px; font-weight: 740; letter-spacing: -0.02em; }
.aiwa-doc-title.is-placeholder { color: var(--aiwa-muted); font-weight: 600; }
.aiwa-doc-head .aiwa-doc-status { color: var(--aiwa-muted); font-size: 11px; }

/* workspace fills the rest; panes scroll inside */
.aiwa-app-shell .para-workspace-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0; }
.aiwa-app-shell .tool-panel.para-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0; border: 0; border-radius: 0; box-shadow: none; max-width: none; overflow: hidden; }
.aiwa-app-shell .notice { flex: 0 0 auto; margin: 0; border-radius: 0; }
.aiwa-app-shell .notice.show { margin: 0; }
.aiwa-app-shell .mobile-editor-tabs { flex: 0 0 auto; }
.aiwa-app-shell .editor-grid { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); }
.aiwa-app-shell .para-editor-grid .editor-pane { min-height: 0; height: auto; display: flex; flex-direction: column; overflow: hidden; }
.aiwa-app-shell .para-editor-grid .pane-heading { flex: 0 0 auto; }
.aiwa-app-shell .pane-status, .aiwa-app-shell .result-meta { flex: 0 0 auto; }
.aiwa-app-shell .para-editor-grid .aiwa-textarea, .aiwa-app-shell .para-editor-grid .result-box, .aiwa-app-shell .detector-report { flex: 1 1 auto; min-height: 0 !important; height: auto !important; max-height: none !important; overflow: auto; resize: none; }
.aiwa-app-shell .result-box.empty { display: grid; place-items: center; }
.aiwa-app-shell .email-editor-grid .input-pane, .aiwa-app-shell .email-editor-grid .output-pane { min-height: 0; }
.aiwa-app-shell .email-result-box { overflow: auto; }
.aiwa-app-shell .detector-evidence-document { flex: 1 1 auto; min-height: 0; overflow: auto; }
.aiwa-app-shell .para-action-bar { flex: 0 0 auto; position: static; }

/* SEO content lives after main and is the only thing that scrolls the page */
.aiwa-app-shell .tool-explainer { margin-right: var(--tools-rail-width); padding: 40px 0 60px; border-top: 1px solid var(--aiwa-line); background: #fff; transition: margin-right 180ms var(--aiwa-ease); }

@media (max-width: 1180px) {
  .aiwa-doc-title { max-width: 34vw; font-size: 15px; }
}
@media (max-width: 900px) {
  .aiwa-app-shell > main { height: calc(100dvh - 56px); min-height: 0; }
  .aiwa-app-shell .tool-explainer { margin-right: 0; }
  .aiwa-app-shell .para-command-inner { flex-wrap: wrap; min-height: 54px; gap: 8px; padding: 7px 10px; }
  .aiwa-doc-head { flex: 1 1 100%; order: -1; }
  .aiwa-doc-title { max-width: 100%; font-size: 14.5px; }
  .aiwa-app-shell .para-command-inner > .para-settings-row, .aiwa-app-shell .para-command-inner > .para-mode-row, .aiwa-app-shell .detector-command-controls { flex: 1 1 100% !important; min-width: 0; max-width: 100%; justify-content: flex-start !important; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; scrollbar-width: none; }
  .aiwa-app-shell .para-command-inner > .para-settings-row::-webkit-scrollbar { display: none; }
  .aiwa-app-shell .detector-command-inner .detector-language-control { margin-left: 0; }
  .aiwa-app-shell .editor-grid, .aiwa-app-shell .para-editor-grid { display: grid !important; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .aiwa-app-shell .para-editor-grid .editor-pane { flex: 1 1 auto; height: 100%; }
  .aiwa-app-shell[data-mobile-editor-view="input"] .output-pane, .aiwa-app-shell[data-mobile-editor-view="output"] .input-pane { display: none; }
  .aiwa-app-shell .para-editor-grid .editor-pane + .editor-pane { border-top: 0; }
  .aiwa-app-shell .para-action-bar { box-shadow: 0 -6px 12px rgba(23, 33, 27, 0.06); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

/* paraphraser bar */
.aiwa-app-shell .pp-bar-inner { justify-content: flex-end; }
.aiwa-app-shell .pp-bar-inner .pp-language { margin-left: 0; }
.aiwa-app-shell .pp-custom { flex: 0 1 300px; }
@media (max-width: 900px) { .aiwa-app-shell .pp-bar-inner .aiwa-doc-head { flex: 1 1 100%; } .aiwa-app-shell .pp-custom { flex: 1 1 100%; } }
/* tone changer: let the selects size to their labels instead of clipping */
.aiwa-app-shell .tone-context-select select, .aiwa-app-shell .tone-target-select select { width: auto; max-width: 150px; padding-right: 22px; }
.aiwa-app-shell .tone-settings-row .command-check > span { white-space: nowrap; }
@media (max-width: 1500px) { .aiwa-app-shell.tone-changer-page .aiwa-doc-kicker { display: none; } .aiwa-app-shell.tone-changer-page .aiwa-doc-title { font-size: 14px; } }
@media (max-width: 900px) { .aiwa-app-shell .email-examples button:nth-of-type(n+4) { display: none; } }

/* email writer: cleaner panes (no pane headings / examples / stats) */
.aiwa-app-shell .email-contact-grid { padding: 12px 24px; }
.aiwa-app-shell .email-brief-head { padding-top: 12px; }
.aiwa-app-shell .email-editor-grid .email-brief-input { padding-bottom: 24px; }
.aiwa-app-shell .email-result-box.empty { min-height: 0; }
@media (max-width: 900px) {
  .aiwa-app-shell .email-contact-grid { grid-template-columns: 1fr; padding: 10px 14px; gap: 8px; }
  .aiwa-app-shell .email-brief-head { flex-wrap: wrap; padding: 10px 14px 0; }
  .aiwa-app-shell .email-editor-grid .email-brief-input { padding-inline: 14px; }
  .aiwa-app-shell .email-incoming-wrap { padding-inline: 14px; }
  .aiwa-app-shell .email-result-box { padding: 14px; }
  .aiwa-app-shell .email-refine { gap: 4px; }
  .aiwa-app-shell .email-refine button { min-height: 28px; padding: 3px 9px; font-size: 11.5px; }
}
@media (max-width: 900px) { html:has(body.aiwa-app-shell), body.aiwa-app-shell { overflow-x: hidden; max-width: 100vw; } }
