:root {
  --bg: #0f0608;
  --surface: #1c0d12;
  --surface2: #261318;
  --surface3: #311820;
  --border: rgba(180,100,80,0.15);
  --border2: rgba(180,100,80,0.3);
  --accent: #c9533a;
  --accent2: #e8a87c;
  --gold: #c9a84c;
  --text: #f0e6e0;
  --text2: #b89490;
  --text3: #7a5a55;
  --red-wine: #8B1A2F;
  --white-wine: #D4A843;
  --rose-wine: #D4687A;
  --champagne: #C4A55A;
  --r: 12px;
  --r2: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#view { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 80px; }
#view::-webkit-scrollbar { display: none; }

/* ── Nav ── */
nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(28,13,18,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 10px 0; border: none; background: none;
  color: var(--text3); cursor: pointer; font-family: 'Outfit', sans-serif;
  font-size: 10px; font-weight: 400; letter-spacing: 0.05em;
  transition: color 0.2s; text-transform: uppercase;
}
.nav-btn svg { width: 22px; height: 22px; stroke-width: 1.5; }
.nav-btn.active { color: var(--accent2); }
.nav-btn.active svg { stroke: var(--accent2); }

/* ── Header ── */
.page-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px; font-weight: 300;
  letter-spacing: 0.04em; color: var(--text);
}
.page-header p { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.section { padding: 16px 20px; }
.section + .section { border-top: 1px solid var(--border); }

/* ── Dashboard ── */
.stats-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 16px 20px;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 14px;
}
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px; font-weight: 300;
  color: var(--text); line-height: 1.1; margin-top: 4px;
}
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

.alert-card {
  background: linear-gradient(135deg, rgba(201,83,58,0.15), rgba(201,83,58,0.05));
  border: 1px solid rgba(201,83,58,0.3);
  border-radius: var(--r2);
  padding: 14px; display: flex; gap: 12px; align-items: flex-start;
  margin: 0 20px 12px;
}
.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-size: 13px; font-weight: 500; color: var(--accent2); }
.alert-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ── Wine List ── */
.wine-list { padding: 0 20px; display: flex; flex-direction: column; gap: 10px; }
.wine-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; align-items: center; gap: 14px;
  padding: 14px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative; overflow: hidden;
}
.wine-item:active { background: var(--surface2); }
.wine-item::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
}
.wine-item.rouge::before { background: var(--red-wine); }
.wine-item.blanc::before { background: var(--white-wine); }
.wine-item.rose::before { background: var(--rose-wine); }
.wine-item.champagne::before { background: var(--champagne); }
.wine-item.autre::before { background: var(--text3); }

.wine-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.wine-icon.rouge { background: rgba(139,26,47,0.2); }
.wine-icon.blanc { background: rgba(212,168,67,0.15); }
.wine-icon.rose { background: rgba(212,104,122,0.15); }
.wine-icon.champagne { background: rgba(196,165,90,0.15); }
.wine-icon.autre { background: rgba(120,100,100,0.15); }

.wine-info { flex: 1; min-width: 0; }
.wine-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px; font-weight: 400;
  color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.wine-meta { font-size: 12px; color: var(--text3); margin-top: 1px; }
.wine-badges { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }

.badge {
  font-size: 10px; padding: 2px 7px;
  border-radius: 20px; font-weight: 500;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.badge.apogee { background: rgba(201,168,76,0.2); color: var(--gold); border: 1px solid rgba(201,168,76,0.3); }
.badge.pret { background: rgba(100,200,120,0.15); color: #7ecf8e; border: 1px solid rgba(100,200,120,0.25); }
.badge.attendre { background: rgba(100,140,200,0.15); color: #8ab4f0; border: 1px solid rgba(100,140,200,0.25); }
.badge.depasse { background: rgba(200,80,60,0.15); color: #f08070; border: 1px solid rgba(200,80,60,0.25); }
.badge.qte { background: rgba(255,255,255,0.07); color: var(--text2); border: 1px solid var(--border); }

.wine-chevron { color: var(--text3); flex-shrink: 0; }

/* ── Wine card grid (onglet Bouteilles) ── */
.wine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 12px 16px;
}
@media (min-width: 480px) {
  .wine-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}
@media (min-width: 720px) {
  .wine-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 0 16px 16px; }
}
.wine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, transform 0.12s;
  display: flex; flex-direction: column;
}
.wine-card:active { transform: scale(0.97); border-color: var(--border2); }

/* Barre de couleur en haut */
.wine-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; z-index: 2;
}
.wine-card.rouge::before  { background: var(--red-wine); }
.wine-card.blanc::before  { background: var(--white-wine); }
.wine-card.rose::before   { background: var(--rose-wine); }
.wine-card.champagne::before { background: var(--champagne); }
.wine-card.autre::before  { background: var(--text3); }

/* Zone étiquette */
.wine-card-img {
  width: 100%; aspect-ratio: 3/4;
  position: relative; overflow: hidden;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.wine-card-img img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  display: block;
}
/* Placeholder quand pas de photo */
.wine-card-img-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; width: 100%; height: 100%;
  padding: 8px;
}
.wine-card-img-placeholder .bottle-svg {
  opacity: 0.25;
  width: 30px; height: 56px;
}
.wine-card-img-placeholder .bottle-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 10px; font-weight: 300;
  color: var(--text3); text-align: center;
  line-height: 1.2; max-width: 100%;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* Gradient sur l'image pour lisibilité du texte */
.wine-card-img::after {
  content: ''; position: absolute;
  bottom: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(to top, rgba(12,4,8,0.92) 0%, transparent 100%);
  pointer-events: none;
}
.wine-card-img-over {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 5px 7px; z-index: 1;
}
.wine-card-millesime {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; font-weight: 400;
  color: rgba(255,255,255,0.95); line-height: 1;
}
.wine-card-domaine {
  font-size: 8px; color: rgba(255,255,255,0.55);
  margin-top: 1px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Bas de la carte */
.wine-card-body {
  padding: 6px 7px 7px;
  display: flex; flex-direction: column; gap: 3px;
  flex: 1;
}
.wine-card-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 12px; font-weight: 400; color: var(--text);
  line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.wine-card-region {
  font-size: 8px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wine-card-badges {
  display: flex; gap: 3px; flex-wrap: wrap; margin-top: 2px;
}
.wine-card-badges .badge {
  font-size: 8px !important;
  padding: 1px 5px;
}
/* Halo apogée sur la carte */
.wine-card.apogee-pret {
  box-shadow: 0 0 0 1.5px rgba(126,207,142,0.5), 0 0 12px rgba(126,207,142,0.1);
}
.wine-card.apogee-depasse {
  box-shadow: 0 0 0 1.5px rgba(240,128,112,0.4);
}

/* Toggle vue liste/grille */
.view-toggle {
  display: flex; gap: 0; border: 1px solid var(--border);
  border-radius: var(--r2); overflow: hidden; flex-shrink: 0;
}
.view-toggle-btn {
  padding: 7px 11px; border: none; background: none;
  color: var(--text3); cursor: pointer; display: flex;
  align-items: center; transition: all 0.15s;
}
.view-toggle-btn.active { background: var(--surface2); color: var(--text); }
.view-toggle-btn svg { width: 16px; height: 16px; stroke-width: 1.8; }
.search-row {
  display: flex; gap: 8px; padding: 12px 20px 0; align-items: center;
}
.search-row .search-wrap { flex: 1; padding: 0; }


/* ── Filters ── */
.filters {
  display: flex; gap: 8px; padding: 12px 20px;
  overflow-x: auto; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter-btn {
  white-space: nowrap; padding: 6px 14px;
  border-radius: 20px; border: 1px solid var(--border);
  background: none; color: var(--text2);
  font-family: 'Outfit', sans-serif; font-size: 12px;
  cursor: pointer; transition: all 0.2s;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.filter-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: white;
}

/* ── Search ── */
.search-wrap { padding: 12px 20px; }
.search-input {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r2);
  padding: 10px 14px 10px 38px; color: var(--text);
  font-family: 'Outfit', sans-serif; font-size: 14px;
  outline: none;
}
.search-input::placeholder { color: var(--text3); }
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 34px; top: 50%; transform: translateY(-50%);
  color: var(--text3); pointer-events: none;
}

/* ── FAB ── */
.fab {
  position: fixed; bottom: 80px; right: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); border: none;
  color: white; font-size: 24px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(201,83,58,0.4);
  z-index: 50; transition: transform 0.15s;
}
.fab:active { transform: scale(0.94); }

/* ── Modal / Drawer ── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 200; display: flex; flex-direction: column;
  justify-content: flex-end;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.drawer {
  background: var(--surface);
  border-radius: var(--r) var(--r) 0 0;
  border-top: 1px solid var(--border2);
  max-height: 92vh; overflow-y: auto;
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  padding-bottom: env(safe-area-inset-bottom);
}
.overlay.open .drawer { transform: translateY(0); }
.drawer-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border2); margin: 12px auto 4px;
}
.drawer-header {
  padding: 8px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px; font-weight: 300;
}
.drawer-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* ── Form ── */
.form-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.field input, .field select, .field textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r2); padding: 10px 12px;
  color: var(--text); font-family: 'Outfit', sans-serif;
  font-size: 14px; outline: none; width: 100%;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
}
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a5a55' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.field textarea { resize: none; height: 80px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stars { display: flex; gap: 6px; margin-top: 2px; }
.star { font-size: 22px; color: var(--border2); cursor: pointer; transition: color 0.1s; }
.star.lit { color: var(--gold); }

.color-type { display: flex; gap: 8px; flex-wrap: wrap; }
.type-btn {
  padding: 7px 14px 7px 10px; border-radius: 20px;
  border: 1px solid var(--border); background: none;
  font-family: 'Outfit', sans-serif; font-size: 12px;
  cursor: pointer; color: var(--text2); transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 8px;
  line-height: 1;
}
.type-btn.active { border-color: var(--accent); color: var(--text); background: rgba(201,83,58,0.1); }

.color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.15);
}
.color-dot.rouge     { background: #7a1f2b; }
.color-dot.blanc     { background: #e8d68a; }
.color-dot.rose      { background: #f0a8b0; }
.color-dot.champagne { background: #f5e3a0; }
.color-dot.autre     { background: transparent; border-color: var(--text3); }

.btn-primary {
  width: 100%; padding: 14px;
  background: var(--accent); border: none;
  border-radius: var(--r2); color: white;
  font-family: 'Outfit', sans-serif; font-size: 15px;
  font-weight: 500; cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:active { background: #b04430; }
.btn-danger {
  width: 100%; padding: 12px;
  background: rgba(200,60,40,0.1); border: 1px solid rgba(200,60,40,0.25);
  border-radius: var(--r2); color: #f08070;
  font-family: 'Outfit', sans-serif; font-size: 14px;
  cursor: pointer; margin-top: 8px;
}

/* ── Detail view ── */
.detail-hero {
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 100%);
  padding: 24px 20px 20px; border-bottom: 1px solid var(--border);
}
.detail-type-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.detail-type-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.detail-type-dot.rouge { background: var(--red-wine); }
.detail-type-dot.blanc { background: var(--white-wine); }
.detail-type-dot.rose { background: var(--rose-wine); }
.detail-type-dot.champagne { background: var(--champagne); }
.detail-type-dot.autre { background: var(--text3); }
.detail-type-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; }
.detail-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px; font-weight: 300; line-height: 1.2;
}
.detail-domaine { font-size: 14px; color: var(--text2); margin-top: 3px; }
.detail-badges { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
  border-bottom: 1px solid var(--border);
}
.detail-cell {
  background: var(--surface); padding: 14px 16px;
}
.detail-cell-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.detail-cell-value { font-size: 16px; color: var(--text); margin-top: 3px; font-weight: 400; }

.apogee-bar-wrap { padding: 16px 20px; }
.apogee-bar-label {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text3); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.apogee-bar-track {
  height: 6px; background: var(--surface2);
  border-radius: 3px; position: relative; overflow: visible;
}
.apogee-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  position: relative;
}
.apogee-bar-now {
  position: absolute; top: -4px; width: 14px; height: 14px;
  border-radius: 50%; background: white;
  border: 2px solid var(--accent2);
  transform: translateX(-50%);
  box-shadow: 0 0 0 3px rgba(232,168,124,0.2);
}
.apogee-years { font-size: 13px; color: var(--text2); text-align: center; margin-top: 10px; }

.notes-section { padding: 16px 20px; }
.notes-title { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.notes-text { font-size: 14px; color: var(--text2); line-height: 1.6; font-style: italic; }
.notes-stars { display: flex; gap: 4px; margin-bottom: 8px; }
.notes-star { font-size: 16px; }

/* ── Stats page ── */
.donut-wrap { display: flex; align-items: center; gap: 20px; padding: 16px 20px; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-label { color: var(--text2); flex: 1; }
.legend-value { color: var(--text); font-weight: 500; }

.progress-list { padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }
.progress-item {}
.progress-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.progress-label { color: var(--text2); }
.progress-val { color: var(--text); font-weight: 500; }
.progress-track { height: 4px; background: var(--surface2); border-radius: 2px; }
.progress-fill { height: 100%; border-radius: 2px; }

/* ── Notif page ── */
.notif-toggle-wrap { padding: 16px 20px; display: flex; align-items: center; gap: 14px; }
.notif-toggle-info { flex: 1; }
.notif-toggle-title { font-size: 15px; color: var(--text); }
.notif-toggle-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.toggle {
  width: 48px; height: 27px; border-radius: 14px;
  background: var(--surface3); border: 1px solid var(--border2);
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background 0.2s;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle-thumb {
  width: 21px; height: 21px; border-radius: 50%;
  background: white; position: absolute; top: 3px; left: 3px;
  transition: left 0.2s;
}
.toggle.on .toggle-thumb { left: 24px; }

.notif-list { padding: 0 20px; display: flex; flex-direction: column; gap: 10px; }
.notif-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px; display: flex; gap: 12px; align-items: flex-start;
}
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.notif-dot.pret { background: #7ecf8e; }
.notif-dot.bientot { background: var(--gold); }
.notif-dot.depasse { background: #f08070; }
.notif-wine { font-size: 14px; color: var(--text); font-weight: 400; }
.notif-msg { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ── Empty state ── */
.empty { text-align: center; padding: 60px 30px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 300; color: var(--text2); }
.empty-sub { font-size: 13px; color: var(--text3); margin-top: 6px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface2); border: 1px solid var(--border2);
  padding: 10px 18px; border-radius: 20px;
  font-size: 13px; color: var(--text);
  z-index: 500; opacity: 0; transition: all 0.3s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Scrollable content sections ── */
.content-section { margin-bottom: 16px; }
.section-head {
  padding: 16px 20px 8px;
  font-size: 11px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* ── Scanner étiquette ── */
.scan-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, rgba(201,83,58,0.12), rgba(201,168,76,0.08));
  border: 1.5px dashed rgba(201,168,76,0.4);
  border-radius: var(--r2); color: var(--accent2);
  font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 10px; transition: all 0.2s; letter-spacing: 0.02em;
}
.scan-btn:active { background: rgba(201,168,76,0.15); }
.scan-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

#scanInput { display: none; }

.scan-preview {
  width: 100%; border-radius: var(--r2); overflow: hidden;
  position: relative; background: #000;
  border: 1px solid var(--border);
}
.scan-preview img { width: 100%; display: block; max-height: 220px; object-fit: cover; }
.scan-preview-badge {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.7); border-radius: 20px;
  padding: 4px 10px; font-size: 11px; color: var(--accent2);
}

.scan-loading {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 20px; background: var(--surface2);
  border-radius: var(--r2); border: 1px solid var(--border);
  text-align: center;
}
.scan-spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border2);
  border-top-color: var(--accent2);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scan-loading-text { font-size: 13px; color: var(--text3); }
.scan-loading-sub  { font-size: 11px; color: var(--text3); opacity: 0.6; margin-top: -4px; }

.scan-result-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: rgba(100,200,120,0.08);
  border: 1px solid rgba(100,200,120,0.2); border-radius: var(--r2);
  font-size: 13px; color: #7ecf8e;
}
.scan-result-bar svg { width: 16px; height: 16px; flex-shrink: 0; stroke: #7ecf8e; }

.scan-error-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: rgba(240,128,112,0.08);
  border: 1px solid rgba(240,128,112,0.2); border-radius: var(--r2);
  font-size: 13px; color: #f08070;
}

#cave3d {
  display: block; width: 100%;
  touch-action: none;
  cursor: grab;
}
#cave3d:active { cursor: grabbing; }

.cave-legend {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px 0;
}
.legend-chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text3);
}
.legend-circle {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}

/* Tooltip */
.cell-tooltip {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  padding: 10px 14px;
  font-size: 13px; color: var(--text);
  z-index: 300; pointer-events: none;
  max-width: 220px; min-width: 150px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
}
.cell-tooltip.visible { display: block; }
.tooltip-name { font-family: 'Cormorant Garamond', serif; font-size: 17px; font-weight: 400; margin-bottom: 2px; }
.tooltip-meta { font-size: 11px; color: var(--text3); }
.tooltip-badge { display: inline-block; margin-top: 5px; }

/* Plan settings */
.plan-settings {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.plan-settings .field { flex: 1; min-width: 80px; }
.plan-settings label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.07em; display: block; margin-bottom: 4px; }
.plan-settings input[type=number] {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 8px 10px;
  color: var(--text); font-family: 'Outfit', sans-serif;
  font-size: 14px; width: 100%; outline: none; -webkit-appearance: none;
}
.btn-small {
  padding: 8px 16px; border-radius: var(--r2);
  border: 1px solid var(--border); background: none;
  color: var(--text2); font-family: 'Outfit', sans-serif;
  font-size: 13px; cursor: pointer; white-space: nowrap; align-self: flex-end;
}
.btn-small:active { background: var(--surface2); }

/* Assign drawer */
.slot-list { padding: 0 20px; display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.slot-wine-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r2);
  border: 1px solid var(--border); background: var(--surface2);
  cursor: pointer; transition: border-color 0.15s;
}
.slot-wine-item:active { border-color: var(--accent); }
.slot-clear {
  margin: 0 20px 16px; padding: 10px;
  border-radius: var(--r2); border: 1px solid rgba(200,60,40,0.2);
  background: rgba(200,60,40,0.08); color: #f08070;
  font-size: 13px; cursor: pointer; text-align: center;
  font-family: 'Outfit', sans-serif;
}
/* ── Authentification ── */
#authScreen {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.auth-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 42px; font-weight: 300;
  letter-spacing: 0.06em; color: var(--text);
  margin-bottom: 4px;
}
.auth-tagline {
  font-size: 13px; color: var(--text3);
  margin-bottom: 36px; text-align: center;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 24px 24px 20px;
  width: 100%; max-width: 360px;
}
.auth-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; gap: 0;
}
.auth-tab {
  flex: 1; padding: 10px; border: none; background: none;
  font-family: 'Outfit', sans-serif; font-size: 14px;
  color: var(--text3); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.15s;
}
.auth-tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 5px; }
.auth-field input {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r2);
  padding: 11px 14px; color: var(--text);
  font-family: 'Outfit', sans-serif; font-size: 15px;
  outline: none; transition: border-color 0.2s;
  -webkit-appearance: none;
}
.auth-field input:focus { border-color: var(--accent); }
.auth-submit {
  width: 100%; padding: 14px;
  background: var(--accent); border: none;
  border-radius: var(--r2); color: white;
  font-family: 'Outfit', sans-serif; font-size: 15px;
  font-weight: 500; cursor: pointer; margin-top: 4px;
  transition: background 0.2s;
}
.auth-submit:active { background: #b04430; }
.auth-error {
  background: rgba(200,60,40,0.1); border: 1px solid rgba(200,60,40,0.25);
  border-radius: var(--r2); padding: 10px 12px;
  font-size: 13px; color: #f08070; margin-bottom: 14px;
  display: none;
}
.auth-error.show { display: block; }

/* Menu compte (header) */
.account-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 0;
}
.account-btn {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px 5px 7px;
  background: var(--surface2); cursor: pointer; color: var(--text2);
  font-family: 'Outfit', sans-serif; font-size: 12px;
}
.account-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: white; font-weight: 600;
}

/* Drawer compte */
.account-info { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.account-name { font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 300; }
.account-email { font-size: 12px; color: var(--text3); margin-top: 2px; }
.cave-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.cave-list-item:active { background: var(--surface2); }
.cave-list-item.active-cave { background: rgba(201,83,58,0.08); }
.cave-check { color: var(--accent2); font-size: 16px; }