/* Calm "journal" theme: paper background, soft pastels, serif headings. */

:root {
  --bg: #f6f3ee;
  --paper: #fffdf9;
  --ink: #2e3135;
  --muted: #8b8f96;
  --line: #e8e2d8;
  --shadow: 0 1px 2px rgba(46, 49, 53, 0.04), 0 6px 18px rgba(46, 49, 53, 0.05);

  --accent: #5f7f6c;        /* sage */
  --accent-soft: #e6eee8;
  --button: #2e3135;
  --button-ink: #fffdf9;

  --office: #4a6fa5;        /* blue = office day */
  --office-soft: #e3ebf7;
  --school: #4f8a5b;        /* green = school tomorrow */
  --school-soft: #e1f0e3;
  --cozy-soft: #f7e6da;
  --cozy-ink: #9a5a35;
  --fresh-soft: #dff0ea;
  --fresh-ink: #3e7a64;
  --neutral-soft: #ece9f3;
  --special-soft: #f3e8f5;
  --special-ink: #7d4f88;

  --warn-bg: #fbf1dc;
  --warn-ink: #7a5a1c;
  --error: #b3413a;
  --radius: 16px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d1f;
    --paper: #24272a;
    --ink: #ece8e1;
    --muted: #9a9ea5;
    --line: #34383c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --accent: #9cbfa9;
    --accent-soft: #2c3a31;
    --button: #ece8e1;
    --button-ink: #1b1d1f;
    --office: #8fb1e3;
    --office-soft: #26334a;
    --school: #8fcf9c;
    --school-soft: #243a29;
    --cozy-soft: #43312a;
    --cozy-ink: #f0bf9f;
    --fresh-soft: #22392f;
    --fresh-ink: #9fd8bf;
    --neutral-soft: #322f3c;
    --special-soft: #3a2c40;
    --special-ink: #e0b8ea;
    --warn-bg: #3a3122;
    --warn-ink: #f0d39a;
    --error: #ff9a8f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}

a { color: var(--accent); }
h1, h2, h3, .title, .dow, .meal-main, .store-name { font-family: var(--serif); font-weight: 600; }

/* ---------- header ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.top h1 { margin: 0 0 12px; font-size: 1.5rem; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 8px 14px 12px;
  font: inherit;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1480px; margin: 0 auto; padding: 24px; }

/* ---------- shared bits ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2, .card h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.card h2 { font-size: 1.25rem; }
.card h3 { font-size: 1.1rem; }
.step {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 0.8rem var(--sans);
}
.hint { color: var(--muted); margin: 0 0 12px; font-size: 0.9rem; }
.muted { color: var(--muted); font-size: 0.85em; }
.label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.label:first-child { margin-top: 0; }
.label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.empty { color: var(--muted); font-style: italic; }

button.primary, button.secondary, a.secondary, label.secondary {
  font: 500 0.92rem var(--sans);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.2;
}
button.primary { background: var(--button); color: var(--button-ink); border: 0; }
button.secondary, a.secondary, label.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
button.secondary:hover, a.secondary:hover { border-color: var(--muted); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; font-weight: 500; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="text"], input[type="date"], textarea, select {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  width: 100%;
}
input[type="date"] { width: auto; }
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 120px; resize: vertical; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.9rem; }

.chip { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 0.75rem; background: var(--neutral-soft); }
.chip.special { background: var(--special-soft); color: var(--special-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.warnings { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 16px; margin-bottom: 14px; font-size: 0.92rem; }
.warnings ul { margin: 4px 0 0; padding-left: 18px; }
.error { color: var(--error); margin-top: 8px; }

details summary { cursor: pointer; color: var(--accent); margin-top: 12px; font-size: 0.9rem; }
pre.briefing { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 12px; font-size: 0.8rem; max-height: 320px; overflow: auto; }

/* ---------- week board ---------- */

.board-wrap { margin-bottom: 24px; }
.board-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.title { margin: 0 0 6px; font-size: 1.8rem; letter-spacing: -0.015em; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.key::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.k-office::before { background: var(--office); }
.k-school::before { background: var(--school); }
.k-off::before { background: var(--line); }

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(165px, 1fr));
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
}

.day {
  scroll-snap-align: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
/* Color strip along the top: blue for office, green for school, both = split */
.day::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: transparent; }
.day.is-office::before { background: var(--office); }
.day.is-school::before { background: var(--school); }
.day.is-office.is-school::before { background: linear-gradient(90deg, var(--office) 50%, var(--school) 50%); }
.day.off { background: transparent; box-shadow: none; border-style: dashed; }
.day.off .day-head, .day.off .note { opacity: 0.6; }

.day-head { display: grid; gap: 2px; }
.dow { font-size: 1.35rem; }
.date { color: var(--muted); font-size: 0.85rem; }
.wx { font-size: 0.85rem; color: var(--ink); }
.mood { justify-self: start; border-radius: 999px; padding: 1px 9px; font-size: 0.72rem; background: var(--neutral-soft); }
.mood.cozy { background: var(--cozy-soft); color: var(--cozy-ink); }
.mood.fresh { background: var(--fresh-soft); color: var(--fresh-ink); }

.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  background: var(--paper);
}
.pill input { color: inherit; appearance: none; width: 8px; height: 8px; border-radius: 50%; margin: 0; background: var(--line); }
.pill:has(input:checked) input { background: currentColor; }
.p-dinner:has(input:checked) { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.p-office:has(input:checked) { color: var(--office); background: var(--office-soft); border-color: transparent; }
.p-school:has(input:checked) { color: var(--school); background: var(--school-soft); border-color: transparent; }

.note { font-size: 0.85rem; padding: 6px 9px; }

.meal { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; }
.meal-main { font-size: 1.1rem; line-height: 1.25; }
.meal-sides { font-size: 0.88rem; margin-top: 2px; }
.ingredients { margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 3px 10px; }
.ingredients li::before { content: "· "; }
.meal-why { font-size: 0.8rem; color: var(--muted); font-style: italic; margin-top: 8px; }
.meal-actions { display: flex; gap: 14px; margin-top: 10px; font-size: 0.85rem; align-items: center; }
.change-input { margin-top: 8px; font-size: 0.85rem; }
.meal-empty { border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted); font-style: italic; font-size: 0.9rem; }

.board-actions { margin-top: 14px; }

/* ---------- Claude + shopping ---------- */

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.duo textarea { min-height: 90px; }

.shop-grid { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 28px; margin-top: 10px; }
.store-name { font-size: 1.4rem; margin-bottom: 4px; }
.sales { list-style: none; padding: 0; margin: 0 0 8px; }
.sales li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.sales li span { flex: 1; }

.checklist { list-style: none; padding: 0; margin: 0; columns: 2 220px; column-gap: 28px; }
.checklist li { padding: 6px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.checklist label { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.checklist input { accent-color: var(--accent); }
.checklist .done { text-decoration: line-through; color: var(--muted); }

/* ---------- other tabs ---------- */

main.narrow { max-width: 820px; }
.dish { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dish:last-child { border-bottom: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--button);
  color: var(--button-ink);
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- smaller screens ---------- */

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(7, 220px); }
}
@media (max-width: 760px) {
  main { padding: 16px; }
  .top { padding: 12px 16px 0; }
  .duo, .shop-grid { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(7, 78vw); }
  .title { font-size: 1.5rem; }
}
