:root {
  --bg: #fffaf3;
  --surface: #ffffff;
  --surface-2: #f6ede0;
  --text: #2a2018;
  --muted: #7a6a5a;
  --border: #eadfce;
  --accent: #d9480f;
  --accent-contrast: #ffffff;
  --accent-soft: #ffe8d9;
  --ok: #3f7d20;
  --ok-soft: #e3f2d8;
  --warn: #9a6700;
  --warn-soft: #fff3cd;
  --danger: #b42318;
  --danger-soft: #fde4e1;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120e;
    --surface: #221b15;
    --surface-2: #2d241c;
    --text: #f3ebe2;
    --muted: #b3a393;
    --border: #3a2f25;
    --accent: #ff8a4c;
    --accent-contrast: #1a0f08;
    --accent-soft: #42261a;
    --ok: #8bd45f;
    --ok-soft: #1f3314;
    --warn: #facc15;
    --warn-soft: #3a3012;
    --danger: #f87171;
    --danger-soft: #3d1a17;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 48px; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; }
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.empty { color: var(--muted); font-style: italic; }

/* ---------- top bar and navigation */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.brand { font-weight: 800; letter-spacing: -.01em; }
.brand em { font-style: normal; color: var(--accent); }
.topbar form { margin: 0; }

.nav { display: flex; gap: 4px; overflow-x: auto; padding-top: 6px; padding-bottom: 6px; }
.nav a {
  flex: 1 0 auto; display: flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 14px;
  border-radius: 10px; text-decoration: none; font-weight: 700;
  color: var(--muted);
}
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar + main.wrap { margin-top: 16px; }

/* ---------- blocks */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.narrow { max-width: 320px; margin: 0 auto; }
.hero { text-align: center; padding: 32px 0 8px; }

.flash {
  background: var(--ok-soft); color: var(--ok);
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; font-weight: 600;
}
.flash.error { background: var(--danger-soft); color: var(--danger); }

.chip {
  display: inline-block; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 600;
}

/* ---------- forms */
input, select, textarea {
  font: inherit; color: inherit;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .875rem; font-weight: 600; color: var(--muted); }
label input, label select, label textarea { color: var(--text); font-weight: 400; font-size: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 700;
  min-height: 44px; padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.small { padding: 4px 12px; font-size: .875rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }

/* img-input: paste/drop/pick an image (static/image-input.js, templates/_image_input.html) */
.img-input { display: grid; gap: 8px; max-width: 480px; }
.img-input [hidden] { display: none !important; }
.img-input .img-zone {
  min-height: 88px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: text;
  caret-color: transparent;
  -webkit-user-select: text;
  user-select: text;
}
.img-input .img-zone:empty::before { content: attr(data-placeholder); pointer-events: none; }
.img-input .img-zone:focus,
.img-input.over .img-zone { outline: 3px solid var(--accent); outline-offset: 2px; border-style: solid; }
.img-input.over .img-zone { background: var(--accent-soft); }
.img-input.busy .img-zone { opacity: .6; }
.img-input .img-preview {
  display: block;
  max-width: min(100%, 200px);
  max-height: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: contain;
  background: var(--surface-2);
}
.img-input .img-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.img-input .img-status { margin: 0; min-height: 1.25em; font-size: .9rem; color: var(--muted); }
.img-input .img-status.error { color: var(--danger); }

/* receitas */
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
a:focus-visible, button:focus-visible, summary:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; flex: none; accent-color: var(--accent); }

.alert-bar { background: var(--warn-soft); border-top: 1px solid var(--border); }
.alert-bar a {
  display: flex; align-items: center; min-height: 44px;
  color: var(--warn); font-weight: 700; text-decoration: none;
}
.alert-bar a:hover { text-decoration: underline; }
.flash.warn { background: var(--warn-soft); color: var(--warn); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.page-head h1 { margin: 8px 0; overflow-wrap: anywhere; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head form { margin: 0; }
.crumbs { margin: 4px 0 0; }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; }

.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.filters .search-row { display: flex; align-items: flex-end; gap: 8px; }
.filters .grow { flex: 1; min-width: 0; }
.filters summary, .danger-zone summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 2px 16px; }
label.check {
  flex-direction: row; align-items: center; gap: 10px;
  min-height: 44px; font-size: 1rem; font-weight: 400; color: var(--text);
}

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.recipe-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; box-shadow: var(--shadow);
}
.recipe-card .thumb {
  flex: none; width: 72px; height: 72px; border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: var(--surface-2);
}
.recipe-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { font-size: 1.8rem; }
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.recipe-name, .ingredient-name {
  display: inline-flex; align-items: center; min-height: 44px;
  font-weight: 700; color: var(--text); text-decoration: none; overflow-wrap: anywhere;
}
.recipe-name:hover, .ingredient-name:hover { color: var(--accent); }
.fav { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
a.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; text-decoration: none; }
.link-btn { display: inline-flex; align-items: center; min-height: 44px; }
.filter-note { margin: 0 0 12px; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 700; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.more { text-align: center; margin: 16px 0; }

.hero-img {
  display: block; width: 100%; max-height: 320px; object-fit: cover;
  border-radius: var(--radius); margin: 8px 0;
}
.recipe h2 { margin-top: 24px; }
.ing-table { width: 100%; border-collapse: collapse; }
.ing-table th { text-align: left; font-size: .8rem; color: var(--muted); padding: 6px 8px; }
.ing-table td { padding: 10px 8px; border-top: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.ing-table td:first-child { white-space: nowrap; font-weight: 600; }
.ing-table td a { color: var(--text); }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.prose { white-space: pre-line; overflow-wrap: anywhere; }
.danger-zone { margin-top: 32px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 14px 12px; }
.danger-zone summary { color: var(--danger); }

.recipe-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 12px; margin: 0; }
.recipe-form legend, form fieldset legend { font-weight: 700; padding: 0 6px; }
form fieldset { min-width: 0; }
form textarea { resize: vertical; }
.num-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ing-rows { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 14px; }
.ing-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding-bottom: 14px; border-bottom: 1px dashed var(--border);
}
.ing-row .ing-name, .ing-row .ing-note, .ing-row .ing-remove { grid-column: 1 / -1; }
.ing-row .ing-remove { justify-self: start; }
@media (min-width: 720px) {
  .ing-row { grid-template-columns: 2fr 90px 1.2fr 1.6fr auto; align-items: center; padding-bottom: 0; border: 0; }
  .ing-row .ing-name, .ing-row .ing-note, .ing-row .ing-remove { grid-column: auto; }

/* semana */
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.weekbar .btn { min-width: 44px; font-size: 1.4rem; padding: 0 12px; }
.weekbar-gap { min-width: 44px; }
.btn.icon { min-width: 44px; padding: 0; }
.weekbar-mid { display: flex; flex-direction: column; align-items: center; text-align: center; }
.weekbar-mid h1 { margin: 0; }
.weekbar-mid a { display: inline-flex; align-items: center; min-height: 44px; font-size: .875rem; font-weight: 700; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin: 0 0 16px; }
.tabs a {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 44px; border-radius: 9px; text-decoration: none; font-weight: 700; color: var(--muted);
}
.tabs a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; }

.flash.warn { background: var(--warn-soft); color: var(--warn); }
.badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 1px 8px; font-size: .75rem; font-weight: 700;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 > * { min-width: 0; }

.day { margin-bottom: 12px; padding: 10px 12px; scroll-margin-top: 8px; }
.day h2 { margin: 0 0 4px; font-size: 1rem; }
.slot {
  display: grid; grid-template-columns: 4.2rem 1fr; gap: 8px; align-items: start;
  min-height: 52px; padding: 8px 4px; border-top: 1px solid var(--border);
  color: inherit; text-decoration: none;
}
.slot:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
.slot-name { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding-top: 3px; }
.slot-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.slot-empty { color: var(--muted); font-size: .9rem; padding-top: 2px; }
.entry { display: flex; gap: 10px; align-items: center; min-width: 0; }
.entry-text { display: flex; flex-direction: column; min-width: 0; }
.entry-text strong, .prep-body strong { overflow-wrap: anywhere; }
.entry-meta { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.thumb.ph { display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; }

.entry-edit .entry { flex-wrap: wrap; }
.chosen { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; padding: 6px 12px; background: var(--ok-soft); color: var(--ok); border-radius: 10px; font-weight: 600; }
.chosen[hidden] { display: none; }
.picker-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pick {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 4px 8px;
  text-align: left; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}

.checklist { list-style: none; margin: 0; padding: 0; }
.gitem { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.gitem form { margin: 0; }
.gitem form:not(.gform) { flex: none; }
.gform { flex: 1; min-width: 0; margin: 0; }
.gcheck {
  display: flex; width: 100%; align-items: center; gap: 12px; min-height: 52px; padding: 6px 4px;
  text-align: left; font: inherit; color: var(--text); background: none; border: 0; cursor: pointer;
}
.gcheck:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
.gbox {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border: 2px solid var(--accent); border-radius: 6px; color: var(--accent-contrast); font-weight: 800; line-height: 1;
}
.gitem.done .gbox { background: var(--accent); }
.gitem.done .gbox::after { content: "✓"; }
.gtext { display: flex; flex-direction: column; min-width: 0; }
.gname { font-weight: 600; overflow-wrap: anywhere; }
.gqty { color: var(--muted); }
.guse { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.gitem.done { opacity: .55; }
.gitem.done .gname, .gitem.done .gqty { text-decoration: line-through; }
.staples { margin: 16px 0; }
.staples summary { display: flex; align-items: center; min-height: 44px; font-weight: 700; cursor: pointer; }
.extra-form { margin-top: 12px; }

.dayhead { margin: 12px 0 0; font-size: .9rem; color: var(--muted); }
.preps { list-style: none; margin: 0; padding: 0; }
.prep, .suggestion { display: flex; align-items: center; gap: 8px; min-height: 52px; border-bottom: 1px solid var(--border); }
.prep form, .suggestion { margin: 0; }
.suggestion { justify-content: space-between; padding: 6px 0; }
.prep-check { width: 44px; height: 44px; flex: none; font-size: 1.6rem; line-height: 1; color: var(--accent); background: none; border: 0; cursor: pointer; }
.prep-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.prep.done .prep-body strong { text-decoration: line-through; color: var(--muted); }

@media (min-width: 720px) {
  .slot { grid-template-columns: 6rem 1fr; }
  .slot-body { flex-direction: row; flex-wrap: wrap; gap: 8px 24px; }
}
