:root {
  --color-bg: #f7f6f3;
  --color-surface: #ffffff;
  --color-border: #e5e2db;
  --color-text: #1c1b19;
  --color-text-muted: #6b675f;
  --color-accent: #2563eb;
  --color-accent-contrast: #ffffff;
  --color-check: #16a34a;
  --color-badge-debutant: #3f7a4e;
  --color-badge-intermediaire: #b7791f;
  --color-badge-pro: #d9531e;
  --color-badge-cinema: #6d28d9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.06), 0 4px 10px rgba(28, 27, 25, 0.04);
  --shadow-modal: 0 10px 40px rgba(28, 27, 25, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #16161a;
    --color-surface: #1e1e24;
    --color-border: #34343d;
    --color-text: #f2f1ee;
    --color-text-muted: #a3a099;
    --color-accent: #4d82f3;
    --color-accent-contrast: #ffffff;
    --color-check: #22c55e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.25);
    --shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --color-bg: #16161a;
  --color-surface: #1e1e24;
  --color-border: #34343d;
  --color-text: #f2f1ee;
  --color-text-muted: #a3a099;
  --color-accent: #4d82f3;
  --color-accent-contrast: #ffffff;
  --color-check: #22c55e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.25);
  --shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: inherit; }

/* Header */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.site-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--color-accent);
}

.site-logo {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
}

.tab-btn:hover { background: var(--color-bg); }

.tab-btn.active {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-toggle-btn:hover { border-color: var(--color-accent); }

.global-search {
  position: relative;
  flex: 1 1 200px;
  max-width: 320px;
}

.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  padding: 8px;
  max-height: 420px;
  overflow-y: auto;
  z-index: 30;
}

.global-search-group + .global-search-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}

.global-search-group h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin: 0 0 4px;
  padding: 0 6px;
}

.global-search-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  color: var(--color-text);
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.global-search-item:hover {
  background: var(--color-bg);
}

.global-search-empty {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin: 0;
  padding: 8px 6px;
}

/* Main / layout */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search-input, .select-input, .number-input {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.search-input {
  flex: 1 1 220px;
  min-width: 160px;
}

.btn-secondary {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

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

.btn-full { width: 100%; margin-top: 4px; }

.catalogue-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 18px;
  align-items: start;
}

.filters {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 60px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.budget-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.number-input { width: 100%; min-width: 0; }
.budget-sep { color: var(--color-text-muted); }

.results-count {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0 0 8px;
}

.empty-state {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 32px 0;
  text-align: center;
}

.hidden { display: none !important; }

/* Grid / cards */

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

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

.card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow);
}

.card-image {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #efece5, #e2ded4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
}

.card-image img { width: 100%; height: 100%; object-fit: cover; }

.card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
}

.card-name {
  font-size: 13.5px;
  font-weight: 700;
  margin: 0;
}

.card-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-price {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-accent);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}

.badge-niveau-debutant { background: var(--color-badge-debutant); }
.badge-niveau-intermediaire { background: var(--color-badge-intermediaire); }
.badge-niveau-pro { background: var(--color-badge-pro); }
.badge-niveau-cinema { background: var(--color-badge-cinema); }

.badge-neutral {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.badge-recommended {
  background: var(--color-accent);
  margin-left: 6px;
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 25, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  max-width: 620px;
  width: 100%;
  padding: 20px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--color-bg); }

.modal h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.modal-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.modal-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin: 0 0 8px;
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px 14px;
  font-size: 12.5px;
}

.spec-grid dt { color: var(--color-text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.spec-grid dd { margin: 2px 0 0; font-weight: 600; }

.leboncoin-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, var(--color-border));
  border-radius: var(--radius-sm);
  padding: 6px 12px;
}

.leboncoin-link:hover {
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
}

.lens-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
}

.lens-item-recommended {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
}

.lens-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.lens-item-name { font-weight: 700; font-size: 13px; }
.lens-item-price { font-size: 12px; color: var(--color-accent); font-weight: 600; }
.lens-item-meta { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }

.combo-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin: 6px 5px 0 0;
  font-size: 11px;
}

/* Kit tab */

.kit-intro {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin: 0 0 12px;
  max-width: 60ch;
}

.kit-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kit-group-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.combo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  align-items: start;
}

.combo-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.combo-card-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.combo-pair {
  font-size: 13.5px;
  font-weight: 700;
  margin: 0 0 4px;
}

.combo-rent-price {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-accent);
  white-space: nowrap;
}

.combo-notes {
  font-size: 12.5px;
  margin-top: 8px;
  color: var(--color-text);
}

/* Guides tab */

.guides-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-category-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

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

.guide-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.guide-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow);
}

.guide-card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 6px;
}

.guide-card-resume {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin: 0;
}

.guide-back-btn {
  margin-bottom: 16px;
}

.guide-detail-content {
  max-width: 68ch;
  margin: 0 auto;
}

.guide-detail-content h2 {
  font-size: 20px;
  margin: 0 0 14px;
}

.guide-intro {
  font-size: 14px;
  line-height: 1.65;
  color: var(--color-text-muted);
  margin: 0 0 20px;
}

.guide-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--color-border);
}

.guide-section:last-of-type {
  border-bottom: none;
}

.guide-section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
}

.guide-section p {
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0;
  color: var(--color-text);
}

.guide-conclusion {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-accent) 25%, var(--color-border));
}

.guide-conclusion h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-accent);
  margin: 0 0 6px;
}

.guide-conclusion p {
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0;
  font-weight: 600;
}

/* Responsive */

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

  .filters {
    position: static;
    display: none;
  }

  .filters.open {
    display: flex;
  }

  .toggle-filters-hint { display: inline; }
}

@media (min-width: 801px) {
  #toggle-filters, #lens-toggle-filters { display: none; }
}
