/* Vinothèque — charte « Chai » (pierre, bordeaux, touche dorée), polices Libre Baskerville et Work Sans.
   Mise en page : barre latérale sur ordinateur, onglets en bas sur téléphone ; fiches en panneau. */

@font-face { font-family: "Libre Baskerville"; src: url("polices/libre-baskerville.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Work Sans"; src: url("polices/work-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #f4f3f0; --surface: #ffffff; --sunk: #ebe8e3; --line: #ddd8d0;
  --fg: #231d1a; --muted: #6f665f;
  --accent: #6b1d2e; --accent-soft: #f1e4e6; --on-accent: #ffffff; --second: #9a7631;
  --jeune: #3f6487; --jeune-bg: #e3eaf2; --pret: #2c7347; --pret-bg: #e0efe5;
  --dern: #8f5b00; --dern-bg: #f6ead0; --audela: #a8302a; --audela-bg: #f6e0de;
  --rouge: #6b1d2e; --blanc: #d2b54c; --rose: #e48ea4; --eff: #c9b98a;
  --verre-rouge: #2e1a1f; --verre-blanc: #b7b07a; --verre-rose: #d99aa8; --verre-eff: #2f3a26; --etiquette: #f7f3ea;
  --scrim: rgba(25, 18, 16, .45);
  --display: "Libre Baskerville", Georgia, serif;
  --body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
  color-scheme: light;
}
:root.sombre {
  --bg: #1b1918; --surface: #242120; --sunk: #2e2a28; --line: #3d3835;
  --fg: #eee8e3; --muted: #a89f98;
  --accent: #d4a85a; --accent-soft: #3a3022; --on-accent: #1b1918; --second: #c98a95;
  --jeune: #8fb3d9; --jeune-bg: #1f2b38; --pret: #7fcf9b; --pret-bg: #1c3125;
  --dern: #efbd5e; --dern-bg: #3a2e14; --audela: #ef8a80; --audela-bg: #3d1f1d;
  --rouge: #b8485f; --blanc: #e0c45e; --etiquette: #e9e3d8;
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; line-height: 1.2; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
.num { font-variant-numeric: tabular-nums; }
.ic { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* Cadre */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; max-width: 1420px; margin: 0 auto; }
nav.side { background: var(--sunk); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
.brand { font-family: var(--display); font-size: 1.35rem; padding: 0 8px 14px; display: flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; }
.brand .ic { width: 24px; height: 24px; color: var(--accent); }
nav.side a { display: flex; gap: 10px; align-items: center; text-decoration: none; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav.side a:hover { background: var(--surface); color: var(--fg); }
nav.side a[aria-current="page"] { background: var(--surface); color: var(--fg); box-shadow: inset 3px 0 0 var(--accent); }
nav.side a.cta { margin-top: 12px; background: var(--accent); color: var(--on-accent); justify-content: center; }
nav.side .who { margin-top: auto; font-size: .8rem; color: var(--muted); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
nav.tabs { display: none; }
@media (min-width: 1421px) { nav.side { border-left: 1px solid var(--line); } }
main { min-width: 0; display: flex; flex-direction: column; outline: none; }
.view { padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 22px; max-width: 1200px; width: 100%; }
.chargement { padding: 40px; color: var(--muted); }
.head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; justify-content: space-between; }
.sub { color: var(--muted); margin: 4px 0 0; }

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  nav.side { display: none; }
  nav.tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 5; padding-bottom: env(safe-area-inset-bottom, 0px); }
  nav.tabs a { padding: 8px 2px 10px; font-size: .7rem; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); text-decoration: none; }
  nav.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
  nav.tabs a.plus { color: var(--accent); }
  .view { padding: 18px max(14px, env(safe-area-inset-left, 0px)) 28px max(14px, env(safe-area-inset-right, 0px)); gap: 18px; }
  h1 { font-size: 1.45rem; }
}

/* Composants */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; color: var(--fg); justify-content: center; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--audela); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.ghost { border-color: transparent; background: none; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.s-jeune { color: var(--jeune); background: var(--jeune-bg); }
.s-pret { color: var(--pret); background: var(--pret-bg); }
.s-dern { color: var(--dern); background: var(--dern-bg); }
.s-audela { color: var(--audela); background: var(--audela-bg); }
.s-inconnu { color: var(--muted); background: var(--sunk); }
.s-reserve { color: var(--accent); background: var(--accent-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; border: 1px solid rgba(0, 0, 0, .12); vertical-align: -1px; }
.c-rouge { background: var(--rouge); } .c-blanc { background: var(--blanc); } .c-rose { background: var(--rose); } .c-eff { background: var(--eff); }
.loc { font-variant-numeric: tabular-nums; font-weight: 600; font-size: .82rem; background: var(--sunk); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.muted { color: var(--muted); }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.note { font-size: .82rem; color: var(--muted); border-left: 3px solid var(--line); padding: 4px 10px; margin: 0; }
.vide { color: var(--muted); padding: 16px 0; margin: 0; }
.erreur { color: var(--audela); background: var(--audela-bg); border-radius: 8px; padding: 8px 12px; margin: 0; }

/* Tableau de bord */
.hero { position: relative; border-radius: 14px; overflow: hidden; min-height: 160px; display: flex; align-items: flex-end; background: var(--sunk); }
.hero > svg, .hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0) 65%); }
.hero .cap { position: relative; z-index: 1; padding: 16px 20px; color: #fff; display: flex; flex-direction: column; gap: 2px; }
.hero .cap h1 { color: #fff; }
.states { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.state { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; cursor: pointer; text-align: left; background: var(--surface); display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--fg); }
.state:hover { border-color: var(--muted); }
.state .big { font-family: var(--display); font-size: 1.9rem; line-height: 1; }
.state small { color: var(--muted); }
.cols2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.alerts { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); background: var(--sunk); }
.alert .bar { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
.alert p { margin: 0; flex: 1; min-width: 0; }
.alert .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 0 4px; line-height: 1; }
@media (max-width: 900px) { .cols2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .states { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Listes et filtres */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search { flex: 1 1 220px; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--surface); }
select.f { border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: var(--surface); max-width: 100%; min-width: 0; flex: 0 1 auto; }
select.f.actif { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: .82rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip:disabled { opacity: .4; cursor: default; }
.chip .n { opacity: .7; font-variant-numeric: tabular-nums; margin-left: 3px; }
.wines { display: flex; flex-direction: column; border-top: 1px solid var(--line); container-type: inline-size; }
.wine { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto auto 34px; gap: 14px; align-items: center; padding: 9px 6px; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; color: var(--fg); text-decoration: none; }
.wine:hover { background: var(--sunk); }
.wine.bu { opacity: .6; }
.wine .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wine .a { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wine .q { font-family: var(--display); font-size: 1.15rem; text-align: right; font-variant-numeric: tabular-nums; }
.wine .w-years { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wine .w-loc { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@container (max-width: 640px) {
  .wine { grid-template-columns: 40px minmax(0, 1fr) auto; row-gap: 4px; column-gap: 12px; }
  .wine .t, .wine .a { white-space: normal; }
  .wine > :first-child { grid-row: 1 / span 3; align-self: start; }
  .wine > .w-txt { grid-row: 1 / span 2; }
  .wine .w-state { grid-column: 2; grid-row: 3; }
  .wine .w-years { display: none; }
  .wine .q { grid-column: 3; grid-row: 1; }
  .wine .w-loc { grid-column: 3; grid-row: 2 / span 2; align-self: start; }
}
.count { font-size: .85rem; color: var(--muted); }
@media (max-width: 560px) {
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .search { grid-column: 1 / -1; }
  select.f { width: 100%; }
}

/* Vignettes et photos */
.thumb { width: 40px; height: 52px; border-radius: 5px; overflow: hidden; background: var(--sunk); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg, .photo svg { width: 100%; height: 100%; }
.photo { width: 96px; height: 128px; border-radius: 8px; flex: none; overflow: hidden; background: var(--sunk); display: grid; place-items: center; }
.photo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.band { height: 96px; border-radius: 10px; overflow: hidden; position: relative; flex: none; background: var(--sunk); }
.band > svg, .band > img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* Panneaux (fiche, dialogues) */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; display: flex; justify-content: flex-end; }
.sheet { background: var(--surface); width: min(580px, 100%); height: 100%; overflow: auto; padding: 22px 24px 32px; display: flex; flex-direction: column; gap: 16px; border-left: 1px solid var(--line); overscroll-behavior: contain; }
@media (max-width: 760px) {
  .scrim { align-items: flex-end; }
  .sheet { height: 94%; border-radius: 18px 18px 0 0; padding: 18px max(16px, env(safe-area-inset-left, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-right, 0px)); border-left: 0; }
}
@media (prefers-reduced-motion: no-preference) { .sheet { animation: entree .18s ease-out; } @keyframes entree { from { transform: translateX(24px); opacity: .6; } } }
.sheet header { display: flex; gap: 14px; align-items: flex-start; }
.sheet header .close { margin-left: auto; }
.sheet header .titre { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kv div { background: var(--sunk); border-radius: 8px; padding: 8px 10px; }
.kv b { display: block; font-family: var(--display); font-weight: 400; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.box { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links a { font-size: .85rem; color: var(--accent); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; }
.links a:hover { border-color: var(--accent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1 1 200px; min-width: 0; }
input.t, textarea.t, select.t { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); width: 100%; min-width: 0; }
input.t:disabled { opacity: .6; }
.cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.cand { aspect-ratio: 3 / 4; border-radius: 6px; border: 2px solid var(--line); cursor: pointer; padding: 0; overflow: hidden; background: #fff; max-width: 100%; }
.cand img { width: 100%; height: 100%; object-fit: contain; }
.cand[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 10px; font-size: .88rem; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
.verdicts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.verdict { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; font-size: .88rem; }
.verdict[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.verdict span { font-size: 1.3rem; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form label, .champ { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); font-weight: 500; min-width: 0; }
.form .full { grid-column: 1 / -1; }
.form .trois { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; grid-column: 1 / -1; }
@media (max-width: 560px) { .form { grid-template-columns: minmax(0, 1fr); } .kv { gap: 6px; } }
.suggest { background: var(--accent-soft); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.suggest strong { font-family: var(--display); font-weight: 400; font-size: 1.2rem; }
.suggest .row .btn { background: var(--surface); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--fg); color: var(--surface); padding: 9px 16px; border-radius: 8px; z-index: 40; font-size: .9rem; max-width: 90%; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
@media (max-width: 760px) { .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); } }
.confirm { display: flex; flex-direction: column; gap: 8px; background: var(--audela-bg); border-radius: var(--r); padding: 12px; }

/* Plan de cave */
.planwrap { overflow-x: auto; padding-bottom: 4px; }
.plan { display: flex; gap: 6px; align-items: flex-end; min-width: min-content; }
.pcol { display: flex; flex-direction: column-reverse; gap: 4px; width: 62px; }
.pcol.reserve { width: 44px; }
.pcol .name { font-weight: 700; text-align: center; font-size: .85rem; padding-top: 4px; }
.pcol.reserve .name { color: var(--dern); }
.shelf { height: 40px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-variant-numeric: tabular-nums; position: relative; overflow: hidden; padding: 0; }
.shelf .fill { position: absolute; left: 0; bottom: 0; right: 0; background: var(--accent-soft); }
.shelf span { position: relative; }
.shelf.sel { outline: 2px solid var(--accent); }
.shelf.plein .fill { background: var(--dern-bg); }
.pcol.reserve .shelf { border-style: dashed; }
.zbar { height: 4px; border-radius: 2px; margin-bottom: 2px; }
.zones { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.zones i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.z-quotidien { background: var(--jeune); } .z-apero { background: var(--rose); } .z-pret { background: var(--pret); }
.z-garde_aude { background: var(--dern); } .z-exceptions { background: var(--accent); } .z-reserve { background: var(--line); }
.plan-edit { display: flex; flex-direction: column; gap: 6px; }
.plan-edit .ligne { display: grid; grid-template-columns: 70px 80px minmax(0, 1fr) minmax(0, 2fr) auto; gap: 6px; align-items: center; }
@media (max-width: 640px) { .plan-edit .ligne { grid-template-columns: 60px 60px minmax(0, 1fr) auto; } .plan-edit .ligne .det { display: none; } }

/* Années à venir */
.years { display: flex; flex-direction: column; gap: 6px; }
.yr { display: grid; grid-template-columns: 48px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.yr .track { height: 22px; background: var(--sunk); border-radius: 4px; position: relative; overflow: hidden; }
.yr .seg2 { position: absolute; top: 0; bottom: 0; }
.yr .goal { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--fg); opacity: .55; }
.yr.low .y { color: var(--audela); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }

/* Souhaits, dégustations */
.wish { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.wish.fini { opacity: .55; }
.wish .meta { font-size: .84rem; color: var(--muted); }
.prio { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.deg { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.deg .memo { font-style: italic; }

/* Plus, connexion */
.menu { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.menu .btn { justify-content: flex-start; }
.connexion { max-width: 380px; margin: 10vh auto; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 14px; }
.amb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.amb { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.amb .band { border-radius: 0; height: 110px; }
.amb .pied { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.lecture-seule .ecriture { display: none !important; }
