/* ═══════════════════════════════════════════════════════════════════
   MixMyCloud — « console de mixage »
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #070b12;
  --surface:   rgba(10, 15, 24, 0.55);
  --surface-2: rgba(255, 255, 255, 0.03);
  --input-bg:  rgba(0, 0, 0, 0.28);
  --border:    rgba(255, 255, 255, 0.08);
  --hairline:  rgba(255, 255, 255, 0.06);
  --text:      #dcebf4;
  --muted:     #7597ab;
  --accent:    #22d3ee;
  --accent-2:  #2dd4bf;

  /* Catégories (jauges, liserés de lignes, points du récap) */
  --col-pg:      #38bdf8;
  --col-vg:      #34d399;
  --col-nic:     #fb923c;
  --col-thinner: #67e8f9;
  --col-flavour: #c084fc;
  --col-mixed:   #2dd4bf;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Alertes */
  --alert-error-bg:       rgba(220, 38, 38, .12);
  --alert-error-text:     #fca5a5;
  --alert-error-border:   rgba(220, 38, 38, .55);
  --alert-warning-bg:     rgba(217, 119, 6, .10);
  --alert-warning-text:   #fcd34d;
  --alert-warning-border: rgba(217, 119, 6, .55);
  --alert-info-bg:        rgba(34, 211, 238, .07);
  --alert-info-text:      #a5f3fc;
  --alert-info-border:    rgba(34, 211, 238, .45);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid rgba(34, 211, 238, .65); outline-offset: 2px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 15% 40%, rgba(34, 211, 238, .06) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(167, 139, 250, .05) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 85%, rgba(56, 189, 248, .04) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  padding: 14px 16px;
  max-width: 1320px;
  margin: 0 auto;
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════
   Barre de marque compacte (même DOM : header > img + h1 + p)
   ═══════════════════════════════════════ */
header {
  display: grid;
  grid-template-columns: auto auto;
  align-content: center;
  justify-content: center;
  column-gap: 12px;
  margin: 2px 0 16px;
}
.site-logo {
  display: block;
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;
  width: 44px;
  height: 44px;
  margin: 0;
  object-fit: contain;
  filter: drop-shadow(0 3px 12px rgba(0, 0, 0, .8));
}
header h1 {
  grid-column: 2;
  grid-row: 1;
  font-family: "Futura", "Century Gothic", "Trebuchet MS", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .07em;
  background: linear-gradient(90deg, #2dd4bf 0%, #fbbf24 55%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, .9));
}
header p {
  grid-column: 2;
  grid-row: 2;
  color: #68c5d8;
  font-size: .78rem;
  margin: 0;
  padding-top: 3px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .9), 0 0 24px rgba(0, 0, 0, .7);
}

/* ═══════════════════════════════════════
   Coquille : colonne de travail + rail Résumé sticky
   ═══════════════════════════════════════ */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}
.rail {
  position: sticky;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .14) transparent;
  padding-right: 2px;
}
.rail::-webkit-scrollbar { width: 8px; }
.rail::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 4px; }
.rail::-webkit-scrollbar-track { background: transparent; }
.rail .card { margin-bottom: 0; }

/* ── Carte générique ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .72rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .14em;
}
.card h2::before {
  content: '';
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  flex: none;
}

/* ═══════════════════════════════════════
   Sélecteur de mode (segmenté, centré)
   ═══════════════════════════════════════ */
.mode-switch {
  display: flex;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  margin: 0 auto 16px;
  width: fit-content;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.mode-btn {
  background: transparent;
  border: none;
  padding: 8px 22px;
  border-radius: 9px;
  font-size: .92rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background .18s, color .18s;
  white-space: nowrap;
}
.mode-btn:not(.active):hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.mode-btn.active {
  background: linear-gradient(135deg, #22d3ee, #2dd4bf);
  color: #05242c;
  font-weight: 650;
  text-shadow: none;
}

/* ── Descriptions de mode ── */
#desc-solver, #desc-direct, #desc-mmm {
  color: var(--muted);
  font-size: .86rem;
  margin-bottom: 12px;
  text-shadow: 0 0 8px rgba(0, 0, 0, .9);
}

/* ── Nom de recette (champ « héros » souligné) ── */
.recipe-name-wrap { margin-bottom: 12px; }
.recipe-name-input {
  width: 100%;
  padding: 8px 2px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 600;
  text-shadow: 0 0 6px rgba(0, 0, 0, .9);
  transition: border-color .2s, box-shadow .2s;
}
.recipe-name-input::placeholder { color: rgba(255, 255, 255, .45); font-weight: 400; }
.recipe-name-input:focus {
  outline: none;
  border-bottom-color: rgba(34, 211, 238, .65);
  box-shadow: 0 1px 0 0 rgba(34, 211, 238, .35);
}

/* ═══════════════════════════════════════
   Règles FONCTIONNELLES portées telles quelles
   (bascules de mode / cible fixe-variable)
   ═══════════════════════════════════════ */
[data-target-mode="variable"] > .comp-row .ing-vol-wrap   { display: none !important; }
[data-target-mode="variable"] > .comp-row .ing-pct-wrap   { display: none !important; }
[data-target-mode="variable"] > .comp-row .ing-direct-vol { display: flex !important; }
[data-target-mode="fixed"] > .comp-row .ing-direct-vol    { display: none; }
#main-panel[data-target-mode="variable"] #desc-solver { display: none; }
#main-panel[data-target-mode="fixed"] #desc-direct    { display: none; }
#main-panel[data-target-mode="variable"] #card-targets .nic-max-inline { display: none; }
#mmmc-e-panel[data-target-mode="variable"] .nic-max-inline { display: none; }
#mmmc-f-panel[data-target-mode="variable"] .nic-max-inline { display: none; }

#card-targets input:disabled,
#card-targets .ratio-step:disabled,
#mmmc-e-targets input:disabled,
#mmmc-e-targets .ratio-step:disabled,
#mmmc-f-targets input:disabled,
#mmmc-f-targets .ratio-step:disabled,
#mfr-apply:disabled { opacity: .55; cursor: not-allowed; }

#main-panel:not([data-mode="mmm"]) #card-mmm        { display: none; }
#main-panel:not([data-mode="mmm"]) #mmm-result      { display: none !important; }
#main-panel:not([data-mode="mmm"]) #mmm-full-result { display: none !important; }
#main-panel:not([data-mode="mmm"]) #desc-mmm        { display: none; }
#main-panel[data-mode="mmm"] #card-targets          { display: none; }
#main-panel[data-mode="mmm"] #card-ingredients      { display: none; }
#main-panel[data-mode="mmm"] #desc-solver           { display: none; }
#main-panel[data-mode="mmm"] #desc-direct           { display: none; }
#main-panel[data-mode="mmm"] .btn-add-comp          { display: none; }

#card-mmm:not([data-mmm-sub="full"]) #mmm-full-panel   { display: none; }
#card-mmm[data-mmm-sub="full"]       #mmm-simple-panel { display: none; }

/* ═══════════════════════════════════════
   Onglets segmentés (MixMyMix + Cible fixe/variable)
   ═══════════════════════════════════════ */
.mmm-subtabs {
  display: inline-flex;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--hairline);
  border-radius: 11px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 18px;
}
.mmm-subtab {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
}
.mmm-subtab:not(.active):hover { color: var(--text); }
.mmm-subtab.active {
  background: rgba(34, 211, 238, .14);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .38);
  color: var(--accent);
}

.target-mode-tabs {
  display: inline-flex;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 14px;
}
.target-mode-tab {
  padding: 4px 13px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
  white-space: nowrap;
}
.target-mode-tab.active {
  background: rgba(34, 211, 238, .14);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .38);
  color: var(--accent);
}
.target-mode-tab:not(.active):hover { color: var(--text); }

/* ═══════════════════════════════════════
   MixMyMix : panneaux empilés en étapes numérotées
   ═══════════════════════════════════════ */
.mmm-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  counter-reset: mmm-step;
}
.mmm-panel {
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 14px 16px;
}
.mmm-panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.mmm-panel-title::before {
  counter-increment: mmm-step;
  content: counter(mmm-step);
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: rgba(34, 211, 238, .13);
  border: 1px solid rgba(34, 211, 238, .4);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.mmm-final-summary {
  margin-top: 14px;
  font-size: .84rem;
  color: var(--muted);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.mmm-final-summary span { white-space: nowrap; }
.mmm-final-summary strong { color: var(--text); font-family: var(--mono); font-size: .8rem; }

/* Cartes « À ajouter » : le résultat payant — bordure teintée accent */
#mmm-result, #mmm-full-result { border-color: rgba(34, 211, 238, .22); }

.btn-mmm-add {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, .18);
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.btn-mmm-add:hover { color: var(--accent); border-color: rgba(34, 211, 238, .5); background: rgba(34, 211, 238, .04); }

/* ═══════════════════════════════════════
   Champs numériques génériques
   ═══════════════════════════════════════ */
input[type="number"], select,
.ing-pct, .ing-ml, .ing-nic-pct, .ing-family-pct, .ing-thinner-pct {
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: .86rem;
  width: 86px;
  background: var(--input-bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  transition: border-color .2s, box-shadow .2s;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { display: none; }
input[type="number"]:focus, select:focus,
.ing-pct:focus, .ing-ml:focus, .ing-nic-pct:focus, .ing-family-pct:focus, .ing-thinner-pct:focus {
  outline: none;
  border-color: rgba(34, 211, 238, .5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .1);
}
select {
  width: auto;
  min-width: 150px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%237597ab'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 24px;
  cursor: pointer;
}
.unit { font-size: .78rem; color: var(--muted); }

/* ── Enveloppe input + steppers ── */
.num-field {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 7px;
  background: var(--input-bg);
  padding: 0 4px 0 8px;
  gap: 2px;
  transition: border-color .2s, box-shadow .2s;
}
.num-field:focus-within {
  border-color: rgba(34, 211, 238, .5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .1);
}
.num-field input[type="number"],
.num-field input[type="text"] {
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  font-size: .86rem;
  padding: 6px 2px;
  width: auto;
  min-width: 36px;
  flex: 1;
  transition: none;
}
.num-field input[type="number"]:focus,
.num-field input[type="text"]:focus { border-color: transparent; box-shadow: none; outline: none; }

/* ── Champ ratio PG/VG combiné ── */
.ratio-input {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 7px;
  background: var(--input-bg);
  padding: 4px 10px;
  gap: 2px;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.ratio-input input[type="number"] {
  border: none;
  background: transparent;
  width: 38px;
  text-align: center;
  color: var(--text);
  font-size: .88rem;
  padding: 2px 0;
  -moz-appearance: textfield;
}
.ratio-input input[type="number"]::-webkit-outer-spin-button,
.ratio-input input[type="number"]::-webkit-inner-spin-button { display: none; }
.ratio-input input[type="number"]:focus { outline: none; box-shadow: none; }
.ratio-input .sep { color: var(--muted); font-weight: 700; font-size: .95rem; user-select: none; }
.ratio-input-sm { width: auto; padding: 4px 6px; }
.ratio-input .ratio-stepper { margin-left: auto; }

/* ── Steppers ▲▼ ── */
.ratio-stepper {
  display: flex;
  flex-direction: column;
  margin-left: 5px;
  gap: 1px;
}
.ratio-step {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .55rem;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
  transition: color .12s, background .12s;
}
.ratio-step:hover { color: var(--text); background: rgba(255, 255, 255, .08); }

/* ═══════════════════════════════════════
   Cibles : tuiles de tableau de bord éditables
   ═══════════════════════════════════════ */
.targets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  align-items: stretch;
}
.target-block {
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 11px;
  padding: 10px 12px 8px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.target-block:focus-within {
  border-color: rgba(34, 211, 238, .45);
  background: rgba(34, 211, 238, .035);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .08);
}
.target-block label {
  display: block;
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 5px;
}
.target-block input, .target-block select { width: 100%; }
/* Le champ devient « nu » dans la tuile : la tuile porte bordure et focus */
.target-block .num-field,
.target-block .ratio-input {
  display: flex;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  box-shadow: none;
}
.target-block .num-field input[type="number"],
.target-block .num-field input[type="text"],
.target-block .ratio-input input[type="number"] {
  font-size: 1.06rem;
  font-weight: 650;
  font-family: var(--mono);
}
.target-block .ratio-input input[type="number"] { width: 3ch; text-align: center; }
.target-block .ratio-input .sep { margin: 0 3px; }
.target-block .ratio-step { opacity: .45; transition: opacity .15s, color .12s, background .12s; }
.target-block:hover .ratio-step,
.target-block:focus-within .ratio-step { opacity: 1; }

/* Liseré rouge/ambre d'erreur de résolution : porté par la tuile entière */
.target-block:has(.target-field-invalid) {
  border-color: rgba(220, 38, 38, .6);
  box-shadow: 0 0 10px rgba(220, 38, 38, .16);
}
.target-block:has(.target-field-invalid):focus-within {
  border-color: rgba(220, 38, 38, .85);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .16);
}
.target-block:has(.target-field-warn) {
  border-color: rgba(251, 191, 36, .6);
  box-shadow: 0 0 10px rgba(251, 191, 36, .16);
}
.target-block:has(.target-field-warn):focus-within {
  border-color: rgba(251, 191, 36, .85);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .16);
}

/* Plafond nicotine atteignable, inline dans la tuile */
.nic-max-inline {
  font-size: .68rem;
  color: var(--muted);
  white-space: nowrap;
  align-self: center;
  padding-right: 2px;
  font-family: var(--mono);
}

/* Hint plancher (« min X ») dans le libellé d'une cible tenue */
.pct-floor-hint { opacity: .8; text-transform: none; letter-spacing: 0; }

/* ── Convertisseur fabricant ── */
.mfr-converter { font-size: .8rem; margin-top: 8px; width: 100%; }
.mfr-converter summary {
  cursor: pointer;
  color: var(--accent);
  user-select: none;
  list-style: none;
  font-size: .76rem;
  text-align: right;
  opacity: .85;
}
.mfr-converter summary:hover { opacity: 1; }
.mfr-converter summary::-webkit-details-marker { display: none; }
.mfr-converter summary::after { content: ' ▸'; font-size: .68rem; }
.mfr-converter[open] summary::after { content: ' ▾'; }
.mfr-fields { display: flex; align-items: center; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.mfr-explain { color: var(--muted); font-size: .75rem; line-height: 1.45; margin: 6px 0 8px; }
.mfr-fields span { color: var(--muted); font-size: .76rem; }
.mfr-fields input[type="number"] {
  width: 46px;
  padding: 3px 5px;
  border-radius: 5px;
  text-align: center;
}
.mfr-fields button {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(34, 211, 238, .5);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: .76rem;
  transition: background .15s;
}
.mfr-fields button:hover { background: rgba(34, 211, 238, .08); }

/* ═══════════════════════════════════════
   Lignes d'ingrédients : bandeaux à liseré de catégorie
   (data-ing-cat est posé par js/ing-row-category.js d'après le type)
   ═══════════════════════════════════════ */
.comp-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.comp-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .025);
  border: 1px solid rgba(255, 255, 255, .05);
  border-left: 3px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  transition: opacity .15s, border-color .15s, background .15s;
}
.comp-row:hover { border-color: rgba(255, 255, 255, .12); border-left-width: 3px; background: rgba(255, 255, 255, .035); }
.comp-row[data-ing-cat="nic"]     { border-left-color: var(--col-nic); }
.comp-row[data-ing-cat="flavour"] { border-left-color: var(--col-flavour); }
.comp-row[data-ing-cat="pg"]      { border-left-color: var(--col-pg); }
.comp-row[data-ing-cat="vg"]      { border-left-color: var(--col-vg); }
.comp-row[data-ing-cat="mixed"]   { border-left-color: var(--col-mixed); }
.comp-row[data-ing-cat="thinner"] { border-left-color: var(--col-thinner); }
.comp-row.dragging { opacity: .35; }
.comp-row.drag-over { border-color: rgba(34, 211, 238, .6); }

.drag-handle {
  cursor: grab;
  color: rgba(255, 255, 255, .18);
  font-size: 1rem;
  padding: 0 2px 4px;
  user-select: none;
  align-self: center;
  line-height: 1;
  transition: color .15s;
}
.drag-handle:hover { color: rgba(255, 255, 255, .5); }
.drag-handle:active { cursor: grabbing; }

.ing-field { display: flex; flex-direction: column; gap: 4px; }
.ing-sub-lbl {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  white-space: nowrap;
}
/* Valeur calculée « ≈ x ml » : puce résultat en mono */
.ing-auto-vol,
.ing-nic-contrib-vol {
  font-size: .76rem;
  font-family: var(--mono);
  color: #8fe8f7;
  white-space: nowrap;
  background: rgba(34, 211, 238, .07);
  border: 1px solid rgba(34, 211, 238, .14);
  border-radius: 6px;
  padding: 4px 8px;
}
.ing-type { min-width: 0; max-width: 150px; }
.ing-pg-type { min-width: 0; max-width: 130px; }
.ing-name {
  width: 120px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 7px;
  background: var(--input-bg);
  padding: 6px 8px;
  font-size: .86rem;
  color: var(--text);
  font-family: inherit;
}
.ing-name:focus { outline: none; border-color: rgba(34, 211, 238, .5); box-shadow: 0 0 0 3px rgba(34, 211, 238, .1); }
.ing-name::placeholder { color: var(--muted); }

.comp-auto-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .8rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.comp-auto-label input[type="checkbox"] { width: auto; cursor: pointer; accent-color: #22d3ee; }
.comp-auto-label.locked-auto { cursor: help; opacity: .5; }
.comp-auto-label.locked-auto input[type="checkbox"] { cursor: not-allowed; }

.comp-del {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .28);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  align-self: center;
  transition: color .15s, background .15s;
}
.comp-del:hover { color: #fca5a5; background: rgba(220, 38, 38, .12); }

.row-fold-toggle {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .16);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 12px;
  line-height: 1;
  align-self: center;
  transition: color .12s, background .12s, border-color .12s;
}
.row-fold-toggle:hover {
  color: var(--accent);
  background: rgba(34, 211, 238, .1);
  border-color: rgba(34, 211, 238, .4);
}
/* Champ secondaire déplié (Type de PG) : rejoint la ligne courante de
   .comp-row s'il reste de la place, sinon retombe naturellement à la ligne
   suivante (display:contents — le champ participe directement au
   flex-wrap du parent, comme n'importe quel autre champ de la ligne).
   Ratio PG/VG reste lui toujours visible, indépendamment de ce repli. */
.ing-secondary { display: none; }
.ing-secondary.expanded { display: contents; }

.btn-add-comp {
  display: block;
  width: 100%;
  background: none;
  border: 1px dashed rgba(255, 255, 255, .18);
  color: var(--muted);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: .8rem;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  margin-top: 4px;
}
.btn-add-comp:hover { border-color: rgba(34, 211, 238, .5); color: var(--accent); background: rgba(34, 211, 238, .04); }

/* ═══════════════════════════════════════
   États de champs (solveur) — logique portée
   ═══════════════════════════════════════ */
.ing-vol-numfield.needs-input {
  border-color: rgba(251, 191, 36, .55);
  box-shadow: 0 0 8px rgba(251, 191, 36, .15);
}
.ing-vol-numfield.needs-input:focus-within {
  border-color: rgba(251, 191, 36, .8);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .15);
}
.ing-vol-numfield.is-valid {
  border-color: rgba(34, 211, 238, .45);
  box-shadow: 0 0 8px rgba(34, 211, 238, .12);
}
.ing-vol-numfield.is-valid:focus-within {
  border-color: rgba(34, 211, 238, .7);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .12);
}
.ing-vol-numfield.is-excess {
  border-color: rgba(220, 38, 38, .55);
  box-shadow: 0 0 8px rgba(220, 38, 38, .15);
}
.ing-vol-numfield.is-excess:focus-within {
  border-color: rgba(220, 38, 38, .8);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}

/* Fallback direct (hors tuile) du liseré cible — inoffensif dans la tuile */
.num-field.target-field-invalid, .ratio-input.target-field-invalid,
.num-field.target-field-warn,    .ratio-input.target-field-warn { border-radius: 7px; }

/* ═══════════════════════════════════════
   Lignes Fondamentaux (verrouillées, Mix Final)
   ═══════════════════════════════════════ */
.foundation-ing-row {
  background: rgba(45, 212, 191, .05);
  border-color: rgba(45, 212, 191, .16);
}
.foundation-ing-lock {
  font-size: .72rem;
  flex-shrink: 0;
  opacity: .55;
  margin-right: 2px;
  align-self: center;
}
.foundation-ing-row select:disabled,
.foundation-ing-row input[type="text"]:disabled,
.foundation-ing-row .num-field.foundation-locked,
.foundation-ing-row .ratio-input.foundation-locked {
  opacity: .55;
  cursor: default;
}
/* Le seul champ éditable d'une ligne verrouillée : accent cyan */
.foundation-ing-row .num-field:not(.foundation-locked) {
  background: var(--input-bg);
  border: 1px solid rgba(34, 211, 238, .45);
  box-shadow: 0 0 8px rgba(34, 211, 238, .12);
  padding: 0 4px 0 8px;
}
.foundation-ing-row .num-field:not(.foundation-locked):focus-within {
  border-color: rgba(34, 211, 238, .7);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .12);
}
/* % sous « Mon mix actuel » (dilué) → ambre ; au-dessus (boosté) → violet */
.foundation-ing-row .num-field.pct-diluted {
  border-color: rgba(251, 191, 36, .55);
  box-shadow: 0 0 8px rgba(251, 191, 36, .15);
}
.foundation-ing-row .num-field.pct-diluted:focus-within {
  border-color: rgba(251, 191, 36, .8);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .15);
}
.foundation-ing-row .num-field.pct-boosted {
  border-color: rgba(192, 132, 252, .55);
  box-shadow: 0 0 8px rgba(192, 132, 252, .15);
}
.foundation-ing-row .num-field.pct-boosted:focus-within {
  border-color: rgba(192, 132, 252, .8);
  box-shadow: 0 0 0 3px rgba(192, 132, 252, .15);
}

/* ═══════════════════════════════════════
   Alertes
   ═══════════════════════════════════════ */
.alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.alert {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-left-width: 3px;
}
.alert.error   { background: var(--alert-error-bg);   color: var(--alert-error-text);   border-color: rgba(220, 38, 38, .2);  border-left-color: var(--alert-error-border); }
.alert.warning { background: var(--alert-warning-bg); color: var(--alert-warning-text); border-color: rgba(217, 119, 6, .2);  border-left-color: var(--alert-warning-border); }
.alert.info    { background: var(--alert-info-bg);    color: var(--alert-info-text);    border-color: rgba(34, 211, 238, .16); border-left-color: var(--alert-info-border); }
.alert-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.alert-actions { flex: none; display: flex; align-items: center; gap: 4px; }
.alert-toggle, .alert-fold {
  flex: none; background: none; border: none; color: inherit; font: inherit;
  font-size: 1rem; line-height: 1; cursor: pointer; padding: 0 2px; opacity: .7;
}
.alert-toggle:hover, .alert-fold:hover { opacity: 1; }
.alert-full { margin-top: 6px; font-weight: 400; white-space: pre-line; }

/* ═══════════════════════════════════════
   Rail : Résumé (lecture d'instruments)
   ═══════════════════════════════════════ */
.summary-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.summary-header h2 { margin: 0; }

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.result-block {
  text-align: center;
  padding: 10px 8px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 10px;
}
.result-block .val {
  font-size: 1.28rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
  text-shadow: 0 0 18px rgba(34, 211, 238, .35);
}
.result-block .lbl { font-size: .68rem; color: var(--muted); margin-top: 3px; }
.ratio-mode-chip {
  display: inline-block;
  font-size: .64rem;
  padding: 1px 5px;
  margin-left: 3px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  font-family: inherit;
  vertical-align: middle;
  transition: border-color .15s, color .15s;
}
.ratio-mode-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── Jauge empilée ── */
.gauge-bar {
  display: flex;
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .05);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, .45);
}
.gauge-segment { height: 100%; transition: width .3s, filter .15s; position: relative; }
.gauge-segment:hover { filter: brightness(1.15); }
.gauge-segment[data-cat="pg"]      { background: var(--col-pg); }
.gauge-segment[data-cat="vg"]      { background: var(--col-vg); }
.gauge-segment[data-cat="nic"]     { background: var(--col-nic); }
.gauge-segment[data-cat="thinner"] { background: var(--col-thinner); }
.gauge-segment[data-cat="flavour"] { background: var(--col-flavour); }
#gauge-tooltip {
  position: fixed;
  display: none;
  background: rgba(10, 15, 24, .97);
  color: #e2e8f0;
  font-size: .78rem;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, .14);
  pointer-events: none;
  z-index: 500;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}

/* ── Tableau récap ── */
.recap-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.recap-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
.recap-table td { padding: 5px 6px; border-bottom: 1px solid rgba(255, 255, 255, .035); }
.recap-table tr:last-child td { border-bottom: none; }
.recap-table tr.total td { font-weight: 700; border-top: 1px solid var(--border); }
.recap-table th + th, .recap-table td + td { text-align: right; }
.recap-table td + td { font-family: var(--mono); font-size: .78rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot-pg      { background: var(--col-pg); }
.dot-vg      { background: var(--col-vg); }
.dot-nic     { background: var(--col-nic); }
.dot-thinner { background: var(--col-thinner); }
.dot-flavour { background: var(--col-flavour); }

/* ── Barre d'actions / export (grille en bas du Résumé) ── */
.summary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.btn-print {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  font-family: inherit;
  line-height: 1.3;
  white-space: nowrap;
}
.btn-print:hover { color: var(--text); border-color: rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .05); }
/* CTA contextuel « Adapter → MixMyMix » : pleine largeur, accent */
#btn-adapt-mmm {
  grid-column: 1 / -1;
  border-color: rgba(34, 211, 238, .4);
  color: var(--accent);
}
#btn-adapt-mmm:hover { background: rgba(34, 211, 238, .07); border-color: rgba(34, 211, 238, .6); color: var(--accent); }

/* ── Carte production (rail) : champs empilés ── */
.card-production { display: flex; flex-direction: column; gap: 12px; padding: 14px 18px; }
.prod-field { display: flex; flex-direction: column; gap: 5px; }
.prod-field label { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap; }
.prod-field input[type="text"],
.prod-field input[type="date"] {
  background: var(--input-bg);
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 7px;
  color: var(--text);
  font-size: .86rem;
  padding: 6px 8px;
  height: 34px;
  width: 100%;
  font-family: inherit;
}
.prod-field input[type="date"] { color-scheme: dark; }
.prod-field input[type="text"]:focus,
.prod-field input[type="date"]:focus {
  outline: none;
  border-color: rgba(34, 211, 238, .5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .1);
}
.steep-wrap { display: flex; gap: 6px; align-items: center; }
.steep-wrap input[type="number"] { width: 64px; }
.steep-wrap select {
  background: var(--input-bg);
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 7px;
  color: var(--text);
  font-size: .86rem;
  padding: 5px 24px 5px 8px;
  height: 34px;
  min-width: 0;
  flex: 1;
}

/* ═══════════════════════════════════════
   Boutons flottants (langue, vapeur) + badge + mention
   ═══════════════════════════════════════ */
.lang-btn {
  position: fixed;
  top: 12px;
  right: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 4px 10px;
  font-size: 1.15rem;
  cursor: pointer;
  z-index: 100;
  line-height: 1;
  transition: background .2s, box-shadow .2s;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .55);
}
.lang-btn:hover { background: rgba(255, 255, 255, .1); box-shadow: 0 4px 20px rgba(0, 0, 0, .6), 0 0 12px rgba(34, 211, 238, .2); }
.vapor-btn {
  position: fixed;
  top: 12px;
  left: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 5px 9px;
  cursor: pointer;
  z-index: 100;
  line-height: 1;
  transition: background .2s, box-shadow .2s, opacity .2s;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .55);
}
.vapor-btn:hover { background: rgba(255, 255, 255, .1); box-shadow: 0 4px 20px rgba(0, 0, 0, .6), 0 0 12px rgba(34, 211, 238, .2); }
.vapor-btn.vapor-off { opacity: .35; }

#france-mention {
  position: fixed;
  bottom: 12px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: rgba(255, 255, 255, .38);
  letter-spacing: .03em;
  pointer-events: none;
  user-select: none;
  z-index: 2;
}

/* Contenu au-dessus des canvas d'arrière-plan */
header, main, .mode-switch, .shell, #main-panel, #summary, .alerts {
  position: relative;
  z-index: 1;
}

/* Impression : lignes production (partagé avec la feuille print) */
#print-steep, #print-comment { font-size: .82rem; color: #222; margin-top: 2px; }
#print-header { display: none; }

/* ═══════════════════════════════════════
   Écrans réduits
   ═══════════════════════════════════════ */
@media (max-width: 1080px) {
  .shell { display: block; }
  .rail { position: static; max-height: none; overflow: visible; padding-right: 0; margin-top: 4px; }
  .rail .card { margin-bottom: 14px; }
}

@media (max-width: 700px) {
  body { padding: 10px; }
  header { gap: 9px; margin-bottom: 12px; }
  header p { display: none; }
  .site-logo { width: 36px; height: 36px; }
  header h1 { font-size: 1.15rem; }

  .mode-switch { width: 100%; }
  .mode-btn { flex: 1; padding: 8px 10px; font-size: .88rem; text-align: center; }

  .card { padding: 12px; overflow-x: auto; }
  select { min-width: unset; width: 100%; }
  .targets-grid { grid-template-columns: 1fr 1fr; }
  .result-block .val { font-size: 1.15rem; }
  .lang-btn { padding: 4px 8px; font-size: 1rem; top: 10px; right: 10px; }
  .vapor-btn { top: 10px; left: 10px; }
}

@media (max-width: 420px) {
  .targets-grid { grid-template-columns: 1fr; }
  .result-block .val { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ═══════════════════════════════════════
   Feuille d'impression (portée de style.css)
   ═══════════════════════════════════════ */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body { background: #fff !important; color: #111 !important; max-width: none; }
  .shell { display: block !important; }
  .rail { position: static !important; max-height: none !important; overflow: visible !important; display: block !important; }

  #print-header {
    display: block !important;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid #222;
    font-family: sans-serif;
  }
  .print-bar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
  .print-bar strong { font-size: 1.1rem; }
  #print-date { font-size: .82rem; color: #666; }
  #print-meta { font-size: .83rem; color: #444; margin-bottom: 10px; }
  .print-ing-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
  .print-ing-table th {
    text-align: left;
    border-bottom: 1px solid #bbb;
    padding: 3px 8px;
    color: #555;
    font-weight: 500;
  }
  .print-ing-table td { padding: 3px 8px; }
  .print-ing-table td:nth-child(2) { color: #333; }
  .print-ing-table th:nth-child(3),
  .print-ing-table td:nth-child(3) { text-align: right; }

  @page { size: A4; margin: 14mm 12mm; }

  canvas, .vapor-btn, .lang-btn, .mode-switch, #main-panel,
  .alerts, .btn-print, .summary-actions, .ratio-mode-chip, .drag-handle,
  #gauge-tooltip, #france-mention, .card-production { display: none !important; }

  header { display: flex; justify-content: center; padding: 0; margin-bottom: 10px; }
  header img { max-width: 60px; max-height: 60px; filter: none !important; }
  header h1 { background-image: linear-gradient(90deg, #2dd4bf 0%, #fbbf24 55%, #c084fc 100%) !important; -webkit-background-clip: text !important; background-clip: text !important; -webkit-text-fill-color: transparent !important; color: #2dd4bf !important; text-shadow: none !important; filter: none !important; font-size: 1.2rem; margin: 0; }
  header p  { display: block; color: #68c5d8 !important; text-shadow: none !important; margin: 0; }

  .card {
    background: #fff !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    margin-bottom: 14px;
    break-inside: avoid;
  }
  .card h2 { color: #111 !important; }
  .card h2::before { display: none; }
  .summary-header { margin-bottom: 14px; }

  .result-block { background: #f2f2f2 !important; border: 1px solid #ddd !important; box-shadow: none !important; }
  .result-block .val { color: #111 !important; text-shadow: none !important; }
  .result-block .lbl { color: #555 !important; }

  .gauge-bar { box-shadow: none !important; background: #e8e8e8 !important; }

  .recap-table th { color: #555 !important; border-color: #ccc !important; }
  .recap-table td { color: #111 !important; border-color: #eee !important; }
  .recap-table tr.total td { border-color: #ccc !important; }

  #summary { display: block !important; }
}
