/* === Tokens === */
:root {
  --sage: #7a8a6f;
  --sage-dark: #5e6f55;
  --sage-soft: #e6ece1;
  --cream: #faf6ef;
  --cream-soft: #f4eee2;
  --ink: #2a2a26;
  --ink-soft: #5d5d57;
  --muted: #6b6b63;
  --line: #e4ddd0;
  --accent: #c98a4f;
  --accent-soft: #f4e2cf;
  --danger: #b04a3a;
  --ok: #4f8a55;
  --radius: 14px;
  --radius-lg: 22px;
  --pad: 16px;
  --pad-sm: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --topbar-h: 56px;
  --bottomnav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--cream);
  overflow-x: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; border-radius: 4px; }

/* === Topbar === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-inline: 8px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
}
.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.01em;
}

.iconbtn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 1.25rem;
  color: var(--ink-soft);
}
.iconbtn:hover { background: var(--sage-soft); }
.iconbtn:active { transform: scale(0.95); }

/* === Main === */
.main {
  padding: var(--pad);
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-bot) + var(--pad));
  min-height: calc(100vh - var(--topbar-h) - var(--bottomnav-h));
  max-width: 720px;
  margin-inline: auto;
}

/* === Bottom nav === */
.bottomnav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--bottomnav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: var(--cream);
  border-top: 1px solid var(--line);
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 6px;
}
.nav-btn .nav-icon { font-size: 1.4rem; line-height: 1; }
.nav-btn[aria-current="page"] { color: var(--sage-dark); }
.nav-btn[aria-current="page"] .nav-icon { transform: translateY(-1px); }

/* === Search === */
.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  margin-bottom: var(--pad);
  box-shadow: var(--shadow);
}
.searchbar input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 0.95rem;
  outline: none;
}
.searchbar input::placeholder { color: var(--muted); }
.searchbar .iconbtn { width: 28px; height: 28px; }

/* === Filter chips === */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--pad)) var(--pad);
  padding: 0 var(--pad) 4px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip.active {
  background: var(--sage);
  color: white;
  border-color: var(--sage);
}

/* === Recipe cards === */
.cards {
  display: grid;
  gap: 12px;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  width: 100%;
  box-shadow: var(--shadow);
}
.card:active { transform: scale(0.99); }
.card-emoji {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--sage-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.card-body { min-width: 0; }
.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
.card-meta b { color: var(--ink-soft); font-weight: 500; }

/* === Empty state === */
.empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  gap: 12px;
}
.empty-emoji { font-size: 3rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--ink); }
.empty-text { font-size: 0.9rem; line-height: 1.5; max-width: 320px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--sage);
  color: white;
  border: 0;
  min-height: 44px;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--sage-dark); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--sage-dark); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--sage-soft); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 0.85rem; min-height: 36px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + var(--safe-bot) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
.toast-action {
  margin-left: 12px;
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.toast-action:hover { background: rgba(255,255,255,0.25); }

/* === Update banner === */
.update-banner {
  position: fixed;
  top: calc(var(--topbar-h) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sage-dark);
  color: white;
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-width: calc(100% - 32px);
}
.update-banner .btn { background: white; color: var(--sage-dark); min-height: 32px; padding: 6px 12px; }
.update-banner .iconbtn { color: white; width: 28px; height: 28px; }

/* === Låseskjerm === */
.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: max(20px, var(--safe-top));
  padding-bottom: max(20px, var(--safe-bot));
}
.lock-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.lock-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.lock-subtitle {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 24px;
}
.lock-dots {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 18px;
}
.lock-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--line);
  transition: background 0.15s, transform 0.15s;
}
.lock-dot.filled {
  background: var(--sage);
  border-color: var(--sage);
  transform: scale(1.1);
}
.lock-error {
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 16px;
  min-height: 1.2em;
}
.lock-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.lock-key {
  height: 60px;
  font-size: 1.4rem;
  font-weight: 500;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  transition: background 0.1s, transform 0.05s;
}
.lock-key:hover { background: var(--cream-soft); }
.lock-key:active { transform: scale(0.96); background: var(--sage-soft); }
.lock-key-back, .lock-key-ok {
  font-size: 1.1rem;
  font-weight: 600;
}
.lock-key-ok { background: var(--sage); color: white; border-color: var(--sage); }
.lock-key-ok:hover { background: var(--sage-dark); }
.lock-extra {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.lock-link {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: underline;
  background: transparent;
  padding: 8px 16px;
}
.lock-link:hover { color: var(--ink-soft); }

.recovery-code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 18px;
  background: var(--sage-soft);
  border: 2px dashed var(--sage);
  border-radius: 12px;
  color: var(--sage-dark);
  margin: 14px 0;
  user-select: all;
}

/* === Dialog === */
.dialog {
  border: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  width: min(540px, 100% - 24px);
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(2px); }
.dialog-form { display: flex; flex-direction: column; max-height: 90vh; }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
}
.dialog-title { font-size: 1.05rem; font-weight: 600; }
.dialog-body { padding: 16px 20px; overflow-y: auto; }
.dialog-foot {
  padding: 12px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--cream);
}
.dialog-foot:empty { display: none; }

/* === Forms === */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 500;
  margin-bottom: 6px;
}
.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  font-size: 0.95rem;
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--sage);
  outline: none;
}
.field-textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-help { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* === Recipe detail === */
.detail-header {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}
.detail-emoji {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  background: var(--sage-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}
.detail-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 6px; }
.detail-meta { font-size: 0.85rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.detail-desc { font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 18px; line-height: 1.5; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--sage-soft);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 16px;
}
.tab {
  padding: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  border-radius: 9px;
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: white; color: var(--sage-dark); box-shadow: var(--shadow); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
}
.section-title { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; }

.ing-list { list-style: none; display: grid; gap: 6px; }
.ing-li { display: block; }
.ing-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.92rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.ing-item:hover { background: var(--cream-soft); }
.ing-item .ing-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: white;
}
.ing-item.in-pantry .ing-check { background: var(--ok); border-color: var(--ok); color: white; }
.ing-item.in-pantry .ing-name { color: var(--muted); text-decoration: line-through; }
.ing-item.partial-pantry .ing-check { background: var(--accent); border-color: var(--accent); color: white; font-size: 0.85rem; }
.ing-item.partial-pantry .ing-amount { color: var(--accent); font-weight: 500; }
.ing-amount { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

.steps { list-style: none; counter-reset: step; display: grid; gap: 10px; }
.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.step::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sage-soft);
  color: var(--sage-dark);
  font-weight: 700;
  font-size: 0.85rem;
}

.callout {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 14px;
}
.callout strong { color: var(--ink); }
.callout.muted { background: var(--cream-soft); border-left-color: var(--muted); color: var(--ink-soft); font-size: 0.84rem; padding: 8px 12px; }

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--sage-dark);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 14px;
  transition: background 0.15s;
}
.source-link:hover { background: var(--sage-soft); }
.source-link strong { font-weight: 600; color: var(--ink); }

/* === Week menu === */
.week {
  display: grid;
  gap: 10px;
}
.day {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}
.day-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink-soft);
  width: 56px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.day-recipe {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  min-width: 0;
}
.day-recipe .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.day-empty { color: var(--muted); font-style: italic; font-size: 0.88rem; flex: 1; }
.day-actions { display: flex; gap: 6px; }
.day-emoji { font-size: 1.3rem; }

/* === Pantry === */
.pantry-list {
  display: grid;
  gap: 8px;
  list-style: none;
}
.pantry-li {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.pantry-li .pantry-item { flex: 1; }
.pantry-edit {
  width: 44px;
  flex-shrink: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pantry-edit:hover { background: var(--sage-soft); color: var(--ink); }
.oda-flag {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.7;
}
.pantry-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  align-items: center;
  font-size: 0.92rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.pantry-item:hover { background: var(--cream-soft); }
.pantry-qty {
  font-size: 0.78rem;
  color: var(--sage-dark);
  font-weight: 600;
  background: var(--sage-soft);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.shop-pantry-note {
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 500;
  margin-top: 2px;
}
.pantry-item .check {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: white;
}
.pantry-item.checked .check { background: var(--ok); border-color: var(--ok); color: white; }
.pantry-item.checked .name { color: var(--muted); }

.pantry-cat { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 16px 0 8px; }
.pantry-cat-main { font-size: 0.85rem; color: var(--ok); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.pantry-cat-sub { margin-left: 4px; font-size: 0.72rem; opacity: 0.85; }

.undo-banner {
  display: flex; align-items: stretch; gap: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 12px; overflow: hidden;
}
.undo-banner-main {
  flex: 1; text-align: left; padding: 10px 14px;
  background: transparent; border: 0; color: var(--text);
  font: inherit; cursor: pointer;
}
.undo-banner-main:hover { background: rgba(0,0,0,0.04); }
.undo-banner-dismiss {
  padding: 0 14px; background: transparent; border: 0;
  border-left: 1px solid var(--border); color: var(--muted);
  font: inherit; cursor: pointer;
}
.undo-banner-dismiss:hover { background: rgba(0,0,0,0.04); color: var(--text); }

/* === Shopping list === */
.shop-cat-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.shop-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 6px;
}
.shop-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.92rem;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-width: 0;
}
.shop-item:hover { background: var(--cream-soft); }
.oda-link {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sage-dark);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.oda-link:hover { background: var(--sage-soft); }
.oda-link-mapped { background: #e1efdc; color: var(--ok); border-color: #c5dec0; }
.oda-link-mapped:hover { background: #d2e8cc; }
.shop-item.bought { color: var(--muted); text-decoration: line-through; }
.shop-amount { color: var(--muted); font-size: 0.85rem; }

.fab {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + var(--safe-bot) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sage);
  color: white;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 25;
}
.fab:active { transform: scale(0.94); }

/* === Ingredient editor === */
.ing-editor {
  display: grid;
  grid-template-columns: 1fr 70px 70px 32px;
  gap: 6px;
  margin-bottom: 6px;
}
.ing-editor .field-input { padding: 9px 10px; font-size: 0.9rem; }
.ing-editor .iconbtn { width: 32px; height: 32px; font-size: 1rem; color: var(--danger); }

.step-editor { display: grid; grid-template-columns: 1fr 32px; gap: 6px; margin-bottom: 6px; align-items: start; }
.step-editor .field-textarea { min-height: 56px; }

.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* === Tag chips inline === */
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--sage-soft);
  color: var(--sage-dark);
  font-weight: 500;
}
.tag.warn { background: var(--accent-soft); color: var(--accent); }
.tag.muted { background: var(--cream-soft); color: var(--muted); }
.tag.tag-ok { background: #e1efdc; color: var(--ok); }
.tag.tag-muted { background: var(--cream-soft); color: var(--ink-soft); }

/* Pantry coverage badge — counter shown on recipe titles and week days */
.cov-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
  line-height: 1.4;
  letter-spacing: 0;
}
.cov-ok { background: #e1efdc; color: var(--ok); }
.cov-partial { background: var(--accent-soft); color: var(--accent); }
.cov-none { background: var(--cream-soft); color: var(--muted); }

.day-recipe .cov-badge { margin-left: auto; flex-shrink: 0; }

/* === Compact summary chips in detail === */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.meta-cell {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.meta-cell .label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.meta-cell .value { font-size: 0.95rem; font-weight: 600; margin-top: 2px; }
.portion-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
}
.portion-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sage-soft);
  color: var(--sage-dark);
  font-size: 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.portion-btn:hover { background: var(--sage); color: white; }
.portion-cell .value { display: inline-block; min-width: 28px; }

/* === Velkomstskjerm === */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: linear-gradient(135deg, var(--cream) 0%, var(--sage-soft) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: max(24px, var(--safe-top));
  padding-bottom: max(24px, var(--safe-bot));
  overflow-y: auto;
}
.welcome-wrap {
  width: 100%;
  max-width: 640px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.welcome-brand {
  font-size: 3.6rem;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.08));
}
.welcome-title {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: -4px;
}
.welcome-tagline {
  font-size: 0.92rem;
  color: var(--sage-dark);
  font-style: italic;
  margin-top: -4px;
}
.welcome-sub {
  font-size: 1rem;
  color: var(--ink-soft);
  margin-bottom: 18px;
  max-width: 320px;
}
.welcome-skip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 0.86rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.welcome-skip input { accent-color: var(--sage); width: 16px; height: 16px; }
.welcome-skip:hover { color: var(--ink-soft); }
.welcome-privacy {
  margin-top: 22px;
  padding: 10px 14px;
  background: var(--surface-muted, rgba(0,0,0,0.04));
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 360px;
  text-align: center;
  line-height: 1.4;
}
.privacy-info h3 {
  font-size: 0.95rem;
  margin: 14px 0 4px;
  color: var(--ink);
}
.privacy-info h3:first-child { margin-top: 0; }
.privacy-info p {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0 0 8px;
  line-height: 1.5;
}
.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  width: 100%;
  margin-bottom: 6px;
}
.welcome-card {
  background: white;
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.05);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.welcome-card:hover {
  border-color: var(--sage);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
}
.welcome-card:active { transform: translateY(0); }
.welcome-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--sage-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
}
.welcome-name {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
  word-break: break-word;
}
.welcome-lock {
  font-size: 0.74rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 3px;
}
.welcome-add {
  margin-top: 12px;
  background: transparent;
  border: 1.5px dashed var(--muted);
  color: var(--ink-soft);
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
}
.welcome-add:hover { border-color: var(--sage); color: var(--sage-dark); background: rgba(255,255,255,0.5); }

@media (max-width: 380px) {
  .welcome-title { font-size: 1.7rem; }
  .welcome-brand { font-size: 2.8rem; }
  .welcome-avatar { width: 60px; height: 60px; font-size: 2rem; }
}

/* === Batch-editor === */
.batch-list { display: flex; flex-direction: column; gap: 12px; }
.batch-row {
  background: var(--cream-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.batch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.batch-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.batch-del { width: 28px; height: 28px; font-size: 0.9rem; color: var(--danger); }
.batch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}
.batch-grid .field { margin-bottom: 0; }
.batch-grid .field-input,
.batch-grid .field-select { padding: 8px 10px; font-size: 0.88rem; }

.pantry-namecol { flex: 1; min-width: 0; }
.pantry-sub {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
}
.pantry-sub.soon { color: var(--accent); font-weight: 500; }
.pantry-sub.expired { color: var(--danger); font-weight: 600; }

/* === Basisvarer === */
.basic-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.basic-row {
  display: grid;
  grid-template-columns: 1fr 70px 70px 32px;
  gap: 6px;
  align-items: center;
}
.basic-name {
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.basic-antall, .basic-enhet { padding: 8px 10px; font-size: 0.88rem; }

.product-pick-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.product-pick-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.product-pick-row:hover { background: var(--cream-soft); }
.pick-emoji { font-size: 1.2rem; text-align: center; }
.pick-name { font-weight: 500; font-size: 0.92rem; }
.pick-cat {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* === Profil-velger === */
.profile-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.profile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
}
.profile-row.active { border-color: var(--sage); background: var(--sage-soft); }
.profile-pick {
  flex: 1;
  padding: 12px;
  text-align: left;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.profile-name {
  font-weight: 600;
  font-size: 0.96rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.profile-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

/* === Hide elements === */
[hidden] { display: none !important; }

/* === Small screens === */
@media (max-width: 360px) {
  :root { --pad: 12px; }
  .card { grid-template-columns: 56px 1fr; }
  .card-emoji { width: 56px; height: 56px; font-size: 1.7rem; }
  .nav-btn .nav-label { font-size: 0.66rem; }
}
