/* Approved follow-up windows. Keep page layouts owned by their existing modules. */
dialog, .entry-hover, .mail-context-preview, .agenda-tooltip.is-rich, .idea-shortcut-popup {
  --window-surface: #fff;
  --window-accent: var(--theme-accent);
  --window-band: var(--theme-accent-soft);
}
:root[data-theme=dark] :is(dialog,.entry-hover,.mail-context-preview,.agenda-tooltip.is-rich,.idea-shortcut-popup) {
  --window-surface: var(--theme-panel);
}
:root[data-theme] dialog, :root[data-theme] :is(#editor,#entry-editor) {
  --surface: var(--window-surface);
  background: var(--surface);
  color: var(--ink);
}
dialog:is(.mail-dialog,.mail-compose,.mail-context-drawer,.stats-items-dialog),
dialog[data-item-type=note] {
  --window-accent: var(--theme-blue-ink);
  --window-band: var(--theme-blue-soft);
}
dialog:is(.pl-dialog,.co-dialog), dialog[data-item-type=event] {
  --window-accent: var(--theme-violet);
  --window-band: var(--theme-violet-soft);
}
dialog.people-editor, dialog.people-picker {
  --window-accent: var(--theme-blue-ink);
  --window-band: var(--theme-blue-soft);
}
dialog[data-item-type=milestone], dialog:has([data-form=milestone],[data-form=p-milestone]) {
  --window-accent: var(--theme-gold);
  --window-band: var(--theme-gold-soft);
}
dialog:has([data-form=project-delete]), dialog.ask-dialog:has(.danger-solid) {
  --window-accent: var(--theme-coral);
  --window-band: var(--theme-coral-soft);
}
/* Bands stop at the heading: forms and reading surfaces stay white. */
:root[data-theme] dialog > :is(header,.p-dialog-head),
:root[data-theme] dialog :is(.editor-head,.mail-context-head,.pl-dialog-head) {
  background: var(--window-band);
  border-bottom: 1px solid color-mix(in srgb,var(--window-accent) 18%,var(--line));
}
:root[data-theme] dialog :is(header,.p-dialog-head,.editor-head) :is(h2,h3) {
  color: var(--ink);
}
dialog :is(.editor-head,.p-dialog-head,.co-dialog-header,.pl-dialog-head,.mail-context-head) h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
dialog :is(.editor-head,.p-dialog-head,.co-dialog-header,.pl-dialog-head,.mail-context-head) h2 > .icon {
  width: 28px;
  height: 28px;
  color: var(--window-accent);
  flex: none;
}
:root[data-theme] dialog :is(.editor-head,.p-dialog-head,.pl-dialog-head,.mail-context-head) > .icon-btn {
  color: var(--window-accent);
  background: transparent;
}
dialog :is(.editor-body,.pl-dialog-body,.p-inline-form,.compose-body) { min-width: 0; }
dialog[data-p-dialog] > form.panel { margin: 0; padding: 0; border: 0; border-radius:0; box-shadow: none; background: var(--surface); }
dialog[data-p-dialog] > form.panel > :is(h2,h3):first-child { display: none; }
:root[data-theme] dialog[data-p-dialog] > form.p-project-form { display: flex; flex-direction: column; gap: 16px; }
dialog[data-p-dialog]:has(> .p-project-form) { --dialog-width: 720px; }
dialog .p-project-form > .fields-two:first-child { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
dialog .p-project-wait { border: 1px solid var(--line); border-radius:var(--radius-card,8px); padding: 14px; }
dialog .p-project-wait > h3 { display: flex; align-items: center; gap: 8px; margin: -14px -14px 14px; padding: 12px 14px; border-radius:var(--radius-control,6px) var(--radius-control,6px) 0 0; background: var(--theme-gold-soft); color: var(--theme-gold); font: 700 18px/1.4 var(--font-heading); }
dialog .p-project-wait > .field { margin-bottom: 0; }
dialog .project-actions { position: sticky; bottom: -24px; margin-top: 10px; padding: 16px 0 24px; background: var(--surface); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; z-index: 2; }
dialog .project-actions > .primary { order: 2; margin-left: auto; }
dialog.mail-compose:has([data-compose-form]) { --dialog-width: 820px; --window-band: var(--theme-accent-soft); --window-accent: var(--theme-accent); }
dialog.mail-compose [data-compose-form] > fieldset > section { padding: 14px; border: 1px solid var(--line); border-radius:var(--radius-card,8px); margin: 0 0 16px; }
dialog.mail-compose section > strong { display: block; margin: -14px -14px 12px; padding: 12px 14px; border-radius:var(--radius-control,6px) var(--radius-control,6px) 0 0; background: var(--theme-gold-soft); font: 700 17px/1.4 var(--font-heading); }
dialog.mail-compose .compose-associations > strong { background: var(--theme-blue-soft); }
dialog.mail-compose .compose-associations .fields-two { grid-template-columns: 1fr; }
dialog.mail-compose [data-compose-form] > .mail-toolbar { position: sticky; bottom: -24px; padding: 14px 0 24px; border-top: 1px solid var(--line); background: var(--surface); }
dialog.mail-compose [data-compose-form] > .mail-toolbar > .primary { margin-left: auto; order: 3; }
@media(min-width:1000px) {
  dialog.mail-compose [data-compose-form] > fieldset { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(230px,1fr); gap: 0 20px; align-items: start; }
  dialog.mail-compose [data-compose-form] > fieldset > :is(.field,.fields-two) { grid-column: 1; }
  dialog.mail-compose [data-compose-form] > fieldset > .compose-associations { grid-column: 2; grid-row: 1 / 5; }
  dialog.mail-compose [data-compose-form] > fieldset > section:not(.compose-associations) { grid-column: 2; grid-row: 5 / 7; }
}
dialog .field { line-height: 1.5; }
dialog .field :is(input:not([type=checkbox],[type=range]),select,textarea) {
  border-radius:var(--radius-control,6px);
  background: var(--surface);
  border-color: var(--line);
}
dialog :is(input,select,textarea,button,summary):focus-visible {
  outline: 2px solid var(--window-accent);
  outline-offset: 3px;
}
dialog :is(.editor-foot,.pl-dialog-footer,.co-actions,.compose-foot) {
  gap: 10px;
  border-color: var(--line);
}
dialog :is(.editor-foot,.pl-dialog-footer,.compose-foot) {
  background: var(--surface);
}
dialog :is(.editor-foot,.pl-dialog-footer,.compose-foot) .btn { min-height: 42px; }
dialog :is(.helper,.editor-subtitle) { line-height: 1.55; }

/* Complete item editors retain the same mounted form, dock and expansion controls. */
:root :is(#editor,#entry-editor).editor-workspace .editor-head {
  background: var(--window-band);
  align-items: center;
}
:root :is(#editor,#entry-editor).editor-workspace .editor-heading h2 {
  display: flex;
  gap: 12px;
  align-items: center;
  font: 700 24px/1.3 var(--font-heading);
}
.editor-heading h2 > .icon { width: 30px; height: 30px; color: var(--window-accent); flex: none; }
:is(#editor,#entry-editor) .editor-subtitle { margin-top: 4px; font-size: 13px; }
#entry-editor .editor-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
#entry-editor .entry-links { padding: 14px; border: 1px solid var(--line); border-radius:var(--radius-card,8px); background: var(--surface); }
#entry-editor .entry-links > summary { margin: -14px -14px 14px; padding: 12px 14px; min-height: 44px; border-radius:var(--radius-control,6px) var(--radius-control,6px) 0 0; background: var(--theme-blue-soft); color: var(--theme-blue-ink); font: 700 16px/1.5 var(--font-heading); }
:is(#editor,#entry-editor).editor-workspace .editor-section,
:is(#editor,#entry-editor).editor-workspace .editor-advanced {
  --section-band: var(--window-band);
  --section-accent: var(--window-accent);
  border: 1px solid var(--line);
  border-radius:var(--radius-card,8px);
  background: var(--surface);
  margin-bottom: 12px;
}
:is(#editor,#entry-editor).editor-workspace .editor-section > summary,
:is(#editor,#entry-editor).editor-workspace .editor-advanced > summary {
  background: var(--section-band);
  padding: 12px 14px;
  border-radius:var(--radius-control,6px);
  min-height: 48px;
  font-family: var(--font-heading);
  font-size: 16px;
}
:is(#editor,#entry-editor).editor-workspace .editor-section[open] > summary,
:is(#editor,#entry-editor).editor-workspace .editor-advanced[open] > summary { border-radius:var(--radius-control,6px) var(--radius-control,6px) 0 0; }
:is(#editor,#entry-editor).editor-workspace .editor-section > summary > .icon { color: var(--section-accent); }
:is(#editor,#entry-editor) .editor-section summary small { font-family: var(--font-body); }
:is(#editor,#entry-editor).editor-workspace .editor-section-body { padding: 16px 14px; }
:is(#editor,#entry-editor).editor-workspace .advanced-body { padding: 12px; }
:is(#editor,#entry-editor).editor-workspace .editor-subtasks {
  --section-band: var(--theme-blue-soft); --section-accent: var(--theme-blue-ink);
}
:is(#editor,#entry-editor).editor-workspace .editor-attachments {
  --section-band: var(--theme-gold-soft); --section-accent: var(--theme-gold);
}
:is(#editor,#entry-editor).editor-workspace .editor-advanced {
  --section-band: var(--theme-violet-soft); --section-accent: var(--theme-violet);
}
:is(#editor,#entry-editor) .editor-project-extra { margin: 0; }
:is(#editor,#entry-editor).editor-workspace .subtask-options { border: 0; margin-bottom: 0; }
:is(#editor,#entry-editor).editor-workspace .subtask-options > summary {
  padding: 7px; min-height: 36px; background: transparent;
}
:is(#editor,#entry-editor).editor-workspace .subtask-options .editor-section-body { padding: 14px; }
:is(#editor,#entry-editor).editor-workspace .editor-addon { margin-bottom: 12px; }
:is(#editor,#entry-editor).editor-workspace .editor-supplements > .editor-addon > .editor-section-body { padding: 16px; }
:root :is(#editor,#entry-editor)[data-editor-mode=page] .editor-head { background: var(--window-band); }
:root :is(#editor,#entry-editor)[data-editor-mode=page] .editor-properties { background: var(--surface); }

/* On wide screens, the selected window has a primary column and a properties column. */
@media(min-width:1200px) {
  body.editor-docked { --editor-dock-width: min(940px,calc(100vw - 280px)); }
  body.editor-docked .app-shell .main { margin-right: 0; }
  :root :is(#editor,#entry-editor).editor-workspace:not([data-editor-mode=page]) {
    inset: 16px 16px 16px auto;
    height: calc(100dvh - 32px);
    border: 1px solid var(--line);
    border-radius:var(--radius-dialog,12px);
    box-shadow: var(--theme-dialog-shadow);
  }
  :root :is(#editor,#entry-editor).editor-workspace:not([data-editor-mode=page]) .editor-body {
    display: grid;
    grid-template-columns: minmax(0,1.35fr) minmax(260px,1fr);
    gap: 22px;
    padding: 22px;
    align-items: start;
  }
  :is(#editor,#entry-editor)[data-editor-mode=panel] .editor-properties > h3 {
    display: block; margin: 0 0 14px; font: 700 22px/1.3 var(--font-heading);
  }
  :is(#editor,#entry-editor)[data-editor-mode=panel] .editor-project .editor-section-body { grid-template-columns: 1fr; }
  :is(#editor,#entry-editor)[data-editor-mode=panel] .editor-project .editor-section-body > * { grid-column: 1; }
  :root :is(#editor,#entry-editor)[data-editor-mode=panel] .editor-head { padding: 18px 22px; }
  /* Authored entries have a single content form, rather than item property columns. */
  :root #entry-editor.editor-workspace:not([data-editor-mode=page]) { width: min(640px,calc(100vw - 32px)); }
  :root #entry-editor.editor-workspace:not([data-editor-mode=page]) .editor-body { display: flex; flex-direction: column; align-items: stretch; gap: 18px; }
}

/* Contextual summaries and anchored menus use the same band/body distinction. */
:root[data-theme] :is(.entry-hover,.mail-context-preview,.agenda-tooltip.is-rich,.idea-shortcut-popup) {
  background: var(--window-surface);
  border-color: var(--line);
  border-radius:var(--radius,10px);
  box-shadow: var(--theme-popover-shadow);
}
.entry-hover .entry-hover-heading {
  background: var(--window-band);
  margin: -18px -18px 14px;
  padding: 16px 18px;
  border-radius:var(--radius-card,8px) var(--radius-card,8px) 0 0;
}
.agenda-tooltip.is-rich > header {
  margin: -14px -16px 8px;
  padding: 13px 16px;
  border-radius:var(--radius-card,8px) var(--radius-card,8px) 0 0;
  background: var(--window-band);
}
.mail-context-preview > header { background: var(--window-band); color: var(--teal); margin: -14px -14px 8px; padding: 13px 14px; border-radius:var(--radius-card,8px) var(--radius-card,8px) 0 0; }
.idea-shortcut-popup .idea-shortcut-heading { background: var(--window-band); margin: -16px -16px 10px; padding: 12px 16px; border-radius:var(--radius-card,8px) var(--radius-card,8px) 0 0; }
.idea-shortcut-popup .idea-shortcut-heading strong { font: 700 18px/1.4 var(--font-heading); }
dialog.ask-dialog {
  border-radius:var(--radius-dialog,12px);
  border: 1px solid var(--line);
  box-shadow: var(--theme-dialog-shadow);
}
dialog.ask-dialog .ask-form { padding: 24px; }
dialog.ask-dialog .ask-form > h2 {
  background: var(--window-band);
  margin: -24px -24px 20px;
  padding: 20px 24px;
  border-radius:var(--radius,10px) var(--radius,10px) 0 0;
  border-bottom: 1px solid var(--line);
  font: 700 22px/1.3 var(--font-heading);
}
@media(max-width:700px) {
  dialog .p-project-form > .fields-two:first-child { grid-template-columns: 1fr; }
  :root :is(#editor,#entry-editor).editor-workspace .editor-heading h2 { font-size: 21px; gap: 9px; }
  .editor-heading h2 > .icon { width: 25px; height: 25px; }
  dialog :is(.editor-head,.p-dialog-head,.co-dialog-header,.pl-dialog-head,.mail-context-head) h2 > .icon { width: 24px; height: 24px; }
  :is(#editor,#entry-editor).editor-workspace .editor-body { gap: 18px; }
  :is(#editor,#entry-editor).editor-workspace .editor-section-body { padding: 14px 12px; }
  :is(#editor,#entry-editor).editor-workspace .editor-section > summary { padding: 12px; }
  dialog .fields-two { min-width: 0; }
}
