:root {
  --bg: #FBFAF4;
  --surface: #FFFFFF;
  --ink: #20302A;
  --muted: #6E7C72;
  --line: #E7E3D6;
  --primary: #2F6B4F;
  --primary-ink: #1E4734;
  --primary-soft: #E6F0E7;
  --accent: #E08A1E;
  --tomato: #C9402A;
  --owned-bg: #EFF4ED;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(32, 48, 42, .05), 0 6px 20px rgba(32, 48, 42, .06);
}

* { box-sizing: border-box; }

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

h1, h2, h3 {
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- LOGIN ---------- */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 30px;
  width: 100%;
  max-width: 360px;
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-mark { font-size: 34px; }
.brand h1 { font-size: 30px; margin-top: 6px; }
.brand-sub { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form label { font-weight: 600; font-size: 14px; }
input[type="password"] {
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
input[type="password"]:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.form-error { color: var(--tomato); font-size: 14px; margin: 4px 0 0; }

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(251, 250, 244, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
}
.logo { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 19px; }
.logo-mark { margin-right: 4px; }
.logout { color: var(--muted); text-decoration: none; font-size: 14px; }
.logout:hover { color: var(--ink); }

/* ---------- LAYOUT ---------- */
.app { max-width: 760px; margin: 0 auto; padding: 22px 18px 110px; }
.view-head { margin-bottom: 16px; }
.view-head h2 { font-size: 26px; }
.view-sub { color: var(--muted); margin: 4px 0 0; }

/* ---------- BUTTONS ---------- */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  padding: 12px 16px; border-radius: 11px; font-weight: 600;
}
.btn-primary:hover { background: var(--primary-ink); }
.btn-ghost {
  background: transparent; color: var(--primary-ink);
  border: 1px solid var(--line); padding: 9px 14px; border-radius: 10px; font-weight: 500;
}
.btn-ghost:hover { background: var(--primary-soft); }

/* ---------- FILTERS ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  padding: 7px 13px; border-radius: 999px; font-size: 14px; color: var(--muted);
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- RECIPE PICK CARDS ---------- */
.card-grid { display: grid; gap: 12px; }
.pick-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, transform .05s;
}
.pick-card:active { transform: scale(.997); }
.pick-card.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }
.pick-card h3 { font-size: 18px; padding-right: 34px; }
.pick-check {
  position: absolute; top: 14px; right: 14px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center;
  color: #fff; font-size: 14px;
}
.pick-card.selected .pick-check { background: var(--primary); border-color: var(--primary); }
.meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 8px; }
.macros { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.macro {
  font-variant-numeric: tabular-nums; font-size: 13px;
  background: var(--primary-soft); color: var(--primary-ink);
  padding: 3px 9px; border-radius: 8px; font-weight: 500;
}
.tags { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px; }

/* ---------- SHOPPING LIST (signature) ---------- */
.courses-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.rayon-block {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 16px 10px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.rayon-title {
  display: flex; align-items: center; gap: 8px;
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--primary-ink); padding: 12px 0 6px;
}
.rayon-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px dashed var(--line); cursor: pointer;
}
.shop-box {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--line); display: grid; place-items: center;
  color: #fff; font-size: 13px; transition: background .12s;
}
.shop-item.owned .shop-box { background: var(--primary); border-color: var(--primary); }
.shop-name { flex: 1; }
.shop-item.owned .shop-name { text-decoration: line-through; color: var(--muted); }
.shop-qty { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.shop-supplier { font-size: 11px; color: var(--accent); font-weight: 600; margin-left: 6px; }

.basics-toggle {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--muted); padding: 8px 2px; font-size: 14px;
}
.empty {
  text-align: center; color: var(--muted); padding: 40px 20px;
  border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ---------- RECIPE LIST ---------- */
.recipe-rows { margin-top: 16px; display: grid; gap: 10px; }
.recipe-row {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.recipe-row h3 { font-size: 16px; }
.recipe-row .meta { margin-top: 4px; }
.row-actions { display: flex; gap: 8px; flex: none; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; color: var(--muted); }
.icon-btn:hover { color: var(--ink); }
.icon-btn.danger:hover { color: var(--tomato); border-color: var(--tomato); }

/* ---------- TABBAR ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}
.tab {
  flex: 1; border: none; background: none; color: var(--muted);
  font-size: 12px; font-weight: 500; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; border-radius: 10px;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--primary); background: var(--primary-soft); }

/* ---------- MODALS ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(32, 48, 42, .4);
  display: grid; place-items: end center;
  padding: 0;
}
.modal-card {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 600px) {
  .modal { place-items: center; padding: 24px; }
  .modal-card { border-radius: 18px; }
}
.modal-card h3 { font-size: 21px; }
.modal-hint { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
#import-json {
  width: 100%; min-height: 220px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  resize: vertical; background: #fcfcfa;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.detail-section { margin-top: 18px; }
.detail-section h4 {
  font-family: "Bricolage Grotesque", sans-serif; font-size: 13px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--primary-ink); margin: 0 0 8px;
}
.detail-ing { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.detail-ing .q { color: var(--muted); font-variant-numeric: tabular-nums; }
.detail-steps { padding-left: 20px; margin: 0; }
.detail-steps li { margin-bottom: 8px; }

/* ---------- PWA / FINITIONS MOBILE ---------- */
html { -webkit-text-size-adjust: 100%; }
button, .chip, .tab, a { -webkit-tap-highlight-color: transparent; }
/* zones de saisie à 16px : empêche le zoom auto au focus sur iPhone */
textarea, input { font-size: 16px; }
/* en mode appli plein écran, on respecte l'encoche du haut */
.topbar { padding-top: env(safe-area-inset-top); }

/* ---------- APP SHELL : plein écran + barre du bas réellement ancrée ---------- */
html, body { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;   /* hauteur réelle de l'écran, gère la barre d'URL mobile */
}
/* barre du haut : figée en haut, pleine largeur (contenu déjà centré via .topbar-inner) */
.topbar { position: static; flex: 0 0 auto; align-self: stretch; }
/* contenu : occupe tout l'espace restant et défile à l'intérieur */
.app {
  flex: 1 1 auto;
  min-height: 0;
  align-self: center;     /* colonne de contenu centrée, plafonnée par max-width: 760px */
  width: 100%;
  margin: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 18px 24px;  /* plus besoin des 110px : la barre n'est plus par-dessus */
}
/* barre du bas : dans le flux, ancrée en bas, bord à bord comme une appli native */
.tabbar {
  position: static;
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  max-width: none;
  margin: 0;
}
