/* Rankora workspace and dialogs: familiar system type, one action colour.
   Public landing typography and exported article formatting stay independent. */
:root {
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
  --ui-control-height: 44px;
  --ui-panel-padding: 24px;
  --ui-radius-control: 8px;
  --ui-radius-panel: 12px;
}
.app-shell {
  --ink: #1d2533;
  --muted: #626d7d;
  --paper: #f5f6f8;
  --card: #ffffff;
  --line: #dfe3e9;
  --blue: #4b5cd7;
  --blue-deep: #3949bc;
  --blue-wash: #eff1fb;
  --rail: #171d2a;
  --rail-muted: #a0aabc;
  --rail-ink: #f1f3f8;
  --success: #2e8569;
  --shadow: 0 3px 16px #18223604;
  background: var(--paper);
  grid-template-columns: 240px minmax(0, 1fr);
}
body.dark .app-shell {
  --ink: #e6eaf1;
  --muted: #a8b1c1;
  --paper: #121721;
  --card: #1a2130;
  --line: #303a4c;
  --blue: #a4b0ff;
  --blue-deep: #c1c9ff;
  --blue-wash: #262f48;
  --rail: #10151f;
  --success: #83cdb2;
  --shadow: none;
}

/* The numbered route remains the visual signature: actual stages, not decoration. */
.app-shell .rail { background: var(--rail); border-right: 1px solid #ffffff0a; box-shadow: none; }
.app-shell .brand { font-size: 13px; letter-spacing: .15em; }
.app-shell .brand i { width: 12px; height: 12px; box-shadow: none; color: #c2cbf3; }
.app-shell .new-button { background: #ffffff07; border-color: #ffffff26; border-radius: 7px; box-shadow: none; font-weight: 600; }
.app-shell .new-button:hover { background: #ffffff12; transform: none; border-color: #ffffff45; }
#restartButton .new-label-desktop { margin: 0; font: inherit; color: inherit; }
#restartButton .new-label-mobile { display: none; }
@media (max-width: 680px) {
  .app-shell .rail { grid-template-columns: minmax(0, 1fr) auto 42px; }
  .app-shell .rail #restartButton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: auto; min-height: 42px; padding: 0 10px; font-size: 13px; white-space: nowrap; }
  #restartButton .new-label-desktop { display: none; }
  #restartButton .new-label-mobile { display: inline; margin: 0; font: inherit; color: inherit; }
}
.app-shell .cw-mode { background: #0a0e171f; border-color: #ffffff14; border-radius: 7px; }
.app-shell .cw-mode button { font-size: 13px; font-weight: 500; border-radius: 5px; }
.app-shell .cw-mode button[aria-pressed="true"] { background: #ffffff10; box-shadow: 0 1px 3px #0002; }
.app-shell :is(.steps, .cw-steps) button { border-radius: 6px; gap: 12px; }
.app-shell :is(.steps, .cw-steps) button b { color: #8d99b2; font-size: 13px; }
.app-shell :is(.steps, .cw-steps) button.active { background: #ffffff0d; color: var(--rail-ink); box-shadow: inset 2px 0 #a7b4ee; border-left-color: transparent; }
.app-shell .steps button.active::before { display: none; }
.app-shell :is(.steps, .cw-steps) button.active b { color: #c5cef3; }
.app-shell :is(.steps, .cw-steps) button:not(:disabled):hover { background: #ffffff0b; }
.app-shell .steps button.active:disabled { opacity: 1; }
.app-shell .cw-resources > span { letter-spacing: .09em; color: var(--rail-muted); }
.app-shell .cw-resources button { font-size: 13px; color: #d8deea; }
.app-shell .cw-resources button span { color: #9caac7; }
.app-shell .theme-button { font-size: 13px; }
.app-shell .rail :is(button, a):focus-visible { outline-color: #bac6ff; }

/* A toolbar, not a row of competing cards. Email stays inside a named account control. */
.app-shell .topbar { max-width: 1360px; margin-inline: auto; min-height: 70px; height: auto; padding: 10px 40px; gap: 20px; background: transparent; backdrop-filter: none; border-bottom: 1px solid var(--line); }
.app-shell .account-button { grid-template-columns: 30px minmax(0, 1fr); max-width: 260px; min-height: 44px; gap: 10px; padding: 5px 8px; margin-left: -8px; border: 1px solid transparent; border-radius: 7px; background: transparent; box-shadow: none; transform: none; }
.app-shell .account-button:hover { background: var(--card); border-color: var(--line); box-shadow: none; transform: none; }
.app-shell .account-button .account-mark { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--muted); box-shadow: none; }
.app-shell .account-button-copy { gap: 1px; }
.app-shell .account-button-copy strong { font-size: 13px; font-weight: 700; }
.app-shell .account-button-copy small { font-size: 13px; font-weight: 400; max-width: none; }
.app-shell .draft-status { font-size: 12px; font-weight: 500; }
.app-shell .draft-status > i { width: 5px; height: 5px; flex-basis: 5px; box-shadow: none; }
.app-shell .draft-status:is(.saved, .server) { color: var(--muted); }
.app-shell .editorial-admin-link { border-color: transparent; background: transparent; border-radius: 6px; font-size: 13px; padding: 8px 4px; }
.app-shell .how-button { font-size: 13px; font-weight: 500; }
.app-shell .how-button:hover { transform: none; }

/* Service headings are compact; the manuscript owns the expressive serif type. */
.app-shell .content { max-width: 1360px; padding: 32px 40px 64px; }
.app-shell .page-heading,
body.compact-workspace .app-shell .page-heading { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; margin-bottom: 24px; }
.app-shell .page-heading::before,
.app-shell .page-heading .desk-line,
.app-shell .page-heading .eyebrow::before,
.app-shell .page-heading h1 em::after { display: none; }
.app-shell .page-heading .eyebrow { padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); font: 500 12px/1.5 Manrope, sans-serif; letter-spacing: .07em; }
.app-shell .page-heading h1,
body.compact-workspace .app-shell .page-heading h1 { margin: 0; max-width: 100%; font: 600 clamp(24px, 2.5vw, 30px)/1.25 Manrope, sans-serif; letter-spacing: -.035em; white-space: normal; }
.app-shell #pageTitle { margin: 0; }
.app-shell #pageTitle em { color: inherit; font-weight: inherit; font-style: normal; padding: 0; }
.app-shell .page-heading h1 br { display: none; }
.app-shell .page-heading h1 br + em::before { content: ' '; }
.app-shell .page-heading > p:last-child { max-width: 640px; font-size: 14px; line-height: 1.65; }
.app-shell .wizard-card { background: var(--card); border-color: var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.app-shell .wizard-card::before { display: none; }
.app-shell .card-top { padding: 14px 28px; border-radius: 12px 12px 0 0; background: transparent; letter-spacing: .06em; }
.app-shell .card-main { padding: 28px; }
.app-shell .actions { border-radius: 0 0 12px 12px; padding-inline: 28px; background: transparent; }
.app-shell .main :is(.button-primary, .button-secondary) { border-radius: 7px; font-weight: 600; box-shadow: none; }
.app-shell .main .button-primary { background: var(--blue); color: #fff; }
.app-shell .main .button-primary:hover:not(:disabled) { background: var(--blue-deep); transform: none; }
body.dark .app-shell .main .button-primary { background: #6477e8; color: #fff; }
body.dark .app-shell .main .button-primary:hover:not(:disabled) { background: #7385f0; }
.app-shell :is(.choice-card, .topic-card, .h1-card, .market-card, .outline-item) { border-radius: 8px; box-shadow: none; }
.app-shell :is(.choice-card, .topic-card, .h1-card):hover { transform: none; box-shadow: none; }
.app-shell :is(.choice-card, .topic-card, .h1-card).active { box-shadow: inset 0 0 0 1px var(--blue); }
.app-shell .source-note { background: transparent; border: 0; box-shadow: none; padding: 0; }
.app-shell :is(.brief-stage-intro h2, .subheading, .settings-block > h2, .seo-editor > h2, .cw-intro h2) { font-family: Manrope, sans-serif; font-size: 20px; font-weight: 600; line-height: 1.35; letter-spacing: -.025em; }

/* An archive notice is navigation, not a second hero. */
.app-shell .library-view-bar { padding: 0 0 20px; margin-bottom: 24px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.app-shell .library-view-bar > div:first-child > span { display: none; }
.app-shell .library-view-bar b { font-size: 14px; font-weight: 600; margin: 0; }
.app-shell .library-view-bar small { font-size: 13px; }
.app-shell .library-view-bar .button-primary,
body.dark .app-shell .library-view-bar .button-primary { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.app-shell .library-view-bar .button-primary:hover:not(:disabled) { background: var(--blue-wash); border-color: var(--blue); color: var(--blue); }
.app-shell .article-preview { max-width: 780px; margin-inline: auto; }
.app-shell .article-preview h1 { font-size: clamp(30px, 3.2vw, 42px); line-height: 1.13; letter-spacing: -.035em; margin-bottom: 22px; }
.app-shell .article-preview h2 { font-size: 27px; line-height: 1.25; letter-spacing: -.025em; }
.app-shell .article-preview h3 { font-size: 22px; line-height: 1.3; }
.app-shell .article-preview :is(p, li) { color: var(--ink); font-size: 15px; line-height: 1.85; }
.app-shell .block-toolbar { font: 500 13px/1.5 Manrope, sans-serif; letter-spacing: .06em; }
.app-shell .block-toolbar button { min-height: 34px; font: 500 13px/1.5 Manrope, sans-serif; padding: 6px 10px; border-color: var(--line); color: var(--muted); background: transparent; }
.app-shell :is(.publication-dock, .cw-article-tools, .workspace-disclosure) { border-radius: 9px; background: var(--card); box-shadow: none; }
.app-shell .publication-dock h2 { font: 600 23px/1.3 Manrope, sans-serif; letter-spacing: -.025em; }
.app-shell .publication-tab { border-radius: 6px; box-shadow: none; }
.app-shell :is(button, a, summary):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.app-shell .rail :is(button, a):focus-visible { outline-color: #bac6ff; }

@media (min-width: 681px) {
  .app-shell .rail { padding-inline: 16px; }
  .app-shell .rail .steps button { font-size: 14px; }
  .app-shell .rail .brand { padding-bottom: 32px; }
  .app-shell .rail .cw-mode { margin-bottom: 18px; }
}
@media (min-width: 681px) and (max-height: 760px) {
  .app-shell .rail .brand { padding-bottom: 22px; }
  .app-shell .rail .cw-mode { margin-bottom: 6px; }
}
@media (min-width: 681px) and (max-width: 1100px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .app-shell .topbar { gap: 12px; padding-inline: 24px; }
  .app-shell .content { padding-inline: 24px; }
  .app-shell .draft-status { order: 4; flex-basis: 100%; max-width: none; }
  .app-shell .draft-status > span { max-width: none; }
  .app-shell .account-button { margin-right: auto; }
  .app-shell .library-view-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .app-shell .library-view-bar > div:last-child { flex-wrap: wrap; }
}
@media (max-width: 680px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-shell .rail { padding-inline: 12px; }
  .app-shell .brand { font-size: 13px; }
  .app-shell .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'account editorial' 'status help'; min-height: 72px; padding: 10px 16px; gap: 6px 12px; }
  .app-shell .account-button { grid-area: account; max-width: 100%; margin-right: auto; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; }
  .app-shell .account-button .account-mark { width: 26px; height: 30px; }
  .app-shell .editorial-admin-link { grid-area: editorial; justify-self: end; }
  .app-shell .how-button { grid-area: help; justify-self: end; padding: 6px 0; }
  .app-shell .draft-status { grid-area: status; max-width: none; font-size: 12px; }
  .app-shell .draft-status > span { position: static; width: auto; height: auto; clip-path: none; max-width: none; white-space: normal; overflow: visible; }
  .app-shell .content,
  body.compact-workspace .app-shell .content { padding: 22px 12px 72px; }
  .app-shell .page-heading,
  body.compact-workspace .app-shell .page-heading { gap: 7px; margin-bottom: 18px; padding-inline: 4px; }
  .app-shell .card-top { padding: 14px 16px; }
  .app-shell .card-main { padding: 20px 16px; }
  .app-shell .actions { padding-inline: 16px; }
  .app-shell .article-preview h1 { font-size: 30px; }
  .app-shell .article-preview h2 { font-size: 25px; }
  .app-shell .block-toolbar { gap: 8px; }
  .app-shell .block-toolbar > div { display: flex; flex-wrap: wrap; }
  .app-shell .block-toolbar button { min-height: 44px; }
  .app-shell .library-view-bar { padding: 0 0 18px; }
  .app-shell .library-view-bar > div:last-child { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .app-shell *, .app-shell *::before, .app-shell *::after { scroll-behavior: auto; transition: none; animation: none; }
}

/* One type family throughout the product UI, including dynamically created dialogs.
   Override old component font shorthands without changing their responsive sizes. */
:is(#appShell, body > dialog),
:is(#appShell, body > dialog) * { font-family: var(--ui-font); }
:is(#appShell, body > dialog) :is(code, pre, kbd, samp) { font-family: ui-monospace, Consolas, monospace; }
#appShell :is(h1, h2, h3, h4) { letter-spacing: -.02em; }
#appShell .article-preview h1 { font-size: clamp(28px, 2.7vw, 36px); font-weight: 700; line-height: 1.25; letter-spacing: -.025em; }
#appShell .article-preview h2 { font-size: 24px; line-height: 1.35; font-weight: 650; }
#appShell .article-preview h3 { font-size: 20px; line-height: 1.4; }
#appShell .article-preview :is(p, li) { line-height: 1.75; }
#appShell .brand { font-weight: 700; letter-spacing: .12em; }
#appShell :is(.card-top, .block-toolbar, .cw-kicker, .publication-dock-head > div > span) { text-transform: none; letter-spacing: .02em; }
#appShell :is(.field, .cw-field) :is(input, textarea, select) { background: var(--card); border-radius: 8px; }
#appShell :is(.choice-card, .topic-card, .h1-card, .market-card, .outline-item) { background: var(--card); }
#appShell :is(.choice-card, .topic-card, .h1-card, .market-card).active,
#appShell .market-card.selected { background: var(--blue-wash); border-color: var(--blue); box-shadow: none; }
#appShell .role-explainer { background: var(--paper); border-color: var(--line); border-radius: 8px; }
#appShell .publication-dock { border-color: var(--line); }
#appShell :is(.publication-title, .publication-image-option, .draft-settings, .seo-preview) { border-radius: 8px; background: var(--paper); }
#appShell .workspace-disclosure { border-width: 0 0 1px; border-radius: 0; padding-inline: 0; }
#appShell .cw-article-tools { border-width: 1px 0 0; border-radius: 0; }
#appShell .cw-article-tools > summary { padding-inline: 0; }
#appShell .cw-article-body { padding-inline: 0; }

body > dialog { border-radius: 14px; border-color: var(--line); box-shadow: 0 20px 64px #0d172633; }
body > dialog[class] :is(h2, h3) { font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
body > dialog[class] h2 { font-size: 28px; }
body > dialog[class] h3 { font-size: 20px; }
body > dialog[class] h2 em { font-style: normal; color: inherit; }
body > dialog :is(.auth-kicker, .cw-kicker, .eyebrow) { color: var(--muted); letter-spacing: .06em; }
body > dialog :is(.button-primary, .button-secondary) { border-radius: 8px; box-shadow: none; font-weight: 600; }
body > dialog .button-primary { background: #4b5cd7; color: #fff; }
body > dialog .button-primary:hover:not(:disabled) { background: #3949bc; transform: none; }
body > dialog[class] :is(.button-primary, .button-secondary):hover { box-shadow: none; transform: none; }
body.dark > dialog .button-primary { background: #4b5cd7; color: #fff; box-shadow: none; }
body.dark > dialog .button-primary:hover:not(:disabled) { background: #3949bc; color: #fff; transform: none; }
body > dialog :is(.field, .cw-field) :is(input, textarea, select) { border-radius: 8px; background: var(--card); }
body > dialog .field > span, body > dialog .field > label { font-weight: 600; }
#authDialog { width: min(460px, calc(100% - 32px)); padding: 28px; }
#authDialog::before { display: none; }
#authDialog #authTitle { font-size: 28px; line-height: 1.25; letter-spacing: -.02em; margin: 12px 0 20px; }
#authDialog .auth-mode-buttons { gap: 4px; margin: 0 0 22px; padding: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
#authDialog .auth-mode-buttons button { border-color: transparent; min-height: 40px; background: transparent; color: var(--muted); }
#authDialog .auth-mode-buttons button[aria-pressed="true"] { border-color: var(--line); background: var(--card); color: var(--ink); }
#authDialog .auth-form { gap: 18px; }
#authDialog .auth-submit { width: 100%; min-height: 46px; }
#authDialog .auth-code-destination { background: var(--paper); border-color: var(--line); border-radius: 8px; }
#authDialog .auth-code-destination > span { font-size: 14px; }
#authDialog #authCode { font-size: 23px; font-weight: 600; min-height: 58px; letter-spacing: .28em; }
#authDialog .auth-resend { flex-wrap: wrap; gap: 8px; }
#authDialog .auth-delivery-help { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
#authDialog #authMessage:not(.error) { color: var(--muted) !important; }
#authDialog #authMessage:empty { display: none; }
#authDialog #authMessage.error { border-left: 3px solid #c45a51; padding: 10px 12px; background: color-mix(in srgb, #c45a51 7%, var(--card)); border-radius: 6px; }
#accountDialog :is(.account-data-summary, .account-danger-zone, .library-card, .account-tabs, .security-choices) { border-radius: 10px; box-shadow: none; }
#accountDialog .account-dialog-head { gap: 20px; }
#accountDialog .account-dialog-head h2 { font-size: 28px; }
#accountDialog .account-data-summary h3 { font-size: 21px; }
#accountDialog .account-tabs { padding: 4px; }
#accountDialog .account-tabs button { min-height: 44px; border-radius: 7px; box-shadow: none; }
@media (max-width: 680px) {
  #appShell .article-preview h1 { font-size: 28px; }
  #appShell .article-preview h2 { font-size: 23px; }
  #authDialog { padding: 24px 20px; }
  body > dialog[class] h2, #authDialog #authTitle, #accountDialog .account-dialog-head h2 { font-size: 25px; }
}

/* Shared layout rhythm. Keep display density separate from the readable type scale.
   The route rail deliberately retains its height-aware rules in content-workspace.css. */
#appShell .content { padding-top: var(--ui-space-6); }
body.compact-workspace #appShell .content { padding-top: var(--ui-space-6); }
#appShell .page-heading { gap: var(--ui-space-2); margin-bottom: var(--ui-space-6); }
#appShell .wizard-card { border-radius: var(--ui-radius-panel); }
#appShell .card-main { padding: var(--ui-panel-padding); }
#appShell :is(.card-top, .actions) { padding: var(--ui-space-4) var(--ui-panel-padding); gap: var(--ui-space-3); }
#appShell :is(.form-grid, .cw-grid) { gap: var(--ui-space-4); }
#appShell :is(.mode-grid, .role-grid, .h1-grid, .option-grid) { gap: var(--ui-space-3); margin-bottom: var(--ui-space-4); }
#appShell :is(.field, .cw-field) { min-width: 0; }
#appShell .field > span, #appShell .field > label { margin-bottom: var(--ui-space-2); line-height: 1.4; }
#appShell .cw-field { gap: var(--ui-space-2); margin-bottom: var(--ui-space-4); }
:is(#appShell, body > dialog) .cw-field > span { min-height: 28px; margin: 0; }
:is(#appShell, body > dialog) .cw-grid { margin-bottom: var(--ui-space-4); }
:is(#appShell, body > dialog) .cw-grid > .cw-field { margin-bottom: 0; }
#appShell :is(.field, .cw-field) :is(input:not([type="checkbox"]):not([type="radio"]), select),
body > dialog[class] :is(.field, .cw-field) :is(input:not([type="checkbox"]):not([type="radio"]), select) {
  min-height: var(--ui-control-height); height: var(--ui-control-height); padding: 9px var(--ui-space-3); line-height: 1.5;
}
:is(#appShell, body > dialog) .password-input input:not([type="checkbox"]):not([type="radio"]) { padding-right: 52px; }
#appShell :is(.field, .cw-field) textarea { padding: var(--ui-space-3); min-height: 112px; line-height: 1.6; }
#appShell :is(.button-primary, .button-secondary),
body > dialog[class] :is(.button-primary, .button-secondary) {
  min-height: var(--ui-control-height); padding: 10px var(--ui-space-4); gap: var(--ui-space-2);
  border-radius: var(--ui-radius-control); line-height: 1.5; height: auto;
}
#appShell :is(.choice-card, .topic-card, .h1-card, .market-card, .outline-item) { padding: var(--ui-space-4); border-radius: var(--ui-radius-control); }
#appShell .choice-card { min-height: 88px; display: flex; flex-direction: column; justify-content: flex-start; }
#appShell .choice-card b { padding-right: 20px; font-size: 14px; line-height: 1.45; }
#appShell .choice-card small { margin-top: var(--ui-space-1); line-height: 1.5; }
#appShell .topic-card { min-height: 128px; }
#appShell :is(.topic-card b, .h1-card b) { font-size: 18px; line-height: 1.4; letter-spacing: -.01em; }
#appShell .topic-card .topic-index { margin-bottom: var(--ui-space-3); }
#appShell :is(.topic-card p, .h1-card p) { margin: var(--ui-space-2) 0 0; line-height: 1.5; }
#appShell .brief-progress { margin-bottom: var(--ui-space-6); }
#appShell .brief-progress b { box-shadow: none; }
#appShell .brief-stage-intro { gap: var(--ui-space-3); grid-template-columns: 36px minmax(0, 1fr); margin-bottom: var(--ui-space-4); }
#appShell .brief-stage-intro > span { width: 32px; height: 32px; border-radius: var(--ui-radius-control); }
#appShell .brief-stage-intro h2 { font-size: 20px; line-height: 1.4; }
#appShell .brief-stage-intro p { margin-top: var(--ui-space-1); }
#appShell .role-explainer { margin: 0 0 var(--ui-space-6); padding: var(--ui-space-4); gap: var(--ui-space-4); }
#appShell :is(.settings-block, .seo-editor, .keyword-section, .cw-site-suggestions) { margin-top: var(--ui-space-6); }
#appShell :is(.settings-block, .seo-editor, .keyword-section-more) { padding-top: var(--ui-space-6); }
#appShell .subheading { margin: var(--ui-space-6) 0 var(--ui-space-3); gap: var(--ui-space-2); flex-wrap: wrap; }
#appShell .keyword-section-head { margin-bottom: var(--ui-space-3); gap: var(--ui-space-2); }
#appShell .query-card { padding-block: var(--ui-space-3); gap: var(--ui-space-3); }
#appShell :is(.market-list, .outline-list) { gap: var(--ui-space-3); }
#appShell :is(.analysis-summary, .form-hint, .image-quota, .visual-brief, .keyword-section-recommended) { padding: var(--ui-space-4); }
#appShell .analysis-summary { margin-bottom: var(--ui-space-6); }

/* One reading column, with tools aligned to its edges instead of nesting more cards. */
#appShell .article-preview { max-width: 780px; }
#appShell .article-block { padding: var(--ui-space-6) 0; }
#appShell .article-block:first-of-type { padding-top: 0; }
#appShell .article-block:has(.block-editor) { padding: var(--ui-space-4); }
#appShell .block-toolbar { gap: var(--ui-space-3); margin-bottom: var(--ui-space-3); flex-wrap: wrap; }
#appShell .block-toolbar > div { flex-shrink: 0; }
#appShell .article-preview :is(p, ul, ol) { margin-block: var(--ui-space-4); }
#appShell .article-preview h1 { margin-bottom: var(--ui-space-4); }
#appShell .article-preview h2 { margin: var(--ui-space-6) 0 var(--ui-space-3); }
#appShell .article-block-body > :first-child { margin-top: 0; }
#appShell .article-block-body > :last-child { margin-bottom: 0; }
#appShell .block-rewrite-options { margin-top: var(--ui-space-4); }
#appShell :is(.workspace-disclosure > summary, .block-rewrite-options > summary) { padding-block: var(--ui-space-3); }
#appShell .workspace-disclosure { margin-block: var(--ui-space-4); }
#appShell .publication-dock { max-width: none; margin: var(--ui-space-6) 0 0; padding: var(--ui-space-4); gap: var(--ui-space-4); }
#appShell .publication-dock-head { gap: var(--ui-space-4); }
#appShell .publication-dock-head h2 { margin: var(--ui-space-2) 0; font-size: 22px; }
#appShell .publication-tabs { gap: var(--ui-space-1); padding: var(--ui-space-1); }
#appShell .publication-tab { min-height: var(--ui-control-height); padding: var(--ui-space-2) var(--ui-space-3); }
#appShell .cw-article-tools { margin: var(--ui-space-6) 0 0; }
#appShell .cw-article-tools > summary { padding-block: var(--ui-space-4); }
#appShell .cw-article-tools > summary strong { margin-top: 0; font-size: 18px; line-height: 1.4; }
#appShell .cw-tool-section { padding-block: var(--ui-space-6); }

/* Dialogs use the same gutters and controls; long forms scroll within the dialog. */
body > dialog[class] { --ui-panel-padding: 24px; max-height: min(820px, calc(100dvh - 32px)); }
body > :is(.account-dialog, .setup-dialog, .new-material-dialog, .delete-account-dialog, .publication-sequence-dialog) { padding: var(--ui-panel-padding); }
body > dialog[class] .cw-dialog-header { padding: var(--ui-panel-padding); gap: var(--ui-space-4); }
body > dialog[class] .cw-dialog-body { padding: var(--ui-panel-padding); }
body > dialog[class] .cw-dialog-header h2 { margin: var(--ui-space-2) 0; }
body > dialog[class] .cw-grid { gap: var(--ui-space-4); }
body > dialog[class] .cw-field { margin-bottom: var(--ui-space-4); }
body > dialog[class] .cw-import > .cw-field { margin-bottom: 0; }
body > dialog[class] .cw-import > button[type="submit"] { margin-bottom: 0; min-height: var(--ui-control-height); }
body > dialog[class] .cw-action-with-help { display: flex; align-items: center; gap: 8px; min-width: 0; }
body > dialog[class] .cw-action-with-help > .field-help { position: relative; top: auto; right: auto; }
body > dialog[class] .cw-close {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border-radius: 10px; color: var(--muted); line-height: 1;
}
body > dialog[class] .cw-close svg { display: block; width: 18px; height: 18px; pointer-events: none; }
body > .cw-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
body > .cw-dialog .cw-dialog-header { flex-shrink: 0; }
body > .cw-dialog .cw-dialog-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#accountDialog #closeAccount { z-index: 4; }
body > dialog[class] .cw-close:hover { color: var(--ink); background: var(--paper); border-color: var(--muted); }
body > dialog[class] .cw-question { margin-bottom: var(--ui-space-6); gap: var(--ui-space-3); }
body > dialog[class] .cw-question h3 { margin-bottom: var(--ui-space-3); }
body > dialog[class] :is(.cw-fact, .cw-empty) { padding: var(--ui-space-4); }
body > dialog[class] .cw-panel-footer { padding-top: var(--ui-space-4); margin-top: var(--ui-space-6); gap: var(--ui-space-3); }
#authDialog { padding: var(--ui-panel-padding); }
#authDialog .auth-mode-buttons { margin-bottom: var(--ui-space-6); }
#authDialog .auth-form { gap: var(--ui-space-4); margin-top: var(--ui-space-6); }
#authDialog .auth-code-help { margin: -8px 0 0; }
#authDialog :is(.auth-resend, .auth-delivery-help) { margin: 0; }
#authDialog #authForgotPassword { min-height: 32px; padding: 4px 0; }
#accountDialog .account-dialog-head { padding: 0 32px var(--ui-space-6) 0; margin: 0; gap: var(--ui-space-4); }
#accountDialog .account-dialog-head h2 { margin: var(--ui-space-2) 0; }
#accountDialog .account-dialog-actions { gap: var(--ui-space-2); }
#accountDialog .account-tabs { margin-block: 0 var(--ui-space-4); }
#accountDialog .account-data-panel { margin-top: 0; gap: var(--ui-space-4); }
#accountDialog :is(.account-data-summary, .account-security, .account-danger-zone) { padding: var(--ui-space-4); }
#accountDialog #accountSecurityStatus { margin-bottom: var(--ui-space-4); padding: var(--ui-space-3); }
#accountDialog #accountSecurityForm { gap: var(--ui-space-4); margin-top: var(--ui-space-6); }
#accountDialog .library-card { padding: var(--ui-space-4); gap: var(--ui-space-4); }
#accountDialog .library-card b { font-size: 17px; line-height: 1.4; }

@media (min-width: 681px) and (max-width: 1100px) {
  #appShell .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #appShell .role-explainer { grid-template-columns: minmax(0, 1fr); }
  #appShell .role-explainer-label { padding: 0 0 var(--ui-space-3); border-right: 0; border-bottom: 1px solid var(--line); }
  #appShell .publication-dock-head { flex-direction: column; align-items: flex-start; }
}
@media (min-width: 681px) and (max-width: 900px) {
  #appShell :is(.mode-grid, .role-grid, .option-grid, .form-grid, .cw-grid) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  #appShell, body > dialog[class] { --ui-panel-padding: 16px; }
  #appShell :is(.mode-grid, .role-grid, .option-grid, .form-grid, .cw-grid) { grid-template-columns: minmax(0, 1fr); }
  #appShell :is(.choice-card, .topic-card) { min-height: 0; }
  #appShell .article-preview h1 { font-size: 28px; }
  #appShell .publication-dock { padding: var(--ui-space-3); }
  #appShell .publication-dock-head { display: flex; flex-direction: column; align-items: flex-start; }
  #appShell .publication-tab { padding-inline: var(--ui-space-2); }
  #accountDialog .account-dialog-head { gap: var(--ui-space-4); padding-bottom: var(--ui-space-4); }
  #accountDialog .account-dialog-actions { flex-wrap: wrap; }
  #authDialog { padding: 24px 20px; }
  body > dialog[class] .cw-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  body > dialog, body > dialog * { transition: none; animation: none; scroll-behavior: auto; }
}
/* Reload-safe task indicator, shared by quick and detailed workflows. */
.workflow-status {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0 0 20px;
  padding: 18px 20px;
  border: 1px solid var(--line, #dbe0ef);
  border-radius: 14px;
  background: var(--card, #f7f8ff);
  color: var(--ink, #172033);
  overflow-wrap: anywhere;
}
.workflow-status[hidden] { display: none; }
.workflow-status [hidden] { display: none !important; }
.workflow-status b { font-size: 16px; line-height: 1.45; }
.workflow-status span { font-size: 14px; line-height: 1.5; color: var(--muted, #64748b); }
.workflow-status progress { display: block; width: 100%; height: 6px; accent-color: #5260e8; }
.workflow-status .button-secondary { justify-self: start; }
.workflow-pending #wizard .task-progress,
.workflow-pending #wizard .cw-pending { display: none; }
@media (max-width: 680px) { .workflow-status { padding: 16px; margin-bottom: 16px; } }
@media (prefers-reduced-motion: reduce) { .workflow-status progress { appearance: none; background: #b4bcf5; } }
/* Section-level tools: one quiet row, shared image quota. */
#appShell .article-block-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 16px; margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--line); }
#appShell .article-block-actions :is(.block-rewrite-options, .block-image-options) { flex: 1 1 260px; min-width: 0; margin: 0; padding: 0; border: 0; }
#appShell .article-block-actions :is(.block-rewrite-options, .block-image-options) > summary { padding: 12px 0; color: var(--muted); font: 600 14px/1.5 var(--ui-font); cursor: pointer; }
#appShell .block-image-limits { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.6; }
#appShell .block-image-limits p { margin: 0 0 8px; overflow-wrap: anywhere; }
#appShell .block-image-limits .block-image-reason { color: var(--ink); }
#appShell .article-block-image-action { min-height: 44px; max-width: 100%; padding: 11px 18px; border: 1px solid #4b5cd7; border-radius: 8px; background: #4b5cd7; color: #fff; box-shadow: 0 3px 9px #4b5cd71a; white-space: normal; font: 600 14px/1.5 var(--ui-font); cursor: pointer; transition: background-color .16s, border-color .16s, box-shadow .16s; }
#appShell .article-block-image-action:hover:not(:disabled) { background: #3949bc; border-color: #3949bc; box-shadow: 0 4px 12px #4b5cd726; }
#appShell .article-block-image-action:active:not(:disabled) { background: #303fa8; border-color: #303fa8; box-shadow: none; }
#appShell .article-block-image-action:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
#appShell .article-block-image-action:disabled { background: var(--paper); border-color: var(--line); color: var(--muted); box-shadow: none; opacity: 1; cursor: not-allowed; }
#newMaterialSummary[data-kind="article"] { border-color: var(--line); background: var(--card); }
#newMaterialSummary[data-kind="article"] > span { color: var(--blue); }
@media (prefers-reduced-motion: reduce) { #appShell .article-block-image-action { transition: none; } }

/* Mobile audit: account data wraps instead of widening or clipping the dialog. */
#accountDialog :is(.account-dialog-head, .account-dialog-head > div, .account-identity-card > div) { min-width: 0; }
#accountDialog :is(#accountEmail, #accountDataEmail) { overflow-wrap: anywhere; }
body > dialog { overscroll-behavior: contain; }
@media (max-width: 680px) {
  #accountDialog .account-dialog-head { padding: 0 0 16px; align-items: stretch; }
  #accountDialog .account-dialog-head :is(.auth-kicker, h2) { padding-right: 40px; }
  #accountDialog .account-dialog-actions { width: 100%; grid-template-columns: minmax(0, 1fr) auto; }
  #accountDialog .account-dialog-actions button { min-width: 0; min-height: 44px; gap: 8px; padding-inline: 12px; white-space: normal; }
  #authDialog :is(#authForgotPassword, #authChangeEmail), #accountPasswordRecovery { min-height: 44px; padding-block: 10px; }
  body > .cw-dialog .cw-close { width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex-shrink: 0; }
  #publicationSequenceDialog .quiet-button { min-height: 44px; }
}
@media (max-width: 360px) {
  #accountDialog .account-dialog-actions { grid-template-columns: minmax(0, 1fr); }
}
body.support-chat-ready #articleScrollControls { position: fixed; display: grid; right: max(14px, env(safe-area-inset-right)); bottom: var(--support-controls-bottom, 86px); width: auto; max-width: none; margin: 0; }
body.support-chat-open .article-scroll-controls { visibility: hidden; pointer-events: none; }
