@font-face {
  font-family: "Bricolage";
  src: url("/static/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #F3F6F1;
  --card: #FFFFFF;
  --ink: #17231C;
  --muted: #5B6C62;
  --line: #D9E2DB;
  --basil: #2F6B47;
  --basil-ink: #FFFFFF;
  --basil-soft: #E2EEE5;
  --marker: #FFE45C;
  --tomato: #B9432C;
  --display: "Bricolage", ui-rounded, system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --tabs-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101712;
    --card: #19221C;
    --ink: #E7EEE9;
    --muted: #9CAEA3;
    --line: #2A3830;
    --basil: #77C493;
    --basil-ink: #0E1A12;
    --basil-soft: #1D3226;
    --marker: rgba(255, 223, 77, .38);
    --tomato: #F08A72;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--basil); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 2rem; line-height: 1.1; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }

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

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 18px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
}
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.view-head p { margin: 4px 0 0; color: var(--muted); }
.stack > * + * { margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ------------------------------------------------ controls */

label { display: block; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-weight: 400;
  font-size: 1rem;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--basil); outline: none; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); font-weight: 600;
}
.btn-primary { background: var(--basil); border-color: var(--basil); color: var(--basil-ink); }
.btn-danger { color: var(--tomato); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--basil); padding: 0 10px; }
.btn-wide { width: 100%; }
.btn:disabled { opacity: .55; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--card);
  display: inline-grid; place-items: center; font-size: 1.2rem; line-height: 1;
}
.form-error { color: var(--tomato); min-height: 1.2em; margin: 0; font-size: .9rem; }

/* ------------------------------------------------ sign in */

.login { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12vh) 24px 40px; }
.login-mark {
  width: 64px; height: 64px; border-radius: 18px; margin-bottom: 22px;
  background: var(--basil) url("/static/icons/basket.svg") center / 60% no-repeat;
}
.login-lead { color: var(--muted); margin: 8px 0 28px; font-size: 1.05rem; }

/* ------------------------------------------------ tabs */

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  height: var(--tabs-h); padding-top: 6px;
  border: 0; background: none; color: var(--muted);
  font-size: .75rem; font-weight: 600;
}
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--basil); }
.tabs button[aria-current="page"] svg { stroke-width: 2.1; }
.tab-count {
  position: absolute; top: 2px; left: calc(50% + 8px);
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--basil); color: var(--basil-ink); font-size: .7rem; line-height: 20px;
}

.offline {
  position: sticky; top: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 8px) 18px 8px;
  background: var(--marker); color: #2A2410; font-size: .875rem; font-weight: 600; text-align: center;
}

/* ------------------------------------------------ plan */

.week-switch { display: flex; gap: 8px; }
.days { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--line); }
.day {
  display: grid; grid-template-columns: 4.6rem 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 14px 2px; text-align: left;
  border: 0; border-bottom: 1.5px solid var(--line); background: none;
}
.day-name { font-family: var(--display); font-weight: 700; font-size: 1.6rem; line-height: 1; letter-spacing: -0.02em; }
.day-date { display: block; font-family: var(--body); font-size: .8rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 4px; }
.day-meal { font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.day-meal.empty { color: var(--muted); font-weight: 400; }
.day-meal.kind-other, .day-meal.kind-leftovers, .day-meal.kind-out { font-style: italic; font-weight: 500; }
.day.today .day-name { color: var(--basil); }
.day-chev { color: var(--muted); font-size: 1.3rem; }
.plan-actions { margin-top: 22px; }
.plan-actions p { margin: 10px 2px 0; }

/* ------------------------------------------------ list */

.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 10px 0 18px; }
.progress span { display: block; height: 100%; background: var(--basil); transition: width .3s ease; }
.add-form { display: flex; gap: 8px; margin-bottom: 18px; }
.add-form input { margin: 0; }
.add-form .btn { flex: none; }

.aisle { margin-top: 22px; }
.aisle h3 { font-size: .95rem; color: var(--muted); margin: 0 0 4px 2px; }
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 16px; border: 1.5px solid var(--line); overflow: hidden; }
.item { display: flex; align-items: stretch; border-top: 1.5px solid var(--line); }
.item:first-child { border-top: 0; }
.item-tick {
  flex: 1; display: flex; align-items: center; gap: 14px; min-height: 58px;
  padding: 10px 6px 10px 14px; border: 0; background: none; text-align: left;
}
.box {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--muted); display: grid; place-items: center;
}
.box svg { width: 15px; height: 15px; stroke: var(--basil-ink); stroke-width: 3; fill: none; opacity: 0; }
.item-text { display: block; }
.item-name { font-size: 1.05rem; }
.item-qty { font-weight: 700; margin-right: 4px; }
.item-note { display: block; font-size: .8rem; color: var(--muted); margin-top: 1px; }
.item-more { flex: none; width: 48px; border: 0; background: none; color: var(--muted); font-size: 1.3rem; }

/* The tick: a highlighter swipe across the words */
.item-name .mark {
  background-image: linear-gradient(var(--marker), var(--marker));
  background-repeat: no-repeat;
  background-position: 0 60%;
  background-size: 0% 72%;
  transition: background-size .28s ease-out;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  padding: 0 2px; margin: 0 -2px;
}
.item.done .item-name .mark { background-size: 100% 72%; }
.item.done .item-name, .item.done .item-note { color: var(--muted); }
.item.done .box { background: var(--basil); border-color: var(--basil); }
.item.done .box svg { opacity: 1; }
.item.pending .item-note::after { content: " Waiting to sync"; color: var(--tomato); }

.basket-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 30px; }
.basket-head h3 { color: var(--muted); }

.empty-state { text-align: left; padding: 28px 22px; border: 1.5px dashed var(--line); border-radius: 16px; }
.empty-state p { margin: 6px 0 16px; color: var(--muted); }

/* ------------------------------------------------ recipes and staples */

.rows { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--line); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 14px 2px; border: 0; border-bottom: 1.5px solid var(--line);
  background: none; text-align: left;
}
.row-title { font-weight: 600; font-size: 1.05rem; }
.row-sub { display: block; font-size: .85rem; color: var(--muted); margin-top: 2px; }
.search { margin: 0 0 14px; }

.recipe-ings { list-style: none; padding: 0; margin: 10px 0 0; }
.recipe-ings li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.recipe-steps { white-space: pre-wrap; margin: 10px 0 0; line-height: 1.6; }
.recipe-section + .recipe-section { margin-top: 24px; }

.footer-note { margin-top: 36px; color: var(--muted); font-size: .85rem; }
.footer-note .btn-quiet { padding: 0; min-height: 0; font-size: .85rem; }

/* ------------------------------------------------ bottom sheet */

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 20, 14, .42); animation: fade .2s ease-out; }
.sheet-panel {
  position: absolute; inset: auto 0 0 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  margin: 0 auto; max-width: 640px;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 24px);
  animation: rise .26s cubic-bezier(.2, .8, .3, 1);
  overscroll-behavior: contain;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.choice-list { list-style: none; margin: 0; padding: 0; }
.choice {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 13px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 1.02rem;
}
.choice.current { color: var(--basil); font-weight: 700; }
.choice-group { margin-top: 18px; }
.choice-group h3 { font-size: .95rem; color: var(--muted); margin-bottom: 2px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet-actions .btn { flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 7rem; gap: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); z-index: 30;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--paper);
  font-weight: 600; font-size: .92rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}

@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
