*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --ink: #0a1128;
  --muted: #5b6478;
  --line: #e8ebf2;
  --bg: #f7f8fb;
  --card: #ffffff;
  --blue: #0066ff;
  --blue-soft: #e8f0ff;
  --green: #0a7a3e;
  --green-soft: #e6f6ec;
  --amber: #9a6700;
  --amber-soft: #fff6e0;
  --red: #b42318;
  --red-soft: #fdeceb;
  --violet: #5b21b6;
  --violet-soft: #f3e8ff;
  --fb: #3b5998;
  --fb-soft: #eef2f8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(10, 17, 40, 0.04), 0 8px 24px rgba(10, 17, 40, 0.04);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 40;
  padding: 8px 12px; background: var(--ink); color: #fff; border-radius: 8px;
}
.skip:focus { top: 12px; }

.wrap { width: min(760px, calc(100% - 32px)); margin-inline: auto; }

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 28px 0 22px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.lede { margin: 0 0 12px; color: var(--muted); max-width: 40rem; }

.brief-line {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: var(--blue-soft);
  border-radius: 8px;
  font-size: 0.92rem;
}

.hard-filters-note {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.meta-line {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.dot { opacity: 0.5; }

.linkish {
  appearance: none; border: 0; background: none; padding: 0;
  color: var(--blue); font: inherit; cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin: 20px 0 12px;
}

.filter-rows { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 2px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: #c9d0e0; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-auction-tog.is-on { background: var(--violet); border-color: var(--violet); color: #fff; }
.chip-facebook-tog { border-color: #c5d0e6; color: var(--fb); }
.chip-facebook-tog.is-on { background: var(--fb); border-color: var(--fb); color: #fff; }

.sort-label select {
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  max-width: 100%;
}

.status-msg { margin: 0 0 10px; min-height: 1.2em; font-size: 0.85rem; color: var(--muted); }

.listings { display: flex; flex-direction: column; gap: 12px; padding-bottom: 40px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card.is-auction {
  border-color: #7c3aed;
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12), var(--shadow);
}

.card.is-facebook {
  border-color: #9db0d0;
}

.card.is-excluded { opacity: 0.72; }

.card-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  flex: 1 1 12rem;
}
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--blue); }

.price-block { text-align: right; flex: 0 0 auto; }
.price {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.delta {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.delta-down { color: var(--green); background: var(--green-soft); }
.delta-up { color: var(--red); background: var(--red-soft); }
.delta-flat { color: var(--muted); background: #eef0f5; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }

.pill {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef0f5;
  color: var(--muted);
}
.pill-active { background: var(--blue-soft); color: #0047b3; }
.pill-drop { background: var(--green-soft); color: var(--green); }
.pill-sold { background: var(--amber-soft); color: var(--amber); }
.pill-gone, .pill-excluded_weight { background: #eef0f5; color: var(--muted); }
.pill-auction { background: var(--violet-soft); color: var(--violet); }
.pill-retail { background: #eef0f5; color: var(--muted); }
.pill-facebook { background: var(--fb-soft); color: var(--fb); }
.pill-bronco { background: var(--blue-soft); color: #0047b3; }
.pill-grenadier { background: #ecfdf5; color: #047857; }
.pill-defender { background: #f0fdf4; color: #166534; }
.pill-weight-ok { background: var(--green-soft); color: var(--green); }
.pill-weight-bad { background: var(--red-soft); color: var(--red); }
.pill-weight-maybe { background: var(--amber-soft); color: var(--amber); }

.meta { margin: 0; font-size: 0.88rem; color: var(--muted); }
.meta span + span::before { content: " · "; opacity: 0.6; }
.why { margin: 8px 0 0; font-size: 0.88rem; color: var(--ink); }
.gvwr-note { margin: 6px 0 0; font-size: 0.82rem; color: var(--muted); }

.repairs {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 8px;
  font-size: 0.88rem;
}
.repairs h3 {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--violet);
}
.repairs dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.repairs dt { color: var(--muted); font-weight: 500; }
.repairs dd { margin: 0; font-weight: 600; color: var(--ink); }
.repairs .est-note { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); font-weight: 400; }

.history {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.history summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.history summary::-webkit-details-marker { display: none; }
.history[open] summary { margin-bottom: 8px; color: var(--ink); }
.history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  padding: 3px 0;
  color: var(--muted);
}
.history-row strong { color: var(--ink); font-weight: 600; }

.empty {
  margin: 28px 0 48px;
  padding: 28px 20px;
  text-align: center;
  background: var(--card);
  border: 1px dashed #c9d0e0;
  border-radius: var(--radius);
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 32px;
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer p { margin: 0 0 4px; }
.foot-note { opacity: 0.85; }

@media (min-width: 720px) {
  .wrap { width: min(800px, calc(100% - 48px)); }
  .site-header { padding: 36px 0 26px; }
  .card { padding: 18px 20px 16px; }
  .sort-label { margin-top: 22px; flex-shrink: 0; }
}

/* Local photos + hide */
.card-body {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
}

.card-media {
  flex: 0 0 112px;
  width: 112px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  background: #eef0f5;
  border: 1px solid var(--line);
  position: relative;
}

.card-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-photo-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #9aa3b5;
  background: repeating-linear-gradient(
    -45deg,
    #eef0f5,
    #eef0f5 6px,
    #e6e9f0 6px,
    #e6e9f0 12px
  );
}

.card-main { flex: 1 1 14rem; min-width: 0; }

.card.is-hidden {
  opacity: 0.62;
  border-style: dashed;
}

.pill-hidden {
  background: #eef0f5;
  color: #4b5568;
  border: 1px dashed #c9d0e0;
}

.card-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-hide {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-hide:hover {
  border-color: #c9d0e0;
  color: var(--ink);
  background: #f3f5f9;
}

.show-hidden-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
}
.show-hidden-label input {
  margin: 0;
  accent-color: var(--ink);
}

@media (min-width: 720px) {
  .card-media {
    flex-basis: 140px;
    width: 140px;
    height: 105px;
  }
}

/* Deal badge */
.card-heading {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex: 1 1 12rem;
  min-width: 0;
}
.deal-badge {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--deal, #64748b);
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  cursor: pointer;
  padding: 0;
  font: inherit;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--deal, #64748b) 18%, transparent);
}
.deal-badge-score {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--deal, #64748b);
}
.deal-badge-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 46px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deal-tip {
  position: fixed;
  z-index: 50;
  max-width: 320px;
  padding: 10px 12px;
  background: #0a1128;
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.4;
  border-radius: 10px;
  white-space: pre-wrap;
  box-shadow: 0 12px 32px rgba(10, 17, 40, 0.28);
  pointer-events: none;
}

/* Flags / actions */
.btn-flag {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-flag:hover {
  border-color: #c9d0e0;
  color: var(--ink);
  background: #f3f5f9;
}
.btn-flag.btn-fav.is-on,
.card.is-favorited .btn-fav.is-on {
  background: #fff7ed;
  border-color: #fdba74;
  color: #c2410c;
}
.pill-fav { background: #fff7ed; color: #c2410c; }
.pill-auction-under { background: var(--violet-soft); color: var(--violet); }

/* Body color chips — visually colored, not gray text */
.pill-body {
  border: 1px solid transparent;
}
.pill-body-white {
  background: #faf8f3;
  color: #3f3a32;
  border-color: #d6d0c4;
}
.pill-body-baby_blue {
  background: #cfeeff;
  color: #0b4f7a;
  border-color: #9ad4f5;
}
.pill-body-unknown {
  background: #eef0f5;
  color: var(--muted);
  border-color: #d8dde8;
}

/* Top color chips */
.pill-top {
  border: 1px solid transparent;
}
.pill-top-white {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}
.pill-top-black {
  background: #0f172a;
  color: #f8fafc;
  border-color: #0f172a;
}
.pill-top-unknown {
  background: #eef0f5;
  color: var(--muted);
  border-color: #d8dde8;
}
/* Body-color top inherits body palette */
.pill-top-body,
.pill-top-body-unknown {
  background: #eef0f5;
  color: var(--muted);
  border-color: #d8dde8;
}
.pill-top-body-white {
  background: #faf8f3;
  color: #3f3a32;
  border-color: #d6d0c4;
}
.pill-top-body-baby_blue {
  background: #cfeeff;
  color: #0b4f7a;
  border-color: #9ad4f5;
}

.min-score-label select {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
}

.card.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.14), var(--shadow);
}
.card.is-favorited {
  border-color: #fdba74;
}

/* Split pane workspace (desktop) */
.workspace {
  width: 100%;
}
.workspace-list {
  min-width: 0;
}
.list-wrap {
  width: min(800px, calc(100% - 32px));
  margin-inline: auto;
}
.workspace-preview {
  display: none;
}
.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.preview-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}
.btn-preview-link,
.btn-preview-close {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.btn-preview-link:hover,
.btn-preview-close:hover { background: #f3f5f9; text-decoration: none; }
.btn-preview-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  display: inline-block;
  margin-top: 8px;
}
.btn-preview-primary:hover { background: #1a2444; color: #fff; }
.preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #e8ebf2;
}
.preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.preview-fallback,
.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  color: var(--muted);
  background: #f3f5f9;
}
.preview-fallback-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
.preview-fallback-body { margin: 0; max-width: 28rem; }
.preview-empty p { margin: 0 0 6px; }
.preview-empty-hint { font-size: 0.85rem; }

@media (min-width: 1100px) {
  body.is-split .workspace {
    display: grid;
    grid-template-columns: minmax(420px, 560px) 1fr;
    gap: 0;
    align-items: stretch;
    min-height: calc(100vh - 220px);
    border-top: 1px solid var(--line);
  }
  body.is-split .workspace-list {
    overflow: auto;
    max-height: calc(100vh - 220px);
    border-right: 1px solid var(--line);
    background: var(--bg);
  }
  body.is-split .list-wrap {
    width: auto;
    margin: 0;
    padding: 0 16px;
  }
  body.is-split .site-header .wrap,
  body.is-split .site-footer .wrap {
    width: min(1200px, calc(100% - 48px));
  }
  body.is-split .workspace-preview {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 220px);
    background: var(--card);
  }
  body.is-split .workspace-preview[hidden] {
    display: flex !important; /* JS unhides; ensure layout */
  }
}

@media (max-width: 1099px) {
  .workspace-preview { display: none !important; }
  .btn-preview { display: none; } /* mobile opens via title link / new tab */
}


/* ---------- About (?) commentary drawer ---------- */
.about-toggle {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 60;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.about-toggle:hover {
  border-color: #c9d0e0;
  background: #f3f5f9;
}
.about-toggle[aria-expanded="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.about-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(10, 17, 40, 0.36);
}

.about-panel {
  position: fixed;
  z-index: 80;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100%;
  max-height: 100dvh;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(10, 17, 40, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.about-panel[hidden],
.about-backdrop[hidden] {
  display: none !important;
}
.about-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.about-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.about-panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.about-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}
.about-close:hover {
  background: #f3f5f9;
  color: var(--ink);
}
.about-panel-body {
  padding: 16px 18px 28px;
  overflow: auto;
  flex: 1 1 auto;
}
.about-panel-body .lede { margin-top: 0; }
.about-panel-body .foot-note {
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0.95;
}

/* NEW pill — distinct from circular deal badge */
.pill-new {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.card.is-new {
  box-shadow: 0 0 0 1px color-mix(in srgb, #be123c 18%, transparent), var(--shadow);
}
