/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1A212C;
  --ink-2: #232B38;
  --teal: #00ADBF;
  --teal-soft: #57B9C9;
  --magenta: #BF1E5E;
  --magenta-dark: #A0194F;
  --brand: #00ADBF;
  --brand-dark: #00929F;
  --brand-light: #E5F7F9;
  --surface: #ffffff;
  --bg: #F4F6F8;
  --border: #E3E7EC;
  --text: #1A212C;
  --text-muted: #64748b;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --header-h: 68px;
  --sidebar-w: 232px;
}

html, body { height: 100%; font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--ink); color: var(--text); font-size: 15px; line-height: 1.6; }

h1, h2, h3, h4, h5, h6 { font-family: 'Ubuntu', sans-serif; font-weight: 300; color: var(--teal); }

/* ─── App shell: dark frame (header + sidebar) around light work area ─── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 0 20px;
  z-index: 110;
}
.app-brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.wb-logo { width: 45px; height: 30px; flex: none; }
.app-wordmark { display: flex; flex-direction: column; line-height: 1.25; }
.app-wordmark-main {
  font-family: 'Ubuntu', sans-serif;
  font-weight: 300;
  font-size: 17px;
  letter-spacing: .3em;
  color: #fff;
  text-transform: uppercase;
}
.app-wordmark-sub {
  font-family: 'Ubuntu', sans-serif;
  font-weight: 300;
  font-size: 11px;
  letter-spacing: .3em;
  color: var(--teal-soft);
  text-transform: lowercase;
}
.app-user { display: flex; align-items: center; gap: 12px; }
.app-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ink-2);
  border: 1px solid var(--teal);
  color: var(--teal);
  font-family: 'Ubuntu', sans-serif;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.app-user-name { font-size: 13px; color: #B9C2CE; }
.app-signout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.18);
  color: #B9C2CE;
  font-family: 'Ubuntu', sans-serif;
  font-weight: 300;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.app-signout:hover { border-color: var(--teal); color: var(--teal); }

.app-sidebar {
  position: fixed;
  top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 14px 16px;
  z-index: 100;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-group {
  font-family: 'Ubuntu', sans-serif;
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6B7684;
  margin: 18px 10px 6px;
}
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #AEB7C2;
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.side-item svg { width: 16px; height: 16px; flex: none; }
.side-item:hover { background: rgba(255,255,255,.06); color: #E5EAF0; }
.side-item.active {
  background: rgba(0,173,191,.12);
  border-left-color: var(--teal);
  color: var(--teal-soft);
}
.side-footer {
  margin-top: auto;
  padding: 18px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.side-footer svg { width: 100%; height: 14px; }
.side-footer span { font-size: 10.5px; color: #6B7684; letter-spacing: .08em; }

main.work {
  position: fixed;
  top: var(--header-h); left: var(--sidebar-w); right: 0; bottom: 0;
  background: var(--bg);
  border-top-left-radius: 14px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Small screens: collapse the frame — header stays, sidebar becomes a scrollable row */
@media (max-width: 820px) {
  .app-header { padding: 0 14px; }
  .app-user-name { display: none; }
  .app-sidebar {
    top: var(--header-h);
    bottom: auto;
    width: 100%;
    height: 52px;
    flex-direction: row;
    align-items: center;
    padding: 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .side-nav { flex-direction: row; align-items: center; }
  .side-group { margin: 0 6px; white-space: nowrap; }
  .side-item { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; border-radius: 6px; }
  .side-item.active { border-left: none; border-bottom-color: var(--teal); }
  .side-footer { display: none; }
  main.work { top: calc(var(--header-h) + 52px); left: 0; border-top-left-radius: 0; }
}
.element-format { display: block; font-size: 12px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.nav-badge {
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ─── Layout ─── */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-sm { max-width: 720px; margin: 0 auto; padding: 32px 24px; }

/* ─── Page header ─── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 22px; }
.page-header p { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* ─── Card ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--magenta);
  color: #fff;
  font-family: 'Ubuntu', sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 13px;
}
.btn-primary:hover { background: var(--magenta-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group label span.req { color: var(--danger); margin-left: 2px; }
.form-group small { color: var(--text-muted); font-size: 12px; margin-top: 4px; display: block; }
input[type=text], input[type=url], input[type=email], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,173,191,.15);
}
textarea { resize: vertical; min-height: 90px; }
.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.radio-group label, .checkbox-group label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 400;
  font-size: 14px;
  cursor: pointer;
}
.radio-group input, .checkbox-group input { margin-top: 2px; accent-color: var(--brand); }
.custom-input-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.custom-input-row input { flex: 1; }

/* ─── Alerts ─── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: var(--brand-light); color: #007A87; border: 1px solid #BFE9EE; }

/* ─── Table ─── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); background: var(--bg); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ─── Stepper ─── */
.stepper { display: flex; gap: 0; margin-bottom: 28px; }
.step-item { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step-item.completed:not(:last-child)::after { background: var(--brand); }
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
  position: relative;
}
.step-item.active .step-num { background: var(--brand); color: #fff; }
.step-item.completed .step-num { background: var(--success); color: #fff; }
.step-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; text-align: center; }
.step-item.active .step-label { color: var(--brand); font-weight: 600; }

/* ─── Persona list ─── */
.persona-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.persona-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
  background: var(--bg);
}
.persona-item .remove-persona {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1;
}
.persona-item .remove-persona:hover { color: var(--danger); }

/* ─── Mode tabs ─── */
.mode-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.mode-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.mode-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ─── Output panel ─── */
.output-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  font-family: inherit;
  position: relative;
}
.output-panel .placeholder {
  color: var(--text-muted);
  font-style: italic;
}
.output-actions { display: flex; gap: 8px; margin-top: 12px; }
.cursor-blink {
  display: inline-block;
  width: 2px; height: 16px;
  background: var(--brand);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ─── Loading spinner ─── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Login page ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-brand .wb-logo { width: 72px; height: 48px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background .15s, box-shadow .15s;
}
.btn-google:hover { background: var(--bg); box-shadow: var(--shadow); }

/* ─── Client cards ─── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.client-card h3 { font-size: 16px; }
.client-card .meta { font-size: 12px; color: var(--text-muted); }
.client-card .actions { margin-top: auto; padding-top: 12px; display: flex; gap: 8px; }

/* ─── Select ─── */
select { cursor: pointer; }

/* ─── Divider ─── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ─── Guided form grid ─── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 680px) { .form-grid { grid-template-columns: 1fr; } }

/* ─── Floating copy button ─── */
.copy-btn {
  position: absolute; top: 12px; right: 12px;
  padding: 4px 10px; font-size: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; color: var(--text-muted);
}
.copy-btn:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }

/* ─── AI prefill loading ─── */
#prefill-status { display: none; align-items: center; gap: 8px; font-size: 13px; color: var(--brand); margin-top: 8px; }

/* ─── Admin badge ─── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-user { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Ad-copy tools: element picker + asset results (shared by Google/LinkedIn/Meta Ads) ── */
.help-text { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.element-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.element-pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
.element-check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 0; font-weight: 500; }
.element-check input[type="checkbox"] { width: auto; margin: 0; }
.element-pick select { width: auto; min-width: 64px; }
@media (max-width: 640px) { .element-picker { grid-template-columns: 1fr; } }

.asset-copy-all { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.asset-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.asset-group-head h3 { font-size: 15px; margin: 0; }
.asset-group-actions { display: flex; gap: 6px; }
.asset-group-note { font-size: 13px; color: #b45309; margin: 0 0 10px; }
.asset-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.asset-row .asset-input { flex: 1; }
.asset-row textarea.asset-input { resize: vertical; }
.char-badge { flex-shrink: 0; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-muted); background: var(--bg, #f3f4f6); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; margin-top: 7px; }
.char-badge.over { color: #b91c1c; background: #fee2e2; border-color: #fca5a5; font-weight: 600; }
.asset-input.asset-invalid { border-color: #f87171; }

/* ── Library ── */
.library-chip { display: flex; align-items: center; gap: 8px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 8px 12px; margin: 12px 0; font-size: 13px; flex-wrap: wrap; }
.library-chip .lib-label { color: #166534; white-space: nowrap; }
.library-chip .lib-title { flex: 1; min-width: 160px; border: 1px solid transparent; background: transparent; font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.library-chip .lib-title:hover, .library-chip .lib-title:focus { border-color: #bbf7d0; background: #fff; outline: none; }
.lib-star, .lib-star-static { background: none; border: none; cursor: pointer; font-size: 16px; color: #94a3b8; padding: 0 2px; line-height: 1; }
.lib-star.starred, .lib-star-static.starred { color: #f59e0b; }
span.lib-star-static { cursor: default; }
.lib-status { font-size: 12px; color: var(--text-muted); }
.lib-status-error { color: #b45309; }

.library-recent { padding: 0; overflow: hidden; }
.library-recent-head { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer; padding: 12px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.library-recent-body { padding: 0 16px 12px; }
.library-recent-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #f1f5f9; font-size: 13px; }
.lib-recent-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-recent-meta { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.lib-avatar { width: 20px; height: 20px; border-radius: 50%; }
.library-recent-foot { padding-top: 10px; border-top: 1px solid #f1f5f9; font-size: 13px; }

.tool-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tool-badge.seo-on-page { background: #ecfdf5; color: #047857; }
.tool-badge.content-brief { background: #eff6ff; color: #1d4ed8; }
.tool-badge.google-ads { background: #fef9c3; color: #a16207; }
.tool-badge.meta-ads { background: #eef2ff; color: #4338ca; }
.tool-badge.linkedin-ads { background: #e0f2fe; color: #0369a1; }
.tool-badge.social-lead-in { background: #fdf2f8; color: #be185d; }

.library-filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.library-filter-bar input[type=text], .library-filter-bar select { width: auto; min-width: 140px; }
.library-table tr.lib-row { cursor: pointer; }
.library-table .lib-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.lib-toggle { display: inline-flex; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.lib-toggle a { padding: 7px 14px; font-size: 13px; color: var(--text-muted); text-decoration: none; }
.lib-toggle a.active { background: #0f172a; color: #fff; }
.lib-pager { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 13px; color: var(--text-muted); }

.lib-inputs-summary summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.lib-inputs-table { font-size: 13px; margin-top: 12px; }
.lib-inputs-table td:first-child { color: var(--text-muted); white-space: nowrap; padding-right: 16px; vertical-align: top; }

/* ── Rich output (Quill) ── */
.rich-output .ql-container { font-size: 14px; font-family: inherit; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }
.rich-output .ql-toolbar { border-top-left-radius: 8px; border-top-right-radius: 8px; background: #f8fafc; }
.rich-output .ql-editor { min-height: 260px; line-height: 1.6; }
.rich-output .ql-editor h2 { font-size: 20px; margin: 18px 0 8px; }
.rich-output .ql-editor h3 { font-size: 16px; margin: 14px 0 6px; }

/* ─── Dashboard ─── */
.breadcrumb { font-size: 12.5px; color: var(--text-muted); letter-spacing: .04em; margin-bottom: 14px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 28px; }
.dash-head h1 { font-size: 26px; color: var(--text); }
.dash-head-actions { display: flex; align-items: center; gap: 12px; }
.dash-head-actions select { width: 200px; }
.dash-section-label {
  font-family: 'Ubuntu', sans-serif;
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.quick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .15s, box-shadow .15s;
}
.quick-card:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.quick-card svg { width: 22px; height: 22px; margin-bottom: 4px; }
.quick-card strong { font-size: 14.5px; font-weight: 600; }
.quick-card span { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.open-link { color: var(--teal); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.open-link:hover { text-decoration: underline; }
