:root {
  --bg: #f6f3ea;
  --bg-card: #ffffff;
  --ink: #0b1f3a;
  --ink-2: #3a4b67;
  --accent: #0b1f3a;
  --gold: #c9a227;
  --muted: #6b7280;
  --border: #e5e1d2;
  --good: #16803d;
  --bad:  #b3261e;
  --warn: #a76e00;
  --quick: #f1efe3;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); }
a:hover { text-decoration: underline; }
.topbar {
  background: var(--accent);
  color: var(--bg);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; letter-spacing: -0.01em; color: var(--gold); font-size: 18px; }
.topbar .brand a { color: inherit; text-decoration: none; }
.topbar .who {
  opacity: 0.9; font-size: 13px; display: flex; align-items: center;
  justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}
.topbar .who a { color: inherit; text-decoration: none; }
.topbar .who a:hover { text-decoration: underline; }
.topbar-user { margin-right: 2px; }
.topbar-link { font-size: 12px; opacity: 0.82; }
.topbar-admin {
  display: inline-block; padding: 4px 10px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.1);
  color: var(--bg); font-size: 12px; font-weight: 600;
}
.topbar-admin:hover { background: rgba(255,255,255,0.16); text-decoration: none; }
.topbar form { display: inline; margin-left: 4px; }
.topbar button {
  background: transparent; color: var(--bg); border: 1px solid rgba(255,255,255,0.3);
  padding: 4px 10px; border-radius: 4px; font-size: 13px; cursor: pointer;
}
.container { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }
h1, h2, h3 { letter-spacing: -0.01em; }
h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 20px; margin: 24px 0 8px; color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }
.btn {
  display: inline-block; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--ink); padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 13px; text-decoration: none;
}
.btn:hover { background: #f0ebd8; }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: #13305a; }
.btn.danger  { background: var(--bad); color: white; border-color: var(--bad); }
.btn.good    { background: var(--good); color: white; border-color: var(--good); }
form.inline { display: inline; margin: 0; }
.flash-error {
  background: #fdf0ee; border: 1px solid #e0a8a1; color: var(--bad);
  padding: 10px 12px; border-radius: 6px; margin: 12px 0;
}
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
}
.pill.status-proposed { background: #f1efe3; color: var(--ink-2); }
.pill.status-accepted { background: #d7efe0; color: var(--good); }
.pill.status-rejected { background: #fbe5e1; color: var(--bad); text-decoration: line-through; }
.pill.tone-hi  { background: #dff4e5; color: var(--good); }
.pill.tone-mid { background: #fff1d1; color: var(--warn); }
.pill.tone-lo  { background: #fbe5e1; color: var(--bad); }

/* ---------- edition detail ---------- */
.edition-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 14px; gap: 20px; flex-wrap: wrap;
}
.edition-head h1 { margin: 0; }
.save-strip {
  margin: -4px 0 14px; color: var(--muted); font-size: 12px;
}
.save-strip .save-error { color: var(--bad); font-weight: 600; }
.intro-block {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin: 16px 0 24px;
}
.intro-block textarea {
  width: 100%; border: 1px dashed var(--border); border-radius: 6px; padding: 10px;
  font: inherit; font-size: 14px; resize: vertical; min-height: 100px; background: #fffef8;
}
.section {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 20px; overflow: hidden;
}
.section-head {
  padding: 10px 16px; background: var(--quick); display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid var(--border);
}
.section-head h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: 0.05em; }
.section-body { padding: 10px; min-height: 40px; }
.card {
  background: #fffef8; border: 1px solid var(--border); border-radius: 6px;
  padding: 14px; margin: 6px; cursor: grab; transition: background 0.12s;
}
.card-event { padding: 8px 10px; }
.card:active { cursor: grabbing; }
.card.card-accepted { background: #f4fbf6; border-color: #bfe0c9; }
.card.card-rejected { background: #fbf1ef; border-color: #e9c4bf; opacity: 0.65; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.card-source { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.source-name { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.source-name a {
  color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted);
}
.published-at { font-size: 12px; }
.card-actions { display: flex; gap: 6px; }
.card-image {
  display: block; max-width: 220px; max-height: 160px; width: auto; height: auto;
  border-radius: 4px; margin: 6px 0 8px; object-fit: cover;
  border: 1px solid var(--border); background: #fff;
}
.card-headline { font-size: 17px; margin: 4px 0 6px; color: var(--accent); font-weight: 600; }
.card-blurb { font-size: 14px; margin: 0 0 8px; color: var(--ink); }
.event-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.event-line { font-size: 14px; line-height: 1.35; color: var(--ink); }
.event-line a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.card-foot { font-size: 11px; }
.pet-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.pet-adopt-btn { font-weight: 600; }
.pet-fb-btn { font-size: 12px; }
.empty { padding: 12px 16px; color: var(--muted); font-style: italic; }
.sortable-ghost { opacity: 0.3; }
.toolbar {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.toolbar .muted { font-size: 12px; margin-left: auto; }
.card-edit { display: none; }
.card-edit.is-open { display: block; }
.card-edit label { display: block; font-size: 12px; margin-top: 8px; color: var(--muted); }
.card-edit input,
.card-edit textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font: inherit;
}
.card-edit textarea { min-height: 80px; }
.card-edit .actions { margin-top: 8px; display: flex; gap: 8px; }

/* ---------- export ---------- */
.export-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  margin: 16px 0 24px; overflow: hidden;
}
.export-panel-head {
  padding: 10px 14px; background: var(--quick); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
}
.export-panel textarea {
  display: block; width: 100%; min-height: 360px; border: 0; padding: 14px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #fffef8; color: var(--ink); resize: vertical;
}
.export-preview {
  padding: 18px; background: #fff; color: #1f2933;
}
.export-preview h1 { font-size: 24px; margin: 0 0 16px; }
.export-preview h2 { font-size: 18px; margin: 24px 0 10px; }
.export-preview h3 { font-size: 16px; margin: 16px 0 6px; }
.export-preview p { margin: 0 0 12px; }
.export-preview ul { margin: 0 0 14px 20px; padding: 0; }
.export-preview li { margin: 0 0 6px; }

/* ---------- candidate selection ---------- */
.candidate-toolbar,
.candidate-panel-head {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin: 14px 0; display: flex; justify-content: space-between;
  gap: 12px; align-items: center; flex-wrap: wrap;
}
.candidate-list {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.candidate-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px;
  align-items: start; padding: 12px 14px; border-top: 1px solid var(--border);
  cursor: pointer;
}
.candidate-row:first-child { border-top: 0; }
.candidate-row:hover { background: #fffdf2; }
.candidate-row input { margin-top: 3px; }
.candidate-main { display: grid; gap: 3px; min-width: 0; }
.candidate-title { font-weight: 650; color: var(--accent); line-height: 1.3; }
.candidate-meta { color: var(--muted); font-size: 12px; }
.candidate-desc { color: var(--ink-2); font-size: 13px; line-height: 1.35; }
.candidate-source {
  font-size: 12px; color: var(--ink-2); text-decoration: none;
  border-bottom: 1px dotted var(--muted);
}
.candidate-events {
  margin-top: 22px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
}
.candidate-events .candidate-panel-head {
  margin: 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background: var(--quick);
}
.candidate-events ul { margin: 0; padding: 10px 18px 12px 32px; }
.candidate-events li { margin: 4px 0; font-size: 13px; }
@media (max-width: 620px) {
  .candidate-row { grid-template-columns: 22px minmax(0, 1fr); }
  .candidate-source { grid-column: 2; }
}

/* ---------- export action group (edition detail) ---------- */
.export-action-group {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}

/* ---------- export status panel (edition detail) ---------- */
.export-status-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  margin: 0 0 20px; overflow: hidden;
}
.export-status-panel-head {
  padding: 8px 14px; background: var(--quick); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.export-status-panel-head strong { font-size: 13px; }
.export-status-body { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.export-status-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px;
}
.export-status-note {
  font-size: 12px; color: var(--muted); margin-top: 4px; padding-top: 4px;
  border-top: 1px solid var(--border);
}
.export-status-error { color: var(--bad); font-size: 12px; font-weight: 600; }
.export-quick-feedback {
  padding: 8px 14px; font-size: 13px; border-top: 1px solid var(--border);
}
.export-quick-feedback.is-ok { color: var(--good); }
.export-quick-feedback.is-error { color: var(--bad); }

/* ---------- export provider badges ---------- */
.export-provider-badge {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
}
.provider-html     { background: #e8f0fe; color: #1a56db; }
.provider-markdown { background: #fef3c7; color: #92400e; }
.provider-beehiiv  { background: #ede9fe; color: #5b21b6; }

/* ---------- export status pills ---------- */
.pill.status-export-rendering  { background: #fff1d1; color: var(--warn); }
.pill.status-export-rendered   { background: #d7efe0; color: var(--good); }
.pill.status-export-submitted  { background: #d7efe0; color: var(--good); }
.pill.status-export-failed     { background: #fbe5e1; color: var(--bad); }
.pill.status-export-pending    { background: #f1efe3; color: var(--ink-2); }

/* ---------- export console tabs ---------- */
.export-tabs {
  display: flex; gap: 2px; margin: 16px 0 0; border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}
.export-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; padding: 8px 16px; cursor: pointer; font-size: 14px;
  font-weight: 500; color: var(--muted); border-radius: 6px 6px 0 0;
  transition: color 0.1s, border-color 0.1s;
}
.export-tab:hover { color: var(--ink); background: var(--quick); }
.export-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.export-tab-badge {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 5px;
  vertical-align: middle;
}
.export-tab-badge.good { background: #d7efe0; color: var(--good); }
.export-tab-badge.warn { background: #fff1d1; color: var(--warn); }
.export-tab-badge.muted { background: var(--quick); color: var(--muted); }

/* ---------- export panel actions row ---------- */
.export-panel-actions {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ---------- export history table ---------- */
.export-history-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.export-history-table th {
  text-align: left; padding: 8px 14px; font-size: 12px; font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--border); background: var(--quick);
}
.export-history-table td {
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.export-history-table tr:last-child td { border-bottom: 0; }
.export-history-table tr:hover td { background: #fffdf5; }

/* ---------- beehiiv API result block ---------- */
.export-beehiiv-result {
  padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border);
}
.export-beehiiv-result.is-ok   { background: #f0faf4; color: var(--good); }
.export-beehiiv-result.is-warn { background: #fff9ec; color: var(--warn); }
.export-beehiiv-result.is-error{ background: #fdf0ee; color: var(--bad); }

/* ---------- export feedback bar (console page) ---------- */
.export-feedback-bar {
  position: sticky; bottom: 0; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; margin-top: 12px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.export-feedback-bar.is-ok   { border-color: var(--good); color: var(--good); }
.export-feedback-bar.is-error{ border-color: var(--bad); color: var(--bad); }
