.xr-editorials-edit { max-width: 1000px; padding: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.xr-editorials-edit .xr-page-title a { color: var(--text-secondary); text-decoration: none; }
.xr-editorials-edit .xr-page-title a:hover { color: var(--text-primary); }
/* The form body is one card with a vertical rhythm (crud.css caps a page card at 900px). */
.xr-crud-page-card.xr-editorials-card { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 1000px; }
.xr-editorials-sitebar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.xr-editorials-sitebar .xr-crud-input { width: auto; min-width: 220px; }
.xr-editorials-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.xr-editorials-filters label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted, inherit); }
.xr-editorials-flags { display: block; text-align: center; }
.xr-editorials-actions { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.xr-editorials-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.xr-editorials-row > .xr-crud-field { min-width: 200px; }
.xr-editorials-grow { flex: 1; min-width: 260px; }
.xr-editorials-block { border: 1px solid var(--border-subtle); border-radius: 4px; padding: 10px; margin: 0; }
.xr-editorials-block > summary { cursor: pointer; font-weight: 600; }
.xr-editorials-code { width: 100%; margin-top: var(--sp-2); }
/* Authoring entry stays distinct from the delivery/provider form fields. */
.xr-editorials-studio-entry {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 18px; margin-bottom: 16px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md, 10px); background: var(--bg-surface-sunken);
}
.xr-editorials-studio-entry > strong { font-size: 15px; font-weight: 650; color: var(--text-primary); }
.xr-editorials-studio-entry .xr-crud-help { margin: 0; max-width: 72ch; line-height: 1.65; }
.xr-editorials-studio-entry .xr-btn-primary { display: inline-flex; align-items: center; min-height: 38px; text-decoration: none; }
.xr-editorials-studio-entry .xr-btn-primary:focus-visible { outline: 2px solid var(--ring, var(--accent)); outline-offset: 3px; }
@media (max-width: 600px) {
  .xr-editorials-studio-entry { padding: 14px; }
  .xr-editorials-studio-entry .xr-btn-primary { min-height: 42px; }
}
/* "Standalone offer" (Yal): the offer picker and what depends on it. */
.xr-editorials-yal { display: flex; flex-direction: column; gap: var(--sp-3); border: 1px solid var(--border-default); border-radius: var(--radius-sm); padding: var(--sp-3); }
.xr-editorials-yal-title { font-weight: 600; color: var(--text-secondary); font-size: var(--fs-label); }
/* A checkbox with its text (the switch class belongs on the <input>, never on a <label>). */
.xr-editorials-check { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.xr-editorials-check input { accent-color: var(--accent); flex: none; }
.xr-editorials-check > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Auto planning: sender | pace | when (legacy md 3 / 4 / 5). */
.xr-editorials-auto { border: 0; padding: 0; margin: var(--sp-2) 0 0; min-width: 0;
  display: grid; grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr) minmax(320px, 1.3fr); gap: var(--sp-4); align-items: start; }
.xr-editorials-auto-col { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.xr-editorials-auto .xr-crud-field { grid-template-columns: 1fr; min-width: 0; }
.xr-editorials-toggles { display: flex; flex-wrap: wrap; margin: 6px 0 10px; }
.xr-editorials-toggle { min-width: 46px; padding: 6px 0; border: 1px solid var(--border-default); background: transparent; color: inherit; cursor: pointer; }
.xr-editorials-hour { min-width: 27px; }
/* 24 hours as 12 + 12 instead of wrapping at an arbitrary hour. */
.xr-editorials-toggles.xr-editorials-hours { display: grid; grid-template-columns: repeat(12, minmax(27px, 1fr)); gap: 2px; }
.xr-editorials-toggle-on { background: var(--accent); color: var(--accent-contrast); }
.xr-editorials-params { display: flex; flex-wrap: wrap; gap: 12px; }
.xr-editorials-buttons { margin-top: 16px; }
.xr-editorials-testlist { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; max-height: 240px; overflow: auto; margin: 8px 0; }
.xr-editorials-testlist > * { min-width: 0; }
/* The extra classes the two "send test" dialogs pass to Modal: a bit wider than the 480px default. */
.xr-modal.xr-editorials-test, .xr-modal.xr-campaigns-test { max-width: 640px; }

@media (max-width: 900px) {
  .xr-editorials-auto { grid-template-columns: 1fr; }
}

/* Version tabs are presentation-only: hidden panes remain validated and saved. */
.xr-editorials-edit[data-version="html"] [data-field-key="text"],
.xr-editorials-edit[data-version="html"] [data-field-key="amp"],
.xr-editorials-edit[data-version="amp"] [data-field-key="text"],
.xr-editorials-edit[data-version="amp"] [data-field-key="html"],
.xr-editorials-edit[data-version="text"] [data-field-key="html"],
.xr-editorials-edit[data-version="text"] [data-field-key="amp"],
.xr-editorials-edit:not(.xr-editorials-advanced) [data-field-key="provider"],
.xr-editorials-edit:not(.xr-editorials-advanced) [data-field-key="api_url"],
.xr-editorials-edit:not(.xr-editorials-advanced) [data-field-key="confirm_url"],
.xr-editorials-edit:not(.xr-editorials-advanced) [data-field-key="unsubscribe_url"] { display:none; }
.xr-editorials-edit [data-field-key="creative_versions"],
.xr-editorials-edit [data-field-key="creative_advanced"],
.xr-editorials-edit [data-field-key="html"],
.xr-editorials-edit [data-field-key="text"],
.xr-editorials-edit [data-field-key="amp"],
.xr-editorials-edit [data-field-key="auto_planning"] { grid-template-columns:minmax(0,1fr); }
.xr-editorials-edit [data-field-key="creative_versions"] > label,
.xr-editorials-edit [data-field-key="creative_advanced"] > label,
.xr-editorials-edit [data-field-key="html"] > label,
.xr-editorials-edit [data-field-key="text"] > label,
.xr-editorials-edit [data-field-key="amp"] > label,
.xr-editorials-edit [data-field-key="auto_planning"] > label,
.xr-editorials-edit .xr-crud-section-title:empty { display:none; }
.xr-creative-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:0 0 10px; }
.xr-creative-toolbar > .xr-crud-help { flex:1; min-width:180px; margin:0; }
.xr-creative-toolbar a { display:inline-flex; align-items:center; text-decoration:none; }
.xr-creative-toolbar a[aria-disabled="true"] { opacity:.5; cursor:not-allowed; }
.xr-creative-widths { display:flex; gap:2px; margin-right:auto; }
.xr-creative-widths [aria-pressed="true"] { background:var(--bg-selected); color:var(--accent); }
.xr-creative-preview-surface { background:var(--bg-surface-sunken); border:1px solid var(--border-default); border-radius:10px; padding:12px; overflow:hidden; }
.xr-creative-preview-frame { display:block; width:100%; max-width:100%; height:clamp(360px,60vh,680px); margin:auto; border:0; background:white; }
.xr-creative-preview-mobile { width:375px; }
.xr-creative-empty { padding:48px 20px; text-align:center; background:var(--bg-surface-sunken); border-radius:10px; }
.xr-creative-auto-heading { border:1px solid var(--border-default); border-radius:10px; padding:14px 16px; }
.xr-creative-auto-heading label { display:flex; align-items:center; justify-content:space-between; gap:16px; cursor:pointer; }
.xr-creative-auto-heading strong,.xr-creative-auto-heading small { display:block; }
.xr-creative-auto-heading small { color:var(--text-secondary); margin-top:4px; font-weight:normal; }
.xr-creative-auto-heading input { width:20px; height:20px; flex:none; accent-color:var(--accent); }
.xr-modal.xr-creative-text-modal { width:min(1040px,96vw); max-width:1040px; }
.xr-creative-text-compare { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:16px; margin:16px 0; }
.xr-creative-text-compare label { display:flex; flex-direction:column; gap:8px; min-width:0; }
.xr-creative-text-compare textarea { width:100%; box-sizing:border-box; resize:vertical; padding:12px; color:var(--text-primary); background:var(--bg-surface-sunken); border:1px solid var(--border-default); border-radius:8px; }
@media(max-width:640px) { .xr-creative-text-compare { grid-template-columns:minmax(0,1fr); } .xr-creative-preview-surface { padding:4px; } .xr-creative-preview-frame { height:55vh; min-height:300px; } }

/* A section's layout class must never override its conditional visibility. */
.xr-editorials-edit .xr-crud-section.xr-crud-hidden { display:none; }
.xr-editorials-edit .xr-crud-form > .xr-crud-actions { position:sticky; bottom:0; z-index:10; padding:12px 0; background:var(--bg-surface); border-top:1px solid var(--border-default); }

.xr-creative-auto-heading label > span { min-width:0; }
.xr-editorials-edit .xr-crud-actions { flex-wrap:wrap; }
@media(max-width:640px) {
  /* Keep navigation available as an icon rail, without consuming the form. */
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar { width:64px; padding-left:10px; padding-right:10px; }
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar-text { width:0; opacity:0; overflow:hidden; }
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar-header { justify-content:center; padding-left:0; padding-right:0; }
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar-toggle,
  .xr-shell:has(.xr-editorials-edit) .xr-nav-chevron,
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar-footer { display:none; }
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar a { padding-left:0; padding-right:0; gap:0; justify-content:center; }
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar-section-label { padding-left:0; padding-right:0; gap:0; justify-content:center; }
  .xr-shell:has(.xr-editorials-edit) .xr-main { padding:12px; }
  .xr-editorials-edit,.xr-editorials-edit .xr-crud-page-card { width:100%; min-width:0; }
  .xr-editorials-edit .xr-crud-page-card { padding:12px; }
  .xr-editorials-edit .xr-page-title { flex-wrap:wrap; }
}

@media(max-width:640px) {
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar { flex:0 0 64px; min-width:64px; max-width:64px; overflow-x:hidden; }
  .xr-shell:has(.xr-editorials-edit) .xr-sidebar-text { min-width:0; flex:0 0 0; }
  .xr-editorials-edit .xr-crud-actions button.xr-btn-ghost:disabled { display:none; }
}

.xr-editorials-edit:not(.xr-editorials-advanced) .xr-crud-section:has([data-field-key="provider"],[data-field-key="api_url"],[data-field-key="confirm_url"],[data-field-key="unsubscribe_url"]) { display:none; }
.xr-editorials-edit .xr-crud-header-actions button:disabled { display:none; }

/* Bound settings move into one modal; the series row remains compact. */
.xr-creative-series-row { display:flex; align-items:center; gap:12px; min-width:0; }
.xr-creative-series-row > div { flex:1; min-width:0; }
.xr-creative-series-row > button { flex:none; white-space:nowrap; }
.xr-modal.xr-crud-section-dialog { width:min(900px,96vw); max-width:900px; }
.xr-crud-section-dialog-fields { display:flex; flex-direction:column; gap:18px; }
.xr-crud-section-dialog .xr-crud-section.xr-crud-hidden { display:none; }
.xr-crud-section-dialog .xr-crud-section-title:empty,
.xr-crud-section-dialog [data-field-key="auto_planning"] > label { display:none; }
.xr-crud-section-dialog [data-field-key="auto_planning"] { grid-template-columns:minmax(0,1fr); }
.xr-crud-section-dialog .xr-creative-toolbar { margin-top:16px; justify-content:flex-end; }
@media(max-width:640px) { .xr-creative-series-row { gap:6px; } .xr-creative-series-row > button { padding-left:8px; padding-right:8px; font-size:12px; } }

@media(max-width:640px) { .xr-crud-section-dialog .xr-editorials-hours { grid-template-columns:repeat(6,minmax(27px,1fr)); } }
