:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #edf3f2;
  --border: #dde7e5;
  --text: #17302d;
  --muted: #6a7d7a;
  --accent: #0f766e;       /* bleu canard */
  --accent-ink: #0b5f58;
  --accent-soft: #dff1ee;
  --coral: #f97362;        /* pop colour: hearts, highlights */
  --coral-soft: #feeae7;
  --green: #0f766e;
  --green-soft: #dff1ee;
  --red: #d2453a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 50, 46, 0.06), 0 4px 14px rgba(20, 50, 46, 0.06);
  --shadow-lg: 0 12px 40px rgba(20, 50, 46, 0.18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button, a, .chip, .card, .item .thumb { touch-action: manipulation; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand { font-family: "Outfit", system-ui, sans-serif; font-weight: 600; letter-spacing: -0.02em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px: pas de zoom automatique sur iOS */ color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.hidden { display: none !important; }
.fi { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.08); flex-shrink: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 999px;
  padding: 9px 16px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 550;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { border-color: #b9cbc8; background: #fbfdfc; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--red); }
.btn.on { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.icon { padding: 0; width: 34px; height: 34px; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { font-size: 22px; color: var(--accent); text-decoration: none !important; cursor: pointer; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; overflow: hidden; }
.brand .logo svg { width: 34px; height: 34px; }
nav.tabs { display: flex; gap: 2px; margin-left: auto; }
nav.tabs button { background: transparent; border: none; color: var(--muted); padding: 8px 14px; border-radius: 999px; font-weight: 600; }
nav.tabs button svg { width: 22px; height: 22px; display: none; }
nav.tabs button.scan { display: none; }
nav.tabs button.active { color: var(--accent-ink); background: var(--accent-soft); }
nav.tabs button:hover { color: var(--text); }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 14px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-edit { display: flex; gap: 14px; align-items: center; }
.avatar-edit .btn { margin: 0 6px 6px 0; cursor: pointer; }
.avatar-edit .hint { margin: 4px 0 0; font-size: 13px; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 96px; }
.view-title { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.view-title h2 { margin: 0; font-size: 28px; }
.view-title .sub { color: var(--muted); font-size: 13px; }

/* auth */
.auth-wrap { min-height: 75vh; display: grid; place-items: center; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .logo { width: 72px; height: 72px; border-radius: 18px; overflow: hidden; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }
.auth-card .logo svg { width: 72px; height: 72px; }
.auth-card h1 { margin: 0 0 4px; font-size: 34px; color: var(--accent); }
.auth-card p.lead { margin: 0 0 20px; color: var(--muted); }
.auth-switch { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.auth-switch a { cursor: pointer; font-weight: 600; }

/* search + filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { flex: 2 1 260px; position: relative; }
.toolbar .search input { padding-left: 40px; border-radius: 999px; background: var(--surface); }
.toolbar .search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.toolbar select { flex: 0 1 170px; width: auto; border-radius: 999px; }
.countries { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin-bottom: 6px; scrollbar-width: none; }
.countries::-webkit-scrollbar { display: none; }
.countries .chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 6px 12px; font-size: 13px; }

/* catalogue cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: relative;
  display: flex; flex-direction: column; cursor: pointer; transition: box-shadow .15s ease, transform .15s ease;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card .thumb { height: 150px; background: #fff; display: grid; place-items: center; position: relative; padding: 12px 12px 0; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.card .thumb .ph { width: 40px; height: 40px; }
.card .owned { position: absolute; top: 8px; left: 8px; }
.card .wish {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; border: none; display: grid; place-items: center;
  background: rgba(255,255,255,0.9); color: #a9bbb8;
}
.card .wish svg { width: 18px; height: 18px; }
.card .wish.on { color: var(--coral); }
.card .wish.on svg path { fill: currentColor; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card .name { font-weight: 650; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; min-width: 0; }
.card .meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .price { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 8px; }
.price .amount { font-weight: 750; font-size: 16px; }
.price .tag { font-size: 11px; color: var(--muted); display: block; font-weight: 400; }
.card .add {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--accent-ink);
  display: grid; place-items: center; flex-shrink: 0;
}
.card .add:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.card .add.on { background: var(--accent); color: #fff; border-color: transparent; }
.card .add svg { width: 16px; height: 16px; }
.badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap;
}
.badge.green { background: var(--accent); color: #fff; }
.badge.red { background: var(--coral-soft); color: var(--red); }
.badge.edition { background: var(--coral-soft); color: #b8432f; }
.card .badge.edition { position: absolute; bottom: 8px; left: 8px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; }
.badge.kind { background: var(--surface-2); color: var(--muted); font-weight: 500; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -0.02em; }
.stat .value.amber { color: var(--accent-ink); }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.hero { background: var(--accent); border-color: var(--accent); color: #fff; }
.stat.hero .label, .stat.hero .hint, .stat.hero .value.amber { color: #fff; }
.breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 18px; }
.breakdown .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.panel h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.bar { display: grid; grid-template-columns: 120px 1fr 28px; align-items: center; gap: 8px; font-size: 13px; margin: 7px 0; }
.bar > span:first-child { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.bar .track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar .n { text-align: right; color: var(--muted); }

/* list rows (collection / wishlist) */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px;
}
.item .thumb { width: 52px; height: 68px; border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; cursor: pointer; }
.item .thumb img { width: 100%; height: 100%; object-fit: contain; }
.item .thumb .ph { width: 28px; height: 28px; }
.item .title { font-weight: 650; }
.item .meta { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.item .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); cursor: pointer; font-weight: 500; }
.chip:hover { border-color: #b9cbc8; }
.chip.on { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.chip.static { cursor: default; background: var(--surface-2); border-color: transparent; }
.item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.amount-strong { font-weight: 750; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.qty button { background: var(--surface); border: none; color: var(--text); width: 30px; height: 30px; }
.qty button:hover { background: var(--surface-2); }
.qty span { min-width: 24px; text-align: center; font-weight: 650; }
.stars { display: inline-flex; gap: 1px; }
.stars button { background: none; border: none; color: #d5dfdd; font-size: 16px; padding: 0 1px; }
.stars button.on { color: var(--coral); }
.rate-input button { font-size: 26px; padding: 0 2px; line-height: 1; }
.rate-label { margin-left: 8px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .big { font-size: 36px; margin-bottom: 6px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 40, 37, 0.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { width: min(640px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 21px; line-height: 1.25; }
.modal-head .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.modal-head .close { background: var(--surface-2); border: none; color: var(--muted); font-size: 20px; line-height: 1; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.detail { display: grid; grid-template-columns: 120px 1fr; gap: 18px; }
.detail .pic { height: 170px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.detail .pic img { width: 100%; height: 100%; object-fit: contain; }
.detail .pic .ph { width: 44px; height: 44px; }
.detail .facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.detail .facts .chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 10px; font-size: 13px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.bigprice { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.bigprice small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.modal .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.addbox { background: var(--bg); border-radius: 16px; padding: 14px; margin: 16px 0 0; }
.addbox h3 { margin: 0 0 10px; font-size: 16px; }
.addbox input, .addbox select { background: var(--surface); }

/* scanner */
.fab {
  position: fixed; right: 20px; bottom: 24px; z-index: 30; width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(15, 118, 110, 0.35); display: grid; place-items: center;
}
.fab svg { width: 26px; height: 26px; }
#reader { width: 100%; border-radius: 14px; overflow: hidden; background: #000; min-height: 240px; }
#reader video { width: 100% !important; }
.scan-hint { color: var(--muted); font-size: 13px; text-align: center; margin: 10px 0; }

/* friends */
.friend-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.friend-row .info { flex: 1; }
.friend-row .meta { color: var(--muted); font-size: 13px; }
.section { margin: 22px 0 8px; font-size: 15px; font-weight: 700; }
.subtabs { display: flex; gap: 6px; margin: 4px 0 12px; }

/* toast */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-lg); font-size: 14px; animation: pop .2s ease; }
.toast.err { background: var(--red); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pager { display: flex; justify-content: center; gap: 10px; margin-top: 18px; align-items: center; color: var(--muted); font-size: 14px; }

/* retailer offers in the detail sheet */
.offers { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.offers h4 { margin: 0 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.offer {
  display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: center; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px;
}
.offer:hover { border-color: var(--accent); text-decoration: none; }
.offer span { font-weight: 600; font-size: 14px; }
.offer b { grid-row: 1 / 3; grid-column: 2; font-size: 16px; }
.offer small { color: var(--muted); font-size: 12px; }
.offer small.in { color: var(--green); }
.offer.off { opacity: 0.55; }

/* profile link in the top bar */
.profile-link { display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--muted); padding: 2px 10px 2px 2px; border-radius: 999px; }
.profile-link:hover, .profile-link.active { background: var(--accent-soft); color: var(--accent-ink); }
.avatar.xl { width: 72px; height: 72px; font-size: 30px; }
textarea { resize: vertical; min-height: 44px; line-height: 1.4; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.hint-inline { text-transform: none; font-weight: 400; color: var(--muted); }

/* member reviews */
.reviews { margin-top: 18px; }
.reviews-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.reviews-head h3 { margin: 0; font-size: 17px; }
.reviews-head .count { font-size: 12px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 1px 8px; vertical-align: middle; font-family: system-ui, sans-serif; }
.review { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.review .who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.review .when { color: var(--muted); font-size: 12px; }
.review p { margin: 3px 0 0; font-size: 14px; white-space: pre-line; }
.stars-ro { color: var(--coral); font-size: 13px; letter-spacing: 1px; }
.stars-ro span { color: #d5dfdd; }
.quote { margin: 6px 0 0; font-size: 13px; color: var(--text); font-style: italic; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* profile page */
.profile-head { display: flex; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.profile-head h2 { margin: 0; font-size: 24px; }
.profile-head .meta { color: var(--muted); font-size: 14px; }
.profile-head p { margin: 6px 0 0; }
.profile-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; color: var(--muted); }
.profile-stats b { color: var(--text); }
.profile-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; align-items: start; }
#profile-form { grid-row: span 2; }
.profile-grid .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.profile-grid .panel h3 { margin: 0 0 12px; font-size: 17px; color: var(--text); }
@media (max-width: 640px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-head { padding: 14px; gap: 14px; }
  .avatar.xl { width: 56px; height: 56px; font-size: 24px; }
  .profile-link { padding: 2px; }
}

/* in-app dialogs (replace confirm/prompt) */
.dialog { text-align: center; }
.dialog p { margin: 6px 0 16px; }
.dialog .actions { justify-content: center; }

@media (max-width: 640px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar-inner { padding: 8px 14px; gap: 8px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .brand { font-size: 21px; }
  .user-chip { margin-left: auto; }
  .user-chip span.name, #logout span.name { display: none; }
  #logout { width: 36px; height: 36px; padding: 0; }
  main { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  .view-title h2 { font-size: 22px; }
  /* bottom tab bar */
  nav.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0; gap: 0; background: #fff; border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around;
  }
  nav.tabs button {
    display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; padding: 6px 2px; font-size: 11px;
    border-radius: 10px; min-height: 52px; justify-content: center;
  }
  nav.tabs button svg { display: block; }
  nav.tabs button.active { background: transparent; color: var(--accent-ink); }
  nav.tabs button.scan { display: flex; }
  nav.tabs button.scan svg {
    width: 48px; height: 48px; padding: 12px; border-radius: 50%; margin-top: -22px; color: #fff;
    background: var(--accent); box-shadow: 0 6px 16px rgba(15, 118, 110, 0.35); border: 4px solid #fff;
  }
  .fab { display: none; }
  /* catalogue */
  .toolbar { gap: 8px; margin-bottom: 8px; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar select { flex: 1 1 40%; padding: 8px 12px; font-size: 14px; }
  .toolbar select { flex: 1 1 0; }
  .toolbar #new-whisky { flex: 0 0 auto; width: 44px; height: 44px; padding: 0; }
  .toolbar #new-whisky span { display: none; }
  .view-title .sub .opt { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card .thumb { height: 120px; padding: 10px 10px 0; }
  .card .body { padding: 8px 10px 10px; }
  .card .name { font-size: 13px; }
  .price .amount { font-size: 15px; }
  /* stats */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 20px; }
  .breakdown { grid-template-columns: 1fr; }
  /* list rows */
  .item { grid-template-columns: 48px 1fr; gap: 10px; padding: 10px 12px; }
  .item .thumb { width: 48px; height: 62px; }
  .item .right { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; }
  .qty button { width: 38px; height: 38px; }
  .btn.icon { width: 38px; height: 38px; }
  .stars button { font-size: 21px; padding: 0 3px; }
  .row { flex-direction: column; gap: 0; }
  /* modals as bottom sheets */
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal {
    width: 100%; max-height: 94vh; max-height: 94dvh; border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
    animation: sheet .2s ease-out;
  }
  .modal::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 12px; }
  .modal-head h2 { font-size: 19px; }
  .detail { grid-template-columns: 84px 1fr; gap: 12px; }
  .detail .pic { height: 120px; }
  .bigprice { font-size: 24px; }
  .modal .actions .btn { flex: 1 1 100%; min-height: 44px; }
  .dialog .actions { flex-direction: row; } .dialog .actions .btn { flex: 1; }
  .friend-row { flex-wrap: wrap; }
  #reader { min-height: 280px; }
}
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- cellar widgets ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.stat .hint.flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; font-size: 14px; }
.shelf-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.shelf-title h3 { margin: 0; font-size: 17px; }
.shelf-title .meta { color: var(--muted); font-size: 13px; }
.shelf-wrap { margin: 4px 0 16px; }
.shelf {
  display: flex; gap: 14px; overflow-x: auto; padding: 14px 16px 0; margin-top: 8px; scrollbar-width: none;
  background: linear-gradient(180deg, var(--surface) 0 78%, var(--surface-2) 78%);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: inset 0 -10px 0 #d3e2df;
}
.shelf::-webkit-scrollbar { display: none; }
.shelf-bottle { flex: 0 0 auto; width: 78px; background: none; border: 0; padding: 0 0 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; font: inherit; color: var(--text); }
.shelf-bottle img, .shelf-bottle .ph { width: 78px; height: 110px; object-fit: contain; transition: transform .15s; filter: drop-shadow(0 6px 6px rgba(20, 50, 46, .18)); }
.shelf-bottle:hover img { transform: translateY(-4px) rotate(-2deg); }
.shelf-bottle span { font-size: 11px; font-weight: 600; line-height: 1.2; text-align: center; max-width: 78px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; position: relative; z-index: 1; }
.widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-bottom: 16px; }
.widgets .bar { grid-template-columns: minmax(0, 130px) 1fr 28px; }
.meta.more { font-size: 12px; margin-top: 4px; }
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.trophy { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 8px 4px; border-radius: 12px; background: var(--surface-2); opacity: .55; filter: grayscale(1); }
.trophy.done { opacity: 1; filter: none; background: var(--coral-soft); }
.trophy .ico { font-size: 22px; line-height: 1.2; }
.trophy b { font-size: 12px; line-height: 1.2; }
.trophy small { font-size: 10.5px; color: var(--muted); line-height: 1.2; }
.cellar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 18px 0 10px; }
.cellar-tools .subtabs { margin: 0; flex-wrap: wrap; }
.search.sm { position: relative; flex: 1 1 200px; max-width: 320px; }
.search.sm input { padding: 8px 12px 8px 36px; border-radius: 999px; font-size: 14px; background: var(--surface); }
.search.sm svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.group { margin-bottom: 12px; }
.group-head { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 8px 2px; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.group-head b { font-family: "Outfit", system-ui, sans-serif; font-size: 17px; font-weight: 600; }
.group-head .meta { color: var(--muted); font-size: 13px; }
.group-head .caret { margin-left: auto; color: var(--muted); transition: transform .15s; }
.group.closed .caret { transform: rotate(-90deg); }
.group.closed .list { display: none; }
.also { font-size: 12px; color: var(--accent-ink); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
.also a { font-weight: 600; cursor: pointer; }
b.common { color: var(--accent-ink); }

/* ---------- friends' activity ---------- */
.feed-mini { margin-bottom: 8px; }
.feed-mini .shelf-title a { font-size: 13px; }
.feed { display: flex; flex-direction: column; }
.feed-item { display: grid; grid-template-columns: 32px 1fr 44px; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.feed-item:first-child { border-top: 0; }
.feed > .feed-item:first-child { padding-top: 4px; }
.feed-body { font-size: 14px; min-width: 0; }
.feed-body a { font-weight: 650; cursor: pointer; }
.feed-body .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; font-size: 12px; color: var(--muted); }
.feed-item .thumb { width: 44px; height: 56px; display: grid; place-items: center; }
.feed-item .thumb img { width: 100%; height: 100%; object-fit: contain; }
.friends-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 0 20px; align-items: start; }
.friend-row[data-fid] { cursor: pointer; }
.friend-head { display: flex; gap: 12px; align-items: center; }
.avatar.lg { width: 48px; height: 48px; font-size: 20px; }
.affinity { display: flex; gap: 14px; align-items: center; background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; margin: 4px 0 8px; }
.affinity .flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.ring { --p: 0; flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--coral) calc(var(--p) * 1%), #fff 0); }
.ring span { width: 46px; height: 46px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
@media (max-width: 860px) { .friends-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .widgets { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat.hero { grid-column: 1 / -1; }
  .stat.hide-m { display: none; }
  .search.sm { max-width: none; flex-basis: 100%; }
  .shelf-bottle { width: 64px; } .shelf-bottle img, .shelf-bottle .ph { width: 64px; height: 92px; }
}

/* ---------- trophies (tiers) ---------- */
.trophies-panel { margin-bottom: 16px; }
.trophies-panel .shelf-title { margin-bottom: 10px; }
.shelf-title h3 .count { font-family: system-ui, sans-serif; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 2px 8px; vertical-align: middle; margin-left: 4px; }
.trophies-panel .shelf-title a { font-size: 13px; }
.trophies { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.trophy { padding: 10px 8px; gap: 3px; opacity: 1; filter: none; background: var(--surface-2); }
.trophy:not(.done) .ico { filter: grayscale(1); opacity: .45; }
.trophy:not(.done) b { color: var(--muted); }
.trophy .tier { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 1px 7px; border-radius: 999px; background: #fff; }
.trophy.t-bronze { background: #f8ece2; } .trophy.t-bronze .tier { color: #a0592a; }
.trophy.t-argent { background: #eef1f3; } .trophy.t-argent .tier { color: #5d6b75; }
.trophy.t-or { background: #fdf3d0; } .trophy.t-or .tier { color: #9a6b00; }
.trophy.t-legende { background: linear-gradient(135deg, #feeae7, #dff1ee); box-shadow: inset 0 0 0 1.5px var(--coral); } .trophy.t-legende .tier { color: var(--coral); }
.trophy.t-reussi { background: var(--coral-soft); } .trophy.t-reussi .tier { color: #b8432f; }
.trophy .prog { width: 80%; height: 5px; border-radius: 3px; background: rgba(23, 48, 45, .1); overflow: hidden; margin-top: 3px; }
.trophy .prog i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.trophy small.desc { font-style: italic; }
.friend-trophies { margin-left: auto; display: flex; align-items: center; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap; }
.friend-trophies b { margin-left: 6px; }
@media (max-width: 640px) {
  .trophies { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .affinity { flex-wrap: wrap; }
  .friend-trophies { margin-left: 0; }
}
.modal-head h2 .count { font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 2px 9px; vertical-align: middle; }
@media (max-width: 640px) { .trophies-panel > .trophies > .trophy:nth-child(7) { display: none; } }

/* ---------- tasting profile ---------- */
.taste-input { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 16px; margin: 2px 0 6px; }
.taste-row { display: grid; grid-template-columns: 58px auto 1fr; align-items: center; gap: 8px; font-size: 14px; }
.taste-row .name { font-weight: 600; }
.taste-row small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.taste-row .dots { display: inline-flex; gap: 4px; }
.taste-row .dots button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); padding: 0; cursor: pointer; transition: transform .1s; }
.taste-row .dots button.on { background: var(--coral); border-color: var(--coral); }
.taste-row .dots button:active { transform: scale(.85); }
.taste-row[data-k="peat"] .dots button.on { background: #57534e; border-color: #57534e; }
.taste-row[data-k="wood"] .dots button.on { background: #a16207; border-color: #a16207; }
.taste-row[data-k="sweet"] .dots button.on { background: #e5a50a; border-color: #e5a50a; }
.taste-row[data-k="spice"] .dots button.on { background: var(--red); border-color: var(--red); }
.taste-row[data-k="finish"] .dots button.on { background: var(--accent); border-color: var(--accent); }
.dialog .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
.taste-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 2px; }
.taste-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); }
.dots-ro { display: inline-flex; gap: 2px; }
.dots-ro i { width: 6px; height: 6px; border-radius: 50%; background: #c9d6d3; }
.dots-ro i.on { background: var(--coral); }
.taste-profile { background: var(--surface-2); border-radius: 12px; padding: 6px 12px; margin-bottom: 6px; }
.taste-profile .bar { grid-template-columns: 70px 1fr 80px; }
.taste-profile .fill { background: var(--coral); }
.taste-profile .n { font-size: 12px; }
/* one colour per axis, everywhere: peat = smoke, wood = oak, sweet = honey, spice = chili, finish = teal, fruit = coral */
[data-k="peat"] { --axis: #57534e; } [data-k="wood"] { --axis: #a16207; } [data-k="sweet"] { --axis: #e5a50a; }
[data-k="spice"] { --axis: var(--red); } [data-k="finish"] { --axis: var(--accent); } [data-k="fruit"] { --axis: var(--coral); }
.taste-chip .dots-ro i.on, .taste-profile .bar .fill { background: var(--axis, var(--coral)); }
