/* Marketing Engine admin. Plain CSS, light and dark. */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --sidebar: #fbfbfa;
  --text: #1b1b19;
  --text-2: #55554f;
  --muted: #8a8a83;
  --border: #e4e3de;
  --border-strong: #cfcec8;
  --accent: #5b5bd6;
  --accent-hover: #4c4cc4;
  --accent-soft: #ececfb;
  --accent-text: #ffffff;
  --danger: #c4372b;
  --danger-soft: #fbeceb;
  --ok: #1f7a43;
  --ok-soft: #e7f4ec;
  --warn: #9a6200;
  --warn-soft: #fbf1dc;
  --info: #1f63c4;
  --info-soft: #e6eefb;
  --purple: #7a3fc2;
  --purple-soft: #f1e9fb;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ch-blog: #8a5cf6;
  --ch-bluesky: #1d8cf0;
  --ch-reddit: #ec6a1f;
  --ch-video: #d63e73;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111112;
    --surface: #1a1a1c;
    --surface-2: #222225;
    --sidebar: #151517;
    --text: #ececea;
    --text-2: #b5b5af;
    --muted: #85857f;
    --border: #2b2b2f;
    --border-strong: #3a3a3f;
    --accent: #8c8cf2;
    --accent-hover: #a0a0f6;
    --accent-soft: #26264a;
    --accent-text: #12122a;
    --danger: #f0817a;
    --danger-soft: #3a1f1d;
    --ok: #6fd093;
    --ok-soft: #1b3325;
    --warn: #f1c56c;
    --warn-soft: #3a3020;
    --info: #7fb0f5;
    --info-soft: #1d2a40;
    --purple: #c4a0f5;
    --purple-soft: #2e2440;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 0.95rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
pre { font-family: var(--mono); font-size: 0.84rem; white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; margin: 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.error { color: var(--danger); }
.spacer { flex: 1; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- Shell ---------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 0.8rem; font-weight: 800; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 10px 6px; display: flex; justify-content: space-between; align-items: center; }
.nav-label a { text-transform: none; letter-spacing: 0; font-size: 0.82rem; }
.nav a, .nav button.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; background: none; border: none; font: inherit; width: 100%; text-align: left; cursor: pointer;
}
.nav a:hover, .nav button.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { margin-left: auto; font-size: 0.75rem; font-weight: 600; min-width: 20px; text-align: center; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-text); }
.nav .count.quiet { background: var(--surface-2); color: var(--muted); }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.sidebar-foot { margin-top: auto; }
.mobile-bar { display: none; }

main { padding: 28px 32px 80px; max-width: 1180px; width: 100%; }

/* ---- Page header and tabs -------------------------------------------------- */

.page-header { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; }
.page-header .crumbs { font-size: 0.86rem; color: var(--muted); margin-bottom: 4px; }
.page-header .crumbs a { color: var(--muted); }
.page-header .sub { color: var(--text-2); margin: 6px 0 0; max-width: 760px; }
.page-header .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px 0 22px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 0.75rem; color: var(--muted); margin-left: 4px; }

/* ---- Cards and layout ------------------------------------------------------ */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 16px 20px 0; }
.card.accent { border-color: var(--accent); }
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .count { color: var(--muted); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.cluster { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: 14px 20px; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: none; }
.list.tight > li { padding: 10px 20px; }
.list a.item-link { color: var(--text); font-weight: 600; }

.empty { text-align: center; padding: 28px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---- Forms and buttons ----------------------------------------------------- */

input:not([type=checkbox]):not([type=radio]), textarea, select {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[readonly], textarea[readonly] { background: var(--surface-2); }
textarea { resize: vertical; line-height: 1.5; }
textarea.mono, .mono { font-family: var(--mono); font-size: 0.86rem; }
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 0.9rem; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.84rem; }
form.stack { gap: 14px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
legend { font-weight: 550; font-size: 0.9rem; padding: 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 550; font-size: 0.92rem; line-height: 1.2; cursor: pointer; white-space: nowrap;
  background: var(--accent); color: var(--accent-text);
}
.btn:hover, button:hover { background: var(--accent-hover); text-decoration: none; }
.btn.secondary, button.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover, button.secondary:hover { background: var(--surface-2); }
.btn.ghost, button.ghost { background: none; color: var(--text-2); }
.btn.ghost:hover, button.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger, button.danger { background: none; color: var(--danger); border-color: transparent; }
.btn.danger:hover, button.danger:hover { background: var(--danger-soft); }
.btn.sm, button.sm { padding: 5px 10px; font-size: 0.84rem; }
.btn.block, button.block { width: 100%; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 500; }
button:disabled, .btn[aria-disabled=true] { opacity: 0.45; cursor: not-allowed; }
form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }

/* ---- Pills, chips, channel tags -------------------------------------------- */

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pill.review { background: var(--warn-soft); color: var(--warn); }
.pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.scheduled { background: var(--info-soft); color: var(--info); }
.pill.publishing, .pill.drafting, .pill.queued { background: var(--purple-soft); color: var(--purple); }
.pill.published { background: var(--ok-soft); color: var(--ok); }
.pill.failed { background: var(--danger-soft); color: var(--danger); }
.pill.archived, .pill.rejected { color: var(--muted); }
.pill.plain::before { display: none; }

.channel { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 550; color: var(--text-2); white-space: nowrap; }
.channel::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--muted); }
.channel.blog::before { background: var(--ch-blog); }
.channel.bluesky::before { background: var(--ch-bluesky); border-radius: 50%; }
.channel.reddit::before { background: var(--ch-reddit); border-radius: 50%; }
.channel.video::before { background: var(--ch-video); }

.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 0.84rem; font-weight: 550; color: var(--text-2); background: var(--surface); user-select: none; }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip input:disabled + span { opacity: 0.4; cursor: not-allowed; }

.tag { font-size: 0.76rem; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-weight: 550; }

/* ---- Notices --------------------------------------------------------------- */

.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice.info { background: var(--info-soft); }
.notice.ok { background: var(--ok-soft); }
.notice.error { background: var(--danger-soft); }
.notice details { width: 100%; }
.problems { margin: 0 0 12px; padding: 10px 14px 10px 30px; background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); font-size: 0.88rem; }
.job-status { display: inline-flex; gap: 8px; align-items: center; color: var(--text-2); font-size: 0.88rem; }
.job-status::before { content: ''; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Inbox ----------------------------------------------------------------- */

.piece-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 14px 20px; border-top: 1px solid var(--border); color: var(--text); }
.piece-card:first-child { border-top: none; }
.piece-card:hover { background: var(--surface-2); text-decoration: none; }
.piece-card .title { font-weight: 600; }
.piece-card .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }
.piece-card .excerpt { grid-column: 1 / -1; color: var(--text-2); font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat .n { font-size: 1.5rem; font-weight: 700; display: block; }
.stat .l { color: var(--muted); font-size: 0.84rem; }
.upcoming li { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; }
.upcoming .when { font-size: 0.82rem; color: var(--muted); }

/* ---- Ideas ----------------------------------------------------------------- */

.idea-card .angle { color: var(--text-2); margin: 6px 0 8px; }
.idea-card .sources { font-size: 0.82rem; color: var(--muted); }
.idea-card .accept { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.idea-card .accept .label { font-size: 0.82rem; color: var(--muted); margin-right: 2px; }
.idea-card .accept .actions { margin-left: auto; display: flex; gap: 8px; }
.piece-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.piece-chip { display: inline-flex; gap: 8px; align-items: center; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); font-size: 0.84rem; }
.piece-chip:hover { border-color: var(--accent); text-decoration: none; }

/* ---- Sources --------------------------------------------------------------- */

.source-row { display: flex; gap: 14px; align-items: flex-start; }
.source-row .body { flex: 1; min-width: 0; }
.source-row summary { cursor: pointer; list-style: none; }
.source-row summary::-webkit-details-marker { display: none; }
.source-row .title { font-weight: 600; }
.source-row .excerpt { color: var(--text-2); font-size: 0.86rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.source-row details[open] .excerpt { display: none; }
.source-row pre { margin-top: 10px; max-height: 26rem; overflow-y: auto; }
.source-row .actions { display: flex; gap: 6px; flex-shrink: 0; }
details.disclosure > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: '+'; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-weight: 600; }
details.disclosure[open] > summary::before { content: '−'; }
details.disclosure[open] > summary { margin-bottom: 14px; }

/* ---- Piece editor ---------------------------------------------------------- */

.editor-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.editor-bar .state { color: var(--muted); font-size: 0.86rem; }
.fm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.fm-grid .wide { grid-column: 1 / -1; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.split textarea { min-height: 560px; }
.preview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 22px 16px; max-height: 760px; overflow-y: auto; font: 16px/1.65 Georgia, 'Iowan Old Style', serif; }
.preview h1, .preview h2, .preview h3 { font-family: system-ui, sans-serif; margin: 20px 0 8px; }
.preview h1 { font-size: 1.5rem; }
.preview h2 { font-size: 1.2rem; }
.preview p, .preview ul, .preview ol, .preview blockquote { margin: 0 0 12px; }
.preview img { max-width: 100%; }
.preview table { border-collapse: collapse; }
.preview th, .preview td { border: 1px solid var(--border); padding: 4px 8px; }
.preview blockquote { border-left: 3px solid var(--border-strong); padding-left: 14px; color: var(--text-2); }
.preview .lede { color: var(--text-2); font-style: italic; }
.thread { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: post; }
.thread .post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; position: relative; }
.thread .post::before { counter-increment: post; content: counter(post); position: absolute; left: -11px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.75rem; display: grid; place-items: center; color: var(--muted); }
.thread textarea { border: none; padding: 2px 4px 2px 10px; background: transparent; }
.thread textarea:focus { outline: none; }
.post-bar { display: flex; gap: 10px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.post-bar input { flex: 1; padding: 6px 9px !important; font-size: 0.86rem; }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.counter.over { color: var(--danger); font-weight: 700; }
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio-list label.check { align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.radio-list label.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-list .opt { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.radio-list .opt small { color: var(--muted); }
.cover-frame { width: 100%; aspect-ratio: 1200 / 630; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #111; }
.cover-frame iframe { width: 1200px; height: 630px; border: 0; transform-origin: 0 0; pointer-events: none; transform: scale(0.25); }
.versions { list-style: none; padding: 0; margin: 0; font-size: 0.88rem; }
.versions li { padding: 6px 0; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.versions li:first-child { border-top: none; }
.versions li.active a { font-weight: 700; }
.versions .note { width: 100%; color: var(--muted); font-size: 0.82rem; }

/* ---- Calendar -------------------------------------------------------------- */

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.calendar .dow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 4px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 110px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.day.past { background: transparent; }
.day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.day-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.event { display: flex; flex-direction: column; gap: 2px; font-size: 0.82rem; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); border-left: 3px solid var(--muted); }
.event:hover { text-decoration: none; outline: 1px solid var(--accent); }
.event.blog { border-left-color: var(--ch-blog); }
.event.bluesky { border-left-color: var(--ch-bluesky); }
.event.reddit { border-left-color: var(--ch-reddit); }
.event .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- Login ----------------------------------------------------------------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin-bottom: 18px; display: flex; align-items: center; gap: 10px; font-size: 1.3rem; }

/* ---- Small screens --------------------------------------------------------- */

@media (max-width: 960px) {
  .grid-2, .split { grid-template-columns: minmax(0, 1fr); }
  .split textarea { min-height: 360px; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10; background: var(--sidebar); border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .mobile-bar details { margin-left: auto; }
  .mobile-bar summary { list-style: none; cursor: pointer; padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-weight: 550; }
  .mobile-bar summary::-webkit-details-marker { display: none; }
  .mobile-bar .menu { position: absolute; left: 0; right: 0; top: 100%; background: var(--sidebar); border-bottom: 1px solid var(--border); padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 14px; max-height: 80vh; overflow-y: auto; }
  main { padding: 20px 16px 64px; }
  .card { padding: 16px; }
  .list > li, .piece-card { padding-left: 16px; padding-right: 16px; }
  .fm-grid { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: minmax(0, 1fr); }
  .calendar .dow { display: none; }
  .day { min-height: 0; }
  .day:not(:has(.event)):not(.today) { display: none; }
  .idea-card .accept .actions { margin-left: 0; width: 100%; }
  .idea-card .accept .actions > * { flex: 1; }
  .idea-card .accept .actions button { width: 100%; }
  .source-row { flex-direction: column; }
}

/* Publishing: show only the chosen adapter's fields (all show without :has support). */
form.publishing:has(input[name=blog_adapter][value=git]:checked) .only-static { display: none; }
form.publishing:has(input[name=blog_adapter][value=static]:checked) .only-git { display: none; }
.nav form.inline { display: block; }
.nav button.nav-link { justify-content: flex-start; }

/* ---- Instagram carousels -------------------------------------------------- */
.slides { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.slide-card { display: grid; grid-template-columns: minmax(0, 1fr) 216px; align-items: start; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.slide-card.new { grid-template-columns: minmax(0, 1fr); border-style: dashed; }
.slide-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.slide-frame { width: 100%; aspect-ratio: 1080 / 1350; border-radius: var(--radius-sm); overflow: hidden; background: #111; align-self: start; }
.slide-frame:empty { display: none; }
.slide-frame iframe { width: 1080px; height: 1350px; border: 0; transform-origin: 0 0; pointer-events: none; transform: scale(0.2); /* 216px column; app.js refines */ }
.thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.thumbs img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; background: var(--surface-2); }
.thumbs figure { margin: 0; }
.thumbs figcaption { font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
#images .thumbs img { aspect-ratio: 1; object-fit: contain; }
.steps { padding-left: 18px; margin: 0 0 12px; display: flex; flex-direction: column; gap: 4px; }
input[type=file] { padding: 6px !important; font-size: 0.86rem; }
@media (max-width: 820px) {
  .slide-card { grid-template-columns: minmax(0, 1fr); }
  .slide-frame { max-width: 320px; }
}

/* ---- Reels and the library ------------------------------------------------ */
.scenes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.scene-card { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; align-items: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; scroll-margin-top: 16px; }
.scene-card.new { grid-template-columns: minmax(0, 1fr); border-style: dashed; }
.scene-card:target { border-color: var(--accent); }
.scene-frame { position: relative; width: 100%; aspect-ratio: 9 / 16; border-radius: var(--radius-sm); overflow: hidden; background: #111; }
.scene-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene-frame img.contain { object-fit: contain; background: #222; }
.scene-frame iframe { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; border: 0; transform-origin: 0 0; transform: scale(0.1667); pointer-events: none; background: transparent;
  color-scheme: light; /* must match the overlay page, or browsers paint the frame opaque on a dark page */ }
.trims { gap: 10px; flex-wrap: nowrap; }
.trims .field { flex: 1; }
.reel-player { width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: var(--radius-sm); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { position: relative; aspect-ratio: 9 / 16; background: var(--surface-2); display: grid; place-items: center; }
.media-thumb.image { aspect-ratio: 4 / 5; }
.media-thumb.audio { aspect-ratio: auto; padding: 16px 8px; }
.media-thumb.audio audio { width: 100%; }
.media-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-thumb .duration { position: absolute; right: 6px; bottom: 6px; background: rgb(0 0 0 / 0.65); color: #fff; font-size: 0.75rem; padding: 1px 6px; border-radius: 4px; }
.media-info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.media-info strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 820px) {
  .scene-card { grid-template-columns: minmax(0, 1fr); }
  .scene-frame { max-width: 220px; }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* "+ format" buttons */
.add-formats { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.add-formats .label { font-size: 0.82rem; color: var(--muted); margin-right: 2px; }
button.chip-button { padding: 4px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 550; background: var(--surface); color: var(--accent); border: 1px dashed var(--border-strong); }
button.chip-button:hover { background: var(--accent-soft); border-style: solid; border-color: var(--accent); }

/* ---- Demos ------------------------------------------------------------------ */
.demo-row { display: flex; gap: 12px; align-items: center; }
.demo-thumb { width: 96px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; background: var(--surface-2); flex-shrink: 0; border: 1px solid var(--border); }
.demo-player { width: 100%; aspect-ratio: 16 / 10; background: #000; border-radius: var(--radius-sm); }
.step-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.step-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
.step-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.step-head .muted { margin-left: auto; }
.step-fields { display: grid; grid-template-columns: 130px minmax(0, 1fr) 70px 70px 70px 70px minmax(0, 1fr); gap: 6px; }
.step-fields input, .step-fields select { padding: 6px 8px; font-size: 0.86rem; }
.step-fields .wide { grid-column: 1 / -1; }
@media (max-width: 820px) { .step-fields { grid-template-columns: 1fr 1fr; } .step-fields .wide { grid-column: 1 / -1; } }
