:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --bg-2: #101013;
  --panel: #15161a;
  --panel-2: #1c1d22;
  --panel-3: #25262c;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --soft: #71717a;
  --line: #27272a;
  --line-soft: #1f1f23;
  --accent: #6366f1;
  --accent-hover: #7c7ff5;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-2: #38bdf8;
  --success: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.4);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* ─── Login ─────────────────────────────────────── */

.login-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  padding: 32px;
  width: 100%;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 24px;
}

/* ─── Shell & topbar ────────────────────────────── */

.shell {
  min-height: 100vh;
  padding-bottom: 32px;
}

.topbar {
  align-items: center;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.brand span {
  color: var(--soft);
  font-size: 12px;
}

.top-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-right: 8px;
}

.pill {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 500;
  gap: 6px;
  padding: 4px 8px;
}

.pill::before {
  background: var(--soft);
  border-radius: 50%;
  content: "";
  display: inline-block;
  height: 6px;
  width: 6px;
}

.pill.ready { color: #e4e4e7; }
.pill.ready::before { background: var(--success); box-shadow: 0 0 6px var(--success); }
.pill.missing { color: #fca5a5; }
.pill.missing::before { background: var(--danger); }
.pill.dry-run { color: #fcd34d; }
.pill.dry-run::before { background: var(--warn); }

/* ─── View tabs ─────────────────────────────────── */

.view-tabs {
  display: flex;
  gap: 6px;
  padding: 16px 24px 0;
}

.view-tab {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  display: grid;
  gap: 2px;
  min-height: 52px;
  padding: 10px 16px;
  text-align: left;
  transition: all 0.15s ease;
  width: 180px;
}

.view-tab:hover {
  background: var(--panel);
  color: var(--text);
}

.view-tab.active {
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 16px -4px rgba(99, 102, 241, 0.4);
  color: var(--text);
}

.view-tab strong {
  font-size: 14px;
  font-weight: 600;
}

.view-tab span {
  color: var(--soft);
  font-size: 12px;
}

/* ─── Layout ────────────────────────────────────── */

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr) minmax(300px, 0.9fr);
  padding: 16px 24px;
}

.left-stack,
.middle-stack,
.right-stack {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

/* ─── Cards ─────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.card-subtitle {
  color: var(--soft);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ─── Metrics ───────────────────────────────────── */

.metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.metric span {
  color: var(--soft);
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 4px;
}

/* ─── Buttons ───────────────────────────────────── */

.btn {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  font-weight: 500;
  gap: 6px;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--panel-3);
  border-color: #3a3a40;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.6);
}

.btn.full { width: 100%; }

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.button-row + .button-row {
  margin-top: 8px;
}

.button-row .btn { flex: 1 1 160px; }

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* ─── Forms ─────────────────────────────────────── */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field:last-child { margin-bottom: 0; }

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.field input,
.field textarea,
.field select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  min-width: 0;
  outline: none;
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.field input:hover,
.field textarea:hover,
.field select:hover {
  border-color: #3a3a40;
}

.field textarea {
  font-family: inherit;
  min-height: 110px;
  resize: vertical;
}

.field textarea.compact { min-height: 70px; }

.field textarea.blog-body {
  line-height: 1.55;
  min-height: 380px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.two {
  display: grid;
  gap: 10px;
  grid-template-columns: 110px minmax(0, 1fr);
}

/* ─── Channels ──────────────────────────────────── */

.channel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.channel {
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  transition: all 0.15s ease;
  user-select: none;
}

.channel:hover { border-color: #3a3a40; }

.channel input {
  accent-color: var(--accent);
  height: 13px;
  margin: 0;
  width: 13px;
}

.channel.checked {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

/* ─── Idea / post / SEO cards ───────────────────── */

.idea-list,
.post-list,
.seo-list,
.published-list {
  display: grid;
  gap: 10px;
}

.idea-card,
.seo-item {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
}

.idea-card h3,
.seo-item h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

.idea-card p,
.seo-item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 10px;
}

.post-card {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  padding: 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.tag {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
}

.post-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 10px;
  justify-content: space-between;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* ─── Blog editor ───────────────────────────────── */

.blog-editor {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  padding: 14px;
}

.blog-editor-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding-bottom: 4px;
}

.blog-editor-head strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.blog-editor-head span {
  color: var(--soft);
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.blog-editor .two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ─── SEO score badge ───────────────────────────── */

.seo-badge-wrap {
  align-items: center;
  display: flex;
  gap: 8px;
}

.seo-badge {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 10px;
}

.seo-badge.great { background: rgba(16, 185, 129, 0.18); border: 1px solid rgba(16, 185, 129, 0.45); color: #6ee7b7; }
.seo-badge.good  { background: rgba(56, 189, 248, 0.16); border: 1px solid rgba(56, 189, 248, 0.4);  color: #7dd3fc; }
.seo-badge.mid   { background: rgba(245, 158, 11, 0.16); border: 1px solid rgba(245, 158, 11, 0.4);  color: #fcd34d; }
.seo-badge.low   { background: rgba(239, 68, 68, 0.16);  border: 1px solid rgba(239, 68, 68, 0.4);   color: #fca5a5; }

.seo-checks {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 10px 12px;
}

.seo-checks summary {
  color: #fcd34d;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.seo-checks summary::-webkit-details-marker { display: none; }
.seo-checks summary::before { content: "▸ "; }
.seo-checks[open] summary::before { content: "▾ "; }

.seo-checks ul {
  color: var(--muted);
  margin: 8px 0 0;
  padding-left: 20px;
}

.seo-checks li { margin-bottom: 4px; }
.seo-checks li strong { color: var(--text); font-weight: 600; }

.seo-checks-pass {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  color: #6ee7b7;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
}

/* ─── Status pills ──────────────────────────────── */

.status {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 3px 7px;
  text-transform: uppercase;
}

.status.draft { color: var(--muted); }
.status.scheduled { background: rgba(56, 189, 248, 0.12); border-color: rgba(56, 189, 248, 0.3); color: #7dd3fc; }
.status.failed { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.3); color: #fca5a5; }
.status.published { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.3); color: #6ee7b7; }

/* ─── Calendar ──────────────────────────────────── */

.calendar {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.day {
  appearance: none;
  aspect-ratio: 1 / 1.1;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  display: grid;
  gap: 3px;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  overflow: hidden;
  padding: 7px;
  text-align: left;
  transition: all 0.15s ease;
}

.day:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.day strong {
  font-size: 12px;
  font-weight: 600;
}

.day span {
  color: var(--soft);
  font-size: 10px;
}

.day.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.day small {
  align-self: end;
  background: rgba(99, 102, 241, 0.7);
  border-radius: 4px;
  color: #fff;
  display: block;
  font-size: 9px;
  font-weight: 500;
  overflow: hidden;
  padding: 2px 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Reply assistant ───────────────────────────── */

.reply-card .reply-drafts {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.reply-draft {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.reply-draft__head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.reply-draft textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  min-height: 70px;
  outline: none;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

.reply-draft textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.reply-history {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-top: 12px;
  padding: 8px 12px;
}

.reply-history summary { color: var(--muted); cursor: pointer; font-weight: 600; }
.reply-history ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.reply-history li { margin-bottom: 4px; }
.reply-history strong { color: var(--text); }

/* ─── Orphan banner ─────────────────────────────── */

.orphan-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(239, 68, 68, 0.1));
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: var(--radius-lg);
  margin: 12px 24px 0;
  padding: 16px 20px;
}

.orphan-banner__head strong {
  color: #fcd34d;
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.orphan-banner__head p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.orphan-banner__list {
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 12px;
  padding: 10px 12px 10px 28px;
}

.orphan-banner__list code {
  background: var(--panel-3);
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  padding: 1px 5px;
}

.orphan-banner__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Notices ───────────────────────────────────── */

.notice {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius);
  color: #c7d2fe;
  font-size: 13px;
  margin: 12px 24px 0;
  padding: 12px 14px;
}

.notice.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--soft);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

/* ─── Published log ─────────────────────────────── */

.published-row {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr auto;
  padding: 10px 0;
}

.published-row:first-child { padding-top: 0; }
.published-row:last-child { border-bottom: 0; padding-bottom: 0; }

.published-row strong {
  font-size: 13px;
  font-weight: 600;
}

.published-row .muted {
  font-size: 12px;
  margin-top: 2px;
}

.published-row a {
  color: #93c5fd;
  font-size: 12px;
  text-decoration: none;
}

.published-row a:hover { text-decoration: underline; }

/* ─── Modal ─────────────────────────────────────── */

.modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: grid;
  inset: 0;
  padding: 24px;
  place-items: center;
  position: fixed;
  z-index: 20;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: min(760px, 90vh);
  max-width: 900px;
  overflow: auto;
  padding: 20px;
  width: min(900px, 100%);
}

.modal-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.modal-head span {
  color: var(--muted);
  font-size: 13px;
}

.modal-posts {
  display: grid;
  gap: 10px;
}

/* ─── Responsive ────────────────────────────────── */

@media (max-width: 1200px) {
  .layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .view-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 12px; }
  .view-tab { width: 100%; }
  .layout { padding: 12px; }
  .metrics, .two, .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-backdrop { padding: 12px; }
  .modal-head { align-items: stretch; flex-direction: column; }
}

/* ─── Loading animations ────────────────────────── */

@keyframes progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-fade {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.progress-bar {
  background: var(--line-soft);
  height: 2px;
  left: 0;
  overflow: hidden;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 30;
}

.progress-bar::after {
  background: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent-hover) 50%, var(--accent) 70%, transparent);
  content: "";
  display: block;
  height: 100%;
  position: absolute;
  top: 0;
  width: 25%;
  animation: progress-slide 1.4s ease-in-out infinite;
}

.spinner {
  border: 2px solid currentColor;
  border-radius: 50%;
  border-right-color: transparent;
  border-top-color: transparent;
  display: inline-block;
  height: 14px;
  width: 14px;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

.btn.busy {
  pointer-events: none;
}

.busy-notice {
  align-items: center;
  background: linear-gradient(90deg, var(--accent-soft), rgba(56, 189, 248, 0.08));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  display: flex;
  font-size: 13px;
  font-weight: 500;
  gap: 12px;
  margin: 12px 24px 0;
  padding: 12px 16px;
  animation: pulse-fade 1.6s ease-in-out infinite;
}

.busy-notice .spinner {
  color: var(--accent);
  height: 16px;
  width: 16px;
  margin: 0;
}

.busy-notice strong {
  font-weight: 600;
}

/* ─── Scrollbar ─────────────────────────────────── */

::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--panel-3); }
