:root {
  --ink: #16181d;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f8fa;
  --card: #ffffff;
  --brand: #7c3aed;
  --brand-dark: #6d28d9;
  --green: #d1fae5;
  --green-dark: #047857;
  --amber: #b45309;
  --danger: #dc2626;
  --sidebar-bg: #180f2e;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; text-decoration: none; }
code { background: #f1f1f4; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }

/* ---------- Public site ---------- */
body.pub { background: #fff; }
.pub-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 48px; border-bottom: 1px solid var(--line); }
.pub-brand { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.brand-mark { background: var(--brand); color: #fff; width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.pub-nav { display: flex; align-items: center; gap: 28px; font-weight: 600; font-size: 14.5px; }
.btn-primary { background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 8px; }
.hero { text-align: center; padding: 100px 24px 70px; max-width: 780px; margin: 0 auto; }
.eyebrow { color: var(--brand-dark); font-weight: 700; font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }
.hero h1 { font-size: 46px; line-height: 1.15; margin: 0 0 18px; letter-spacing: -0.02em; }
.hero .sub { font-size: 18px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 30px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; }
.btn { display: inline-block; padding: 12px 22px; border-radius: 9px; font-weight: 700; font-size: 15px; cursor: pointer; border: none; }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-block { width: 100%; text-align: center; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.section { max-width: 1100px; margin: 0 auto; padding: 70px 24px; }
.section h2 { font-size: 32px; text-align: center; margin-bottom: 10px; letter-spacing: -0.01em; }
.lede { text-align: center; color: var(--ink-soft); font-size: 16px; margin-bottom: 46px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.feature-card { border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.feature-card .icon { font-size: 26px; margin-bottom: 10px; }
.feature-card h3 { margin: 0 0 8px; font-size: 17px; }
.feature-card p { margin: 0; color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; }
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.price-card { border: 1.5px solid var(--line); border-radius: 16px; padding: 28px; position: relative; }
.price-card.featured { border-color: var(--brand); box-shadow: 0 8px 24px rgba(124,58,237,0.14); }
.price-card .tag { position: absolute; top: -12px; left: 24px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.price-card h3 { margin: 6px 0 4px; }
.price-card .price { font-size: 32px; font-weight: 800; margin-bottom: 18px; }
.price-card .price span { font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.price-card ul { list-style: none; padding: 0; margin: 0 0 22px; }
.price-card li { padding: 7px 0; font-size: 14px; color: #374151; border-top: 1px solid #f1f1f4; }
.price-card li:first-child { border-top: none; }
.pub-footer { text-align: center; padding: 40px 24px; color: var(--ink-soft); font-size: 13.5px; border-top: 1px solid var(--line); }

/* ---------- Auth ---------- */
.auth-wrap, .onboard-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.auth-card { background: var(--card); border-radius: 16px; padding: 40px; width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,0.06); }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.auth-card .sub { color: var(--ink-soft); margin: 0 0 24px; font-size: 14.5px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--ink-soft); }
.auth-alt a { color: var(--brand-dark); font-weight: 600; }
.error-box { background: #fee2e2; color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=color], select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 14.5px; font-family: inherit; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Color swatches / checkbox chips (onboarding + settings) ---------- */
.color-swatches { display: flex; gap: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; display: block; cursor: pointer; position: relative; border: 2px solid transparent; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.check-chip input { margin: 0; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar-bg); color: #e5e7eb; display: flex; flex-direction: column; padding: 22px 16px; flex-shrink: 0; }
.brand { font-weight: 800; font-size: 19px; display: flex; align-items: center; gap: 8px; padding: 0 8px 20px; }
.brand .brand-mark { background: transparent; font-size: 22px; width: auto; height: auto; }
.store-name { padding: 10px 8px 18px; font-weight: 700; font-size: 14px; border-bottom: 1px solid #2a2540; margin-bottom: 14px; }
.plan-sub { font-weight: 400; color: #9296a6; font-size: 12px; text-transform: capitalize; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a { padding: 10px 12px; border-radius: 8px; font-size: 14.5px; font-weight: 600; color: #c7cad4; display: flex; align-items: center; gap: 10px; }
.side-nav a.active, .side-nav a:hover { background: #2d275280; color: #fff; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }
.sidebar-footer { border-top: 1px solid #2a2540; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-mode-pill { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; width: fit-content; }
.ai-mode-pill.live { background: #05372a; color: #34d399; }
.ai-mode-pill.test { background: #3a2e05; color: #fbbf24; }
.link-btn { background: none; border: none; color: #9296a6; font-size: 13.5px; cursor: pointer; padding: 0; font-weight: 600; }
.link-btn:hover { color: #fff; }
.main-pane { flex: 1; padding: 32px 40px; max-width: 1180px; }
.flash { background: var(--green); color: var(--green-dark); padding: 10px 16px; border-radius: 8px; margin-bottom: 20px; font-weight: 600; font-size: 14px; }
.flash.danger { background: #fee2e2; color: var(--danger); }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; gap: 20px; }
.page-header h1 { margin: 0 0 4px; font-size: 26px; }
.page-header p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.stat-card .label { color: var(--ink-soft); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 800; }
.stat-card .value.green { color: var(--green-dark); }
.stat-card .value.danger { color: var(--danger); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; margin-bottom: 20px; }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card h2.no-margin { margin: 0; }
.card-sub { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 16px; }
.empty-state { color: var(--ink-soft); font-size: 14px; padding: 30px 10px; text-align: center; }
.empty-state a { color: var(--brand-dark); font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); padding: 12px 20px; border-bottom: 1px solid var(--line); }
td { padding: 14px 20px; border-bottom: 1px solid #f1f1f4; font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: #fafafb; }

.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; background: #eef2ff; color: #4338ca; }
.pill.completed, .pill.done, .pill.active { background: var(--green); color: var(--green-dark); }
.pill.failed { background: #fee2e2; color: var(--danger); }
.pill.running { background: #fef3c7; color: var(--amber); }
.pill.platform-pill { background: #f3e8ff; color: #7e22ce; text-transform: none; }

.btn.btn-sm { padding: 7px 14px; font-size: 13px; }

.add-btn { background: none; border: 1.5px dashed var(--line); border-radius: 8px; padding: 10px; width: 100%; font-weight: 700; font-size: 13.5px; color: var(--brand-dark); cursor: pointer; margin-top: 4px; }

.engine-badge { font-size: 10.5px; font-weight: 800; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.engine-badge.mock { background: #fef3c7; color: var(--amber); }
.engine-badge.gemini, .engine-badge.claude { background: var(--green); color: var(--green-dark); }
.engine-badge.error { background: #fee2e2; color: var(--danger); }
.run-spinner { color: var(--ink-soft); font-size: 13.5px; padding: 10px 0; }

@media (max-width: 900px) {
  .feature-grid, .pricing-grid, .stat-grid, .form-grid-2, .composer-grid { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
}

/* ---------- Onboarding steps ---------- */
.onboard-steps { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; width: 420px; }
.onboard-steps .step { flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
.onboard-steps .step.done { background: var(--brand); }

/* ---------- Composer ---------- */
.composer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.gen-preview-thumb { width: 100%; max-width: 260px; border-radius: 12px; overflow: hidden; margin-bottom: 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.gen-preview-thumb svg { display: block; width: 100%; height: auto; }
.gen-preview-caption { white-space: pre-wrap; font-size: 14px; line-height: 1.6; background: #fafafb; border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.gen-preview-hashtags { color: var(--brand-dark); font-size: 13.5px; margin-bottom: 16px; }
.gen-save-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gen-save-row input[type=datetime-local] { width: auto; flex: 1; min-width: 190px; }

/* ---------- Post cards (composer results, calendar drafts, campaign posts, all posts) ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.post-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.post-thumb { width: 100%; aspect-ratio: 1 / 1; background: #f1f1f4; }
.post-thumb svg { display: block; width: 100%; height: 100%; }
.post-body { padding: 14px 16px; }
.post-meta-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.post-caption { font-size: 13.5px; line-height: 1.55; color: #374151; white-space: pre-wrap; margin-bottom: 8px; max-height: 110px; overflow-y: auto; }
.post-hashtags { color: var(--brand-dark); font-size: 12.5px; margin-bottom: 8px; }
.post-when { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; }
.post-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input[type=datetime-local] { width: auto; font-size: 12.5px; padding: 6px 8px; }

/* ---------- Calendar ---------- */
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; padding-bottom: 6px; }
.cal-cell { min-height: 90px; border: 1px solid #f1f1f4; border-radius: 8px; padding: 6px; font-size: 12px; }
.cal-cell.empty { border: none; }
.cal-cell.today { border-color: var(--brand); background: #faf5ff; }
.cal-daynum { font-weight: 700; margin-bottom: 4px; color: var(--ink-soft); }
.cal-post { background: #f3e8ff; color: #6b21a8; border-radius: 5px; padding: 2px 6px; margin-bottom: 3px; font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-post.posted { background: var(--green); color: var(--green-dark); }

/* ---------- Campaign ideas ---------- */
.idea-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.idea-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; }
.idea-item.used { opacity: 0.55; }
.idea-item .idea-text { flex: 1; }

/* ---------- Platform connections ---------- */
.connection-row { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.connection-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.connection-row .form-grid-2 { margin-bottom: 10px; }
.connection-row code { background: #f4f4f7; padding: 2px 6px; border-radius: 5px; font-size: 12px; }
.post-published-link { font-size: 12.5px; color: var(--green-dark); margin-bottom: 8px; }
.post-published-link a { color: inherit; }
.post-publish-error { font-size: 12.5px; color: var(--danger); background: #fef2f2; border-radius: 6px; padding: 6px 9px; margin-bottom: 8px; }

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

/* ---------- API docs ---------- */
.doc-wrap { max-width: 860px; margin: 0 auto; padding: 60px 24px 100px; }
.doc-wrap h1 { font-size: 34px; margin: 0 0 8px; letter-spacing: -0.01em; }
.doc-wrap .sub { color: var(--ink-soft); font-size: 16px; margin: 0 0 40px; }
.doc-group { margin-bottom: 40px; }
.doc-group h2 { font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; }
.doc-group-note { color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; margin: 0 0 18px; }
.doc-endpoint { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
.doc-endpoint p { font-size: 14px; color: var(--ink); margin: 0 0 14px; }
.doc-endpoint-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.doc-method { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 6px; letter-spacing: 0.03em; }
.doc-method-get { background: var(--green); color: var(--green-dark); }
.doc-method-post { background: #eef2ff; color: #4338ca; }
.doc-path { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; font-weight: 700; }
.doc-block { margin-bottom: 10px; }
.doc-block:last-child { margin-bottom: 0; }
.doc-block-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); margin-bottom: 4px; }
.doc-block pre { background: #0f1117; color: #d8dae2; border-radius: 8px; padding: 12px 14px; font-size: 12.5px; line-height: 1.6; overflow-x: auto; margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
