/* Base mobile-first. Les thèmes ne font que redéfinir les variables et ajouter du décor. */
:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #2a2622;
  --muted: #776f66;
  --accent: #b5532c;
  --accent-soft: #f4e4da;
  --border: #e7e2dc;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: var(--font);
  --shadow: 0 1px 2px rgb(0 0 0 / .06);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--font);
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2 { font-family: var(--font-title); line-height: 1.2; }
h1 { font-size: 1.75rem; margin: .4em 0 .3em; }
h2 { font-size: 1.25rem; margin: 1.6em 0 .6em; }

main { padding: 0 16px 48px; max-width: 760px; margin: 0 auto; }

/* En-tête */
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--font-title); font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.header-action {
  font-size: .9rem; font-weight: 600; text-decoration: none;
  padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; border-top: 1px solid var(--border); }

/* Accueil */
.intro p { color: var(--muted); margin-top: 0; }
#search {
  width: 100%; font: inherit; padding: 12px 14px; margin: 8px 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  flex: none; padding: 6px 14px; border-radius: 999px; font-size: .9rem; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.course { scroll-margin-top: 64px; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: 1fr; }
.card a {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 14px 16px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.card img { margin: -14px -16px 10px; width: calc(100% + 32px); max-width: none; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; }
.card-title { font-weight: 600; font-family: var(--font-title); }
.card-meta { font-size: .85rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); }

@media (min-width: 560px) {
  .cards { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 2.1rem; }
}

/* Recette */
.back { display: inline-block; margin: 14px 0 4px; font-size: .9rem; text-decoration: none; }
.hero { width: calc(100% + 32px); max-width: none; margin: 8px -16px 0; aspect-ratio: 4/3; object-fit: cover; }
.description { color: var(--muted); font-style: italic; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tags span { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.facts div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-size: .95rem; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.servings { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.servings button {
  width: 36px; height: 36px; border-radius: 50%; font-size: 1.2rem; line-height: 1; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.ingredients ul { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.ingredients li + li { border-top: 1px solid var(--border); }
.ingredients label { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; cursor: pointer; }
.ingredients input { accent-color: var(--accent); transform: translateY(2px); }
.ingredients .amounts { margin-left: auto; color: var(--muted); white-space: nowrap; text-align: right; }
.ingredients input:checked ~ span { text-decoration: line-through; opacity: .5; }
.cookware { font-size: .95rem; color: var(--muted); }

.step { display: flex; gap: 12px; margin: 0 0 16px; }
.step p { margin: 0; }
.step-no {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: .85rem; font-weight: 700; background: var(--accent); color: var(--surface); margin-top: 1px;
}
.ing { font-weight: 600; }
.amount { font-weight: 400; color: var(--muted); font-size: .9em; }
.timer { white-space: nowrap; font-weight: 600; color: var(--accent); }
.note {
  margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0; font-style: italic;
}
.originals { margin-top: 24px; }
.originals summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.originals img { margin-top: 12px; border-radius: var(--radius); border: 1px solid var(--border); }

/* Formulaires */
.form-page { padding-top: 12px; }
.form-page.center { text-align: center; }
form label { display: block; margin: 0 0 16px; font-weight: 600; }
form small { font-weight: 400; color: var(--muted); }
form input:not([type=checkbox]), form textarea {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
form.login { max-width: 360px; margin: 0 auto; text-align: left; }
.button {
  display: inline-block; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  padding: 12px 22px; border: 0; border-radius: 999px; background: var(--accent); color: var(--surface);
}
form .button { width: 100%; }
.error { background: #fde8e8; color: #9b1c1c; padding: 10px 14px; border-radius: var(--radius); }

.theme-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.theme-list a { display: flex; flex-direction: column; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); }
.theme-list span { color: var(--muted); font-size: .9rem; }

.submission { border-top: 1px solid var(--border); padding-top: 8px; }
.submission pre { white-space: pre-wrap; font: inherit; background: var(--surface); padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { width: 120px; height: 120px; object-fit: cover; border-radius: 6px; }
.section-head { margin: 1.6em 0 .6em; }
.section-head h2 { margin: 0; }

/* Admin */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.admin h2 { scroll-margin-top: 64px; }
.admin h3 { font-size: 1rem; margin: 1.2em 0 .4em; color: var(--muted); }
.flash { background: var(--accent-soft); padding: 10px 14px; border-radius: var(--radius); }
.stats { font-size: .95rem; }
.admin-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-list > li { padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; }
.admin-list > li + li { border-top: 1px solid var(--border); }
.admin-list .row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; justify-content: space-between; }
.admin-list .badges { justify-content: flex-start; font-size: .85rem; }
.badge { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; border-radius: 50%; font-size: .8rem; font-weight: 700; }
.badge.ok { background: #dcefdc; color: #2f6b2f; }
.badge.ko { background: #f6dcdc; color: #9b1c1c; }
.admin-list form { margin: 0; }
.admin-list label { display: flex; gap: 10px; align-items: baseline; margin: 0; font-weight: 400; cursor: pointer; }
.admin-list input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; flex: none; transform: translateY(3px); }
.todo > li { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 8px; }
.todo > li.done span { text-decoration: line-through; opacity: .55; }
.icon { border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 2px 6px; }
.todo-add { margin-top: 16px; }
form select { display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.history { list-style: none; padding: 0; font-size: .9rem; }
.history li { padding: 6px 0; border-bottom: 1px dashed var(--border); }

.editor .code, .current .code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; line-height: 1.45; }
.current pre { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.help { margin: -8px 0 16px; font-size: .85rem; }
.help summary { cursor: pointer; color: var(--accent); }
.help code { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.proposal pre { white-space: pre-wrap; font: inherit; background: var(--surface); padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); }
.roles { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 16px; padding: 10px 14px; display: grid; gap: 10px; }
.roles legend { font-weight: 600; padding: 0 6px; }
.role { display: flex; gap: 12px; align-items: center; }
.role img, .thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; flex: none; }
.role select { margin: 0; }
.thumb { margin: -8px 0 16px; }
.editor-actions { display: flex; gap: 10px; position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); }
.editor-actions .button { flex: 1; }
/* Spécificité renforcée : les thèmes redéfinissent .button */
.button.button.secondary { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); }
.link-button { border: 0; background: none; color: var(--muted); text-decoration: underline; font: inherit; cursor: pointer; padding: 8px 0; }
.apercu { margin-top: 24px; border-top: 3px dashed var(--border); padding-top: 8px; }

/* Éditeur : original / formulaire / aperçu */
.page-editor main { max-width: 1800px; }
.editor-layout { display: grid; gap: 20px 28px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.pane-title { font-weight: 700; margin: 0 0 6px; }
.pane-original details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.pane-original summary { cursor: pointer; font-weight: 700; }
.pane-original img { width: 100%; margin-top: 10px; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; }
.pane-original .proposal pre { margin: 8px 0; }
.pane-preview .apercu { margin: 0; border-top: 3px dashed var(--border); padding-top: 4px; }

@media (min-width: 760px) {
  .editor-layout.has-original { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .editor-layout.has-original .pane-preview { grid-column: 1 / -1; }
  .pane-original { position: sticky; top: 70px; max-height: calc(100vh - 80px); overflow: auto; }
}
@media (min-width: 1200px) {
  .editor-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .editor-layout.has-original { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); }
  .editor-layout.has-original .pane-preview { grid-column: auto; }
  .pane-preview { position: sticky; top: 70px; max-height: calc(100vh - 80px); overflow: auto; }
  .pane-preview .hero { width: 100%; margin: 8px 0 0; }
  .editor textarea.code { min-height: calc(100vh - 360px); }
  /* L'aperçu est toujours visible et se met à jour tout seul : bouton inutile. */
  #preview-btn { display: none; }
}
