:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface2: #F4F4F1;
  --border: #E8E8E4;
  --text: #1A1A18;
  --muted: #6B6B66;
  --accent: #2563EB;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --warn: #B45309;
  --danger: #DC2626;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", monospace;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e8eaef;
  --muted: #9aa3b5;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --warn: #fbbf24;
  --danger: #f87171;
  --shadow: none;
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

.container { width: min(1200px, 92vw); margin: 0 auto; }

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
}
[data-theme="dark"] .site-header { background: rgba(15, 17, 23, 0.92); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}
.logo {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}
.logo span { color: var(--accent); }
.nav { display: flex; gap: 1.1rem; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.nav a.active, .nav a:hover { color: var(--text); text-decoration: none; }

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text); }

main { flex: 1; padding: 2.5rem 0 3.5rem; }

.page-title { margin: 0 0 0.4rem; font-size: clamp(1.75rem, 3vw, 2.25rem); font-weight: 600; letter-spacing: -0.02em; }
.page-dek { color: var(--muted); margin: 0 0 1.75rem; max-width: 62ch; font-size: 1rem; }

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}
.vertical-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  display: block;
  color: inherit;
  text-decoration: none;
}
.vertical-card:hover {
  border-color: #D4D4CF;
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
  text-decoration: none;
}
.vertical-card h2 { margin: 0 0 0.5rem; font-size: 1.3rem; font-weight: 600; }
.vertical-card p { color: var(--muted); margin: 0 0 1rem; font-size: 0.95rem; }
.stat-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.stat {
  background: var(--surface2);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}
.stat strong { color: var(--accent); display: block; font-size: 1.15rem; font-weight: 600; }

.limits-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.6;
}
.limits-info p { margin: 0 0 0.5rem; }
.limits-info p:last-child { margin: 0; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.filters select, .filters input[type="search"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  min-width: 140px;
}
.filter-toggles { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.toggle-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--muted);
}
.toggle-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.section-heading {
  margin: 2.5rem 0 1rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-heading span { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  align-items: stretch;
}
.card, .ad-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 420px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover, .ad-card:hover {
  border-color: #D4D4CF;
  box-shadow: var(--shadow-hover);
}
.card.hidden { display: none; }

.card-thumb, .ad-card-preview {
  position: relative;
  background: var(--surface2);
  cursor: zoom-in;
  aspect-ratio: 16 / 10;
  height: 180px;
  flex-shrink: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.card-thumb img, .ad-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.ad-text-preview {
  height: 100%;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 100%);
}
.ad-headline {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-primary {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-cta-pill {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.card-body, .ad-card-body {
  padding: 1rem 1.05rem 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.tag.validated { color: var(--accent); border-color: rgba(37, 99, 235, 0.25); background: var(--accent-soft); }
.tag.platform { color: var(--text); }
.card h3, .ad-card h3 { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.3; }
.card h3 a, .ad-card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover, .ad-card h3 a:hover { color: var(--accent); }

.why-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.chip.more { color: var(--muted); font-style: italic; }

.collapsible {
  margin-top: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.collapsible summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.collapsible .inner { padding: 0 1.25rem 1.25rem; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 92vh; border-radius: 8px; }
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
}

.pattern-block {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pattern-block h3 { margin: 0 0 0.25rem; font-size: 1.05rem; font-weight: 600; }
.verdict {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}
.verdict.differentiator { background: var(--accent-soft); color: var(--accent); }
.verdict.weak { background: rgba(180, 83, 9, 0.1); color: var(--warn); }
.verdict.norm { background: var(--surface2); color: var(--muted); }
.verdict.anti { background: rgba(220, 38, 38, 0.08); color: var(--danger); }
.verdict.hypothesis { background: var(--surface2); color: var(--muted); }

.bar-pair { margin: 0.75rem 0; }
.bar-label { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.25rem; display: flex; justify-content: space-between; }
.bar-track { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-fill.winner { background: var(--accent); }
.bar-fill.control { background: #C4C4BE; }
.pct-tip { cursor: help; border-bottom: 1px dotted var(--muted); }

.crop-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.crop-row img {
  max-width: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.crop-cap { font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem; }

.platform-section {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.compare-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.compare-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare-panel h4 { margin: 0; padding: 0.75rem 1rem; font-size: 0.85rem; background: var(--surface2); font-weight: 600; }
.compare-panel img { width: 100%; display: block; cursor: zoom-in; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.empty-state { color: var(--muted); padding: 2rem; text-align: center; }

.coverage-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  line-height: 1.55;
}

.card .thesis {
  font-size: 0.88rem;
  color: var(--text);
  margin: 0;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.card-reference {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
  word-break: break-word;
}
.card-reference .ref-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.72rem;
}
.validation-line {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin: auto 0 0;
  padding-top: 0.35rem;
}
.ad-meta-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}
.ad-evidence {
  margin: 0.5rem 0 0.35rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface2, #f4f4f2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
}
.ad-evidence-summary {
  margin: 0 0 0.45rem;
  font-weight: 600;
  color: var(--text);
  font-size: 0.8rem;
}
.ad-evidence-list {
  margin: 0 0 0.4rem;
  padding-left: 1rem;
  color: var(--muted);
}
.ad-evidence-list li { margin-bottom: 0.25rem; }
.ad-evidence-list .ev-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.9;
  margin-top: 0.1rem;
}
.ad-evidence-chips { margin: 0.35rem 0; }
.ad-evidence-limits {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}
.ad-revalidation-warn {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--warn, #b45309);
  font-weight: 600;
}
.ad-revalidation-ok {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}
.ad-section-note {
  font-size: 0.88rem;
  color: var(--muted);
  max-width: 62ch;
  margin: -0.5rem 0 1rem;
  line-height: 1.55;
}
.ad-section-note strong { color: var(--text); font-weight: 600; }
.hook-chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.2);
  text-transform: lowercase;
}
.chip.diff { border-color: rgba(37, 99, 235, 0.2); color: var(--accent); background: var(--accent-soft); }
.chip.move { background: var(--surface2); color: var(--muted); }
.diff-chips, .move-chips { margin-top: 0; }
.card-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
}
.png-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  font-size: 0.68rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  font-weight: 600;
}
.grid-failed .card { opacity: 0.88; }
.tag.group { background: rgba(180, 83, 9, 0.08); color: var(--warn); }
.tag.warn { color: var(--warn); }

/* Detail dossier pages */
.detail-page, .prose-page { max-width: 780px; }
.detail-breadcrumb { font-size: 0.85rem; color: var(--muted); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0 1.25rem; }
.detail-shot img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.detail-block { margin: 1.75rem 0; }
.detail-block h2 { font-size: 1.05rem; margin: 0 0 0.65rem; font-weight: 600; }
.detail-block h3 { font-size: 0.95rem; font-weight: 600; }
.reference-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem 1.25rem;
  margin: 0;
}
.ref-grid > div { min-width: 0; overflow: hidden; }
.ref-grid dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.2rem;
  font-weight: 600;
}
.ref-grid dd {
  margin: 0;
  font-size: 0.92rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.warn-banner {
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.2);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--danger);
}
.footnote-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  padding: 0.65rem 0.85rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.75rem;
}
.section-map { margin: 0; padding-left: 1.25rem; }
.muted { color: var(--muted); }

.grade-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.grade-a { background: var(--accent-soft); color: var(--accent); border-color: rgba(37, 99, 235, 0.25); }
.grade-b { background: var(--surface2); color: var(--text); }
.grade-c { background: var(--surface2); color: var(--muted); }

.tier-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.5rem;
  border-radius: 5px;
  text-transform: uppercase;
}
.tier-outcome { background: rgba(37, 99, 235, 0.12); color: var(--accent); border: 1px solid rgba(37, 99, 235, 0.2); }
.tier-demand { background: rgba(180, 83, 9, 0.1); color: var(--warn); border: 1px solid rgba(180, 83, 9, 0.25); }
.tier-curated { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

.demand-card .demand-thumb { background: var(--surface2); min-height: 140px; display: flex; align-items: center; justify-content: center; }
.demand-placeholder { padding: 2rem; text-align: center; color: var(--muted); font-size: 0.85rem; }
.demand-meta { font-size: 0.82rem; color: var(--muted); margin: 0.35rem 0 0.5rem; }
.tag.bestseller { background: rgba(180, 83, 9, 0.12); color: var(--warn); }
.tag.type { background: var(--surface2); }

.dossier-q { border-left: 3px solid var(--border); padding-left: 1rem; min-width: 0; }
.ad-page-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.pair-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
  overflow: hidden;
}
.pair-panel img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.ad-copy {
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: 12em;
  overflow: hidden;
  margin: 0;
}
.ad-copy-truncated::after {
  content: "";
  display: block;
  height: 1.5em;
  margin-top: -1.5em;
  background: linear-gradient(transparent, var(--surface));
}
.fulfillment-line { font-size: 0.88rem; color: var(--muted); word-break: break-word; }
.multi-path-block {
  margin-top: 1rem;
  padding: 0.85rem;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.tombstone { color: var(--warn); }
.ref-grid.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

/* Inline ad card (dossier Q4) */
.inline-ad-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 360px;
}
.inline-ad-card .ad-text-preview { height: auto; min-height: 120px; }
.inline-ad-card-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}
.inline-ad-card-footer .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.25rem; }

.taxonomy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.taxonomy-table th, .taxonomy-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.taxonomy-table th { background: var(--surface2); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.taxonomy-section { margin-bottom: 2.5rem; }

#result-count { color: var(--muted); font-size: 0.9rem; margin: -0.75rem 0 1rem; }

@media (max-width: 640px) {
  .nav { gap: 0.65rem; }
  .filters { flex-direction: column; }
  .card, .ad-card { min-height: 380px; }
  .card-thumb, .ad-card-preview { height: 160px; }
  .ad-page-pair { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .container { width: 94vw; }
  .header-inner { flex-wrap: wrap; }
}
