:root {
  --bg: #f3ebde;
  --surface: rgba(255, 250, 242, 0.88);
  --surface-strong: rgba(255, 247, 236, 0.97);
  --ink: #1d312d;
  --muted: #5a665f;
  --line: rgba(29, 49, 45, 0.1);
  --accent: #0f766e;
  --accent-soft: #c7ece8;
  --rust: #b65a38;
  --sun: #f2c36b;
  --shadow: 0 24px 64px rgba(32, 28, 18, 0.12);
  --radius: 20px;
  --radius-sm: 14px;
  --sidebar-w: 230px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(242,195,107,.45), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(15,118,110,.18), transparent 28rem),
    linear-gradient(160deg, #f7f0e5 0%, #efe3d0 58%, #f4ecdf 100%);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(29,49,45,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29,49,45,.035) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

.aura {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.33;
  pointer-events: none;
  z-index: 0;
}
.aura-1 { top: -10rem; right: -6rem; background: rgba(182,90,56,.42); }
.aura-2 { left: -10rem; bottom: -12rem; background: rgba(15,118,110,.28); }

/* ── APP LAYOUT ────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  background: rgba(255, 250, 242, 0.75);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  text-decoration: none;
  color: var(--ink);
  display: block;
  padding: 0.5rem 0.6rem 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

.sidebar-brand h1 {
  margin: 0.2rem 0 0;
  font-size: 1.3rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(29,49,45,.07);
  color: var(--ink);
}

.nav-item.active {
  background: rgba(15,118,110,.12);
  color: var(--accent);
  font-weight: 700;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-top: 1rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ink), #23443e);
  color: #fff7ef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-username {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-email {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  width: 100%;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
}

/* ── MAIN AREA ─────────────────────────────────────────── */
.main-area {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

.shell {
  padding: 1.75rem 2rem 3rem;
  display: grid;
  gap: 1.5rem;
  max-width: 1100px;
}

/* ── SECTIONS ──────────────────────────────────────────── */
.dash-section { display: none; }
.dash-section.active { display: grid; gap: 1.5rem; }

.page-header h2 {
  margin: 0.25rem 0 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  letter-spacing: -0.02em;
}

/* ── STATS ROW ─────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 100px;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  font-family: "Iowan Old Style", Georgia, serif;
  line-height: 1;
}

/* ── OVERVIEW GRID ─────────────────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 1rem;
}

.overview-card {
  padding: 1.4rem;
}

.overview-card h3 {
  margin: 0.3rem 0 0.6rem;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

/* ── TWO PANE (kept for other uses) ───────────────────── */
.two-pane {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 1.25rem;
  align-items: start;
}
.pane-card { padding: 1.4rem; }

/* ── CREATE PANEL ──────────────────────────────────────── */
.create-panel { overflow: visible; }

.create-panel-header {
  padding: 1.6rem 1.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.create-panel-header h3 {
  margin: 0.25rem 0 0;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 1.15rem;
}

.create-panel-form { padding: 0 1.75rem 1.25rem; }

.form-section {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0 1.5rem;
  align-items: start;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--line);
}
.form-section:last-of-type { border-bottom: none; }

.form-section-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  padding-top: 0.6rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.form-step {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--rust);
}

.form-section-fields { display: grid; gap: 0.75rem; }
.form-section-fields.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-section-fields.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-section-fields.cols-4 { grid-template-columns: repeat(4, 1fr); }

.create-panel-footer {
  padding: 1.25rem 0 0.25rem;
  display: flex;
  justify-content: flex-end;
}

/* ── AUTOMATION GRID ───────────────────────────────────── */
.automation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.1rem;
  align-items: start;
}

.auto-card { padding: 1.25rem 1.4rem; }
.auto-card--paused { opacity: 0.7; }

.auto-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.auto-card-title h4 {
  margin: 0 0 0.2rem;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 1rem;
}

.auto-card-topics {
  margin: 0;
  font-size: 0.83rem;
  color: var(--muted);
  max-width: 22ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auto-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.9rem;
}

.auto-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
}

.auto-meta-key {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rust);
}

.auto-card-schedule { margin-bottom: 0.75rem; }
.auto-card-schedule .auto-meta-key { display: block; margin-bottom: 0.4rem; }

.schedule-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.schedule-pill {
  padding: 0.2rem 0.55rem;
  background: rgba(15,118,110,.08);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid rgba(15,118,110,.15);
}

.auto-card-batch {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.auto-card-actions { display: grid; gap: 0.5rem; }

.generate-form {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.5rem;
}

/* ── SUGGESTION GRID ───────────────────────────────────── */
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.suggestion-card {
  padding: 1.25rem;
}

.suggestion-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.pill-status-approved { background: rgba(15,118,110,.12); color: #0f5d57; }
.pill-status-draft { background: rgba(242,195,107,.25); color: #8a6a00; }
.pill-status-rework_requested { background: rgba(182,90,56,.12); color: #8c4227; }

/* ── LINKEDIN BUTTON ───────────────────────────────────── */
.linkedin-btn {
  background: linear-gradient(135deg, #0a66c2, #004182);
  color: #fff;
  border-color: transparent;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.linkedin-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(10,102,194,.3); }

.linkedin-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #0a66c2;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  font-style: italic;
}

/* ── LOGS ──────────────────────────────────────────────── */
.log-list {
  display: grid;
  gap: 0.75rem;
}

.log-card {
  padding: 1rem 1.2rem;
}

.log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── SHARED ────────────────────────────────────────────── */
.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.15), transparent 40%);
  pointer-events: none;
}

.section-head { margin-bottom: 1rem; }
.section-head h3 {
  margin: 0.25rem 0 0;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.eyebrow, .stat-label {
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.73rem;
  color: var(--rust);
  font-weight: 700;
}

.two-col {
  display: flex;
  gap: 0.8rem;
}
.two-col > * { flex: 1; }

.meta-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 0.4rem 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.button-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.93rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(29,49,45,.14);
  border-radius: 12px;
  background: rgba(255,252,246,.92);
  padding: 0.8rem 1rem;
  color: var(--ink);
  font: inherit;
  font-size: 0.93rem;
}
textarea { resize: vertical; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1.8rem;
}
.checkbox input { width: auto; margin: 0; }

button {
  cursor: pointer;
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
  font-family: inherit;
}
button:hover { transform: translateY(-1px); }

.primary-btn {
  background: linear-gradient(135deg, var(--ink), #23443e);
  color: #fff7ef;
  box-shadow: 0 8px 24px rgba(29,49,45,.18);
}
.secondary-btn {
  background: linear-gradient(135deg, var(--accent), #0f5d57);
  color: white;
}
.ghost-btn {
  background: transparent;
  border-color: rgba(29,49,45,.18);
  color: var(--ink);
}

.pill {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(29,49,45,.08);
  background: rgba(255,250,242,.8);
  font-size: 0.82rem;
  white-space: nowrap;
}
.pill-live { background: rgba(15,118,110,.12); color: #0f5d57; }
.pill-off { background: rgba(182,90,56,.12); color: #8c4227; }

.stack-form { display: grid; gap: 0.9rem; }

.hook { font-weight: 700; margin: 0.5rem 0 0.25rem; }
.body-copy { color: var(--muted); margin: 0.25rem 0; font-size: 0.9rem; }
.quality { font-size: 0.88rem; color: var(--muted); white-space: nowrap; }
.subtle { color: var(--muted); font-size: 0.88rem; margin: 0.2rem 0; }

.empty-state {
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(29,49,45,.18);
  background: rgba(255,251,245,.65);
}
.empty-state h4 { margin: 0 0 0.4rem; font-family: "Iowan Old Style", Georgia, serif; }
.empty-state p { margin: 0; color: var(--muted); }

code {
  background: rgba(29,49,45,.07);
  padding: 0.15em 0.4em;
  border-radius: 6px;
  font-size: 0.88em;
  font-family: monospace;
}

/* ── TOAST ─────────────────────────────────────────────── */
#toast-root {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff7ef;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(29,49,45,.28);
  max-width: 360px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.toast--in { opacity: 1; transform: translateY(0); }
.toast--error { background: #7d341d; }

.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* ── AUTH PAGES ────────────────────────────────────────── */
.topbar, .auth-body .shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0 1rem;
}

.topbar h1 {
  margin: 0;
  font-family: "Iowan Old Style", Georgia, serif;
  letter-spacing: -0.02em;
}

.brand-link, .topbar-link, .text-btn, .auth-footer a { text-decoration: none; }
.brand-link { color: inherit; }

.topbar-note {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.topbar-note span, .topbar-link {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(29,49,45,.08);
  background: rgba(255,250,242,.8);
  font-size: 0.88rem;
  color: var(--ink);
}

.topbar-link-strong {
  background: linear-gradient(135deg, var(--ink), #23443e);
  color: #fff7ef !important;
}

.auth-body .shell { display: grid; gap: 1.25rem; padding-bottom: 2rem; }

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 9rem);
}

.auth-card {
  width: min(520px, 100%);
  padding: 1.6rem;
}

.auth-entry-panel { padding: 1.5rem; }

.full-width-btn { width: 100%; margin-top: 1rem; }

.alert-box {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(182,90,56,.2);
  background: rgba(182,90,56,.12);
  color: #7d341d;
}

.auth-footer { margin: 0.25rem 0 0; color: var(--muted); }
.auth-footer a { color: var(--accent); font-weight: 700; }

.inline-form { margin: 0; }

/* Landing */
.landing-hero { align-items: center; }
.landing-badges .badge-card strong { font-size: 1.45rem; }
.landing-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1.2rem; }

.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  padding: 2rem;
}
.hero h2 {
  font-size: clamp(2rem, 3vw, 3.4rem);
  line-height: 1;
  max-width: 16ch;
  font-family: "Iowan Old Style", Georgia, serif;
  margin: 0;
}
.hero-copy { max-width: 60ch; color: var(--muted); }
.hero-badges {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 1rem;
  align-content: center;
}
.badge-card, .stat-panel {
  padding: 1.15rem;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid rgba(29,49,45,.08);
}
.badge-card strong { display: block; font-size: clamp(1.6rem,3vw,2.2rem); margin-bottom: 0.2rem; }

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
}

@media (max-width: 820px) {
  .app-layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-brand { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 0.25rem; flex: 0; }
  .sidebar-footer { border-top: none; padding-top: 0; margin-top: 0; margin-left: auto; }
  .sidebar-email { display: none; }

  .shell { padding: 1rem 1rem 2rem; }
  .two-pane, .overview-grid { grid-template-columns: 1fr; }
  .suggestion-grid, .automation-grid { grid-template-columns: 1fr; }
  .two-col, .button-row { flex-direction: column; }
  .mini-form, .generate-form { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; }
  .form-section-label { flex-direction: row; align-items: center; padding-top: 0; }
  .form-section-fields.cols-2,
  .form-section-fields.cols-3,
  .form-section-fields.cols-4 { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .stats-row { gap: 0.6rem; }
  .stat-card { min-width: calc(50% - 0.3rem); }
  .nav-item span { display: none; }
}
