:root {
  --bg: #0e0e10;
  --panel: #17171a;
  --ink: #f2f2f2;
  --muted: #9a9aa3;
  --line: #2c2c32;
  --accent: #bb0a30;
  --accent-soft: rgba(187, 10, 48, 0.18);
  --ok: #6f9f7a;
  --danger: #c45c4a;
  --card: #1a1a1f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --font-display: "Audiowide", "Segoe UI", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1000px 420px at 0% -10%, #3a121c 0%, transparent 55%),
    radial-gradient(800px 360px at 100% 0%, #1a1a28 0%, transparent 45%),
    var(--bg);
}

.app-chrome {
  position: sticky;
  top: 0;
  z-index: 30;
  background:
    linear-gradient(180deg, rgba(20, 17, 15, 0.96) 0%, rgba(20, 17, 15, 0.9) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(58, 49, 43, 0.85);
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1.25rem 0.45rem;
  max-width: 1100px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-logo {
  height: 2rem;
  width: auto;
  max-width: min(280px, 58vw);
  display: block;
  flex-shrink: 0;
  filter: invert(1);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent);
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
  line-height: 1.25;
  max-width: 48%;
}

.btn-config,
.btn-primary,
.btn-ghost,
.icon-close {
  font: inherit;
  cursor: pointer;
}

.btn-config {
  margin-left: auto;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #2a231e, #1c1714);
  color: var(--muted);
  border-radius: 999px;
  flex-shrink: 0;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn-config svg {
  width: 1.2rem;
  height: 1.2rem;
  display: block;
}

.btn-config:hover {
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-1px);
}

.tabs {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.35rem 1.25rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.tab.is-active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.empty {
  color: var(--muted);
  padding: 2rem 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.swipe-row {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  isolation: isolate;
  --reveal: 0;
}

.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.12s linear;
}

.swipe-row.is-revealing-left .swipe-bg-left,
.swipe-row.is-revealing-right .swipe-bg-right {
  opacity: 1;
}

.swipe-bg-left {
  justify-content: flex-start;
  background: #6f9f7a;
}

.swipe-bg-right {
  justify-content: flex-end;
  background: #c45c4a;
}

/* Suivi: right swipe = back to list (amber) */
.swipe-row.is-followed-tab .swipe-bg-left {
  background: #c4a35a;
}

.swipe-action {
  width: 7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: calc(0.35 + var(--reveal) * 0.65);
  transform: scale(calc(0.88 + var(--reveal) * 0.12));
}

.swipe-action svg {
  width: 1.55rem;
  height: 1.55rem;
  display: block;
}

.swipe-front {
  position: relative;
  z-index: 1;
  touch-action: pan-y;
  will-change: transform;
  background: var(--card);
}

.swipe-front.is-dragging {
  cursor: grabbing;
}

.swipe-row.is-leaving {
  pointer-events: none;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    border-color: #5a4a40;
  }
}

.thumb {
  aspect-ratio: 4 / 3;
  background: #2c2622 center/cover no-repeat;
  position: relative;
}

.thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  background: rgba(20, 17, 15, 0.82);
  border: 1px solid var(--line);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price {
  margin: 0;
  color: var(--accent);
  font-weight: 650;
}

.actions {
  display: flex;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.55rem;
}

.actions button {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.actions button.follow:hover { border-color: var(--ok); color: var(--ok); }
.actions button.remove:hover { border-color: var(--danger); color: var(--danger); }

/* —— Config panel —— */
.config-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 5, 0.62);
  backdrop-filter: blur(6px);
  z-index: 40;
  animation: fade-in 0.25s var(--ease);
}

.config-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 100vw);
  height: 100vh;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(165deg, rgba(217, 119, 58, 0.08), transparent 32%),
    var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45);
  animation: slide-in 0.35s var(--ease);
}

.config-panel[hidden],
.config-backdrop[hidden] {
  display: none !important;
}

.config-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding: 1.4rem 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.config-head h2 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 650;
}

.icon-close {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

.icon-close:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.config-body {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.config-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.config-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.55rem 0.4rem;
  border-radius: 9px;
  cursor: pointer;
}

.config-tab.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.config-tab:hover:not(.is-active) {
  color: var(--ink);
}

.config-panel-pane {
  display: none !important;
  flex-direction: column;
  gap: 0.75rem;
}

.config-panel-pane.is-active {
  display: flex !important;
}

.config-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
}

.option-toggle strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 500;
}

.option-toggle small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.filter-preview {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
  color: var(--muted);
  font-size: 0.82rem;
}

.section-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.section-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.stack.tight { gap: 0.45rem; }

.filter-row,
.custom-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  display: grid;
  gap: 0.55rem;
}

.filter-row label,
.form-grid label,
.custom-row {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-row input,
.form-grid input {
  border: 1px solid var(--line);
  background: #181411;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.92rem;
}

.filter-row .row-actions {
  display: flex;
  justify-content: flex-end;
}

.filter-row .row-top {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 0.5rem;
}

.btn-ghost {
  border: 1px dashed #5a4a40;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  align-self: start;
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.btn-tiny {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.2rem 0.35rem;
}

.sites-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.site-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}

.site-toggle span {
  font-size: 0.95rem;
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #3a312b;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}

.slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #d7ccc0;
  border-radius: 50%;
  transition: transform 0.2s var(--ease);
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.form-grid .span-2 { grid-column: 1 / -1; }

.custom-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-size: 0.9rem;
}

.config-foot {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1.25rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: rgba(0, 0, 0, 0.18);
}

.config-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.82rem;
  color: var(--muted);
}

.config-status.is-ok { color: var(--ok); }
.config-status.is-err { color: var(--danger); }

.foot-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
}

.btn-primary {
  border: none;
  background: linear-gradient(180deg, #e0894a, var(--accent));
  color: #1a120e;
  font-weight: 600;
  border-radius: 12px;
  padding: 0.65rem 1.1rem;
  box-shadow: 0 8px 20px rgba(217, 119, 58, 0.28);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

@keyframes slide-in {
  from { transform: translateX(18px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 640px) {
  .top { gap: 0.75rem; }
  .meta {
    font-size: 0.7rem;
    max-width: 42%;
  }
  .filter-row .row-top { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }

  .grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Swipe is primary on phone — hide button row */
  .card .actions {
    display: none;
  }

  .swipe-row {
    box-shadow: var(--shadow);
  }

  .card {
    box-shadow: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  .card .actions {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

.badge-year {
  left: auto;
  right: 0.7rem;
}

.card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.year-block, .engines-block, .price-field {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 1rem 0;
}

.year-labels, .price-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.price-field input {
  width: 8rem;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font: inherit;
}

.dual-range {
  position: relative;
  height: 2rem;
  --range-left: 20%;
  --range-right: 40%;
}

.dual-range::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--line);
}

.dual-range::after {
  content: "";
  position: absolute;
  left: var(--range-left);
  right: calc(100% - var(--range-right));
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--accent);
}

.dual-range input[type="range"] {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  background: none;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  cursor: pointer;
}

.dual-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: pointer;
}

.year-ticks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.engines-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.engine-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  cursor: pointer;
}

.engine-chip input { accent-color: var(--accent); }

.site-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
