/* ── Light theme ──────────────────────────────────────────────────── */
:root[data-theme="light"] {
  --pico-font-family: "Ubuntu", system-ui, sans-serif;
  --pico-background-color: #f5f6fa;
  --pico-card-background-color: #ffffff;
  --pico-card-sectioning-background-color: #f8f9fb;
  --pico-primary: #E3414F;
  --pico-primary-hover: #c9323f;
  --pico-primary-focus: rgba(227, 65, 79, 0.25);
  --pico-primary-background: #E3414F;
  --pico-primary-hover-background: #c9323f;
  --pico-primary-inverse: #fff;
  --pico-secondary: #373278;
  --pico-secondary-hover: #4a44a0;
  --pico-secondary-background: #373278;
  --pico-secondary-hover-background: #2b2660;
  --pico-secondary-inverse: #fff;
  --pico-color: #1a1a2e;
  --pico-h1-color: #1a1a2e;
  --pico-h2-color: #1a1a2e;
  --pico-h3-color: #1a1a2e;
  --pico-h4-color: #1a1a2e;
  --pico-h5-color: #1a1a2e;
  --pico-h6-color: #1a1a2e;
  --pico-muted-color: #6b7280;
  --pico-border-color: #e2e8f0;
  --pico-form-element-background-color: #ffffff;
  --pico-form-element-border-color: #d1d5db;
  --pico-form-element-color: #1a1a2e;
  --pico-form-element-placeholder-color: #9ca3af;
  --pico-table-border-color: #e2e8f0;
  --pico-table-row-stripped-background-color: rgba(0,0,0,0.02);
  --pico-nav-element-spacing-horizontal: 1rem;
  --pico-nav-link-color: #374151;
  --pico-code-background-color: #f3f4f6;
  --pico-code-color: #374151;
  --pico-dropdown-background-color: #ffffff;
  --pico-dropdown-border-color: #e2e8f0;
  --pico-dropdown-color: #374151;
  --pico-dropdown-hover-background-color: #f3f4f6;
  --pico-mark-background-color: rgba(227, 65, 79, 0.1);
  --pico-mark-color: #E3414F;
  --pico-progress-background-color: #e2e8f0;
  --pico-progress-color: #E3414F;
  --pico-switch-background-color: #d1d5db;
  --pico-switch-checked-background-color: #E3414F;
}

/* ── Dark theme ───────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --pico-font-family: "Ubuntu", system-ui, sans-serif;
  --pico-background-color: #171a21;
  --pico-card-background-color: #1b2838;
  --pico-card-sectioning-background-color: #1b2838;
  --pico-primary: #E3414F;
  --pico-primary-hover: #ef6b76;
  --pico-primary-focus: rgba(227, 65, 79, 0.25);
  --pico-primary-background: #E3414F;
  --pico-primary-hover-background: #c9323f;
  --pico-primary-inverse: #fff;
  --pico-secondary: #373278;
  --pico-secondary-hover: #4a44a0;
  --pico-secondary-focus: rgba(55, 50, 120, 0.25);
  --pico-secondary-background: #373278;
  --pico-secondary-hover-background: #2b2660;
  --pico-secondary-inverse: #fff;
  --pico-color: #c7d5e0;
  --pico-h1-color: #c7d5e0;
  --pico-h2-color: #c7d5e0;
  --pico-h3-color: #c7d5e0;
  --pico-h4-color: #c7d5e0;
  --pico-h5-color: #c7d5e0;
  --pico-h6-color: #c7d5e0;
  --pico-muted-color: #8f98a0;
  --pico-border-color: #2a3a4a;
  --pico-form-element-background-color: #1b2838;
  --pico-form-element-border-color: #2a3a4a;
  --pico-form-element-color: #c7d5e0;
  --pico-form-element-placeholder-color: #8f98a0;
  --pico-form-element-focus-color: #c7d5e0;
  --pico-table-border-color: #2a3a4a;
  --pico-table-row-stripped-background-color: rgba(42, 71, 94, 0.15);
  --pico-nav-element-spacing-horizontal: 1rem;
  --pico-nav-link-color: #c7d5e0;
  --pico-code-background-color: #2a475e;
  --pico-code-color: #c7d5e0;
  --pico-dropdown-background-color: #1b2838;
  --pico-dropdown-border-color: #2a3a4a;
  --pico-dropdown-color: #c7d5e0;
  --pico-dropdown-hover-background-color: #2a475e;
  --pico-mark-background-color: rgba(227, 65, 79, 0.2);
  --pico-mark-color: #E3414F;
  --pico-progress-background-color: #2a3a4a;
  --pico-progress-color: #E3414F;
  --pico-switch-background-color: #2a3a4a;
  --pico-switch-checked-background-color: #E3414F;
}

/* ── Site header ──────────────────────────────────────────────────── */
.site-header {
  background: #2D2968;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 1rem;
}
[data-theme="dark"] .site-header {
  background: #111520;
}
.site-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #5C57B2 0%, #E3414F 50%, #5C57B2 100%);
}
.header-logo {
  text-decoration: none;
  flex-shrink: 0;
}
.logo-name {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #E3414F, #9A94C8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.logo-sub {
  font-size: 11px;
  color: #9A94C8;
  margin-top: 2px;
  letter-spacing: 0.04em;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}
.site-header .nav-link {
  color: #9A94C8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.site-header .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.site-header .nav-link.nav-active {
  color: #fff;
  border-color: #5C57B2;
  background: rgba(92, 87, 178, 0.2);
}
#theme-toggle,
#feedback-btn {
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0;
  margin: 0 0 0 8px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  vertical-align: middle;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: #9A94C8;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
#feedback-btn svg {
  display: block;
}
#theme-toggle:hover,
#feedback-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ── Feedback modal ───────────────────────────────────────────────── */
.feedback-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.feedback-dialog[open] {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 0;
  background: transparent;
}
.feedback-error {
  color: #E3414F;
  margin-top: 0.5rem;
}
.feedback-success {
  text-align: center;
  padding: 1rem 0.5rem;
}

/* ── Noise overlay ────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.012;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* ── Dashboard stat cards ─────────────────────────────────────────── */
.grid > article {
  text-align: center;
}
.grid > article header {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}
.grid > article strong {
  font-size: 2rem;
}

/* ── Status badges ────────────────────────────────────────────────── */
mark {
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
}
mark.secondary {
  background: var(--pico-secondary-background);
  color: var(--pico-secondary-inverse);
}
mark.success {
  background: rgba(76, 175, 80, 0.15);
  color: #4caf50;
}
mark.warning {
  background: rgba(255, 152, 0, 0.15);
  color: #ff9800;
}
mark.danger {
  background: rgba(227, 65, 79, 0.15);
  color: #E3414F;
}

/* ── Offer pipeline bar ───────────────────────────────────────────── */
.offer-pipeline {
  display: flex;
  align-items: flex-start;
  margin: 1.5rem 0 2rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 80px;
  flex: 1;
  position: relative;
}

.pipeline-step .p-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--pico-border-color);
  background: var(--pico-background-color);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.pipeline-step .p-label {
  font-size: 0.7rem;
  color: var(--pico-muted-color);
  text-align: center;
  white-space: nowrap;
  line-height: 1.3;
}

.pipeline-step.p-done .p-dot {
  background: var(--pico-primary);
  border-color: var(--pico-primary);
}
.pipeline-step.p-done .p-label { color: var(--pico-primary); }

.pipeline-step.p-current .p-dot {
  background: var(--pico-primary);
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 4px rgba(227, 65, 79, 0.2);
}
.pipeline-step.p-current .p-label {
  color: var(--pico-color);
  font-weight: 600;
}

.pipeline-step.p-terminal .p-dot {
  background: #E3414F;
  border-color: #E3414F;
}
.pipeline-step.p-terminal .p-label {
  color: #E3414F;
  font-weight: 600;
}

.pipeline-step.p-faded .p-dot {
  opacity: 0.3;
}
.pipeline-step.p-faded .p-label {
  opacity: 0.3;
}

.pipeline-connector {
  flex: 1;
  height: 2px;
  background: var(--pico-border-color);
  margin-top: 6px;
  transition: background 0.2s;
  min-width: 16px;
}
.pipeline-connector.p-done { background: var(--pico-primary); }
.pipeline-connector.p-cut {
  background: #E3414F;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.pipeline-connector.p-cut::after {
  content: '✕';
  position: absolute;
  color: #E3414F;
  font-size: 0.8rem;
  background: var(--pico-background-color);
  padding: 0 0.2rem;
  line-height: 1;
  top: 50%;
  transform: translateY(-50%);
}

/* ── Next action callout ──────────────────────────────────────────── */
.next-action {
  border-left: 3px solid var(--pico-primary);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 0 6px 6px 0;
  background: rgba(227, 65, 79, 0.06);
  font-size: 0.92rem;
}
.next-action strong { display: block; margin-bottom: 0.2rem; }

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--pico-muted-color);
}
.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}
.empty-state p { margin-bottom: 1rem; }

/* ── Role dropdown in nav ─────────────────────────────────────────── */
nav details.dropdown { margin-bottom: 0; }

/* ── Table ────────────────────────────────────────────────────────── */
table { font-size: 0.9rem; }

/* ── HTMX loading ─────────────────────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }

/* ── Offer type tabs ──────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--pico-border-color);
  margin-bottom: 1.5rem;
}
.tab-nav button {
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  background: transparent;
  color: var(--pico-muted-color);
  padding: 0.5rem 1.5rem;
  cursor: pointer;
}
.tab-nav button.active {
  border-bottom-color: var(--pico-primary);
  color: var(--pico-primary);
}

/* ── Upload zone ──────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--pico-border-color);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--pico-primary); }

/* ── Form input text visibility fix ──────────────────────────────── */
/* color-scheme on root causes Chrome to native-render inputs;
   override per-theme with explicit values + matching color-scheme */
:root[data-theme="dark"] input[type="search"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] input[type="text"] {
  color: #c7d5e0 !important;
  background-color: #1b2838 !important;
  -webkit-text-fill-color: #c7d5e0 !important;
  color-scheme: dark;
}
:root[data-theme="light"] input[type="search"],
:root[data-theme="light"] input[type="number"],
:root[data-theme="light"] input[type="text"] {
  color: #1a1a2e !important;
  background-color: #ffffff !important;
  -webkit-text-fill-color: #1a1a2e !important;
  color-scheme: light;
}
input[type="search"]::-webkit-search-cancel-button {
  filter: invert(0.5);
}

/* ── Filter bar ───────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-border-color);
  border-radius: 8px;
}
.filter-bar label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pico-muted-color);
  margin-bottom: 0.25rem;
}
.filter-bar input,
.filter-bar select {
  margin: 0;
}

/* ── Game discovery ───────────────────────────────────────────────── */
#games-results article[data-app-id] {
  overflow: hidden;
}
#games-results article[data-app-id]:hover {
  background: var(--pico-card-sectioning-background-color);
}
#games-results article[data-app-id].selected {
  border-left-color: var(--pico-primary) !important;
  background: rgba(227, 65, 79, 0.06);
}

/* ── Game card image area ─────────────────────────────────────────── */
.game-card-img {
  position: relative;
  margin: -0.75rem -0.75rem 0.55rem -0.75rem;
  background: var(--pico-card-sectioning-background-color);
  line-height: 0;
  min-height: 72px;
}
.game-card-img.no-art {
  background: linear-gradient(135deg,
    var(--pico-card-sectioning-background-color) 0%,
    rgba(227, 65, 79, 0.08) 100%);
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.game-card-img.no-art::after {
  content: 'No art';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--pico-muted-color);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
}
.game-card-img img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
  opacity: 0.92;
  transition: opacity 0.15s;
}
article[data-app-id]:hover .game-card-img img { opacity: 1; }
.game-card-img .game-select-cb {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  margin: 0;
  z-index: 2;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--pico-primary);
}

/* ── Game tag pills ───────────────────────────────────────────────── */
.game-tag {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  display: inline-block;
}
:root[data-theme="dark"] .game-tag {
  background: rgba(42, 71, 94, 0.8);
  color: #8f98a0;
}
:root[data-theme="light"] .game-tag {
  background: rgba(55, 50, 120, 0.1);
  color: #373278;
}

/* ── Tom Select dark/light overrides ─────────────────────────────── */
.ts-control, .ts-dropdown {
  background: var(--pico-form-element-background-color) !important;
  border-color: var(--pico-form-element-border-color) !important;
  color: var(--pico-color) !important;
  font-family: var(--pico-font-family);
  font-size: 1rem;
}
.ts-control {
  border-radius: var(--pico-border-radius, 4px);
  padding: calc(var(--pico-form-element-spacing-vertical, 0.5rem) - 1px) var(--pico-form-element-spacing-horizontal, 0.75rem);
  min-height: 2.5rem;
}
.ts-dropdown .option { padding: 0.4rem 0.75rem; color: var(--pico-color); }
.ts-dropdown .option.active, .ts-dropdown .option:hover {
  background: var(--pico-dropdown-hover-background-color) !important;
  color: var(--pico-color) !important;
}
.ts-dropdown .option.selected {
  background: var(--pico-primary) !important;
  color: var(--pico-primary-inverse) !important;
}
.ts-control .item {
  background: var(--pico-secondary-background) !important;
  color: var(--pico-secondary-inverse) !important;
  border: none !important;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
}
.ts-wrapper.single.input-active .ts-control {
  background: var(--pico-form-element-background-color) !important;
}

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

/* Patch-notes "What's new" strip on dashboard — collapses when fully read */
.changelog-strip {
  margin-bottom: 1.5rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.02);
}
.changelog-strip > summary {
  cursor: pointer;
  font-size: 0.95rem;
  list-style: none;
  user-select: none;
}
.changelog-strip > summary::-webkit-details-marker { display: none; }
.changelog-strip > summary::before {
  content: '\25B8';
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s;
}
.changelog-strip[open] > summary::before { transform: rotate(90deg); }
.changelog-entry {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--pico-muted-border-color);
}
.changelog-entry:first-of-type {
  border-top: none;
  padding-top: 0.6rem;
}
.changelog-entry header { margin-bottom: 0.3rem; }
.changelog-entry header time {
  color: var(--pico-muted-color);
  font-size: 0.8em;
  margin-left: 0.5rem;
}
.changelog-body { font-size: 0.9rem; }
.changelog-body p { margin-bottom: 0.4rem; }
.changelog-body ul { margin: 0.3rem 0 0.6rem 1.2rem; }
.changelog-body li { margin-bottom: 0.2rem; }
.changelog-pill {
  display: inline-block;
  background: var(--pico-muted-color);
  color: #fff;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.changelog-pill-new { background: #27ae60; }
