:root {
  --brick: #8a3b2e;
  --brick-dark: #6f2e23;
  --cream: #faf6ef;
  --card: #ffffff;
  --ink: #2c2622;
  --muted: #857b70;
  --line: #e8ded0;
  --gold: #c99a3f;
  --green: #4f7a52;
  --shadow: 0 6px 22px rgba(60, 40, 30, 0.10);
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
html, body { overflow-x: clip; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

/* App-shell: kop en onderbalk staan vast, alleen de inhoud scrollt */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
h1, h2, h3, .serif { font-family: Georgia, "Times New Roman", serif; }
h1, h2, h3 { line-height: 1.2; font-weight: 600; }
a { color: var(--brick); }
img { max-width: 100%; display: block; }

/* Layout */
.wrap { max-width: 900px; margin: 0 auto; padding: 0 16px; }
.topbar {
  flex: 0 0 auto; z-index: 20;
  background: var(--brick);
  color: #fff;
  padding: env(safe-area-inset-top) 0 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
  user-select: none; -webkit-user-select: none;
}
.topbar-inner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; max-width: 900px; margin: 0 auto; }
.brand { font-family: Georgia, serif; font-size: 20px; font-weight: 600; letter-spacing: .3px; }
.brand span { opacity: .8; font-size: 13px; display: block; font-family: inherit; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.icon-btn {
  background: rgba(255,255,255,.15); color: #fff; border: none;
  width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer;
}

/* Tabs */
.tabs {
  flex: 0 0 auto; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(60,40,30,.06);
  user-select: none; -webkit-user-select: none;
}
.tabs button {
  flex: 1; background: none; border: none; padding: 10px 4px 12px; cursor: pointer;
  color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .06s ease, color .12s;
}
.tabs button .t-ic { font-size: 20px; line-height: 1; }
.tabs button.active { color: var(--brick); font-weight: 600; }
.tabs button:active { transform: scale(.92); }

main { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 16px 0 28px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brick); color: #fff; border: none; border-radius: 12px;
  padding: 12px 18px; font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn { transition: transform .06s ease, background .15s; user-select: none; -webkit-user-select: none; }
.btn:active { background: var(--brick-dark); transform: scale(.97); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--brick); border: 1.5px solid var(--brick); }
.btn.soft { background: #f1e7d8; color: var(--brick-dark); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: #a8402f; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
input, textarea, select {
  width: 100%; font-size: 16px; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }

/* Cards / grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; border: 1px solid var(--line);
  transition: transform .07s ease;
}
.card:active { transform: scale(.98); }
.card .thumb { aspect-ratio: 4/3; background: #efe6d7 center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: #c9bba6; font-family: Georgia, serif; font-size: 32px; }
.card .body { padding: 10px 12px 12px; }
.card .body h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fav-dot { color: var(--brick); }

/* Recipe detail */
.hero { position: relative; border-radius: var(--radius); overflow: hidden; background: #efe6d7; box-shadow: var(--shadow); }
.hero img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.hero .placeholder { aspect-ratio: 16/10; display: flex; align-items: center; justify-content: center; color: #c9bba6; font-family: Georgia, serif; font-size: 48px; }
.gallery { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; }
.gallery img { height: 72px; width: 96px; object-fit: cover; border-radius: 8px; }

.pill { display: inline-block; background: #f1e7d8; color: var(--brick-dark); border-radius: 999px; padding: 4px 11px; font-size: 12px; margin: 0 6px 6px 0; }
.tag { background: #eef2ea; color: var(--green); }

.section { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); border: 1px solid var(--line); }
.section h3 { margin-top: 0; color: var(--brick-dark); }
ul.ing { list-style: none; padding: 0; margin: 0; }
ul.ing li { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: center; }
ul.ing li:last-child { border-bottom: none; }
ul.ing .amt { font-weight: 600; min-width: 74px; color: var(--brick-dark); }
ol.steps { padding-left: 0; list-style: none; counter-reset: s; }
ol.steps li { counter-increment: s; position: relative; padding: 8px 0 12px 42px; border-bottom: 1px dashed var(--line); }
ol.steps li:last-child { border-bottom: none; }
ol.steps li::before { content: counter(s); position: absolute; left: 0; top: 6px; width: 28px; height: 28px; background: var(--brick); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-family: Georgia, serif; }

/* Stars */
.stars { font-size: 22px; color: var(--gold); letter-spacing: 2px; }
.stars .empty { color: #dcd2c2; }
.rate button { background: none; border: none; font-size: 26px; color: #dcd2c2; cursor: pointer; padding: 0 2px; }
.rate button.on { color: var(--gold); }

/* Comments */
.comment { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: none; }
.comment .who { font-weight: 600; font-size: 14px; }
.comment .when { color: var(--muted); font-size: 12px; }

/* Auth */
.auth { max-width: 380px; margin: 8vh auto 0; padding: 24px 20px; }
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo .mark { font-family: Georgia, serif; font-size: 40px; color: var(--brick); }
.auth-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.switch { text-align: center; margin-top: 14px; font-size: 14px; }
.switch a { cursor: pointer; font-weight: 600; }

/* Utility */
.muted { color: var(--muted); }
.center { text-align: center; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty-state .big { font-family: Georgia, serif; font-size: 40px; color: #d8cab4; }
.error-msg { background: #fbe9e6; color: #9c3323; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.ok-msg { background: #e9f2e6; color: #3f6b41; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.filterbar { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; }
.filterbar .chip { white-space: nowrap; background: #fff; border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 14px; cursor: pointer; }
.filterbar .chip.active { background: var(--brick); color: #fff; border-color: var(--brick); }
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.list-head h2 { margin: 0; font-size: 22px; }
.fab { position: fixed; right: 16px; bottom: 78px; z-index: 25; }
.repeat-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.repeat-row .grow { flex: 1; }
.repeat-row button.rm { background: #f3e4e1; color: #9c3323; border: none; border-radius: 8px; width: 40px; min-width: 40px; height: 44px; font-size: 20px; cursor: pointer; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; align-items: flex-end; }
.sheet { background: var(--cream); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.shop-item.done .txt { text-decoration: line-through; color: var(--muted); }
.shop-item input[type=checkbox] { width: 22px; height: 22px; }
.shop-item .txt { flex: 1; }
/* Subtiele fade bij het wisselen van scherm, geeft een app-gevoel */
main > .wrap { animation: viewfade .18s ease both; }
@keyframes viewfade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  main > .wrap { animation: none; }
  .btn:active, .card:active, .tabs button:active { transform: none; }
}

@media (min-width: 640px) {
  main > .wrap, .auth { max-width: 720px; }
}
