/* Shared styles for the admin page and Mom's cookbook.
   Monochrome like tokyo-trip; green = saved/done, red = delete/errors, amber = needs a look. */
:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #f8f8f8;
  --ink: #111111;
  --ink-2: #4a4a4a;
  --muted: #737373;
  --line: #e5e5e5;
  --accent: #111111;
  --on-accent: #ffffff;
  --accent-soft: #ececec;
  --good: #1f8a4c;
  --good-soft: #e6f4ec;
  --bad: #d33a2c;
  --bad-soft: #fbe9e7;
  --warn: #9a6400;
  --warn-soft: #fdf3dc;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b;
    --surface: #171717;
    --surface-2: #121212;
    --ink: #f2f2f2;
    --ink-2: #bdbdbd;
    --muted: #8c8c8c;
    --line: #2a2a2a;
    --accent: #f2f2f2;
    --on-accent: #111111;
    --accent-soft: #262626;
    --good: #4ccb7f;
    --good-soft: #13261b;
    --bad: #ff6b5e;
    --bad-soft: #2a1715;
    --warn: #f0b44c;
    --warn-soft: #2a2213;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 80px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: #111; color: #fff; /* black in both modes */
}
.topbar h1 { font-size: 17px; margin: 0; }
.topbar button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 999px; padding: 4px 12px; cursor: pointer; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 16px 0;
}
.card h2 { font-size: 17px; margin: 0 0 4px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); min-width: 0;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .grid3 { gap: 6px; } .grid3 label.field > span { font-size: 12px; } }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 9px 16px; cursor: pointer; font-weight: 600;
}
a.btn { color: inherit; text-decoration: none; display: inline-block; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }

.status { padding: 10px 12px; border-radius: 10px; margin: 12px 0; font-size: 14px; white-space: pre-wrap; }
.status.info { background: var(--accent-soft); }
.status.good { background: var(--good-soft); color: var(--good); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.warn { background: var(--warn-soft); color: var(--warn); }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--ink-2); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: var(--good-soft); color: var(--good); }

.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.thumbs figure { margin: 0; position: relative; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.thumbs button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); cursor: pointer; font-size: 13px; line-height: 22px; padding: 0; }

.ing { display: grid; grid-template-columns: 70px 70px minmax(0, 1fr) minmax(0, .8fr) 32px; gap: 6px; align-items: start; margin: 6px 0; }
.ing input { padding: 7px 8px; }
.ing .orig { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin: -2px 0 4px; }
.ing .x { border: 0; background: transparent; color: var(--bad); font-size: 18px; cursor: pointer; padding: 6px 0; }
@media (max-width: 520px) {
  .ing { grid-template-columns: 60px 60px minmax(0, 1fr) 28px; }
  .ing .note { grid-column: 1 / -2; }
}

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cand { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.cand .snip { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; max-height: 4.5em; overflow: hidden; }
.cand img { max-width: 120px; max-height: 120px; border-radius: 8px; }

details > summary { cursor: pointer; font-weight: 600; }

/* ---------- Mom's cookbook (body.book) ----------
   Built for weak eyesight: large text (rem, scaled by the A−/A+ buttons), strong contrast,
   tap targets of at least 48 px, one thing per line. */
html.size-1 { font-size: 18px; }
html.size-2 { font-size: 21px; }   /* default */
html.size-3 { font-size: 25px; }
html.size-4 { font-size: 30px; }

body.book {
  font-size: 1rem; line-height: 1.5;
  --muted: #4d4d4d; --ink-2: #2b2b2b; --line: #d4d4d4;
}
@media (prefers-color-scheme: dark) {
  body.book { --muted: #b8b8b8; --ink-2: #dedede; --line: #3a3a3a; }
}
body.book .wrap { padding: 12px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
body.book .hint { font-size: .85rem; color: var(--muted); }
body.book .card { padding: 18px; }
body.book .status { font-size: .9rem; }

/* Top bar: fixed pixel sizes so it fits at any text size */
body.book .topbar {
  position: sticky; top: 0; z-index: 5; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; min-height: 60px;
}
body.book .topbar h1 { flex: 1; font-size: 20px; padding-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back {
  min-width: 96px; min-height: 44px; text-align: left; background: none !important; border: 0 !important;
  color: #fff; font-size: 19px; font-weight: 600; padding: 0 6px !important; cursor: pointer;
}
.textsize { display: flex; gap: 6px; min-width: 96px; justify-content: flex-end; }
.textsize button {
  width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid #fff; background: transparent; color: #fff;
  font-weight: 700; cursor: pointer; padding: 0; line-height: 1;
}
.textsize button:first-child { font-size: 15px; }
.textsize button:last-child { font-size: 22px; }
.textsize button:disabled { opacity: .35; }

/* Search */
body.book .search-box { position: relative; margin: 6px 0 10px; }
body.book #search {
  font-size: 1rem; padding: .6em .8em .6em 2.2em; min-height: 56px; border-width: 2px; border-color: var(--line);
  background: var(--surface); border-radius: 14px;
}
body.book .search-box::before {
  content: ''; position: absolute; left: .85em; top: 50%; width: .7em; height: .7em; margin-top: -.45em;
  border: 2.5px solid var(--muted); border-radius: 50%; pointer-events: none;
}
body.book .search-box::after {
  content: ''; position: absolute; left: 1.42em; top: 50%; width: .35em; height: 2.5px; margin-top: .3em;
  background: var(--muted); transform: rotate(45deg); pointer-events: none;
}

/* Category buttons */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  border: 2px solid var(--line); background: var(--surface); border-radius: 999px;
  min-height: 48px; padding: 0 .8em; font-size: .9rem; font-weight: 600; cursor: pointer; color: inherit; text-decoration: none;
  display: inline-flex; align-items: center;
}
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Recipe list: title + one line of facts, nothing else */
.recipe-list { list-style: none; margin: 0; padding: 0; }
.recipe-list li { margin: 12px 0; }
.recipe-card {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 2px solid var(--line); padding: 16px 18px; color: inherit; text-decoration: none; min-height: 72px;
}
.recipe-card .text { flex: 1; min-width: 0; }
.recipe-card strong { display: block; font-size: 1.15rem; line-height: 1.3; }
.recipe-card .facts { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.recipe-card .arrow { font-size: 1.6rem; color: var(--muted); line-height: 1; }
.recipe-card:active { background: var(--accent-soft); }
.recipe-list .empty { color: var(--muted); padding: 24px 4px; font-size: 1rem; }
#list-info { margin: 4px 2px 0; }

/* Recipe page */
.recipe-title { font-size: 1.6rem; line-height: 1.2; margin: 10px 0 6px; }
#detail-view .desc { color: var(--ink-2); margin: 0 0 8px; }
#detail-view .facts { font-size: .95rem; font-weight: 600; color: var(--ink-2); margin: 0 0 4px; }
#detail-view h3 { font-size: 1.25rem; margin: 0 0 2px; }

.ingredients { list-style: none; margin: 8px 0 0; padding: 0; }
.ingredients li {
  display: grid; grid-template-columns: 1.6em minmax(0, 1fr); gap: .55em; align-items: start;
  padding: .55em 0; border-top: 1.5px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; min-height: 48px;
}
.ingredients li:first-child { border-top: 0; }
.ingredients li::before {
  content: ''; width: 1.15em; height: 1.15em; border: 2.5px solid var(--ink-2); border-radius: 6px; margin-top: .18em; box-sizing: border-box;
}
.ingredients li[aria-checked="true"]::before {
  background: var(--good) center / 70% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8.5l4 4 8-9' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  border-color: var(--good);
}
.ingredients li[aria-checked="true"] > span { color: var(--muted); text-decoration: line-through; }
.ingredients .qty { font-weight: 800; }
.ingredients .note { color: var(--muted); }

.steps { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step; display: grid; grid-template-columns: 1.9em minmax(0, 1fr); gap: .5em;
  padding: .7em .5em; margin: 0 -.5em; border-radius: 12px; line-height: 1.55; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.steps li::before {
  content: counter(step); width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9em;
}
.steps li.here { background: var(--warn-soft); outline: 2.5px solid var(--warn); }
.steps li.done { color: var(--muted); }
.steps li.done::before { background: var(--muted); }

.notes summary { font-size: 1rem; min-height: 44px; display: flex; align-items: center; }
.notes p { white-space: pre-wrap; color: var(--ink-2); margin: 10px 0 0; font-size: .9rem; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent); color: var(--on-accent); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); z-index: 10;
  font-size: 18px; font-weight: 600;
}
.toast .btn.primary { background: var(--on-accent); color: var(--accent); font-size: 18px; min-height: 44px; }

/* Photos */
.recipe-card .thumb {
  width: 4.2rem; height: 4.2rem; flex: none; border-radius: 12px; object-fit: cover; background: var(--accent-soft);
}
.recipe-card .thumb.none {
  display: block; background: var(--accent-soft) center / 55% no-repeat url("/icons/bowl.svg");
}
#detail-view .hero {
  display: block; width: calc(100% + 32px); margin: -12px -16px 6px; aspect-ratio: 4 / 3; height: auto; max-height: 45vh; object-fit: cover;
  background: var(--accent-soft);
}
@media (min-width: 600px) { #detail-view .hero { width: 100%; margin: 4px 0 6px; border-radius: var(--radius); } }
