/* Recipe Box — phone-first, high-contrast, one column. */
:root {
  --bg: #ffffff;
  --surface: #f3f5f2;
  --text: #111a14;
  --muted: #4b564f;
  --line: #d3d9d4;
  --primary: #0a6b3d;
  --primary-dark: #07522e;
  --primary-soft: #e3f1e8;
  --on-primary: #ffffff;
  --danger: #b42318;
  --warn-bg: #fff4d6;
  --warn-text: #5c4100;
  --done: #6b746e;
  --radius: 14px;
  --tap: 56px;
  --nav-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  flex: none; width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  border: 0; background: transparent; color: var(--primary); cursor: pointer;
}
.icon-btn:active { background: var(--primary-soft); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 16px; max-width: 640px; margin: 0 auto; outline: none; }

/* ---------- bottom tabs (reachable with a thumb) ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--bg); border-top: 1px solid var(--line);
}
.tabs a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
}
.tabs svg { width: 28px; height: 28px; }
.tabs a.active { color: var(--primary); }
.tabs a.active::before {
  content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--primary);
}
.count {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--primary); color: var(--on-primary);
  font-size: 13px; line-height: 22px; text-align: center;
}

/* sticky action bar above the tabs */
.actionbar {
  position: fixed; left: 0; right: 0; z-index: 15;
  bottom: calc(var(--nav-h) + var(--safe-b));
  padding: 10px 16px; background: var(--bg); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 14px rgba(0,0,0,.06);
}
.actionbar .btn { width: 100%; max-width: 608px; margin: 0 auto; display: flex; }
body.has-actionbar main { padding-bottom: 96px; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius);
  border: 2px solid var(--primary); background: var(--bg); color: var(--primary);
  font-weight: 700; font-size: 18px; text-decoration: none; cursor: pointer;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:active { background: var(--primary-dark); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.quiet { border-color: var(--line); color: var(--text); }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }
.stack > * + * { margin-top: 12px; }

label.field { display: block; font-weight: 700; margin-bottom: 14px; }
label.field > span.hint { display: block; font-weight: 400; color: var(--muted); font-size: 16px; }
input[type=text], input[type=password], input[type=search], input[type=url], input[type=number], textarea {
  display: block; width: 100%; margin-top: 6px;
  min-height: var(--tap); padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg);
  font-size: 18px; /* 16px+ stops iPhones zooming in */
}
textarea { min-height: 150px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

h2 { font-size: 26px; line-height: 1.2; margin: 4px 0 12px; }
h3 { font-size: 20px; margin: 24px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 16px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

/* ---------- banner & toast ---------- */
.banner {
  margin: 0; padding: 12px 16px; background: var(--warn-bg); color: var(--warn-text);
  font-weight: 600; font-size: 16px; text-align: center;
}
.toast {
  position: fixed; left: 16px; right: 16px; z-index: 50;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  max-width: 480px; margin: 0 auto; padding: 14px 18px; border-radius: 12px;
  background: #16211a; color: #fff; font-weight: 600; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  pointer-events: none;
}

/* ---------- recipe list ---------- */
.search { margin: 0 0 12px; }
.search input { margin: 0; }
.rlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rlist li { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.rlist a.rname {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  min-height: 68px; padding: 10px 4px; color: var(--text); text-decoration: none;
}
.rlist a.rname strong { font-size: 19px; font-weight: 650; }
.rlist a.rname span { font-size: 15px; color: var(--muted); }
.pick {
  flex: none; width: 64px; display: grid; place-items: center;
  border: 0; background: transparent; cursor: pointer; padding: 0;
}
.box {
  width: 32px; height: 32px; border-radius: 8px; border: 2.5px solid var(--muted);
  display: grid; place-items: center; background: var(--bg);
}
.pick[aria-pressed="true"] .box { background: var(--primary); border-color: var(--primary); }
.pick[aria-pressed="true"] .box::after {
  content: ""; width: 9px; height: 16px; margin-top: -4px;
  border: solid #fff; border-width: 0 3.5px 3.5px 0; transform: rotate(45deg);
}
.empty { text-align: center; padding: 32px 8px; }
.empty .btn { margin-top: 8px; }

/* ---------- single recipe ---------- */
.servings {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0 4px;
}
.servings .lbl { font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--primary);
  background: var(--bg); color: var(--primary); font-size: 28px; font-weight: 700; line-height: 1; cursor: pointer;
}
.stepper button:active { background: var(--primary-soft); }
.stepper output { min-width: 44px; text-align: center; font-size: 24px; font-weight: 800; }
.scaled-note { font-size: 15px; color: var(--muted); margin: 6px 2px 0; }
.ings { list-style: none; padding: 0; margin: 0; }
.ings li { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.ings b { font-weight: 800; }
.steps { padding-left: 0; margin: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 8px 0 12px 44px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 8px;
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff;
  font-weight: 800; font-size: 16px; display: grid; place-items: center;
}
.source { word-break: break-all; }

/* ---------- grocery list ---------- */
.additem { display: flex; gap: 8px; margin-bottom: 16px; }
.additem input { margin: 0; flex: 1; }
.additem .btn { flex: none; padding: 0 18px; }
.glist { list-style: none; margin: 0; padding: 0; }
.glist li { border-bottom: 1px solid var(--line); }
.gitem {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  min-height: 64px; padding: 10px 4px; border: 0; background: transparent; cursor: pointer;
}
.gitem .box { flex: none; }
.gitem .txt { flex: 1; min-width: 0; }
.gitem .txt strong { display: block; font-size: 20px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.gitem .txt span { display: block; font-size: 14px; color: var(--muted); }
.gitem[aria-pressed="true"] .box { background: var(--done); border-color: var(--done); }
.gitem[aria-pressed="true"] .box::after {
  content: ""; width: 9px; height: 16px; margin-top: -4px;
  border: solid #fff; border-width: 0 3.5px 3.5px 0; transform: rotate(45deg);
}
.gitem[aria-pressed="true"] .txt strong { color: var(--done); text-decoration: line-through; text-decoration-thickness: 2px; font-weight: 500; }
.gsection {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 24px 0 4px; font-size: 15px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.updated { text-align: center; font-size: 14px; color: var(--muted); margin: 16px 0; }

/* ---------- add/edit form ---------- */
.readback { list-style: none; padding: 0; margin: 6px 0 0; font-size: 16px; }
.readback li { display: grid; grid-template-columns: 64px 64px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.readback .q { font-weight: 800; }
.readback .u { color: var(--primary); font-weight: 700; }
.readback .warn { color: var(--danger); }
details.paste { margin-bottom: 20px; }
details.paste summary {
  list-style: none; cursor: pointer; min-height: var(--tap);
  display: flex; align-items: center; font-weight: 700; color: var(--primary);
}
details.paste summary::-webkit-details-marker { display: none; }
details.paste summary::before { content: "▸"; margin-right: 8px; transition: transform .15s; }
details.paste[open] summary::before { transform: rotate(90deg); }
.notice { background: var(--primary-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-weight: 600; }

/* ---------- make-list sheet ---------- */
.mk { list-style: none; padding: 0; margin: 0 0 8px; }
.mk li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mk li .n { font-weight: 700; flex: 1; min-width: 0; }
.mk li .n small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.preview { list-style: none; padding: 0; margin: 0; columns: 1; }
.preview li { padding: 6px 0; border-bottom: 1px dashed var(--line); }

.login { padding-top: 8vh; }
.login h2 { font-size: 30px; }
