/* IG Posting Bot: hand-written styles.
   Theme: tokens on :root (light) and [data-theme="dark"]. <html data-theme> comes from the `theme`
   cookie (server) or, with no explicit choice, from the system preference (inline <head> script).
   All text/background pairs below meet WCAG AA (4.5:1); input borders meet 3:1. Spacing is on an 8px grid. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e2e5e9;
  --border-input: #8a939e;
  --text: #16191d;
  --text-muted: #5a636e;
  --accent: #2f5bd3;
  --accent-hover: #264bb3;
  --accent-soft: #edf1fd;
  --accent-ink: #ffffff;
  --success: #0a7550;
  --success-soft: #e6f4ed;
  --warn: #8a5300;
  --warn-soft: #fcf1dd;
  --danger: #bf2536;
  --danger-soft: #fbe9eb;
  --neutral-soft: #eceef1;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --overlay: rgba(255, 255, 255, 0.9);

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --radius: 8px;
  --radius-lg: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e1114;
  --surface: #161a1f;
  --surface-2: #1b2026;
  --border: #2a3038;
  --border-input: #6b7580;
  --text: #e8eaed;
  --text-muted: #9ba4ae;
  --accent: #7c9cff;
  --accent-hover: #97b0ff;
  --accent-soft: #1d2642;
  --accent-ink: #0b0e14;
  --success: #5ccf9d;
  --success-soft: #10281e;
  --warn: #f0b357;
  --warn-soft: #2b2312;
  --danger: #ff7d8a;
  --danger-soft: #33191d;
  --neutral-soft: #232931;
  --overlay: rgba(22, 26, 31, 0.9);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--sp-2); letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 var(--sp-3); }
code { font-family: var(--mono); font-size: .875em; background: var(--neutral-soft); padding: 1px 6px; border-radius: 4px; }
small, .small { font-size: .875rem; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: var(--sp-2) var(--sp-4); min-height: 56px;
  display: flex; align-items: center; gap: var(--sp-2) var(--sp-5); flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after {
  content: ""; position: absolute; left: 9px; top: 6px;
  border-left: 8px solid var(--accent-ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent;
}
.brand-mark.lg { width: 40px; height: 40px; border-radius: 10px; }
.brand-mark.lg::after { left: 15px; top: 11px; border-left-width: 13px; border-top-width: 9px; border-bottom-width: 9px; }
.nav { display: flex; gap: var(--sp-1); flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 6px var(--sp-3); border-radius: var(--radius); color: var(--text-muted); font-weight: 550; white-space: nowrap; }
.nav a:hover { background: var(--neutral-soft); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.me-email { color: var(--text-muted); font-size: .875rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me form { margin: 0; }
.topbar-spacer { flex: 1; }

.theme-toggle {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: none;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (max-width: 900px) {
  .nav { order: 3; flex-basis: 100%; }
}
@media (max-width: 640px) {
  .me-email { display: none; }
}

/* ---- layout ---- */
.container { max-width: 1200px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) var(--sp-7); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-muted); margin: var(--sp-1) 0 0; }
.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.crumbs { font-size: .875rem; color: var(--text-muted); margin-bottom: var(--sp-1); }
.crumbs a { color: var(--text-muted); }
.stack > * + * { margin-top: var(--sp-4); }
.section-gap { margin-top: var(--sp-5); }
.cols { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 1fr) 336px; align-items: start; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); }
.card + .card { margin-top: var(--sp-5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 var(--sp-4); border-radius: var(--radius);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .9375rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger.solid { background: var(--danger); color: var(--surface); }
.btn-danger.solid:hover { filter: brightness(0.95); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--neutral-soft); color: var(--text); }
.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: .875rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }

/* ---- badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--sp-2);
  border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--text-muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.expired, .badge.reconnect { background: var(--danger-soft); color: var(--danger); }
.badge.none { background: var(--neutral-soft); color: var(--text-muted); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

/* ---- flash messages / notes ---- */
.flash { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); margin-bottom: var(--sp-4); border: 1px solid transparent; }
.flash-ok { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.flash-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.flash ul { margin: var(--sp-1) 0 0; padding-left: var(--sp-5); }
.note { background: var(--surface-2); border: 1px dashed var(--border-input); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); color: var(--text-muted); font-size: .9375rem; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 650; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; }
td.end, th.end { text-align: right; }
.cell-page { display: flex; align-items: center; gap: var(--sp-3); min-width: 200px; }
.cell-page .name { font-weight: 600; color: var(--text); }
.cell-page .handle { color: var(--text-muted); font-size: .875rem; }
/* On phones, rows of a .stack-mobile table become label/value cards. */
@media (max-width: 640px) {
  table.stack-mobile thead { display: none; }
  table.stack-mobile tr { display: block; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
  table.stack-mobile tbody tr:last-child { border-bottom: 0; }
  table.stack-mobile td { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); padding: 6px 0; border: 0; text-align: right; }
  table.stack-mobile td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-size: .8125rem; font-weight: 600; text-align: left; }
  table.stack-mobile td:first-child { text-align: left; padding-bottom: var(--sp-2); }
  table.stack-mobile td.end { justify-content: flex-end; padding-top: var(--sp-2); }
  table.stack-mobile tbody tr:hover td { background: none; }
}
.row-link { color: inherit; }
.row-link:hover { text-decoration: none; }
.row-link:hover .name { color: var(--accent); text-decoration: underline; }

/* ---- avatars ---- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; object-fit: cover;
  display: inline-grid; place-items: center; font-weight: 700; font-size: .9375rem;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border);
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.5rem; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: .875rem; }
.field .help { color: var(--text-muted); font-size: .8125rem; }
.field .error { color: var(--danger); font-size: .8125rem; font-weight: 600; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; height: 40px; padding: 0 var(--sp-3); font: inherit; font-size: .9375rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-input); border-radius: var(--radius);
}
textarea { height: auto; min-height: 96px; padding: var(--sp-2) var(--sp-3); resize: vertical; line-height: 1.45; }
select {
  appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
input[readonly] { background: var(--surface-2); }
input[type=file] { font: inherit; font-size: .875rem; max-width: 100%; color: var(--text-muted); }
input[type=file]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: var(--sp-2); font-weight: 550; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check .muted { font-weight: 400; }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-top: var(--sp-5); }
.inline-form { display: flex; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1 1 240px; }
.checklist { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.checklist .check { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-height: 48px; }
.checklist .check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.checklist .sub { display: block; font-size: .8125rem; color: var(--text-muted); font-weight: 400; }
.saved { color: var(--success); font-weight: 600; font-size: .875rem; }

.color-input { display: flex; gap: var(--sp-2); align-items: center; }
.color-input input[type=color] {
  width: 40px; height: 40px; flex: none; padding: 3px; border: 1px solid var(--border-input);
  border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.color-input input[type=color]:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.color-input input[type=text] { font-family: var(--mono); text-transform: uppercase; }

/* ---- auth pages ---- */
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; padding: var(--sp-6); }
.auth-card .brand-mark { margin-bottom: var(--sp-4); }
.auth-card h1 { font-size: 1.375rem; }

/* ---- page cards (submit) ---- */
.page-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); }
.page-card { display: flex; gap: var(--sp-3); align-items: center; color: inherit; }
.page-card:hover { text-decoration: none; border-color: var(--accent); }
.page-card .name { font-weight: 650; }
.empty { text-align: center; padding: var(--sp-7) var(--sp-5); color: var(--text-muted); }
.empty h2 { color: var(--text); }

/* ---- templates ---- */
.tpl-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.tpl-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tpl-card + .tpl-card { margin-top: 0; }
.tpl-thumb { display: grid; place-items: center; padding: var(--sp-4); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tpl-thumb img { width: 100%; max-width: 180px; aspect-ratio: 9 / 16; object-fit: contain; display: block; border: 1px solid var(--border); border-radius: 4px; }
.tpl-body { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; }
.tpl-body h3 { margin: 0; }
.tpl-body .actions { margin-top: auto; padding-top: var(--sp-2); }

.editor { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .editor { grid-template-columns: minmax(0, 1fr) 392px; align-items: start; } }
@media (min-width: 1000px) { .editor-side .card { position: sticky; top: 80px; } }
fieldset.card { margin: 0; min-width: 0; }
fieldset.card + fieldset.card, .card + fieldset.card, fieldset.card + .card { margin-top: var(--sp-5); }
legend { float: left; width: 100%; padding: 0; margin-bottom: var(--sp-4); font-weight: 650; font-size: 1rem; }
legend + * { clear: left; }
.tfields { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); }
.tfields .field.wide { grid-column: 1 / -1; }
.preview-controls { display: grid; gap: var(--sp-3); grid-template-columns: 1fr 1fr; margin-bottom: var(--sp-4); }
.preview-controls .field.wide { grid-column: 1 / -1; }
.preview-controls textarea { min-height: 64px; }
/* Neutral frame: the preview's own colors come from the template, never from the UI theme. */
.preview-frame { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3); min-height: 240px; display: grid; place-items: center; }
.preview-frame img { display: block; width: 100%; max-width: 336px; height: auto; margin: 0 auto; border: 1px solid var(--border); border-radius: 4px; }
.preview-frame .flash { width: 100%; margin: 0; }
.htmx-indicator { visibility: hidden; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { visibility: visible; }
.sticky-actions {
  position: sticky; bottom: var(--sp-2); z-index: 5; margin-top: var(--sp-5); padding: var(--sp-3) var(--sp-4);
  background: var(--overlay); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap;
}

/* ---- link box ---- */
.link-box { display: flex; gap: var(--sp-2); }
.link-box input { font-family: var(--mono); font-size: .8125rem; }
.link-card { border-color: var(--success); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; font-size: .9375rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.error-page { text-align: center; padding: var(--sp-7) var(--sp-4); }
.error-page .code { font-size: 3rem; font-weight: 800; letter-spacing: -0.03em; color: var(--text-muted); }

/* ---- shared bits (Phase 4) ---- */
.block { display: block; }
.btn-lg { height: 48px; padding: 0 var(--sp-5); font-size: 1rem; }
input.input-lg { height: 48px; font-size: 1rem; }
.danger-text { color: var(--danger); }
.btn.danger-text:hover { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.flash > :last-child { margin-bottom: 0; }
.form-actions.tight { margin-top: var(--sp-3); }
.form-actions form { margin: 0; }
.spinner {
  display: inline-block; width: 1em; height: 1em; flex: none; vertical-align: -0.125em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
.btn.htmx-request { cursor: progress; }

/* toasts (HTMX results and errors) */
.toasts {
  position: fixed; left: 50%; bottom: var(--sp-4); transform: translateX(-50%); z-index: 50;
  display: grid; gap: var(--sp-2); width: min(560px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--success);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16); font-weight: 550; font-size: .9375rem;
  animation: toast-in .15s ease-out;
}
.toast.info { border-left-color: var(--accent); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---- submit page ---- */
.submit-card { max-width: 880px; }
.submit-card > .flash + .field { margin-top: var(--sp-4); }
.page-picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.page-picker legend { font-weight: 600; font-size: .875rem; margin-bottom: var(--sp-2); float: none; }
.page-picker .error { display: block; margin-top: var(--sp-2); color: var(--danger); font-size: .8125rem; font-weight: 600; }
.page-options { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.page-option {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); min-height: 64px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.page-option:hover { border-color: var(--border-input); }
.page-option input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
.page-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.page-option:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.page-option.is-disabled { opacity: .6; cursor: not-allowed; }
.page-option-text { display: flex; flex-direction: column; min-width: 0; }
.page-option-text .name { font-weight: 650; }
.page-option-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-warning ul { margin: var(--sp-2) 0 var(--sp-3); padding-left: var(--sp-5); }
.dup-warning a:not(.btn) { color: inherit; text-decoration: underline; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.list-head h2 { margin: 0; }
.chips { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 var(--sp-3); border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: .875rem; font-weight: 600;
}
.chip:hover { text-decoration: none; color: var(--text); border-color: var(--border-input); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.sub-list { list-style: none; margin: 0; padding: 0; }
.sub-list li + li { border-top: 1px solid var(--border); }
.sub-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); color: inherit; }
.sub-item:hover { background: var(--surface-2); text-decoration: none; }
.sub-item:hover .name { color: var(--accent); }
.thumb {
  width: 54px; height: 96px; flex: none; border-radius: 6px; overflow: hidden; background: var(--neutral-soft);
  display: grid; place-items: center; color: var(--text-muted); font-weight: 700; border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sub-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sub-title .name { font-weight: 650; }
.sub-text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.sub-meta { color: var(--text-muted); font-size: .8125rem; overflow-wrap: anywhere; }
.sub-status { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-1); flex: none; }
@media (max-width: 640px) {
  .sub-item { flex-wrap: wrap; align-items: flex-start; }
  .sub-main { flex-basis: calc(100% - 54px - var(--sp-3)); }
  .sub-status { flex-direction: row; flex-wrap: wrap; align-items: center; margin-left: calc(54px + var(--sp-3)); }
}

/* ---- review page ---- */
.state-card h2 { margin-bottom: var(--sp-2); }
.progress-card { max-width: 880px; }
.steps { list-style: none; margin: var(--sp-2) 0 var(--sp-4); padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center; font-size: .875rem; color: var(--text-muted); }
.step + .step::before { content: ""; position: absolute; top: 13px; right: 50%; width: 100%; height: 2px; background: var(--border); }
.step.done + .step::before { background: var(--success); }
.step-dot {
  position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--border-input); background: var(--surface);
}
.step.done .step-dot { background: var(--success); border-color: var(--success); }
.step.done .step-dot::after { content: ""; width: 7px; height: 12px; margin-top: -3px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.step.current { color: var(--text); font-weight: 650; }
.step.current .step-dot { border-color: var(--accent-soft); }
.step.current .step-dot::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent; animation: spin .9s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .step.current .step-dot::after { animation-duration: 3s; } }
@media (max-width: 640px) {
  .steps { grid-template-columns: 1fr; gap: var(--sp-3); }
  .step { flex-direction: row; text-align: left; }
  .step + .step::before { display: none; }
}
.discard-row { margin-top: var(--sp-4); display: flex; justify-content: flex-end; }

.review { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .review { grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); }
  .review-media { position: sticky; top: 80px; }
}
.review-side > .card + .card { margin-top: var(--sp-4); }
.video-card { padding: var(--sp-3); }
.reel {
  display: block; width: min(100%, calc(72vh * 9 / 16)); height: auto; margin: 0 auto;
  aspect-ratio: 9 / 16; background: #000; border-radius: var(--radius);
}
.video-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.video-card .summary { margin: var(--sp-3) 0 0; }
.job-bar {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
  border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.job-bar.is-idle { display: none; }
.notices:not(:has(.flash)) { display: none; }
.notices .flash { margin-bottom: var(--sp-4); }
.notice { display: flex; gap: var(--sp-3); align-items: flex-start; justify-content: space-between; }
.notice p { margin: 0; }
.notice form { margin: 0; flex: none; }
.card-head h2 label { font: inherit; }
.card-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; margin-top: var(--sp-3); }
.field-foot { display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.counter { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: .8125rem; }
.counter.over { color: var(--danger); font-weight: 650; }
.dirty-hint, .field .help.dirty-hint { color: var(--warn); font-size: .8125rem; font-weight: 600; }
.reveal summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: var(--sp-1) 0; }
.reveal[open] summary { margin-bottom: var(--sp-2); }
.note q { font-style: italic; color: var(--text); }
.headline-body .note { margin-bottom: var(--sp-2); }
.post-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.post-buttons .btn { white-space: normal; height: auto; min-height: 48px; line-height: 1.2; padding: var(--sp-2) var(--sp-3); }
.post-card > p.small { margin: var(--sp-2) 0 0; }
.confirm-box { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: var(--sp-4); }
.confirm-box h3 { margin-bottom: var(--sp-1); }
.confirm-box .kv { margin-top: var(--sp-3); }

/* ---- Phase 5: Instagram connection ---- */
.section-gap-bottom { margin: calc(-1 * var(--sp-3)) 0 var(--sp-5); }
.tip { display: inline-flex; }
.tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
#instagram .form-actions { margin-top: var(--sp-4); }
#instagram .form-actions ~ p { margin: var(--sp-2) 0 0; }
#instagram .form-actions ~ .note { margin-top: var(--sp-3); }
#instagram .card-head + .note { margin: 0 0 var(--sp-3); }
#instagram .flash { margin-bottom: var(--sp-3); }

/* ---- Phase 6: publishing ---- */
.steps.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .steps.four { grid-template-columns: 1fr; } }
.post-card .steps { margin-top: 0; }
.post-card > .btn-lg { width: 100%; margin: var(--sp-1) 0 var(--sp-3); }
.post-card > .note { margin: var(--sp-3) 0 0; }
.post-card.is-posted { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.post-card .flash { margin-bottom: var(--sp-3); }
.caption-preview {
  display: block; white-space: pre-line; overflow-wrap: anywhere; color: var(--text);
  border-left: 3px solid var(--border-input); padding-left: var(--sp-2); margin-bottom: var(--sp-1);
}
textarea[readonly] { background: var(--surface-2); color: var(--text-muted); cursor: default; }
.card-actions:not(:has(*)) { display: none; }
.sub-ext { display: block; padding: 0 var(--sp-4) var(--sp-3) calc(54px + var(--sp-3) + var(--sp-4)); margin-top: calc(-1 * var(--sp-2)); }
.quota { font-variant-numeric: tabular-nums; white-space: nowrap; }
.quota.low { color: var(--warn); font-weight: 650; }
.quota.none-left { color: var(--danger); font-weight: 650; }

/* ---- submit: where the video comes from (tabs: Paste link | Upload video | Search TikTok | Search Instagram) ---- */
.submit-card [hidden] { display: none !important; }
.submit-limits { margin: var(--sp-5) 0 0; }
.page-picker.attention .page-option:not(.is-disabled) { border-color: var(--danger); }
.icon { width: 18px; height: 18px; flex: none; }
.source { margin-top: var(--sp-5); }
.source-label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: var(--sp-2); }
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); }
.tab {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 10px var(--sp-3); margin-bottom: -1px; min-height: 44px;
  border: 0; border-bottom: 2px solid transparent; border-radius: var(--radius) var(--radius) 0 0;
  background: none; color: var(--text-muted); font: inherit; font-weight: 600; font-size: .9375rem; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab[aria-selected="true"]:hover { background: var(--accent-soft); }
.tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tab .icon { width: 16px; height: 16px; }
.tab-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }
.tab-panel .form-actions { margin-top: var(--sp-4); }
@media (max-width: 560px) {
  .tabs { gap: 0; }
  .tab { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 8px 2px; font-size: .8125rem; }
  .tab span { max-width: 100%; text-align: center; line-height: 1.2; white-space: normal; overflow-wrap: break-word; }
}

/* upload */
.upload-status:empty, .tt-use-status:empty, .tt-results:empty { display: none; }
.upload-status .flash { margin-bottom: var(--sp-3); }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1);
  min-height: 176px; padding: var(--sp-5) var(--sp-4); text-align: center; cursor: pointer;
  border: 2px dashed var(--border-input); border-radius: var(--radius-lg); background: var(--surface-2); color: var(--text-muted);
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.dropzone-icon {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: var(--sp-1);
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--accent);
}
.dropzone-icon .icon { width: 22px; height: 22px; }
.dropzone-title { font-weight: 600; color: var(--text); }
.dropzone .link-text { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.dropzone-hint { font-size: .8125rem; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.upload-file {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.upload-file-icon { display: grid; place-items: center; color: var(--accent); }
.upload-file-icon .icon { width: 24px; height: 24px; }
.upload-file-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.upload-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { margin-top: var(--sp-3); }
.progress-track { height: 8px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s linear; }
@media (prefers-reduced-motion: reduce) { .progress-bar { transition: none; } }
.progress-meta {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-2);
  color: var(--text-muted); font-variant-numeric: tabular-nums;
}

/* search */
.search-row { display: flex; gap: var(--sp-2); }
.search-input { position: relative; flex: 1; min-width: 0; }
.search-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-input input { padding-left: 38px; }
.search-input input:disabled { background: var(--surface-2); cursor: not-allowed; }
#panel-search > .note + .search-row, #panel-instagram > .note + .search-row { margin-top: var(--sp-3); }
.search-options { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-3); }
.inline-select { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: .875rem; font-weight: 600; color: var(--text-muted); }
.inline-select select {
  width: auto; height: 32px; padding-left: var(--sp-2); font-size: .875rem;
  background-position: calc(100% - 18px) 13px, calc(100% - 13px) 13px;
}
.tt-search .help { display: block; margin-top: var(--sp-2); color: var(--text-muted); font-size: .8125rem; }
.tt-search .help:empty { display: none; }
.tt-search .btn .htmx-indicator, .tt-card .btn .htmx-indicator, .tt-more .btn .htmx-indicator { display: none; }
.tt-search.htmx-request .btn .htmx-indicator, .btn.htmx-request .htmx-indicator { display: inline-block; }
.tt-use-status { margin-top: var(--sp-4); scroll-margin-top: 80px; }
.tt-use-status .flash { margin: 0; }
.tt-results { margin-top: var(--sp-4); transition: opacity .15s; }
.tt-results.htmx-request { opacity: .55; pointer-events: none; }
.tt-error { margin: 0; }
.tt-empty { padding: var(--sp-6) var(--sp-4); border: 1px dashed var(--border); border-radius: var(--radius); }
.tt-empty p { margin-bottom: 0; }
.tt-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.tt-head p { margin: 0; }
.tt-head-side { display: flex; align-items: center; gap: var(--sp-2) var(--sp-4); flex-wrap: wrap; }
.tt-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); }
.tt-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.tt-card:hover { border-color: var(--border-input); }
.tt-thumb { position: relative; display: block; aspect-ratio: 9 / 16; overflow: hidden; background: var(--neutral-soft); }
.tt-thumb-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); }
.tt-thumb-fallback .icon { width: 32px; height: 32px; opacity: .5; }
.tt-thumb img { position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; }
.tt-duration {
  position: absolute; right: 6px; bottom: 6px; z-index: 2; padding: 1px 6px; border-radius: 4px;
  background: rgba(0, 0, 0, .72); color: #fff; font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.tt-body { display: flex; flex-direction: column; gap: 4px; flex: 1; padding: var(--sp-2) var(--sp-3) var(--sp-3); }
.tt-body p { margin: 0; }
.tt-caption {
  min-height: 4.2em; overflow: hidden; overflow-wrap: anywhere; font-size: .875rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical;
}
.tt-author { font-size: .8125rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-stats { display: flex; flex-wrap: wrap; gap: 2px var(--sp-2); font-size: .75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tt-stats > span { display: inline-flex; align-items: center; gap: 3px; }
.tt-stats .icon { width: 12px; height: 12px; }
.tt-actions {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-1) var(--sp-2); flex-wrap: wrap;
  margin-top: auto; padding-top: var(--sp-2);
}
.tt-more { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; }
.tt-more p { margin: 0; }
.tt-more .flash { width: 100%; margin: 0; }
@media (max-width: 560px) {
  .tt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .tt-body { padding: var(--sp-2); }
  .tt-actions .btn { flex: 1 1 100%; }
  .search-row { flex-wrap: wrap; }
  .search-row > .btn { flex: 1 1 100%; }
}
.source-file { overflow-wrap: anywhere; }

/* ---- batches: several videos at once ---- */
/* paste link: 1-5 link boxes */
.link-rows { display: grid; gap: var(--sp-2); }
.link-row { display: grid; gap: 4px; }
.link-input { display: flex; align-items: center; gap: var(--sp-2); }
.link-input input { flex: 1; min-width: 0; }
.link-num {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--neutral-soft); color: var(--text-muted); font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.link-row.has-error input { border-color: var(--danger); }
.link-row .error { color: var(--danger); font-size: .8125rem; font-weight: 600; }
.link-more { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; min-height: 32px; }
.link-more .btn { padding-left: var(--sp-2); color: var(--accent); }
.link-more .btn:hover { color: var(--accent-hover); }

/* upload: a row per file */
.upload-files { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.upload-files .upload-file { align-items: flex-start; }
.upload-files .upload-file-icon { padding-top: 2px; }
.upload-file.is-error { border-color: var(--danger); background: var(--danger-soft); }
.upload-file.is-done .upload-file-icon { color: var(--success); }
.upload-row-bar { display: block; margin-top: 6px; }
.upload-row-bar .progress-bar { display: block; }
.upload-file.is-done .progress-bar { background: var(--success); }
.upload-row-error { display: block; margin-top: 4px; color: var(--danger); font-weight: 600; font-size: .8125rem; }
.upload-count { margin: var(--sp-2) 0 0; }
.upload-files:not([hidden]) ~ .upload-progress { margin-top: var(--sp-2); }

/* search: tick up to 5 results */
.tt-card { position: relative; }
.tt-pick {
  position: absolute; top: 6px; left: 6px; z-index: 3; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 6px; border-radius: 999px; background: rgba(0, 0, 0, .62); color: #fff;
  font-size: .75rem; font-weight: 650; cursor: pointer; user-select: none;
}
.tt-pick input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.tt-pick:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tt-pick:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.tt-pick:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.tt-card.is-picked, .tt-card:has(input[data-pick]:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tt-selbar {
  position: sticky; bottom: var(--sp-2); z-index: 6; margin-top: var(--sp-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--accent); border-radius: var(--radius-lg);
  background: var(--overlay); backdrop-filter: blur(6px); box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.tt-selcount { font-weight: 650; font-variant-numeric: tabular-nums; }
.tt-selactions { display: flex; gap: var(--sp-2); }
.tt-selbar .btn .htmx-indicator { display: none; }
.tt-selbar .btn.htmx-request .htmx-indicator { display: inline-block; }

/* the combined duplicate warning */
.dup-warning .dup-items { list-style: none; padding-left: 0; display: grid; gap: 4px; }
.dup-items li { overflow-wrap: anywhere; }
.dup-label { font-weight: 650; }
.dup-src { display: inline-block; max-width: min(100%, 36ch); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; opacity: .85; }

/* recent list: a batch row */
.batch-row .thumb { position: relative; overflow: visible; isolation: isolate; }
.thumb-stack img { position: absolute; inset: 0; border-radius: 6px; border: 1px solid var(--border); }
.thumb-stack img:nth-child(2) { transform: translate(5px, -4px) scale(.94); z-index: -1; opacity: .8; }
.thumb-stack img:nth-child(3) { transform: translate(10px, -8px) scale(.88); z-index: -2; opacity: .6; }

/* batch page */
.batch-bar { display: flex; align-items: center; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap; padding: var(--sp-4); margin-bottom: var(--sp-4); }
.batch-counts { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; flex: 1; min-width: 0; }
.batch-total { font-weight: 650; margin-right: var(--sp-1); }
.batch-actions { margin: 0; }
.batch-actions .btn .htmx-indicator { display: none; }
.batch-actions .btn.htmx-request .htmx-indicator { display: inline-block; }
.batch-note { flex-basis: 100%; margin: 0; }
.batch-note:empty { display: none; }
.post-all:empty { display: none; }
.post-all { margin-bottom: var(--sp-4); scroll-margin-top: 80px; }
.post-all .flash { margin-bottom: var(--sp-2); }
.post-all-box { position: relative; background: var(--surface); }
.post-all-box h2 { padding-right: 40px; margin-bottom: var(--sp-3); }
.post-all-close { position: absolute; top: var(--sp-2); right: var(--sp-2); }
.mode-choice { border: 0; margin: 0 0 var(--sp-3); padding: 0; min-width: 0; display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mode-choice legend { float: none; grid-column: 1 / -1; font-weight: 600; font-size: .875rem; margin-bottom: 0; }
.mode-option {
  display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.mode-option input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.mode-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.mode-option:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.post-all-list { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; gap: var(--sp-2); }
.post-all-item { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.post-all-item .thumb { width: 45px; height: 80px; }
.post-all-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.post-all-text .caption-preview { max-height: 4.4em; overflow: hidden; font-size: .875rem; }
.post-all-box .kv { margin-bottom: var(--sp-3); }
.post-all-box .flash, .post-all-note { margin-bottom: var(--sp-3); }
.post-all-skipped { margin: var(--sp-1) 0 0; padding-left: var(--sp-5); }
.post-all-skipped a { color: inherit; text-decoration: underline; }

.bcard-grid { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 760px) { .bcard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1120px) { .bcard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.bcard { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); min-width: 0; scroll-margin-top: 80px; }
.bcard + .bcard { margin-top: 0; }
.bcard.is-posted { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.bcard.is-failed { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.bcard-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.bcard-title { display: flex; align-items: center; gap: var(--sp-2); margin: 0; font-size: 1rem; min-width: 0; }
.bcard-title .muted { font-weight: 500; }
.bcard-num {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: .8125rem; font-weight: 700;
}
.bcard-source { margin: calc(-1 * var(--sp-2)) 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard-source a { color: var(--text-muted); }
.bcard-progress { padding: var(--sp-3); border-radius: var(--radius); background: var(--surface-2); }
.bcard-state { font-weight: 650; margin: 0 0 var(--sp-3); }
.steps.compact { grid-template-columns: 1fr; gap: var(--sp-2); margin: 0; }
.steps.compact .step { flex-direction: row; text-align: left; gap: var(--sp-2); }
.steps.compact .step + .step::before { display: none; }
.steps.compact .step-dot { width: 20px; height: 20px; }
.steps.compact .step.done .step-dot::after { width: 5px; height: 9px; margin-top: -2px; }
.bcard-state-box { padding: var(--sp-3); border-radius: var(--radius); background: var(--surface-2); }
.bcard-state-box p { margin: 0; }
.bcard-error { color: var(--danger); font-weight: 600; }
.bcard-video .reel { width: min(100%, 240px); }
.bcard-video .video-meta { margin-top: var(--sp-2); justify-content: center; gap: var(--sp-3); }
.bcard-video .video-meta .small { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard .job-bar, .bcard .notices .flash { margin-bottom: 0; }
.bcard .notices .flash + .flash { margin-top: var(--sp-2); }
.bcard .notice { flex-direction: column; }
.bcard-section { margin: 0; padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.bcard .card-head { margin-bottom: var(--sp-2); }
.bcard .card-head h2, .bcard .post-card h2 { font-size: .9375rem; }
.bcard .card-actions { margin-top: var(--sp-2); }
.bcard textarea { font-size: .875rem; }
.bcard textarea[data-headline] { min-height: 64px; }
.bcard-post { padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.bcard-post .card-head { margin-bottom: var(--sp-2); }
.bcard-post > .btn { width: 100%; margin: var(--sp-1) 0 var(--sp-2); }
.bcard .post-buttons .btn { min-height: 40px; }
.bcard .steps.four { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.bcard .steps.four .step { flex-direction: row; text-align: left; gap: var(--sp-2); font-size: .8125rem; }
.bcard .steps.four .step + .step::before { display: none; }
.bcard .steps.four .step-dot { width: 20px; height: 20px; }
.bcard .confirm-box { padding: var(--sp-3); }
.bcard .confirm-box .kv { grid-template-columns: 1fr; gap: 2px; }
.bcard .confirm-box .kv dd { margin-bottom: var(--sp-2); }
.bcard .confirm-box .form-actions .btn { flex: 1 1 auto; }
.bcard-foot { margin-top: auto; padding-top: var(--sp-2); border-top: 1px solid var(--border); font-size: .875rem; text-align: right; }
@media (max-width: 640px) {
  .batch-bar { padding: var(--sp-3); }
  .batch-actions, .batch-actions .btn { width: 100%; }
  .bcard { padding: var(--sp-3); }
}
