/* ---------- Automations page (RSS, evergreen, CSV) ---------- */

.auto-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.auto-back { align-self: flex-start; margin-left: -6px; }

/* list rows */
.auto-list { overflow: hidden; }
.auto-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px 14px; align-items: start; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.auto-item:last-child { border-bottom: 0; }
.auto-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); }
.auto-icon.is-muted { background: var(--surface-3); color: var(--text-3); }
.auto-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.auto-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.auto-name { font: inherit; font-size: 14.5px; font-weight: 650; color: var(--text); background: none; border: 0; padding: 0; text-align: left; overflow-wrap: anywhere; min-width: 0; }
button.auto-name { cursor: pointer; }
button.auto-name:hover { color: var(--accent-ink); text-decoration: underline; }
.auto-sub { display: block; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 100%; }
a.auto-sub:hover { color: var(--accent-ink); }
.auto-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); min-width: 0; }
.auto-meta-item { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.auto-meta-item > .icon-wrap { color: var(--text-3); flex: none; }
.auto-error { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--danger-ink); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--surface)); border-radius: 8px; padding: 6px 10px; overflow-wrap: anywhere; min-width: 0; }
.auto-error > .icon-wrap { flex: none; margin-top: 1px; }
.auto-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.auto-progress { height: 4px; max-width: 320px; }
.auto-next { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); }
.auto-next > .ellipsis { min-width: 0; }
.auto-next > .tag, .auto-next > .faint { flex: none; }

@media (max-width: 640px) {
  .auto-item { grid-template-columns: 34px minmax(0, 1fr); padding: 12px; gap: 8px 10px; }
  .auto-icon { width: 34px; height: 34px; border-radius: 9px; }
  .auto-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* run history */
.auto-runs { display: flex; flex-direction: column; }
.auto-run { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.auto-run:last-child { border-bottom: 0; }
.auto-run-dot { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--success) 14%, var(--surface)); color: var(--success-ink); }
.auto-run.has-error .auto-run-dot { background: color-mix(in srgb, var(--danger) 13%, var(--surface)); color: var(--danger-ink); }
.auto-errors { margin: 0; padding-left: 16px; color: var(--danger-ink); font-size: 12px; overflow-wrap: anywhere; }
.auto-errors li + li { margin-top: 2px; }

/* wizard stepper */
.auto-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 4px; padding: 0; min-width: 0; }
.auto-steps li { flex: 1 1 0; min-width: 0; }
.auto-steps button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; text-align: left; min-width: 0; }
.auto-steps button:hover { background: var(--hover); }
.auto-steps button[aria-current="step"] { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); color: var(--accent-ink); }
.auto-step-num { width: 22px; height: 22px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.auto-steps button[aria-current="step"] .auto-step-num { background: var(--accent); color: var(--accent-contrast); }
.auto-steps button.is-done .auto-step-num { background: color-mix(in srgb, var(--success) 16%, var(--surface)); color: var(--success-ink); }
@media (max-width: 560px) {
  .auto-steps li { flex: 0 0 auto; }
  .auto-steps li:has([aria-current="step"]) { flex: 1 1 auto; }
  .auto-steps button:not([aria-current="step"]) .auto-step-label { display: none; }
}

/* choice cards (radio + optional extra controls) */
.auto-choices { display: flex; flex-direction: column; gap: 8px; }
.auto-choice { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; background: var(--surface); min-width: 0; }
.auto-choice.is-selected { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.auto-choice > .check { width: 100%; }
.auto-choice-extra { margin: 10px 0 2px 24px; min-width: 0; }
@media (max-width: 480px) { .auto-choice-extra { margin-left: 0; } }

/* feed preview */
.auto-feed { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.auto-feed-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); min-width: 0; }
.auto-feed-head > .icon-wrap { color: var(--accent-ink); flex: none; }
.auto-feed-item { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.auto-feed-thumb { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.auto-feed-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auto-feed-title { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
a.auto-feed-title:hover { color: var(--accent-ink); }
.auto-feed-foot { padding: 8px 12px; background: var(--surface-2); }
.auto-feed-empty { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--r); }
.auto-caption { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; max-height: 220px; overflow-y: auto; }

/* evergreen editor */
.auto-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.auto-section-head h3 { font-size: 14px; }
.auto-section-head .hint { margin-top: 2px; }
.auto-eg-post { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); min-width: 0; }
.auto-eg-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.auto-eg-num { width: 24px; height: 24px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); }
.auto-eg-var { border-left: 3px solid var(--border-strong); padding-left: 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.auto-eg-var .hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-add-post { border-style: dashed; }
.auto-media { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.auto-media-tile { position: relative; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); flex: none; }
.auto-media-tile img, .auto-media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* image overlay control: same theme-independent treatment as .media-tile .tile-actions */
.auto-media-x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 6px; border: 0; padding: 0; background: rgba(0, 0, 0, .6); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.auto-media-x:hover, .auto-media-x:focus-visible { background: var(--danger); }

/* CSV upload */
.auto-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px; cursor: pointer; }
.auto-drop > .icon-wrap { color: var(--accent-ink); }
.auto-drop:hover { border-color: var(--accent); }
.auto-drop:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.auto-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.auto-file > .icon-wrap { color: var(--accent-ink); flex: none; }

/* CSV review table */
.auto-col-msg { min-width: 220px; max-width: 380px; overflow-wrap: anywhere; }
.auto-col-md { min-width: 140px; max-width: 220px; overflow-wrap: anywhere; }
.auto-col-link { max-width: 200px; }
.auto-col-status { min-width: 170px; max-width: 280px; }
.auto-ellipsis { display: block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tbody tr.auto-row-error td { background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.table tbody tr.auto-row-error:hover td { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.table tbody tr.auto-row-error td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.auto-thumbs { display: flex; align-items: center; gap: 4px; }
.auto-thumbs img, .auto-thumb-missing { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); flex: none; }
.auto-thumbs a { display: inline-flex; }

/* page bar (title + summary + primary action per automation type) */
.auto-bar-slot { display: contents; }
.auto-page .page-bar .auto-back { margin-left: -4px; }
.auto-bar-name { overflow: hidden; text-overflow: ellipsis; max-width: min(46ch, 60vw); }
.auto-bar-sub { white-space: nowrap; }
@media (max-width: 560px) {
  .auto-hide-sm { display: none; }
  .auto-bar-sub { white-space: normal; }
}

/* centred empty state and side-by-side option cards */
.auto-empty, .auto-option { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 24px; }
.auto-empty { max-width: 560px; width: 100%; margin: 24px auto 0; }
.auto-empty h2, .auto-option h2 { font-size: 16px; }
.auto-empty p { max-width: 42ch; }
.auto-empty-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); margin-bottom: 4px; }
.auto-empty-actions { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.auto-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 860px; width: 100%; margin: 24px auto 0; align-items: stretch; }
.auto-option p { max-width: 40ch; }
.auto-option .auto-empty-actions { margin-top: auto; padding-top: 8px; }
@media (max-width: 640px) {
  .auto-options { grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
  .auto-empty, .auto-option { padding: 24px 16px; }
  .auto-empty { margin-top: 8px; }
}

/* file-format help inside the upload dialog */
.auto-format { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; background: var(--surface-2); }
.auto-format > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.auto-format > summary::-webkit-details-marker { display: none; }
.auto-format[open] > summary { color: var(--text); }
