/* The dedicated agent surface inherits Polxy's ink, paper and signal palette. */
body.app-mode[data-active-view="polxy"] > .app-shell > main {
  display: block !important;
  min-width: 0;
  padding: 24px 76px 24px 28px !important;
}
#polxy-agent-page {
  --agent-ink: #08090d;
  --agent-paper: #fffaf2;
  --agent-line: #d8d3c9;
  color: var(--agent-ink);
  min-width: 0;
  width: 100%;
  height: calc(100dvh - 48px);
  min-height: 560px;
}
#polxy-agent-page.active { display: flex !important; flex-direction: column; gap: 18px; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page { padding: 0 !important; background: transparent !important; }
#polxy-agent-page .polxy-agent-toolbar { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 0 4px; }
#polxy-agent-page h1 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -0.025em; }
#polxy-agent-page .polxy-agent-project { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 650; }
#polxy-agent-page select { width: min(240px, 26vw); min-height: 44px; background: var(--agent-paper); border: 1px solid var(--agent-ink); padding: 8px 30px 8px 12px; font: inherit; color: inherit; }
#polxy-agent-page .polxy-agent-page-actions { display: flex; gap: 8px; margin-left: auto; }
#polxy-agent-page button { min-height: 44px; font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0; }
#polxy-agent-page .polxy-agent-page-actions button { background: var(--agent-paper); border: 1px solid var(--agent-ink); border-radius: 0; padding: 8px 14px; color: var(--agent-ink); box-shadow: none; }
#polxy-agent-page #polxy-agent-new-chat { background: #dfff3f; }
#polxy-agent-page .polxy-agent-page-layout { display: flex; flex: 1; min-height: 0; gap: 20px; }
#polxy-agent-page .polxy-agent-conversation-host { flex: 1; min-width: 0; min-height: 0; }
#polxy-agent-page .polxy-agent-history { flex: 0 0 236px; background: var(--agent-paper); border: 1px solid var(--agent-ink); padding: 16px; overflow-y: auto; }
#polxy-agent-page .polxy-agent-history[hidden] { display: none; }
#polxy-agent-page .polxy-agent-history h2 { font-size: 16px; margin: 0 0 12px; }
#polxy-agent-page .polxy-agent-history p { font-size: 12px; line-height: 1.5; }
#polxy-agent-history-list { margin-top: 18px; }
#polxy-agent-history-list button { display: grid; width: 100%; text-align: left; gap: 7px; padding: 12px 8px; background: transparent; border: 0; border-bottom: 1px solid #d8d3c9; box-shadow: none; border-radius: 0; }
#polxy-agent-history-list button[aria-current] { background: #e5f6f6; }
#polxy-agent-history-list strong { line-height: 1.45; overflow-wrap: anywhere; }
#polxy-agent-history-list small { font-weight: 400; font-size: 11px; }
#polxy-agent-history-refresh { background: transparent; border: 0; text-decoration: underline; text-underline-offset: 4px; padding: 0; box-shadow: none; }

/* Override the legacy modal geometry only while the same DOM is inline. */
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog.dashboard-answer-dialog {
  position: relative !important; inset: auto !important; display: block !important;
  width: 100% !important; max-width: none !important; min-width: 0 !important;
  height: 100% !important; max-height: none !important; min-height: 0 !important;
  margin: 0 !important; padding: 0 !important; transform: none !important;
  border: 2px solid #08090d !important; border-radius: 0 !important; box-shadow: 5px 5px 0 #08090d !important;
  background: #fffaf2 !important; color: #08090d !important; overflow: hidden !important;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-modal {
  position: relative !important; display: flex !important; flex-direction: column !important;
  width: 100% !important; max-width: none !important; min-width: 0 !important;
  height: 100% !important; min-height: 0 !important; max-height: none !important;
  padding: 0 !important; gap: 0 !important; overflow: hidden !important; background: #fffaf2 !important;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog.dashboard-answer-dialog.is-polxy-console .dashboard-answer-modal > header {
  display: flex !important; flex: 0 0 auto; justify-content: flex-end !important;
  align-items: center !important; height: auto !important; min-height: 48px !important; padding: 8px 22px !important;
  border: 0 !important; background: transparent !important; box-shadow: none !important;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-modal > header > div:first-child,
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .polxy-answer-window-actions,
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-question,
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-context,
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog #dashboard-answer-history { display: none !important; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog.dashboard-answer-dialog.is-polxy-console.polxy-agent-empty .dashboard-answer-modal > header { display: none !important; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-body {
  position: relative !important; flex: 1 1 0; width: 100% !important; max-width: 100% !important;
  min-height: 0 !important; height: auto !important; max-height: none !important;
  overflow: auto !important; margin: 0 !important; padding: 20px 32px !important;
  background: transparent !important; border: 0 !important; border-radius: 0 !important;
  scrollbar-color: #7b8587 #fffaf2; scrollbar-width: thin; scroll-padding-block: 24px;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .polxy-console-thread { width: min(100%, 840px) !important; max-width: 100% !important; margin: 0 auto !important; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-recommendations {
  flex: 0 0 auto; max-height: 28vh !important; overflow-y: auto !important; padding: 12px 24px !important;
  border: 0 !important; border-top: 1px solid #d8d3c9 !important; background: #fffaf2 !important;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog.is-actions-collapsed .dashboard-answer-recommendations { display: none !important; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .polxy-answer-composer {
  position: relative !important; inset: auto !important; flex: 0 0 auto; display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important; gap: 8px 12px !important;
  width: min(840px, calc(100% - 48px)) !important; max-width: 100% !important; min-width: 0 !important;
  margin: 12px auto 24px !important; padding: 14px 16px !important; transform: none !important;
  background: #fffaf2 !important; border: 1px solid #08090d !important; border-radius: 0 !important; box-shadow: none !important;
}
#dashboard-answer-dialog .polxy-agent-context-row { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 11px; line-height: 1.4; }
#dashboard-answer-dialog .polxy-agent-context-row button { border: 0; background: transparent; box-shadow: none; min-height: 30px; padding: 0 4px; text-decoration: underline; font-size: 11px; }
#dashboard-answer-dialog .polxy-agent-input-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#dashboard-answer-dialog .polxy-agent-composer-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; grid-column: 1; }
#dashboard-answer-dialog .polxy-agent-composer-tools button { background: transparent; color: #08090d; border: 0; border-radius: 0; box-shadow: none; min-height: 34px; padding: 4px 0; font-size: 11px; text-transform: none; letter-spacing: 0; }
#dashboard-answer-dialog #polxy-agent-draft-status { font-size: 11px; line-height: 1.4; }
#dashboard-answer-dialog .polxy-agent-attachments { display: flex; gap: 8px; flex-wrap: wrap; grid-column: 1 / -1; }
#dashboard-answer-dialog .polxy-agent-attachments:empty { display: none; }
#dashboard-answer-dialog .polxy-agent-attachments button { font-size: 11px; min-height: 32px; background: #e5f6f6; border: 1px solid #08090d; color: #08090d; box-shadow: none; padding: 4px 8px; overflow-wrap: anywhere; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog #dashboard-answer-followup-input {
  grid-column: 1 / -1 !important; width: 100% !important; min-width: 0 !important; min-height: 66px !important;
  max-height: 180px !important; margin: 0 !important; padding: 10px 0 !important;
  background: transparent !important; color: #08090d !important; border: 0 !important; border-radius: 0 !important;
  font-size: 16px !important; line-height: 1.5 !important; resize: vertical; box-shadow: none !important;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog #dashboard-answer-submit {
  grid-column: 2 !important; grid-row: 3 !important; min-width: 86px !important; min-height: 44px !important;
  background: #dfff3f !important; color: #08090d !important; border: 1px solid #08090d !important; border-radius: 0 !important;
  padding: 10px 18px !important; box-shadow: 2px 2px 0 #08090d !important; font-size: 13px !important;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog #dashboard-answer-submit.is-stop { background: #ff7777 !important; }
#dashboard-answer-dialog .polxy-agent-welcome { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 40px 12px; }
#dashboard-answer-dialog .polxy-agent-welcome h2 { max-width: 18ch; font-size: clamp(28px, 3vw, 42px); font-weight: 900; line-height: 1.15; letter-spacing: -0.025em; color: #08090d; margin: 0 0 16px; }
#dashboard-answer-dialog .polxy-agent-welcome p { max-width: 45ch; font-size: 15px; line-height: 1.6; color: #384346; }
#dashboard-answer-dialog .polxy-agent-starters { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
#dashboard-answer-dialog .polxy-agent-starters button { min-height: 44px; background: transparent; color: #08090d; border: 1px solid #b5b6ae; border-radius: 0; box-shadow: none; padding: 10px 14px; font-size: 12px; text-transform: none; }
#polxy-agent-page :is(button, select):focus-visible,
#dashboard-answer-dialog :is(.polxy-agent-starters button, .polxy-agent-composer-tools button, textarea):focus-visible { outline: 3px solid #247d8e !important; outline-offset: 3px; }
#polxy-agent-page button:disabled { opacity: .55; cursor: wait; }
#polxy-agent-page button:not(:disabled):hover { filter: brightness(.97); }
#dashboard-answer-dialog ::selection { background: #dfff3f; color: #08090d; }
body.app-mode .sidebar-bottom-actions .nav-item { width: 100%; min-height: 44px; }
html body.app-mode #dashboard-answer-dialog:not([data-agent-presentation="page"]) #polxy-agent-open-page { min-height: 40px; padding: 8px 12px; font-size: 12px; }
html body.app-mode #dashboard-answer-dialog:not([data-agent-presentation="page"]) #dashboard-answer-followup-form { flex-wrap: wrap !important; }
html body.app-mode #dashboard-answer-dialog:not([data-agent-presentation="page"]) .polxy-agent-context-row,
html body.app-mode #dashboard-answer-dialog:not([data-agent-presentation="page"]) .polxy-agent-attachments { flex-basis: 100%; }
html body.app-mode #dashboard-answer-dialog:not([data-agent-presentation="page"]) .polxy-agent-composer-tools { flex-basis: calc(100% - 100px); }

/* These controls sit on paper in both themes, including under global dark header rules. */
html[data-polxy-theme="calm-monochrome"] body.app-mode #polxy-agent-page .polxy-agent-toolbar,
html[data-polxy-theme="calm-monochrome"] body.app-mode #polxy-agent-page .polxy-agent-toolbar :is(h1, label, span, select) {
  background: #fffaf2 !important; color: #08090d !important; box-shadow: none !important;
}
html[data-polxy-theme="calm-monochrome"] body.app-mode #polxy-agent-page #polxy-agent-new-chat,
html[data-polxy-theme="calm-monochrome"] body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog #dashboard-answer-submit {
  background: #08090d !important; color: #fffaf2 !important;
}
html[data-polxy-theme="calm-monochrome"] body.app-mode #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-modal > header :is(button, b, span),
html[data-polxy-theme="calm-monochrome"] body.app-mode #polxy-agent-page #dashboard-answer-dialog .polxy-agent-welcome :is(h2, p, button),
html[data-polxy-theme="calm-monochrome"] body.app-mode #polxy-agent-page .polxy-agent-history :is(h2, p, strong, small, button) {
  color: #08090d !important; -webkit-text-fill-color: #08090d !important; background: transparent !important;
}
html[data-polxy-theme="calm-monochrome"] body.app-mode #polxy-agent-page #dashboard-answer-dialog #dashboard-answer-submit.is-stop { background: #ff7777 !important; color: #08090d !important; }

@media (max-width: 820px) {
  body.app-mode[data-active-view="polxy"] > .app-shell > main { padding: 66px 12px 16px !important; }
  #polxy-agent-page { height: calc(100dvh - 82px); min-height: 500px; }
  #polxy-agent-page .polxy-agent-toolbar { gap: 10px; }
  #polxy-agent-page h1 { font-size: 23px; }
  #polxy-agent-page .polxy-agent-project { margin-left: auto; white-space: nowrap; }
  #polxy-agent-page select { width: 180px; max-width: 46vw; }
  #polxy-agent-page .polxy-agent-page-actions { margin-left: 0; width: 100%; }
  #polxy-agent-page .polxy-agent-page-actions button { flex: 1; }
  #polxy-agent-page .polxy-agent-page-layout { position: relative; }
  #polxy-agent-page .polxy-agent-history { position: absolute; z-index: 5; inset: 0; flex-basis: auto; }
  html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-body { padding: 16px !important; }
  html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .polxy-answer-composer { width: calc(100% - 24px) !important; margin: 8px auto 16px !important; padding: 12px !important; }
  #dashboard-answer-dialog .polxy-agent-welcome { padding: 20px 0; }
  #dashboard-answer-dialog .polxy-agent-welcome h2 { font-size: 28px; }
  #dashboard-answer-dialog .polxy-agent-starters { margin-top: 16px; gap: 8px; }
  #dashboard-answer-dialog .polxy-agent-starters button { font-size: 11px; padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  #polxy-agent-page *, #dashboard-answer-dialog .polxy-agent-welcome * { scroll-behavior: auto !important; transition: none !important; }
}

/* Polxy's character welcomes new conversations, then leaves room for the work. */
#polxy-agent-page .polxy-agent-toolbar h1 { display: flex; align-items: center; gap: 10px; }
#polxy-agent-page .polxy-character-avatar { width: 40px; height: 40px; object-fit: cover; object-position: center 25%; border-radius: 12px; background: #fff; }
#polxy-agent-page[data-character-state="welcome"] .polxy-character-avatar { display: none; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog.dashboard-answer-dialog {
  border: 1px solid #d8d3c9 !important; border-radius: 16px !important; box-shadow: none !important; background: #fff !important;
}
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .dashboard-answer-modal { background: #fff !important; }
#dashboard-answer-dialog .polxy-character-welcome { display: grid; grid-template-columns: minmax(150px, 260px) minmax(0, 1fr); gap: 44px; max-width: 820px; min-height: 100%; margin: auto; padding: 20px 0; text-align: left; }
#dashboard-answer-dialog .polxy-character-portrait { position: relative; width: 100%; max-width: 260px; aspect-ratio: 3 / 4; margin: 0; justify-self: center; align-self: center; background: transparent; }
#dashboard-answer-dialog .polxy-character-portrait :is(picture, img) { display: block; width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; }
#dashboard-answer-dialog .polxy-character-intro h2 { max-width: 19ch; font-size: 38px; line-height: 1.13; font-weight: 850; letter-spacing: -0.03em; margin: 0 0 20px; text-wrap: balance; }
#dashboard-answer-dialog .polxy-character-intro p { max-width: 42ch; margin: 0; font-size: 15px; line-height: 1.65; color: #384346; }
#dashboard-answer-dialog .polxy-character-intro .polxy-agent-starters { justify-content: flex-start; gap: 8px; margin-top: 26px; }
#dashboard-answer-dialog .polxy-character-intro .polxy-agent-starters button { border-color: #d8d3c9; border-radius: 10px; font-size: 12px; padding: 10px 12px; background: #fffaf2; transition: background-color 150ms ease-out, border-color 150ms ease-out; }
#dashboard-answer-dialog .polxy-character-intro .polxy-agent-starters button:hover { background: #f0f5d7; border-color: #687451; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog .polxy-answer-composer { border-color: #b5b6ae !important; border-radius: 12px !important; background: #fffaf2 !important; }
html body.app-mode[data-active-view="polxy"] #polxy-agent-page #dashboard-answer-dialog #dashboard-answer-submit { border-radius: 8px !important; box-shadow: none !important; }
#dashboard-answer-dialog:not([data-agent-presentation="page"]) .polxy-character-welcome { grid-template-columns: 110px minmax(0, 1fr); gap: 22px; min-height: 0; }
#dashboard-answer-dialog:not([data-agent-presentation="page"]) .polxy-character-intro h2 { font-size: 26px; }
@media (min-width: 821px) and (max-height: 760px) {
  #dashboard-answer-dialog .polxy-character-welcome { grid-template-columns: 190px minmax(0, 1fr); padding-block: 6px; }
  #dashboard-answer-dialog .polxy-character-intro h2 { font-size: 32px; }
}
@media (max-width: 820px) {
  #dashboard-answer-dialog .polxy-character-welcome { grid-template-columns: 1fr; gap: 16px; padding: 0; text-align: center; }
  #dashboard-answer-dialog .polxy-character-portrait { width: 135px; }
  #dashboard-answer-dialog .polxy-character-intro h2 { font-size: 27px; line-height: 1.16; margin: 0 auto 12px; }
  #dashboard-answer-dialog .polxy-character-intro p { font-size: 14px; max-width: 38ch; margin: 0 auto; }
  #dashboard-answer-dialog .polxy-character-intro .polxy-agent-starters { justify-content: center; margin-top: 16px; gap: 6px; }
  #dashboard-answer-dialog .polxy-character-intro .polxy-agent-starters button { font-size: 11px; min-height: 40px; padding: 8px 9px; }
}

html body.app-mode #polxy-agent-page #dashboard-answer-dialog #polxy-character-description { font-size: 15px !important; font-weight: 450 !important; line-height: 1.65 !important; }
@media (max-width: 820px) {
  html body.app-mode #polxy-agent-page #dashboard-answer-dialog #polxy-character-description { font-size: 14px !important; }
}

@media (max-width: 820px) {
  #polxy-agent-page .polxy-agent-project { flex: 0 1 auto !important; width: auto !important; font-size: 12px !important; }
  #polxy-agent-page .polxy-agent-project select { width: 165px !important; max-width: 44vw !important; min-width: 0 !important; }
  #polxy-agent-page .polxy-agent-page-actions button { min-width: 0; white-space: nowrap; font-size: 11px; padding: 8px 6px; }
}
/* Owned uploads use the same in-chat schedule review as generated media. */
.polxy-image-proposal .polxy-owned-media-preview {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 16px 0;
  object-fit: contain;
}

#dashboard-answer-dialog .polxy-production-assets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 20px;
  margin-top: 16px;
}
#dashboard-answer-dialog .polxy-production-assets > div { min-width: 0; }
#dashboard-answer-dialog .polxy-production-assets .polxy-owned-media-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
}
