/* Котоменю — warm pink and butter-yellow. Light / dark via <html data-theme> (set by js/theme.js). */

:root {
  --bg: #fff6f4;
  --surface: #ffffff;
  --surface-2: #fff0ea;
  --text: #3b2630;
  --muted: #8a6f79;
  --line: #f1dcd9;
  --primary: #e35d8a;
  --primary-press: #c94775;
  --primary-ink: #ffffff;
  --accent: #f6c445;
  --accent-soft: #fff3cf;
  --accent-ink: #4a3500;
  --danger: #c8324f;
  --shadow: 0 1px 2px rgba(120, 40, 70, .06), 0 4px 16px rgba(120, 40, 70, .06);
  --radius: 18px;
  --tabbar-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1c1418;
  --surface: #271c21;
  --surface-2: #31242a;
  --text: #f7e9ee;
  --muted: #b89ca7;
  --line: #3d2c33;
  --primary: #ff8db0;
  --primary-press: #ff6f9c;
  --primary-ink: #2a0f19;
  --accent: #f3c95a;
  --accent-soft: #3a2f16;
  --accent-ink: #2b2000;
  --danger: #ff7a90;
  --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.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
p { margin: 0; }
a { color: var(--primary); }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.error { color: var(--danger); font-size: 14px; min-height: 0; }
.error:empty { display: none; }

/* ---------- layout ---------- */

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen-head { display: flex; flex-direction: column; gap: 2px; padding: 4px 2px; }

.center-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.narrow { width: 100%; max-width: 400px; }

.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.brand img { border-radius: 22px; box-shadow: var(--shadow); }

.section { display: flex; flex-direction: column; gap: 8px; }
.section > h2 { padding: 0 4px; color: var(--muted); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabbar a {
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.tabbar a.on { color: var(--primary); font-weight: 600; }
.tab-icon { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar a.on .tab-icon { filter: none; opacity: 1; }

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

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.row-form { display: flex; gap: 8px; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

input, select, textarea {
  font: inherit;
  font-size: 16px;            /* iOS zooms into anything smaller */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  width: 100%;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; background: none; font-size: 18px; cursor: pointer;
}

.btn {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:active { background: var(--primary-press); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.segmented button {
  font: inherit; font-size: 14px; min-height: 40px; border: 0; border-radius: 9px;
  background: none; color: var(--muted); cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- lists, chips ---------- */

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
:root[data-theme="dark"] .chip { color: var(--accent); }

/* ---------- week preview ---------- */

.hello { flex-direction: row; align-items: center; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); }
.hello-cat { font-size: 40px; line-height: 1; }
.empty { align-items: center; text-align: center; padding: 32px 16px; }

.days { display: flex; flex-direction: column; gap: 10px; }
.day { gap: 6px; }
.day.today { border-color: var(--primary); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; }
.meal { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }

/* ---------- overlays ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 100;
  max-width: calc(100% - 32px);
}

dialog.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  color: var(--text);
  border-radius: 22px 22px 0 0;
}
dialog.sheet::backdrop { background: rgba(30, 10, 20, .4); }
.sheet-body { padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px); }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 22px; } }

.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- recipes ---------- */

.back { text-decoration: none; font-weight: 600; padding: 4px 2px; align-self: flex-start; }
.warn { color: #b8620b; }
:root[data-theme="dark"] .warn { color: var(--accent); }

.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; font: inherit; font-size: 14px; min-height: 36px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
}
.filter-chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }

.recipe-list { display: flex; flex-direction: column; gap: 10px; }
.recipe-card { flex-direction: row; align-items: center; gap: 12px; text-decoration: none; color: inherit; position: relative; padding: 12px; }
.recipe-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.card-rating { font-size: 18px; }

/* a food icon in a tile with cat ears */
.dish-tile {
  position: relative; flex: 0 0 auto; width: 56px; height: 56px; margin-top: 8px;
  border-radius: 16px; background: var(--accent-soft); display: grid; place-items: center; font-size: 30px;
}
.dish-tile::before, .dish-tile::after {
  content: ""; position: absolute; top: -8px; width: 18px; height: 18px; background: inherit;
  clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 3px;
}
.dish-tile::before { left: 6px; transform: rotate(-12deg); }
.dish-tile::after { right: 6px; transform: rotate(12deg); }
.dish-tile.main { background: #ffe1ea; }
.dish-tile.side { background: #e6f3e1; }
:root[data-theme="dark"] .dish-tile.main { background: #4a2532; }
:root[data-theme="dark"] .dish-tile.side { background: #263a27; }
.dish-tile.big { width: 76px; height: 76px; font-size: 42px; border-radius: 22px; }
.dish-tile.big::before, .dish-tile.big::after { width: 24px; height: 24px; top: -11px; }
.dish-tile span { position: relative; z-index: 1; }

.recipe-head { display: flex; gap: 14px; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1px; font-size: 14px; }
.fact .small { font-size: 11px; line-height: 1.2; }
.fact-icon { font-size: 18px; }
.notice { background: var(--accent-soft); border-color: transparent; gap: 4px; }

.section-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.section-head h2 { color: var(--muted); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stepper { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.stepper .btn { width: 36px; padding: 0; font-size: 20px; }
.amount { white-space: nowrap; font-weight: 600; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 14px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.tag.missing { background: #ffe0e5; color: var(--danger); }
:root[data-theme="dark"] .tag.missing { background: #4a2028; }

.steps { margin: 0; padding: 16px 16px 16px 36px; gap: 10px; }
.steps li { padding-left: 4px; }
.steps .chip { margin-left: 6px; }
.cook-btn { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); box-shadow: 0 6px 20px rgba(227, 93, 138, .35); }

.rating { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
.rate-buttons { display: flex; gap: 6px; }
.rate {
  -webkit-appearance: none; appearance: none; padding: 0; margin: 0;
  width: 48px; height: 44px; display: grid; place-items: center;
  font: 24px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  border-radius: 12px; border: 2px solid transparent; background: var(--surface-2); cursor: pointer;
  transition: transform .1s;
}
.rate.on { background: var(--accent-soft); border-color: var(--primary); transform: scale(1.08); }

/* cooking mode */
body.no-scroll { overflow: hidden; }
.cooking {
  position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column; gap: 12px;
}
.cooking-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: sticky; top: 0; background: var(--bg); padding: 4px 0; z-index: 1; }
.cooking-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.cooking-step { font-size: 20px; line-height: 1.45; cursor: pointer; counter-increment: step; }
.cooking-step p::before { content: counter(step) ". "; color: var(--primary); font-weight: 700; }
.cooking-step.done { opacity: .45; }
.cooking-step.done p { text-decoration: line-through; }
.btn.timer { align-self: flex-start; font-size: 17px; }
.btn.timer.running { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
details summary { cursor: pointer; font-weight: 600; }

/* checkboxes */
.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
input.check { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); flex: 0 0 auto; }

/* ---------- recipe editor ---------- */

.row-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
textarea { resize: vertical; line-height: 1.4; }
.chips-row.wrap { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; align-items: end; }
.field-check { min-height: 44px; }
.edit-list { display: flex; flex-direction: column; gap: 10px; }
.edit-item { gap: 8px; padding: 12px; }
.edit-row { display: flex; gap: 8px; align-items: center; }
.edit-row > input.num { width: 96px; flex: 0 0 auto; }
.edit-row > select { width: auto; flex: 0 0 auto; }
.move { display: flex; gap: 4px; margin-left: auto; }
.move .btn { width: 36px; padding: 0; }
.product-pick { flex: 1; justify-content: flex-start; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-pick.empty { color: var(--muted); border-style: dashed; }
.tag { display: inline-flex; align-items: center; gap: 4px; }
.tag-x { border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 0 2px; min-height: 0; }
select.tag-add { width: auto; min-height: 32px; padding: 4px 10px; border-radius: 999px; font-size: 14px; }
.edit-actions { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); display: flex; }
.edit-actions .btn { flex: 1; box-shadow: 0 6px 20px rgba(227, 93, 138, .35); }
.pick-list { max-height: 45vh; overflow-y: auto; }
.pick { width: 100%; text-align: left; background: none; border: 0; padding: 8px 0; font: inherit; color: var(--text); cursor: pointer; min-height: 44px; }
.screen-head.row-head { flex-direction: row; }

/* ---------- photos ---------- */

.dish-photo { flex: 0 0 auto; width: 56px; height: 56px; border-radius: 16px; object-fit: cover; background: var(--surface-2); }
.recipe-photo { width: 100%; height: auto; max-height: 340px; object-fit: cover; border-radius: var(--radius); background: var(--surface-2); }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hidden-input { display: none; }

/* ---------- the week plan ---------- */

.week-nav { display: flex; gap: 6px; align-items: center; }
.week-nav .btn { min-width: 40px; }
.day.out { opacity: .75; }
.day-tools { display: flex; align-items: center; gap: 6px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; min-width: 36px; min-height: 36px; cursor: pointer; border-radius: 10px; }
.cook-line { background: var(--accent-soft); border-radius: 10px; padding: 6px 10px; }
.cook-line.muted { background: var(--surface-2); }
.meal-row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; min-height: 44px; }
.meal-row > .muted:only-child { grid-column: 1 / -1; }
.day.out .meal-row { grid-template-columns: 1fr auto; }
.meal-label { line-height: 1.2; }
.meal-items { min-width: 0; }
.plan-empty {
  width: 100%; min-height: 44px; font: inherit; font-size: 15px; text-align: left; padding: 8px 12px; cursor: pointer;
  border: 1px dashed var(--line); border-radius: 12px; background: none; color: var(--primary);
}
.plan-empty.off { color: var(--muted); border-style: solid; background: var(--surface-2); }
.plan-item {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; font: inherit;
  color: inherit; background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 6px 10px;
}
.plan-item-body { display: flex; flex-direction: column; min-width: 0; }
.plan-title { font-weight: 600; line-height: 1.25; }
.plan-side { font-size: 14px; line-height: 1.25; }
.plan-meta { font-size: 13px; color: var(--muted); }
.plan-meta.warn { color: #b8620b; }
.dish-tile.mini { width: 36px; height: 36px; font-size: 20px; border-radius: 11px; margin-top: 5px; }
.dish-tile.mini::before, .dish-tile.mini::after { width: 12px; height: 12px; top: -5px; }
.dish-tile.mini::before { left: 4px; } .dish-tile.mini::after { right: 4px; }
.dish-photo.mini { width: 36px; height: 36px; border-radius: 11px; }
.pick-recipe { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.side-box { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; }
.segmented.auto button { padding: 0 4px; }
.list-row-pad { padding: 10px 0; border-bottom: 1px solid var(--line); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wd-table { display: flex; flex-direction: column; gap: 6px; }
.wd-row { display: grid; grid-template-columns: 32px 88px 1fr; gap: 8px; align-items: center; }
.sub-head { font-size: 15px; margin: 8px 0 0; }
.check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button.back { border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; min-height: 36px; }
.build-btn { align-self: stretch; }
.bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
