:root {
  color-scheme: light;
  --paper: #fbf8f1;
  --ink: #20201d;
  --muted: #6b665c;
  --line: #ded5c8;
  --green: #2f6f5e;
  --tomato: #b94d3f;
  --gold: #d7a640;
  --blue: #466c93;
  --white: #fffdf8;
  --shadow: 0 12px 35px rgba(45, 36, 22, .14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  background: linear-gradient(145deg, #fbf8f1 0%, #f1f7f4 48%, #f8efe8 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }

.app-shell {
  min-height: 100svh;
  padding: env(safe-area-inset-top) 16px calc(82px + env(safe-area-inset-bottom));
}

.update-banner {
  position: sticky;
  top: 8px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: #edf6f1;
  color: var(--green);
  padding: 10px;
  box-shadow: 0 8px 20px rgba(45, 36, 22, .1);
}

.update-banner span {
  font-weight: 850;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 14px;
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(18px);
}

.eyebrow {
  color: var(--muted);
  font-size: .77rem;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 2rem; line-height: 1; margin-bottom: 0; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin: 20px 0 8px; }

.screen { display: none; }
.screen.active { display: block; }

.search-row, .pantry-entry, .select-row, .split, .toggle-line {
  display: flex;
  gap: 10px;
  align-items: center;
}

.split > label { flex: 1; min-width: 0; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 111, 94, .14); }

.icon-button, .text-button {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  border-radius: 8px;
  min-width: 48px;
  height: 48px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.text-button { min-width: auto; padding-inline: 18px; }
.primary { background: var(--green); border-color: var(--green); color: white; }
.danger { color: #9d312b; }
.hidden { display: none !important; }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  padding: 9px 12px;
  white-space: nowrap;
}

.chip.active { border-color: var(--green); color: var(--green); background: #edf6f1; }

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

.recipe-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, .88);
  color: var(--ink);
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 12px;
  padding: 10px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(45, 36, 22, .08);
  min-height: 98px;
}

.recipe-card .photo {
  width: 76px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--gold));
  background-size: cover;
  background-position: center;
}

.card-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.card-copy strong {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.card-copy small, .mini-tags {
  color: var(--muted);
  font-size: .82rem;
}

.mini-tags { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.favorite-mark { color: var(--gold); font-size: 1.2rem; align-self: start; }

.compact .recipe-card { grid-template-columns: 52px 1fr auto; min-height: 72px; }
.compact .photo { width: 52px; }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, .94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(20px);
}

.nav-item {
  height: 52px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: .78rem;
}

.nav-item.active { color: white; background: var(--blue); }

dialog {
  width: min(100vw, 560px);
  max-height: 92svh;
  border: 0;
  border-radius: 8px 8px 0 0;
  padding: 0;
  margin: auto auto 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(23, 22, 19, .45); backdrop-filter: blur(4px); }

.editor, .detail-body {
  padding: 18px;
}

.editor {
  display: grid;
  gap: 12px;
}

.editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: .86rem;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

menu {
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.check-label {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.check-label input { width: auto; }

.detail-view { max-height: 92svh; overflow: auto; }

.detail-hero {
  height: 210px;
  background: linear-gradient(135deg, var(--tomato), var(--gold), var(--green));
  background-size: cover;
  background-position: center;
}

.serving-stepper {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.serving-stepper span {
  min-width: 104px;
  text-align: center;
  font-weight: 800;
}

ul { padding-left: 22px; }
li { margin: 8px 0; }

.shopping-list {
  display: grid;
  gap: 8px;
  padding-top: 14px;
}

.shopping-item {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 8px;
  padding: 12px;
}

.shopping-item input { width: auto; }
.shopping-item.done span { text-decoration: line-through; color: var(--muted); }

.settings-grid { display: grid; gap: 12px; }

.settings-action {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  display: grid;
  gap: 4px;
  color: var(--ink);
}

.settings-action span { font-weight: 850; }
.settings-action small { color: var(--muted); }
.file-action input { display: none; }
.app-version-card {
  background: #edf6f1;
  border-color: rgba(47, 111, 94, .26);
}

@media (min-width: 720px) {
  .app-shell {
    width: min(680px, 100%);
    margin: 0 auto;
  }
}
