:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #5d6b63;
  --line: #e1e7e2;
  --paper: #f4f6f3;
  --card: #ffffff;
  --accent: #1c6b45;
  --accent-ink: #f5fbf7;
  --accent-soft: #e7f5ed;
  --ok: #1c6b45;
  --warn: #8a4b08;
  --danger: #8f1d1d;
  --shadow: 0 1px 2px rgba(23, 33, 28, 0.04), 0 16px 40px rgba(23, 33, 28, 0.06);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 100% -10%, #e5f3ea 0%, transparent 55%),
    var(--paper);
  color: var(--ink);
  font: 16px/1.5 "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

h1, h2, h3, .weekday {
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1 { margin: 0; font-size: 28px; line-height: 1; }
h2 { margin: 0; font-size: 28px; }
h3 { margin: 0; font-size: 22px; }

.top, main, .wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.top {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px);
}

.brand { display: flex; gap: 12px; align-items: center; }

.mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 42%, #fff 0 5px, transparent 6px),
    linear-gradient(160deg, #2f9d64, var(--accent));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

main { padding: 8px 0 56px; }

#view-semaine[hidden], #view-reglages[hidden] { display: none !important; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-top: 8px;
}

.week-actions, .week-switch, nav {
  display: flex;
  gap: 8px;
  align-items: end;
}

nav {
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.hint { color: var(--muted); margin: 6px 0 0; }

#status.busy {
  width: fit-content;
  max-width: 100%;
  position: sticky;
  top: 72px;
  z-index: 4;
  background: #fff6ea;
  color: var(--warn);
  padding: 10px 14px;
  border-radius: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
}

input, textarea, select, button, .jump {
  font: inherit;
  color: var(--ink);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}

input:focus, textarea:focus, select:focus { border-color: #8fbfa4; }

button, .jump {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

button:hover, .jump:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.55; cursor: wait; }

button.ghost, button.remove, nav button, .shop-tabs button, .week-switch button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  filter: none;
}

button.ghost:hover, button.remove:hover, .week-switch button:hover { background: #fff; }

.week-switch {
  align-items: end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
}

.week-switch button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  font-size: 22px;
  line-height: 1;
}

.week-switch input { min-width: 150px; }

nav button { border: 0; border-radius: 999px; padding: 8px 14px; }

nav button[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.jump {
  display: none;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

#plan {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.days { display: grid; gap: 12px; }

.day, .grocery, .panel, .empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.day { padding: 14px 16px 6px; }
.day.today { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

.today-flag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: 2px;
}

.day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 4px;
}

.weekday {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill {
  margin: 0;
  background: var(--paper);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}

.away { color: var(--warn); }

.meal-line {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.slot {
  display: grid;
  gap: 2px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meal-name { margin: 0; }
.meal-name.empty-meal { color: var(--muted); }
.meal-line .meta { margin: 2px 0 0; }

button.meal-open {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-weight: inherit;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}
button.meal-open:hover { filter: none; }
button.meal-open:hover .meal-name { color: var(--accent); }
.meal-open .meal-name,
.meal-open .meta,
.recipe-link { display: block; }
.recipe-link {
  margin-top: 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.recipe {
  width: min(460px, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  inset: 0 0 0 auto;
  margin: 0;
  border: 0;
  padding: 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: -16px 0 40px rgba(23, 33, 28, 0.12);
}
.recipe::backdrop { background: rgba(23, 33, 28, 0.28); }
.recipe-body {
  height: 100%;
  overflow: auto;
  padding: 22px 22px 40px;
}
.recipe-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  position: sticky;
  top: -22px;
  margin: -22px -22px 16px;
  padding: 22px 22px 12px;
  background: var(--card);
}
.recipe-top h2 { font-size: 28px; }
.recipe-top .ghost { flex: none; }
.recipe h3 { margin-top: 22px; font-size: 20px; }
.recipe-wait { margin: 18px 0; }
.ingredients {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.ingredients li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.ingredients .qty { color: var(--muted); white-space: nowrap; }
.steps {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 12px;
}

.minutes {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}

.meal-actions { display: flex; gap: 6px; justify-content: end; align-items: center; }
.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}
.icon-btn svg { width: 18px; height: 18px; display: block; }
.meal-line.is-picked { background: var(--accent-soft); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 12px; }
.meal-line.is-skipped .meal-name { color: var(--muted); }
.replace-bar {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  width: min(560px, calc(100% - 24px));
  padding: 10px 10px 10px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.replace-bar p { margin: 0; flex: 1; }
.replace-bar[hidden] { display: none !important; }
.skipped-flag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fff6ea;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
}
.calendar-scroll { overflow-x: auto; }
.calendar {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(64px, 1fr));
  gap: 6px;
  min-width: 560px;
}
.cal-head, .cal-slot {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-head { text-align: center; align-self: end; }
.cal-slot { align-self: center; }
.cal-cell {
  display: grid;
  gap: 4px;
  padding: 6px;
  background: var(--paper);
  border-radius: 12px;
}
.cal-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
  font-size: 11px;
}
.cal-field input {
  width: 100%;
  min-width: 0;
  padding: 6px 4px;
  text-align: center;
}
.slot-detail { margin: 2px 0 0; font-size: 11px; letter-spacing: 0; text-transform: none; font-weight: 600; }

.pantry { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.pantry h3 { font-size: 20px; }

.grocery {
  position: sticky;
  top: 78px;
  padding: 16px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}

.grocery h3 { margin-bottom: 4px; }

.shop-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--paper);
  border-radius: 14px;
}

.shop-tabs button {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
}

.shop-tabs button[aria-current="page"] {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 33, 28, 0.08);
}

.empty { padding: 28px; }
.empty h3 { margin-bottom: 6px; }

.settings {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.panel { padding: 16px; display: grid; gap: 12px; }
.panel h3 { margin-bottom: 2px; }
.panel .hint { margin-top: 0; }

.stack { display: grid; gap: 10px; }
.row {
  display: flex;
  gap: 10px;
  align-items: end;
  background: var(--paper);
  border-radius: 14px;
  padding: 10px;
}

.notes { margin-top: 4px; }

.person {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: var(--paper);
}

.person-head { display: flex; gap: 8px; align-items: end; }

.tags { position: relative; display: grid; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; }

.chip {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px 3px 10px;
  color: var(--ink);
  font-size: 14px;
}

.chip button {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0 2px;
  border-radius: 999px;
}

.suggest {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 220px;
  overflow: auto;
  box-shadow: var(--shadow);
}

.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 0;
}

.suggest button[aria-selected="true"], .suggest button:hover { background: var(--accent-soft); }

.banner {
  width: fit-content;
  max-width: min(1180px, calc(100% - 32px));
  position: sticky;
  top: 68px;
  z-index: 5;
  margin: 0 0 8px max(16px, calc((100% - 1180px) / 2));
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff6ea;
  color: var(--warn);
}

.banner.error { background: #fde8e8; color: var(--danger); }
.banner.ok { background: var(--accent-soft); color: var(--ok); }

.meta { color: var(--muted); font-size: 14px; }
.discount { color: var(--ok); font-size: 13px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
th.aisle {
  color: var(--ink);
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 16px;
  letter-spacing: -0.02em;
  text-transform: none;
  padding-top: 16px;
}
td.qty { white-space: nowrap; color: var(--muted); text-align: right; }
td .ghost { padding: 6px 10px; font-size: 13px; }
td .icon-btn { padding: 0; }
td.check { width: 28px; }
td.check input { width: 18px; height: 18px; accent-color: var(--accent); }
tr.done .item-name { color: var(--muted); text-decoration: line-through; }

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

@media (max-width: 900px) {
  .top, .toolbar, .week-actions, .card-head { flex-direction: column; align-items: stretch; }
  nav { align-self: stretch; }
  nav button { flex: 1; }
  #plan { grid-template-columns: 1fr; }
  .grocery { position: static; max-height: none; }
  .jump { display: inline-flex; justify-content: center; }
  .meal-line { grid-template-columns: 1fr auto; }
  .slot { grid-column: 1 / -1; margin-bottom: -6px; }
  .row { flex-direction: column; align-items: stretch; }
}

@media print {
  .top, .week-actions, .meal-actions, .recipe, .recipe-link, .replace-bar, #banner, #status { display: none !important; }
  body { background: #fff; }
  #plan { display: block; }
  .grocery { position: static; max-height: none; box-shadow: none; }
  .day, .grocery { break-inside: avoid; }
}
