@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/inter-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/jbmono-variable.woff2') format('woff2');
}

:root {
  --navy: #1A2332;
  --gold: #EDB44C;
  --gold-hover: #d9a340;
  --paper: #f7f7f5;
  --paper-soft: #fafaf8;
  --ink: #191919;
  --white: #ffffff;
  --border: rgba(25, 25, 25, 0.1);
  --shadow: 0 1px 2px rgba(25, 25, 25, .05), 0 8px 24px rgba(25, 25, 25, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Hero ─────────────────────────────────────────────────────────── */

.hero {
  background: var(--navy);
  color: var(--white);
}

/* Padding + max-width + centering live together on the same element here,
   matching .tabbar-inner / .toolbar / .wrap below — keeps every section's
   left/right content edge aligned instead of drifting apart on wide screens. */
.hero-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 64px 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}
@media (max-width: 720px) { .hero-inner { padding: 32px 24px 24px; } }

.feedback-log-corner {
  position: absolute;
  top: 14px;
  right: 64px;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .7);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.feedback-log-corner:hover { color: var(--white); border-color: rgba(255, 255, 255, .4); }
@media (max-width: 720px) { .feedback-log-corner { right: 24px; } }

.notif-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: #e0553f;
  vertical-align: middle;
}
.notif-dot[hidden] { display: none; }

.eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 11px;
  color: rgba(255, 255, 255, .4);
  margin: 0 0 .6rem;
}

h1 {
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.05;
  letter-spacing: -.03em;
  margin: 0;
  font-weight: 300;
}
h1 em { font-style: normal; color: var(--gold); }

.hero-desc {
  margin: .6rem 0 0;
  max-width: 480px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, .55);
}

.stats { display: flex; gap: 1.75rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 26px;
  color: var(--gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, .45);
}

/* ── Tabs ─────────────────────────────────────────────────────────── */

.tabbar {
  background: var(--navy);
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.tabbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
@media (max-width: 720px) { .tabbar-inner { padding: 12px 24px; } }

.tabbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.brand-select {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .06);
  color: var(--white);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 32px 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23EDB44C' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.brand-select:hover { border-color: rgba(255, 255, 255, .4); }
.brand-select option { background: var(--white); color: var(--ink); }

.tab-action {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .7);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.tab-action:hover { color: var(--white); border-color: rgba(255, 255, 255, .4); }
.tab-action-primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
  font-weight: 600;
}
.tab-action-primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); color: var(--ink); }

/* ── Add section ──────────────────────────────────────────────────── */

.add-section {
  background: var(--paper-soft);
  border-bottom: 1px solid var(--border);
}
.add-section-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 64px;
}
@media (max-width: 720px) { .add-section-inner { padding: 16px 24px; } }

.add-section-label {
  margin: 0 0 .5rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gold-hover);
}

/* ── Toolbar ──────────────────────────────────────────────────────── */

.toolbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 64px 0;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
}
@media (max-width: 720px) { .toolbar { padding: 16px 24px 0; } }

select, .btn, .input {
  font: inherit;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink);
  padding: 8px 12px;
}

.btn {
  cursor: pointer;
  font-weight: 500;
  letter-spacing: -.01em;
}
.btn-primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}
.btn-primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn-ghost { background: transparent; }

.add-form { display: flex; gap: .5rem; flex: 1 1 420px; }
.add-form .input { flex: 1; min-width: 140px; }
.add-form select { flex: 0 0 auto; max-width: 200px; }

.spacer { flex: 1; }

/* ── Grid ─────────────────────────────────────────────────────────── */

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 64px 96px; }
@media (max-width: 720px) { .wrap { padding: 20px 24px 96px; } }

/* Grid (not CSS multi-column) so tiles flow left-to-right, top-to-bottom in
   DOM order — matching the stable Reference N numbering. Multi-column masonry
   fills top-to-bottom within a column first, which would scramble that order. */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .grid { grid-template-columns: 1fr; } }

.tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-soft);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: border-color .15s ease;
}
.tile.selected { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }

.tile-media-wrap { position: relative; width: 100%; background: var(--paper); }
.tile-media { display: block; width: 100%; height: auto; cursor: pointer; }

.tile-check {
  position: absolute;
  top: .5rem;
  left: .5rem;
  z-index: 3;
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
  cursor: pointer;
}

.ref-chip {
  position: absolute;
  top: .5rem;
  right: .5rem;
  z-index: 2;
  background: var(--navy);
  color: var(--gold);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .04em;
  padding: .25rem .45rem;
  border-radius: 6px;
  pointer-events: none;
}

.mute-chip, .brand-chip {
  position: absolute;
  bottom: .5rem;
  right: .5rem;
  z-index: 2;
  background: rgba(26, 35, 50, .75);
  color: var(--white);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .6rem;
  letter-spacing: .06em;
  padding: .25rem .45rem;
  border-radius: 6px;
  pointer-events: none;
}

.tile-overlay { padding: .65rem .75rem .75rem; border-top: 1px solid var(--border); }

.badge-row { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .4rem; }
.badge {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .6rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .18rem .4rem;
  border-radius: 5px;
}
.badge-pin { background: transparent; color: var(--ink); opacity: .5; border: 1px solid var(--border); }
.badge-recon, .badge-manual { background: rgba(237, 180, 76, .16); color: var(--gold-hover); }
.badge-offer { background: var(--navy); color: var(--gold); }

.tile-title {
  margin: 0 0 .2rem;
  font-size: .84rem;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-author { margin: 0 0 .5rem; font-size: .72rem; color: var(--ink); opacity: .5; }

.tile-tags { display: flex; gap: .35rem; align-items: center; }
.tile-tags select { font-size: .68rem; padding: 4px 6px; flex: 1; min-width: 0; }

.analysis-box {
  margin-top: .5rem;
  padding: .5rem .6rem;
  background: rgba(237, 180, 76, .08);
  border: 1px solid rgba(237, 180, 76, .25);
  border-radius: 8px;
}
.analysis-eyebrow {
  margin: 0 0 .2rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .58rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gold-hover);
}
.analysis-list {
  margin: 0;
  padding-left: 1rem;
  font-size: .72rem;
  line-height: 1.5;
}
.analysis-list li { margin-bottom: .15rem; }
.analysis-list li:last-child { margin-bottom: 0; }

.tile-bottom-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: .35rem;
}

.tile-link {
  display: block;
  margin-top: .4rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .66rem;
  color: var(--gold-hover);
  text-decoration: none;
  white-space: nowrap;
}
.tile-link:hover { text-decoration: underline; }

.tile-remove {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .64rem;
  color: var(--ink);
  opacity: .4;
  cursor: pointer;
  white-space: nowrap;
}
.tile-remove:hover { opacity: .8; color: #b3413a; }

.tile-delete {
  appearance: none;
  border: none;
  background: none;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  opacity: .35;
  cursor: pointer;
  line-height: 0;
}
.tile-delete:hover { opacity: 1; color: #b3413a; }

/* ── Selection bar ────────────────────────────────────────────────── */

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  display: flex;
  align-items: center;
  gap: .75rem;
  z-index: 20;
  font-size: 13px;
}
.selection-bar[hidden] { display: none; }
.selection-bar .count { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--gold); }
.selection-bar select {
  background: rgba(255, 255, 255, .08);
  color: var(--white);
  border-color: rgba(255, 255, 255, .2);
}
/* The dropdown list itself renders on an opaque native background (not the
   transparent navy above), so options need their own explicit dark-on-light
   colors or the inherited white text disappears against it. */
.selection-bar select option {
  background: var(--white);
  color: var(--ink);
}
.selection-bar .btn-ghost { color: rgba(255, 255, 255, .6); border-color: rgba(255, 255, 255, .2); }

/* ── Panel (per-brand add-from-existing) ─────────────────────────── */

.panel-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30;
  display: flex; align-items: flex-start; justify-content: center;
}
.panel-backdrop[hidden] { display: none; }
.panel {
  background: var(--paper);
  margin-top: 64px;
  border-radius: 12px;
  max-width: 720px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.panel h2 { font-size: 18px; font-weight: 500; margin: 0 0 4px; }
.panel .sub { font-size: 13px; opacity: .6; margin: 0 0 16px; }
.panel-close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink); }

.panel-ad-list { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; max-height: 320px; overflow-y: auto; }
.panel-ad-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 13px;
}
.panel-ad-row img, .panel-ad-row video { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.panel-ad-row .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feedback-month {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gold-hover);
  margin: 20px 0 8px;
}
.feedback-month:first-of-type { margin-top: 4px; }

.feedback-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
}
.feedback-row input { margin-top: 3px; accent-color: var(--gold-hover); }
.feedback-row-body { flex: 1; }
.feedback-message { margin: 0 0 2px; font-size: 13px; }
.feedback-meta { margin: 0; font-size: 11px; opacity: .5; font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ── Feedback ─────────────────────────────────────────────────────── */

.feedback-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 15;
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.toast.show { opacity: 1; }

.empty-state {
  padding: 48px 0;
  text-align: center;
  opacity: .5;
  font-size: 14px;
}
