/* Recipe Book — warm paper, high contrast, thumb-friendly.
   Built to be legible on a phone propped against a mixing bowl. */

:root {
  --paper:   #f7f5f2;
  --surface: #ffffff;
  --ink:     #1c1917;
  --muted:   #78716c;
  --line:    #e7e2db;
  --accent:  #c2410c;
  --accent-soft: #fdf0e7;
  --shadow:  0 1px 2px rgba(28,25,23,.06), 0 4px 12px rgba(28,25,23,.05);
  --radius:  14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #17150f;
    --surface: #23201a;
    --ink:     #f5f1ea;
    --muted:   #a8a29e;
    --line:    #35302a;
    --accent:  #fb923c;
    --accent-soft: #33251a;
    --shadow:  0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700; font-size: 17px; letter-spacing: -.01em; text-decoration: none;
}

.topbar .spacer { margin-left: auto; }

.wrap { max-width: 780px; margin: 0 auto; padding: 20px 18px 64px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer;
}

.btn:active { transform: scale(.98); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn-sm { padding: 7px 13px; min-height: 36px; font-size: 14px; }

.btn-quiet {
  border-color: transparent; background: transparent; color: var(--muted);
  font-weight: 500;
}

.btn-danger { color: #b91c1c; border-color: transparent; background: transparent; }

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=url], input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px;   /* 16px stops iOS zooming on focus */
}

textarea { resize: vertical; min-height: 92px; line-height: 1.5; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}

.field { margin-bottom: 16px; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; font-weight: 400; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.card h2 { margin: 0 0 14px; font-size: 15px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }

/* ---------------------------------------------------------------- library */

.searchbar { margin-bottom: 18px; }

.recipe-list { display: grid; gap: 12px; }

.recipe-card {
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.recipe-card .hit {
  display: flex; gap: 14px; align-items: center; flex: 1; min-width: 0;
  padding: 14px; text-decoration: none;
}

.recipe-card .hit:active { opacity: .7; }

.want {
  border: 0; background: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--muted);
  padding: 14px 16px; min-height: 44px;
}
.want.on { color: var(--accent); }

/* filter chips — "what should I cook tonight" */
.chips {
  display: flex; gap: 8px; overflow-x: auto; margin-bottom: 18px;
  padding-bottom: 4px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 550; text-decoration: none; white-space: nowrap;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .n { opacity: .55; margin-left: 3px; font-weight: 500; }

.thumb {
  width: 62px; height: 62px; flex: 0 0 auto;
  border-radius: 10px; object-fit: cover;
  background: var(--accent-soft);
  display: grid; place-items: center; font-size: 24px;
}

.recipe-card .body { min-width: 0; flex: 1; }

.recipe-card h3 { margin: 0 0 3px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }

.source { font-size: 13px; color: var(--muted); }

.meta { font-size: 13px; color: var(--muted); margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }

.stars { color: var(--accent); letter-spacing: 1px; }

/* ---------------------------------------------------------------- recipe page */

.recipe-head { margin-bottom: 20px; }
.recipe-head h1 { margin: 0 0 6px; font-size: 27px; line-height: 1.2; letter-spacing: -.02em; }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 650; letter-spacing: .02em;
}

.ingredients, .steps { margin: 0; padding-left: 20px; }
.ingredients li, .steps li { margin-bottom: 7px; }
.ingredients { list-style: none; padding-left: 0; }
.ingredients li { padding-left: 18px; position: relative; }
.ingredients li::before {
  content: ""; position: absolute; left: 3px; top: .62em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}

.adj-list { list-style: none; margin: 0; padding: 0; }

.adj-list li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.adj-list li:last-child { border-bottom: 0; padding-bottom: 0; }

.adj-kind {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--accent);
  background: var(--accent-soft); padding: 3px 8px; border-radius: 5px; margin-top: 1px;
}

.adj-list form { margin-left: auto; }

.cook-entry { padding: 14px 0; border-bottom: 1px solid var(--line); }
.cook-entry:last-child { border-bottom: 0; padding-bottom: 0; }
.cook-entry .when { font-weight: 650; }
.cook-entry .verdict { color: var(--muted); margin-top: 3px; }
.cook-entry ul { margin: 8px 0 0; padding-left: 18px; font-size: 15px; }

.gallery { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.gallery img { width: 84px; height: 84px; object-fit: cover; border-radius: 9px; }

/* ---------------------------------------------------------------- cook mode */

.card.remember { border-left: 3px solid var(--accent); }
.card.suggested { border-left: 3px solid #d97706; }
.card.warn { border-left: 3px solid #b91c1c; }
.card.warn p { margin: 0; }

summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: " ▾"; color: var(--muted); font-size: 13px; }
details[open] summary::after { content: " ▴"; }

/* Checklists get a big hit area — you're tapping these with a wet thumb. */
.check li { padding: 0; }
.check label {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 9px 0; margin: 0; cursor: pointer;
  font-size: 16px; font-weight: 400; color: var(--ink);
}
.check input[type=checkbox] { width: 21px; height: 21px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.check li.done span { opacity: .42; text-decoration: line-through; }
.ingredients.check li::before { display: none; }

label.inline {
  display: flex; gap: 10px; align-items: center;
  font-size: 15px; font-weight: 400; color: var(--ink); margin: 0;
}
label.inline input { width: 20px; height: 20px; accent-color: var(--accent); }
label.keep { padding: 9px 0; align-items: flex-start; }

.photo-btn { cursor: pointer; }
.photo-btn.busy { opacity: .6; pointer-events: none; }

/* the mid-cook conversation */
.turn { display: flex; flex-direction: column; margin-bottom: 12px; }
.turn.user { align-items: flex-end; }
.turn.assistant { align-items: flex-start; }

.bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 16px;
  font-size: 15.5px; line-height: 1.45; white-space: pre-wrap;
}
.turn.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.turn.assistant .bubble { background: var(--paper); border-bottom-left-radius: 5px; }

.turn-photo {
  max-width: 60%; border-radius: 12px; margin-bottom: 6px;
  display: block; height: auto;
}

.card.ask { position: sticky; bottom: 12px; z-index: 5; }

.ask-row { display: flex; gap: 8px; align-items: stretch; }
.ask-row .photo-btn { flex: 0 0 auto; padding: 11px 16px; font-size: 19px; }
.photo-btn.attached { background: var(--accent-soft); border-color: var(--accent); }

.ask details summary { font-size: 13px; color: var(--muted); padding: 4px 0; }

.gallery figure { margin: 0; position: relative; }
.gallery figure form { position: absolute; top: 2px; right: 2px; }
.gallery figure button {
  background: rgba(0,0,0,.55); color: #fff; border-radius: 50%;
  width: 26px; height: 26px; min-height: 0; padding: 0; line-height: 1;
}

.rating { display: flex; gap: 6px; flex-wrap: wrap; }
.rating label { margin: 0; flex: 1; }
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating span {
  display: block; text-align: center; padding: 11px 4px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); font-size: 13px; letter-spacing: -1px; cursor: pointer;
}
.rating input:checked + span {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}

.starters { list-style: none; margin: 0 0 12px; padding: 0; }
.starters li {
  padding: 9px 0; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 15px;
}
.starters li:last-child { border-bottom: 0; }

.done-card { border-left: 3px solid var(--accent); }
.done-card p { margin: 0 0 4px; font-size: 15px; }
.done-card p:last-child { margin-bottom: 0; }

.page-previews { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
.page-previews img {
  width: 92px; height: 118px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line);
}
.gallery.pages img { width: 128px; height: 164px; }

/* ---------------------------------------------------------------- shopping */

.pick { display: flex; align-items: center; padding: 0 2px 0 14px; margin: 0; cursor: pointer; }
.pick input { width: 21px; height: 21px; accent-color: var(--accent); }
.recipe-card.picked { border-color: var(--accent); background: var(--accent-soft); }

#shopbar {
  position: sticky; bottom: 14px; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; padding: 11px 14px;
  background: var(--ink); color: var(--paper);
  border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
#shopbar span { font-size: 15px; }
#shopbar .btn-quiet { color: var(--paper); opacity: .7; }
#shopbar .btn-primary { margin-left: auto; }

.shop { list-style: none; margin: 0; padding: 0; }
.shop label { align-items: baseline; }
.shop .qty {
  flex: 0 0 auto; min-width: 76px; font-variant-numeric: tabular-nums;
  font-weight: 650; color: var(--accent); font-size: 15px;
}
.shop .what { flex: 1; }
.shop .for { display: block; font-size: 12.5px; color: var(--muted); }
.shop .mixed {
  color: #b45309; font-weight: 700; cursor: help;
  margin-left: 3px; font-size: 13px;
}
.shop li.done .qty, .shop li.done .what { opacity: .4; text-decoration: line-through; }

/* ---------------------------------------------------------------- import */

.evidence {
  display: block; margin-top: 5px; padding-left: 10px;
  border-left: 2px solid var(--line);
  color: var(--muted); font-size: 14px; font-style: italic;
}

.qa { padding: 9px 0; border-bottom: 1px solid var(--line); }
.qa:last-child { border-bottom: 0; }
.qa .q { font-weight: 600; }
.qa .a { color: var(--muted); font-size: 15px; margin-top: 2px; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty p { margin: 0 0 18px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }

.muted { color: var(--muted); }
.stack > * + * { margin-top: 10px; }

/* ---------------------------------------------------------------- login */

.login { max-width: 340px; margin: 8vh auto 0; text-align: center; }
.login .mark { font-size: 54px; line-height: 1; margin-bottom: 14px; }
.login h1 { margin: 0 0 6px; font-size: 27px; letter-spacing: -.02em; }
.login .source { margin-bottom: 26px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login input[type=password] { text-align: center; }
.login .err { color: #b91c1c; font-size: 14px; margin: 0; }
.login .hint { margin-top: 18px; }

.was {
  display: block; font-size: 12.5px; color: var(--muted);
  text-decoration: line-through; margin-top: 2px;
}
.adj-list .for { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* items you added yourself, distinct from what the recipes asked for */
.shop li.mine { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; }
.shop li.mine .tick {
  border: 0; background: none; cursor: pointer; font-size: 20px;
  color: var(--accent); padding: 0 2px; line-height: 1;
}
.shop li.mine .what { flex: 1; }
.shop li.mine form:last-child { margin-left: auto; }
.shop li.mine.done .qty, .shop li.mine.done .what { opacity: .4; text-decoration: line-through; }
