:root {
  color-scheme: light dark;
  --bg: #f8f1e6;
  --surface: #fffaf3;
  --surface-2: #f1e5d3;
  --text: #2c2118;
  --muted: #7b6553;
  --border: #e5d5bf;
  --accent: #b05e26;
  --accent-strong: #8f4718;
  --on-accent: #fffaf3;
  --ok: #2f6d3c;
  --ok-bg: #e3f0df;
  --error: #a63228;
  --error-bg: #f8e2dc;
  --shadow: 0 1px 2px rgb(74 46 22 / 0.06), 0 8px 24px rgb(74 46 22 / 0.08);
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16110d;
    --surface: #211912;
    --surface-2: #2c2219;
    --text: #f3e8da;
    --muted: #b49f8a;
    --border: #3b2f24;
    --accent: #e0904f;
    --accent-strong: #f0a86c;
    --on-accent: #1d140d;
    --ok: #9fd3a5;
    --ok-bg: #1f3322;
    --error: #f2a093;
    --error-bg: #3a1f1a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
}

main { flex: 1; padding-bottom: 48px; }

h1, h2, h3, legend { font-family: var(--serif); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 6vw, 3.2rem); margin: 0 0 12px; }
h2 { font-size: 1.7rem; margin: 0 0 20px; }
h3 { font-size: 1.25rem; margin: 0; }
p { margin: 0 0 12px; }
a { color: var(--accent-strong); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }
small, .small { font-size: 0.86rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

.sr-only, .hp {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ── Header and footer ─────────────────────────────────────────────── */

.topbar { padding: 14px 0; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
}
.topbar-link { color: var(--muted); font-size: 0.92rem; text-decoration: none; }
.topbar-link:hover { color: var(--accent); text-decoration: underline; }

.footer { padding: 28px 0 36px; color: var(--muted); font-size: 0.9rem; text-align: center; border-top: 1px solid var(--border); }
.footer a { color: inherit; }

/* ── Buttons and form controls ─────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 1rem/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.button:hover { background: var(--accent-strong); color: var(--on-accent); }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: 0.6; cursor: progress; }
.button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.button.secondary:hover { background: var(--surface-2); }
.button.small { min-height: 38px; padding: 6px 16px; font-size: 0.92rem; }

.button-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-strong);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.button-link.small { font-size: 0.86rem; }
.danger { color: var(--error); }

input, textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; padding: 0; accent-color: var(--accent); flex: none; }
input[type="file"] { padding: 9px; background: var(--surface); }

.field { display: grid; gap: 6px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
fieldset.field > legend { font-family: var(--sans); font-size: 1rem; padding: 0; margin-bottom: 6px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check.big { font-weight: 600; font-size: 1.1rem; }
.stack { display: grid; gap: 18px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.narrow { max-width: 460px; margin: 40px auto; }

.alert { padding: 14px 18px; border-radius: 12px; margin: 0 0 20px; }
.alert:focus { outline: none; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert p { margin: 0; }
.alert.error { background: var(--error-bg); color: var(--error); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-nouvelle { background: #fbe6c8; color: #8a4b12; }
.status-confirmee { background: #dcebf8; color: #1f5582; }
.status-livree, .paid, .state-disponible { background: var(--ok-bg); color: var(--ok); }
.status-annulee, .state-masque { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.state-masque { text-decoration: none; }
.state-indisponible { background: #fbe6c8; color: #8a4b12; }
@media (prefers-color-scheme: dark) {
  .status-nouvelle, .state-indisponible { background: #3d2a14; color: #f3c58c; }
  .status-confirmee { background: #172c40; color: #9cc8ef; }
}

/* ── Home ──────────────────────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  align-items: center;
  gap: 40px;
  padding: 28px 0 36px;
}
.tagline { font-size: 1.2rem; color: var(--muted); max-width: 38ch; margin-bottom: 24px; }
.hero-photo { margin: 0; }
.hero-photo img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.hero-photo img.placeholder, .bread-photo img.placeholder, .thumb.placeholder {
  object-fit: contain;
  padding: 8%;
  background: radial-gradient(circle at 50% 35%, #f7e3c4, #ecd0a8);
}
@media (prefers-color-scheme: dark) {
  .hero-photo img.placeholder, .bread-photo img.placeholder, .thumb.placeholder { background: radial-gradient(circle at 50% 35%, #3a2b1d, #2a1f15); }
}

.intro { max-width: 68ch; font-size: 1.08rem; margin-bottom: 28px; }

.batch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 14px 20px;
  margin: 0 0 36px;
  border-radius: 14px;
  background: var(--surface-2);
  font-weight: 600;
}
.batch-label {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.breads { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 24px; margin-bottom: 28px; }

.bread {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.bread.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.bread-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.bread-body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 18px 20px 20px; }
.bread-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bread-price { margin: 0; font-weight: 700; font-size: 1.15rem; color: var(--accent-strong); white-space: nowrap; }
.bread-weight { margin: 0; color: var(--muted); font-size: 0.92rem; }
.bread-desc { margin: 4px 0 8px; font-size: 0.97rem; }
.bread.off .bread-photo img { filter: grayscale(0.85); opacity: 0.7; }
.bread.off .bread-price { color: var(--muted); }
.tag { margin: auto 0 0; color: var(--muted); font-style: italic; }

.qty { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 8px; }
.qty-label { margin-right: auto; color: var(--muted); font-size: 0.92rem; }
.qty input {
  width: 4.2em;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 8px 4px;
  -moz-appearance: textfield;
  appearance: textfield;
}
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font: 600 1.4rem/1 var(--sans);
  cursor: pointer;
}
.step:hover { border-color: var(--accent); color: var(--accent-strong); }

.customer { display: grid; gap: 16px; margin: 0 0 20px; max-width: 640px; }
.customer legend { float: left; width: 100%; padding: 0; margin-bottom: 4px; font-size: 1.4rem; }

.order-bar {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 640px;
  padding: 12px 12px 12px 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.order-total { margin: 0; display: flex; align-items: baseline; gap: 10px; }
.order-total span { color: var(--muted); }
.order-total output { font-weight: 700; font-size: 1.3rem; }

.closed { text-align: center; font-size: 1.1rem; }

/* ── Order receipt ─────────────────────────────────────────────────── */

.receipt { max-width: 600px; margin: 24px auto; }
.eyebrow { margin: 0 0 6px; color: var(--accent-strong); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.receipt h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.receipt-batch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.lines { width: 100%; border-collapse: collapse; margin: 18px 0; }
.lines td, .lines th { padding: 10px 0; border-bottom: 1px solid var(--border); text-align: left; }
.lines td:last-child { text-align: right; white-space: nowrap; }
.lines tfoot th, .lines tfoot td { border-bottom: 0; font-size: 1.15rem; font-weight: 700; }
.note { margin: 12px 0; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.note p:last-child { margin: 0; }
.keep { padding: 14px 16px; border-radius: 12px; background: var(--surface-2); font-size: 0.95rem; overflow-wrap: anywhere; }
.receipt-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; }

/* ── Administration ────────────────────────────────────────────────── */

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 28px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.admin-nav a, .tabs a {
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.admin-nav a:hover, .tabs a:hover { background: var(--surface-2); }
.admin-nav a[aria-current], .tabs a[aria-current] { background: var(--accent); color: var(--on-accent); }
.admin-nav form { margin-left: auto; padding-right: 12px; }
.admin-nav .button-link { color: var(--muted); font-size: 0.92rem; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.admin h1 { font-size: 2rem; }

.prep { margin-bottom: 28px; }
.prep h2 { margin-bottom: 4px; }
.prep-batches { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; margin-top: 14px; }
.prep-batch h3 { font-size: 1.05rem; margin-bottom: 8px; }
.prep-list { list-style: none; margin: 0 0 6px; padding: 0; }
.prep-list li { padding: 4px 0; }
.prep-list strong { display: inline-block; min-width: 2ch; color: var(--accent-strong); font-size: 1.1rem; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.order-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; }
.order-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.order-head h3 { margin-right: auto; }
.order-card p { margin: 0; }
.order-lines { list-style: none; margin: 8px 0 0; padding: 0; }
.order-lines li, .order-sum { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.order-sum { border-bottom: 0; }
.order-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.order-actions select { width: auto; flex: 1; min-width: 130px; padding: 8px 12px; }
.order-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }

.bread-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 12px; }
.bread-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px 12px 12px; }
.thumb { width: 84px; height: 63px; object-fit: cover; border-radius: 10px; flex: none; }
.thumb.placeholder { padding: 6px; }
.bread-row-text { display: grid; gap: 2px; justify-items: start; flex: 1; min-width: 0; }
.bread-row-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}
.icon-button:disabled { opacity: 0.35; cursor: default; }
.photo-preview { width: 100%; max-width: 360px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; border: 1px solid var(--border); }
.danger-zone { margin-top: 20px; text-align: right; }

/* ── Small screens ─────────────────────────────────────────────────── */

@media (max-width: 760px) {
  body { font-size: 16px; }
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 12px; }
  .hero-photo { order: -1; }
  .hero:not(.has-photo) .hero-photo { display: none; }
  .tagline { max-width: none; }
  .card { padding: 20px; }
  .breads { grid-template-columns: 1fr; gap: 20px; }
  .order-bar { bottom: 8px; padding-left: 18px; }
  .order-bar .button { padding: 10px 18px; }
  .orders { grid-template-columns: 1fr; }
  .bread-row { flex-wrap: wrap; }
  .bread-row-actions { width: 100%; justify-content: flex-end; }
  .admin-nav { border-radius: 22px; }
  .admin-nav form { margin-left: 0; padding: 4px 12px 6px; }
}

@media (max-width: 420px) {
  .order-bar .wide { display: none; }
}
