/* marketing.css — dark theme for Marketing & Content app */

:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --muted: #71717a;
  --accent: #f97316;
  --accent-hover: #ea6c0a;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --info: #3b82f6;
  --sidebar-width: 220px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

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

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.sidebar-tagline {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(249, 115, 22, 0.08);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(249, 115, 22, 0.1);
}

.nav-item .icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.sidebar-footer a {
  color: var(--muted);
  font-size: 11px;
}

.sidebar-footer a:hover {
  color: var(--danger);
}

/* ── Main content ─────────────────────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.page-content {
  padding: 28px;
  flex: 1;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── Stat grid ────────────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(42, 45, 58, 0.6);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-draft      { background: rgba(113,113,122,0.2); color: var(--muted); }
.badge-published  { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-active     { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-paused     { background: rgba(234,179,8,0.15);  color: var(--warning); }
.badge-covered    { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-uncovered  { background: rgba(239,68,68,0.15);  color: var(--danger); }
.badge-facebook   { background: rgba(59,130,246,0.15); color: var(--info); }
.badge-google     { background: rgba(234,179,8,0.15);  color: var(--warning); }
.badge-pending    { background: rgba(249,115,22,0.15); color: var(--accent); }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

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

.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

select option {
  background: var(--card);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── Filter bar ───────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
  width: auto;
  min-width: 140px;
}

/* ── Alerts / Flash ───────────────────────────────────────────────────────── */

.flash {
  padding: 11px 16px;
  border-radius: 6px;
  margin-bottom: 18px;
  font-size: 13px;
  border: 1px solid;
}

.flash-success { background: rgba(34,197,94,0.1); color: var(--success); border-color: rgba(34,197,94,0.3); }
.flash-error   { background: rgba(239,68,68,0.1); color: var(--danger);  border-color: rgba(239,68,68,0.3); }
.flash-info    { background: rgba(59,130,246,0.1); color: var(--info);   border-color: rgba(59,130,246,0.3); }

/* ── Section headings ─────────────────────────────────────────────────────── */

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  margin-top: 28px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.section-title:first-child {
  margin-top: 0;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.empty-state p {
  margin-bottom: 16px;
}

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

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

.cal-header {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 0;
}

.cal-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 80px;
  padding: 6px;
}

.cal-day-num {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.cal-day.today .cal-day-num {
  color: var(--accent);
  font-weight: 700;
}

.cal-day.empty {
  background: transparent;
  border-color: transparent;
}

.cal-entry {
  background: rgba(249,115,22,0.15);
  color: var(--accent);
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 10px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Spend chart ──────────────────────────────────────────────────────────── */

.chart-bar-wrap {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
}

.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.8;
  transition: opacity 0.15s;
  position: relative;
}

.chart-bar:hover {
  opacity: 1;
}

.chart-bar::after {
  content: attr(data-label);
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 32px;
  width: 340px;
}

.login-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 28px;
}

/* ── Detail rows ──────────────────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.detail-item .detail-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.detail-item .detail-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */

.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }

/* Progress bar for keyword coverage */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  width: 120px;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

/* ── Template Library Matrix ──────────────────────────────── */

.tpl-matrix {
    overflow-x: auto;
}

.tpl-matrix-header {
    display: grid;
    grid-template-columns: 180px repeat(5, 1fr);
    gap: 1px;
    margin-bottom: 1px;
}

.tpl-matrix-row {
    display: grid;
    grid-template-columns: 180px repeat(5, 1fr);
    gap: 1px;
    margin-bottom: 1px;
}

.tpl-matrix-label {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.tpl-matrix-col-header {
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-align: center;
}

.tpl-matrix-cell {
    padding: 8px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.tpl-matrix-cell.tpl-filled {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.15);
    color: var(--text-secondary);
}

.tpl-matrix-cell.tpl-filled:hover {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
}

.tpl-matrix-cell.tpl-empty {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    justify-content: center;
}

.tpl-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tpl-edited-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(249, 115, 22, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

.tpl-empty-text {
    color: var(--text-muted);
    font-size: 14px;
}

.tpl-var-chip {
    padding: 4px 10px;
    font-size: 12px;
    font-family: monospace;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--accent-purple, #a855f7);
    cursor: pointer;
    transition: all 0.15s;
}

.tpl-var-chip:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
}

/* ── Foundation (Phase 2 ad factory) ─────────────────────────────────────── */

.foundation-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.foundation-header-main h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.foundation-subtitle {
  color: var(--muted);
  font-size: 13px;
}
.foundation-status-pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.foundation-status-pill.configured {
  background: rgba(34,197,94,0.12);
  color: var(--success);
  border-color: rgba(34,197,94,0.3);
}
.foundation-status-pill.not-configured {
  background: rgba(234,179,8,0.12);
  color: var(--warning);
  border-color: rgba(234,179,8,0.3);
}

.foundation-first-run-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 20px;
  background: rgba(234,179,8,0.08);
  border: 1px solid rgba(234,179,8,0.3);
  border-radius: 8px;
  color: var(--text);
}
.foundation-first-run-text { font-size: 13px; }
.foundation-first-run-text strong { color: var(--warning); }
.foundation-first-run-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--warning);
  color: #1a1d27;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.foundation-first-run-btn:hover {
  background: #facc15;
  color: #1a1d27;
}

.foundation-launch-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.foundation-action-card {
  display: block;
  padding: 22px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  font: inherit;
  text-align: left;
  width: 100%;
}
.foundation-action-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  color: var(--text);
}
.foundation-action-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: auto;
}
.foundation-action-card.disabled:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.foundation-action-icon {
  font-size: 26px;
  margin-bottom: 10px;
}
.foundation-action-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.foundation-action-sub {
  font-size: 12px;
  color: var(--muted);
}

.foundation-library {
  margin-top: 12px;
}
.foundation-library-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 14px;
}
.foundation-library-section {
  margin-bottom: 28px;
}
.foundation-library-subheading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.foundation-library-icon { font-size: 16px; }
.foundation-library-count {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

.foundation-doc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.foundation-doc-card {
  display: block;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.foundation-doc-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  color: var(--text);
}
.foundation-doc-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.foundation-doc-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.foundation-doc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.foundation-doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.foundation-doc-meta-sep { color: var(--border); }
.foundation-doc-status {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 10px;
  background: rgba(249,115,22,0.12);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 1024px) {
  .foundation-doc-grid { grid-template-columns: repeat(2, 1fr); }
  .foundation-launch-pad { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .foundation-doc-grid { grid-template-columns: 1fr; }
  .foundation-header { flex-direction: column; align-items: flex-start; }
}

/* ── Foundation Doc Reader ────────────────────────────────────────────────── */

.foundation-doc-reader-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.foundation-doc-reader-back {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.foundation-doc-reader-back:hover { color: var(--accent); }
.foundation-doc-reader-title {
  flex: 1;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.foundation-doc-reader-actions {
  display: flex;
  gap: 8px;
}
.foundation-doc-reader-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.foundation-doc-reader-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.foundation-doc-reader-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.foundation-doc-reader-meta-sep { color: var(--border); }

.foundation-doc-reader-editinfo {
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--muted);
}
.foundation-doc-reader-editinfo summary {
  cursor: pointer;
  color: var(--muted);
  display: inline-block;
  padding: 4px 0;
}
.foundation-doc-reader-editinfo summary:hover { color: var(--accent); }
.foundation-doc-reader-editinfo-body {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.foundation-doc-reader-editinfo-body code {
  display: block;
  margin-top: 6px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text);
  word-break: break-all;
}

.foundation-doc-reader-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
  align-items: start;
}

.foundation-doc-reader-sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  font-size: 12px;
  padding-right: 8px;
}
.foundation-doc-reader-sidebar-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 10px;
}
.foundation-doc-reader-toc {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--border);
}
.foundation-doc-reader-toc-item {
  padding: 0;
}
.foundation-doc-reader-toc-item a {
  display: block;
  padding: 4px 12px;
  color: var(--muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
  line-height: 1.4;
}
.foundation-doc-reader-toc-item a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}
.foundation-doc-reader-toc-level-3 a { padding-left: 24px; font-size: 11px; }
.foundation-doc-reader-toc-level-4 a { padding-left: 36px; font-size: 11px; }

.foundation-doc-reader-content {
  max-width: 780px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  min-width: 0;
}
.foundation-doc-reader-content h1,
.foundation-doc-reader-content h2,
.foundation-doc-reader-content h3,
.foundation-doc-reader-content h4 {
  scroll-margin-top: 100px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.3;
}
.foundation-doc-reader-content h1 {
  font-size: 24px;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.foundation-doc-reader-content h2 {
  font-size: 20px;
  margin: 32px 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.foundation-doc-reader-content h3 {
  font-size: 16px;
  margin: 24px 0 10px 0;
}
.foundation-doc-reader-content h4 {
  font-size: 14px;
  margin: 20px 0 8px 0;
}
.foundation-doc-reader-content p {
  margin: 0 0 14px 0;
}
.foundation-doc-reader-content ul,
.foundation-doc-reader-content ol {
  margin: 0 0 14px 0;
  padding-left: 24px;
}
.foundation-doc-reader-content li {
  margin-bottom: 4px;
}
.foundation-doc-reader-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.foundation-doc-reader-content a:hover { color: var(--accent-hover); }
.foundation-doc-reader-content code {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent);
}
.foundation-doc-reader-content pre {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0 0 14px 0;
}
.foundation-doc-reader-content pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text);
  font-size: 12px;
}
.foundation-doc-reader-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 2px 14px;
  margin: 0 0 14px 0;
  color: var(--muted);
  background: rgba(249,115,22,0.04);
}
.foundation-doc-reader-content blockquote p:last-child { margin-bottom: 0; }
.foundation-doc-reader-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}
.foundation-doc-reader-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 14px 0;
  font-size: 13px;
}
.foundation-doc-reader-content th,
.foundation-doc-reader-content td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}
.foundation-doc-reader-content th {
  background: var(--card);
  font-weight: 600;
}
.foundation-doc-reader-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
.foundation-doc-reader-content strong { color: var(--text); font-weight: 600; }

@media (max-width: 900px) {
  .foundation-doc-reader-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .foundation-doc-reader-sidebar {
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
  }
  .foundation-doc-reader-title { white-space: normal; font-size: 18px; }
}

/* ── Foundation: Hook Bank ─────────────────────────────────────────────── */
.foundation-hook-bank-topbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.foundation-hook-bank-back {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
}
.foundation-hook-bank-back:hover { color: var(--fg); background: var(--bg-soft); }
.foundation-hook-bank-title { font-size: 22px; margin: 0; }
.foundation-hook-bank-subtitle { font-size: 13px; color: var(--muted); margin-left: auto; }

.foundation-hook-bank-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  padding-bottom: 0;
}
.foundation-hook-bank-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 13px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.foundation-hook-bank-tab:hover { color: var(--fg); }
.foundation-hook-bank-tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent, #3b82f6);
  font-weight: 600;
}
.foundation-hook-bank-tab-count {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}
.foundation-hook-bank-tab.active .foundation-hook-bank-tab-count {
  background: var(--accent, #3b82f6);
  color: #fff;
}

.foundation-hook-bank-filters {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.foundation-hook-bank-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.foundation-hook-bank-filter-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.foundation-hook-bank-filter-search { flex: 1 1 240px; }
.foundation-hook-bank-filter-actions { flex-direction: row; align-items: center; gap: 6px; }
.foundation-hook-bank-filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.foundation-hook-bank-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.foundation-hook-bank-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.foundation-hook-bank-chip input { display: none; }
.foundation-hook-bank-chip:hover { border-color: var(--accent, #3b82f6); }
.foundation-hook-bank-chip.active {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: #fff;
}
.foundation-hook-bank-empty-chip { font-size: 12px; color: var(--muted); font-style: italic; }

.foundation-hook-bank-select,
.foundation-hook-bank-input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  min-width: 140px;
}
.foundation-hook-bank-input { width: 100%; }

.foundation-hook-bank-btn {
  display: inline-block;
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}
.foundation-hook-bank-btn.primary {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: #fff;
}
.foundation-hook-bank-btn.primary:hover { filter: brightness(1.05); }
.foundation-hook-bank-btn.secondary:hover { background: var(--bg-soft); }

.foundation-hook-bank-result-count {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 14px;
}
.foundation-hook-bank-result-sep { margin: 0 6px; opacity: 0.6; }

.foundation-hook-bank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.foundation-hook-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.foundation-hook-card:hover {
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.foundation-hook-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.foundation-hook-card-num {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.foundation-hook-card-subavatar {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.foundation-hook-card-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--fg);
}
.foundation-hook-card-visual {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.foundation-hook-card-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}
.foundation-hook-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.foundation-hook-card-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.foundation-hook-card-badge.type-direct {
  background: #e0f2fe;
  color: #0c4a6e;
  border-color: #bae6fd;
}
.foundation-hook-card-badge.type-indirect {
  background: #fef3c7;
  color: #78350f;
  border-color: #fde68a;
}
.foundation-hook-card-why summary,
.foundation-hook-card-example summary {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.foundation-hook-card-why p,
.foundation-hook-card-example p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--fg);
  line-height: 1.5;
}
.foundation-hook-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.foundation-hook-card-btn {
  display: inline-block;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}
.foundation-hook-card-btn.primary {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: #fff;
}
.foundation-hook-card-btn.primary:hover { filter: brightness(1.05); }
.foundation-hook-card-btn.secondary:hover { background: var(--bg-soft); }

.foundation-hook-bank-empty {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.foundation-hook-bank-empty-icon { font-size: 32px; }
.foundation-hook-bank-empty-title { font-size: 14px; font-weight: 600; color: var(--fg); }

@media (max-width: 800px) {
  .foundation-hook-bank-grid { grid-template-columns: 1fr; }
  .foundation-hook-bank-subtitle { margin-left: 0; }
  .foundation-hook-bank-filter-cell { min-width: 100%; }
  .foundation-hook-bank-filter-search { flex: 1 1 100%; }
}

/* ── Foundation: Generate Ad ───────────────────────────────────────────── */
.foundation-generate-topbar {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.foundation-generate-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}
.foundation-generate-back:hover { color: var(--fg); }
.foundation-generate-title { margin: 0; font-size: 20px; }
.foundation-generate-subtitle { color: var(--muted); font-size: 13px; }

.foundation-generate-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.foundation-generate-tab {
  padding: 8px 14px;
  font-size: 13px;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.foundation-generate-tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent, #4a90e2);
  font-weight: 600;
}
.foundation-generate-tab.disabled {
  color: var(--muted);
  opacity: 0.5;
  cursor: not-allowed;
}

.foundation-generate-info-banner {
  background: rgba(74, 144, 226, 0.08);
  border: 1px solid rgba(74, 144, 226, 0.3);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.foundation-generate-form {
  background: var(--panel, #111);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}
.foundation-generate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.foundation-generate-field { display: flex; flex-direction: column; gap: 6px; }
.foundation-generate-field-full { grid-column: 1 / -1; }

.foundation-generate-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.foundation-generate-required { color: #e05a5a; margin-left: 2px; }
.foundation-generate-optional {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.foundation-generate-field-hint {
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}

.foundation-generate-input,
.foundation-generate-select,
.foundation-generate-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  background: var(--bg, #0a0a0a);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.foundation-generate-input:focus,
.foundation-generate-select:focus,
.foundation-generate-textarea:focus {
  outline: none;
  border-color: var(--accent, #4a90e2);
}
.foundation-generate-textarea { resize: vertical; min-height: 64px; }

.foundation-generate-radio-group {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 6px 0;
}
.foundation-generate-radio-group label {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg);
  cursor: pointer;
}
.foundation-generate-radio-group label.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.foundation-generate-radio-group input[type="radio"]:disabled { cursor: not-allowed; }

.foundation-generate-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.foundation-generate-btn {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2, #1a1a1a);
  color: var(--fg);
  cursor: pointer;
}
.foundation-generate-btn.primary {
  background: var(--accent, #4a90e2);
  border-color: var(--accent, #4a90e2);
  color: #fff;
}
.foundation-generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.foundation-generate-status {
  font-size: 13px;
  color: var(--muted);
}

.foundation-generate-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(224, 90, 90, 0.08);
  border: 1px solid rgba(224, 90, 90, 0.4);
  border-radius: 6px;
  color: #e05a5a;
  font-size: 13px;
}

.foundation-generate-results {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.foundation-generate-results-title {
  font-size: 15px;
  margin: 0 0 4px;
  color: var(--fg);
}
.foundation-generate-ad-card {
  background: var(--panel, #111);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.foundation-generate-ad-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.foundation-generate-ad-hook {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}
.foundation-generate-ad-body {
  font-size: 13px;
  color: var(--fg);
  white-space: pre-wrap;
}
.foundation-generate-ad-cta {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.foundation-generate-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 13px;
}

@media (max-width: 800px) {
  .foundation-generate-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ */
/* Foundation ad card (Task 12) — shared by JS render + _partials     */
/* ------------------------------------------------------------------ */
.foundation-ad-card {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  background: var(--panel, #111);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.foundation-ad-card-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #0b0b0b;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.foundation-ad-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.foundation-ad-card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--muted);
  text-align: center;
  background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.05));
  width: 100%;
  height: 100%;
}
.foundation-ad-card-placeholder-icon {
  font-size: 32px;
  opacity: 0.4;
  margin-bottom: 6px;
}
.foundation-ad-card-placeholder-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}
.foundation-ad-card-placeholder-hint {
  font-size: 11px;
  color: var(--muted);
}
.foundation-ad-card-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.foundation-ad-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.foundation-ad-card-variant {
  font-weight: 600;
}
.foundation-ad-card-status {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  font-size: 10px;
}
.foundation-ad-card-status.status-draft { background: rgba(120,140,180,0.18); }
.foundation-ad-card-status.status-winner { background: rgba(80,200,120,0.2); }
.foundation-ad-card-status.status-flopped { background: rgba(224,90,90,0.18); }
.foundation-ad-card-hook-wrap,
.foundation-ad-card-body-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.foundation-ad-card-hook {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--fg);
}
.foundation-ad-card-body {
  flex: 1;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  white-space: pre-wrap;
}
.foundation-ad-card-copy {
  flex-shrink: 0;
  padding: 4px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.foundation-ad-card-copy:hover {
  background: rgba(255,255,255,0.1);
  color: var(--fg);
}
.foundation-ad-card-cta {
  display: inline-block;
  align-self: flex-start;
  padding: 6px 12px;
  background: rgba(120,180,255,0.12);
  border: 1px solid rgba(120,180,255,0.35);
  border-radius: 6px;
  color: #9ec5ff;
  font-size: 12px;
  font-weight: 600;
}
.foundation-ad-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.foundation-ad-card-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--muted);
}
.foundation-ad-card-badge.platform { color: #9ec5ff; border-color: rgba(120,180,255,0.3); }
.foundation-ad-card-badge.type { color: #c5a8ff; border-color: rgba(180,140,255,0.3); }
.foundation-ad-card-badge.belief { color: #ffd89e; border-color: rgba(255,200,120,0.3); }
.foundation-ad-card-badge.avatar { color: #a8e6cf; border-color: rgba(120,220,180,0.3); }
.foundation-ad-card-actions {
  margin-top: auto;
  padding-top: 4px;
}
.foundation-ad-card-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.foundation-ad-card-link:hover {
  color: var(--fg);
}

@media (max-width: 800px) {
  .foundation-ad-card {
    grid-template-columns: 1fr;
  }
  .foundation-ad-card-media {
    max-width: 320px;
  }
}

/* Task 13: On-demand image generation buttons */
.foundation-ad-card-media {
  position: relative;
}
.foundation-ad-card-genimage-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fg);
  background: rgba(120, 180, 255, 0.14);
  border: 1px solid rgba(120, 180, 255, 0.35);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.foundation-ad-card-genimage-btn:hover:not(:disabled) {
  background: rgba(120, 180, 255, 0.24);
  border-color: rgba(120, 180, 255, 0.55);
}
.foundation-ad-card-genimage-btn:disabled,
.foundation-ad-card-genimage-btn.is-loading {
  opacity: 0.6;
  cursor: progress;
}
.foundation-ad-card-genimage-btn.is-regen {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  margin-top: 0;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  background: rgba(15, 20, 30, 0.72);
  color: #e8eef8;
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
}
.foundation-ad-card-genimage-btn.is-regen:hover:not(:disabled) {
  background: rgba(15, 20, 30, 0.88);
  border-color: rgba(255, 255, 255, 0.4);
}
.foundation-ad-card-placeholder .foundation-ad-card-genimage-btn {
  display: inline-block;
  margin: 0.75rem auto 0;
}
.foundation-ad-card-genimage-error {
  margin-top: 0.4rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  color: #ffb3b3;
  background: rgba(224, 90, 90, 0.12);
  border: 1px solid rgba(224, 90, 90, 0.3);
  border-radius: 4px;
}

/* ── Foundation: Ad detail page (Task 15) ───────────────────────────────── */

.foundation-ad-detail-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #2a2f3a;
}
.foundation-ad-detail-back {
  color: #8ab4f8;
  text-decoration: none;
  font-size: 0.9rem;
}
.foundation-ad-detail-back:hover { text-decoration: underline; }
.foundation-ad-detail-title {
  font-size: 1.45rem;
  margin: 0;
  color: #e8ebf2;
}
.foundation-ad-detail-batch {
  margin-left: auto;
  font-size: 0.8rem;
  color: #9aa3b2;
}
.foundation-ad-detail-batch code {
  background: #1b1f29;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  color: #cbd3e1;
}
.foundation-ad-detail-batch a {
  color: #8ab4f8;
  margin-left: 0.5rem;
  text-decoration: none;
}
.foundation-ad-detail-batch a:hover { text-decoration: underline; }

.foundation-ad-detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 500px) 1fr;
  gap: 2rem;
  align-items: start;
}

.foundation-ad-detail-media {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.foundation-ad-detail-img {
  width: 100%;
  max-width: 500px;
  border-radius: 8px;
  border: 1px solid #2a2f3a;
  display: block;
}
.foundation-ad-detail-placeholder {
  aspect-ratio: 1 / 1;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #151923;
  border: 1px dashed #2a2f3a;
  border-radius: 8px;
  color: #7a8394;
}
.foundation-ad-detail-placeholder-icon {
  font-size: 3rem;
  opacity: 0.4;
}
.foundation-ad-detail-placeholder-label {
  font-size: 0.85rem;
}
.foundation-ad-detail-regen-btn {
  align-self: flex-start;
  padding: 0.5rem 0.95rem;
  background: #1b2433;
  color: #cbd3e1;
  border: 1px solid #2a3548;
  border-radius: 5px;
  font-size: 0.85rem;
  cursor: pointer;
}
.foundation-ad-detail-regen-btn:hover { background: #243049; }
.foundation-ad-detail-regen-btn[disabled] { opacity: 0.55; cursor: wait; }
.foundation-ad-detail-genimage-error {
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
  background: rgba(224, 90, 90, 0.15);
  border: 1px solid rgba(224, 90, 90, 0.35);
  color: #ffb3b3;
  font-size: 0.8rem;
}

.foundation-ad-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}
.foundation-ad-detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.foundation-ad-detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa3b2;
}
.foundation-ad-detail-select,
.foundation-ad-detail-textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: #0f131c;
  color: #e8ebf2;
  border: 1px solid #2a2f3a;
  border-radius: 5px;
  font-size: 0.9rem;
  font-family: inherit;
}
.foundation-ad-detail-textarea {
  resize: vertical;
  min-height: 80px;
}
.foundation-ad-detail-select:focus,
.foundation-ad-detail-textarea:focus {
  outline: none;
  border-color: #3a5a8c;
  background: #121724;
}
.foundation-ad-detail-saveflag {
  font-size: 0.72rem;
  color: #7a8394;
  height: 1em;
}

.foundation-ad-detail-sep {
  border: none;
  border-top: 1px solid #2a2f3a;
  margin: 0.6rem 0;
}

.foundation-ad-detail-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.35rem 0;
  border-bottom: 1px solid #1b1f29;
}
.foundation-ad-detail-row.block {
  grid-template-columns: 1fr;
  gap: 0.25rem;
}
.foundation-ad-detail-rowlabel {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa3b2;
  font-weight: 600;
}
.foundation-ad-detail-rowvalue {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  min-width: 0;
}
.foundation-ad-detail-rowtext {
  color: #cbd3e1;
  font-size: 0.85rem;
  word-break: break-word;
  flex: 1;
}
.foundation-ad-detail-text {
  margin: 0.25rem 0;
  color: #e2e6ef;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  flex: 1;
}
.foundation-ad-detail-text.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  background: #0c0f17;
  padding: 0.6rem 0.75rem;
  border-radius: 5px;
  border: 1px solid #1e2330;
}
.foundation-ad-detail-copy {
  flex-shrink: 0;
  padding: 0.25rem 0.55rem;
  background: #1b2433;
  color: #9aa3b2;
  border: 1px solid #2a3548;
  border-radius: 3px;
  font-size: 0.7rem;
  cursor: pointer;
}
.foundation-ad-detail-copy:hover { background: #243049; color: #cbd3e1; }

.foundation-ad-detail-dangerzone {
  margin-top: 1rem;
  padding: 0.85rem;
  border: 1px solid rgba(224, 90, 90, 0.3);
  border-radius: 6px;
  background: rgba(224, 90, 90, 0.06);
}
.foundation-ad-detail-delete-btn {
  padding: 0.55rem 1rem;
  background: rgba(224, 90, 90, 0.15);
  color: #ffb3b3;
  border: 1px solid rgba(224, 90, 90, 0.5);
  border-radius: 5px;
  font-size: 0.85rem;
  cursor: pointer;
}
.foundation-ad-detail-delete-btn:hover {
  background: rgba(224, 90, 90, 0.3);
  color: #fff;
}

.foundation-ad-detail-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.7rem 1.1rem;
  border-radius: 5px;
  font-size: 0.85rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 1000;
}
.foundation-ad-detail-toast.is-ok {
  background: #2a6e4d;
  border: 1px solid #3a8e65;
}
.foundation-ad-detail-toast.is-error {
  background: #7a2e2e;
  border: 1px solid #a13e3e;
}

@media (max-width: 800px) {
  .foundation-ad-detail-layout {
    grid-template-columns: 1fr;
  }
  .foundation-ad-detail-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

/* ── Foundation: Ad History page (Task 16) ─────────────────────────────── */

.foundation-history-topbar {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.5rem;
  flex-wrap: wrap;
}
.foundation-history-back {
  color: #6b7280;
  text-decoration: none;
  font-size: 0.9rem;
}
.foundation-history-back:hover { color: #111827; }
.foundation-history-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: #111827;
}
.foundation-history-subtitle {
  color: #6b7280;
  font-size: 0.9rem;
}

.foundation-history-batch-chip {
  margin: 0.5rem 1.5rem;
  padding: 0.6rem 0.9rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  color: #3730a3;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.foundation-history-batch-chip code {
  background: #e0e7ff;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}
.foundation-history-batch-chip-close {
  color: #3730a3;
  text-decoration: none;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.4rem;
  border-radius: 4px;
}
.foundation-history-batch-chip-close:hover { background: #c7d2fe; }

.foundation-history-filters {
  margin: 0.75rem 1.5rem 1rem;
  padding: 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.foundation-history-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.foundation-history-filter-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 180px;
  min-width: 160px;
}
.foundation-history-filter-cell.foundation-history-filter-search {
  flex: 2 1 280px;
}
.foundation-history-filter-cell.foundation-history-filter-actions {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.foundation-history-filter-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
  font-weight: 600;
}
.foundation-history-select,
.foundation-history-input {
  padding: 0.5rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
  color: #111827;
  width: 100%;
  box-sizing: border-box;
}
.foundation-history-select:focus,
.foundation-history-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.foundation-history-btn {
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}
.foundation-history-btn.primary {
  background: #4f46e5;
  color: #fff;
}
.foundation-history-btn.primary:hover { background: #4338ca; }
.foundation-history-btn.secondary {
  background: #fff;
  color: #374151;
  border-color: #d1d5db;
}
.foundation-history-btn.secondary:hover { background: #f3f4f6; }

.foundation-history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  padding: 0 1.5rem 1.5rem;
}
@media (max-width: 900px) {
  .foundation-history-grid {
    grid-template-columns: 1fr;
  }
}

.foundation-history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1.5rem 2rem;
}
.foundation-history-page-btn {
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.foundation-history-page-btn:hover { background: #f3f4f6; }
.foundation-history-page-btn.disabled {
  color: #9ca3af;
  background: #f9fafb;
  cursor: not-allowed;
}
.foundation-history-page-indicator {
  color: #6b7280;
  font-size: 0.9rem;
}

.foundation-history-empty {
  margin: 2rem 1.5rem 3rem;
  padding: 3rem 1rem;
  text-align: center;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
}
.foundation-history-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.foundation-history-empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.35rem;
}
.foundation-history-empty-sub {
  color: #6b7280;
  font-size: 0.9rem;
}
.foundation-history-empty-sub a { color: #4f46e5; }

/* Task 17: landing history link */
.foundation-history-link-row {
  text-align: center;
  margin: 0.75rem 0 1.5rem;
}
.foundation-history-link {
  color: #6b7280;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
}
.foundation-history-link:hover { color: #4f46e5; text-decoration: underline; }

