:root {
  --badge: calc(12px + env(safe-area-inset-bottom)); /* tarpas po apatiniu meniu */
  --bg: #1b1816;
  --card: #2a2623;
  --card-2: #35302c;
  --input: #3a3531;
  --text: #f4eee8;
  --muted: #a9a19a;
  --line: rgba(255, 255, 255, .07);
  --cream: #f1e9df;
  --accent: #8fd694;
  --accent-soft: rgba(143, 214, 148, .14);
  --danger: #f08a7e;
  --p: #7cb3ff;
  --f: #f5c26b;
  --c: #c9a2ff;
  --radius: 22px;
  --glass: rgba(58, 53, 49, .78);
  color-scheme: dark;
}
/* „Netlify“ nemokamame plane apačioje rodomas neišjungiamas ženkliukas, jam paliekama vietos */
:root.nf { --badge: 58px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { overflow-x: hidden; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(var(--badge) + 110px);
}
.view > h2 { margin: 10px 0 18px; font-size: 21px; font-weight: 600; text-align: center; }
h3 { margin: 0 0 10px; font-size: 17px; font-weight: 600; }
h4 { margin: 18px 2px 8px; font-size: 17px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}

/* Mygtukai ir laukai */
button, .btn-like {
  font: inherit;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  color: inherit;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:disabled { opacity: .3; cursor: default; }
.primary { background: var(--cream); color: #1b1816; font-weight: 600; }
.ghost { background: var(--card-2); color: var(--text); font-weight: 500; }
.danger { background: none; color: var(--danger); }
.big { padding: 16px; font-size: 17px; }
.wide { width: 100%; margin-top: 10px; }
.icon-btn { width: 42px; height: 42px; padding: 0; font-size: 26px; border-radius: 50%; background: var(--card); }
.icon-btn.add { background: var(--card-2); color: var(--text); font-size: 22px; width: 36px; height: 36px; }

input, select {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--input);
  color: var(--text);
  margin-top: 6px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.inline { display: flex; gap: 8px; margin-top: 12px; }
.inline input { margin: 0; flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.row .danger { margin-right: auto; }

/* Šiandien */
.date-nav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; }
.date-nav h2 { margin: 0; text-transform: capitalize; font-size: 21px; font-weight: 600; }
.summary { display: flex; align-items: center; gap: 22px; }
.ring-wrap { position: relative; width: 146px; height: 146px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--card-2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 0 999; transition: stroke-dasharray .5s; }
.ring-fg.over { stroke: var(--danger); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text b { font-size: 30px; font-weight: 600; }
.ring-text span { font-size: 13px; color: var(--muted); }
.summary-side { display: flex; flex-direction: column; gap: 14px; }
.summary-side div { display: flex; flex-direction: column; }
.summary-side b { font-size: 21px; font-weight: 600; }

.macro + .macro { margin-top: 14px; }
.macro-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.bar { height: 7px; background: var(--card-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .5s; }
.bar-fill.p { background: var(--p); }
.bar-fill.f { background: var(--f); }
.bar-fill.c { background: var(--c); }

.meal-head { display: flex; align-items: center; gap: 10px; }
.meal-head h3 { margin: 0; flex: 1; }
.entry, .prod {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  padding: 12px 2px;
  border-radius: 0;
  border-top: 1px solid var(--line);
  gap: 10px;
}
.meal .entry:first-of-type { margin-top: 10px; }
.entry-name { font-weight: 500; }
.entry-kcal { font-weight: 600; white-space: nowrap; }
.prod .plus { color: var(--muted); font-size: 22px; }
#local-results .prod:first-child, #prod-list .prod:first-child, #rc-search-results .prod:first-child { border-top: 0; }

/* Receptų kortelės */
.recipe-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 12px 10px 10px;
  margin-bottom: 10px;
  cursor: pointer;
}
.thumb {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  flex: none;
  object-fit: cover;
  background: linear-gradient(135deg, #4a3f37, #2f2925);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}
.recipe-info { flex: 1; min-width: 0; }
.recipe-info .entry-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-block; background: var(--card-2); border-radius: 999px; padding: 4px 10px; font-size: 13px; color: var(--text); margin-top: 6px; }
.recipe-card .edit { width: 36px; height: 36px; padding: 0; color: var(--muted); font-size: 18px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .icon-circle { width: 64px; height: 64px; border-radius: 50%; background: var(--card); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--text); }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* Skeneris */
#reader { border-radius: 16px; overflow: hidden; margin-bottom: 4px; }

/* Dialogai */
dialog {
  border: 0;
  border-radius: 26px;
  padding: 22px;
  width: min(480px, calc(100% - 24px));
  background: var(--card);
  color: var(--text);
  margin: calc(12px + env(safe-area-inset-top)) auto auto;
  max-height: calc(100dvh - var(--badge) - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin-bottom: 4px; font-size: 19px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.chip { padding: 7px 13px; font-size: 14px; background: var(--card-2); }
.preview { background: var(--accent-soft); border-radius: 16px; padding: 14px; font-size: 15px; }

/* Receptų redagavimas */
textarea {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--input);
  color: var(--text);
  margin-top: 8px;
  resize: vertical;
}
.import-box { background: var(--card-2); border-radius: 18px; padding: 14px; margin: 12px 0 16px; }
.import-box .wide { margin-top: 0; }
.import-box p { margin: 10px 0 0; }
.import-box summary { cursor: pointer; font-weight: 500; margin-top: 12px; }
#rc-status:empty { display: none; }
.rc-photo { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.rc-photo .thumb { width: 64px; height: 64px; font-size: 26px; }
.rc-item { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.rc-item:first-child { border-top: 0; }
.rc-name { flex: 1; min-width: 0; }
.rc-item input { width: 76px; margin: 0; padding: 9px; text-align: right; }
.rc-del { width: 32px; height: 32px; font-size: 20px; color: var(--muted); background: none; }
#rc-search { margin: 10px 0 0; }
#rc-total { margin-top: 14px; }

/* Svoris */
.wchart { width: 100%; height: auto; margin-top: 14px; }
.wchart polyline { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.wchart circle { fill: var(--accent); }
.wrow { display: flex; justify-content: space-between; padding: 9px 2px; border-top: 1px solid var(--line); font-size: 15px; }
#weight-list { margin-top: 8px; }

/* Apatinis plaukiojantis meniu */
.tabbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
  /* Vientisas fonas iki ekrano apačios: turinys dingsta po meniu, o ženkliukas lieka šiame plote */
  padding: 22px 16px var(--badge);
  background: linear-gradient(to bottom, rgba(27, 24, 22, 0), var(--bg) 22px);
  z-index: 10;
}
.tabs, .fab {
  pointer-events: auto;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.tabs { display: flex; border-radius: 999px; padding: 5px; flex: 1; max-width: 420px; }
.tabs button { flex: 1; padding: 11px 10px; color: var(--muted); font-size: 14px; font-weight: 500; transition: background .2s; }
.tabs button span { display: none; }
.tabs button.active { flex: 2.2; color: var(--text); background: rgba(255, 255, 255, .1); }
.tabs button.active span { display: inline; }
.fab { width: 62px; height: 62px; border-radius: 50%; padding: 0; color: var(--text); flex: none; }
.fab svg.i { width: 26px; height: 26px; }
.fab.active { background: var(--cream); color: #1b1816; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--badge) + 80px);
  transform: translateX(-50%);
  background: var(--cream);
  color: #1b1816;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 20;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* Filtrai ir žymos */
.filters { display: flex; gap: 8px; overflow-x: auto; margin: 16px -16px 0; padding: 0 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex: none; padding: 9px 16px; font-size: 15px; }
.chip span { color: var(--muted); margin-left: 4px; }
.chip.on { background: var(--cream); color: #1b1816; font-weight: 600; }
.chip.on span { color: #6b625b; }

/* „Dar negaminti“ kortelės */
.hcards { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; scrollbar-width: none; }
.hcards::-webkit-scrollbar { display: none; }
.hcard { position: relative; flex: none; width: 232px; background: var(--card); border-radius: var(--radius); overflow: hidden; scroll-snap-align: start; cursor: pointer; }
.hcard img, .hcard-empty { width: 100%; height: 150px; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 46px; background: linear-gradient(135deg, #4a3f37, #2f2925); }
.hcard-name { padding: 12px 14px 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill.over { position: absolute; top: 10px; left: 10px; margin: 0; background: rgba(27, 24, 22, .7); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

/* Recepto puslapis */
.hero { position: relative; margin: calc(-14px - env(safe-area-inset-top)) -16px 0; }
.hero img, .hero-empty { width: 100%; height: 300px; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 80px; background: linear-gradient(135deg, #4a3f37, #2f2925); }
.hero::after { content: ""; position: absolute; inset: auto 0 0; height: 90px; background: linear-gradient(to bottom, transparent, var(--bg)); }
.hero .back { position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 16px; z-index: 1; background: rgba(27, 24, 22, .65); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--text); }
.view > div > .rv-title, .rv-title { text-align: left; font-size: 25px; margin: -10px 0 10px; position: relative; z-index: 1; }
.tagline { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tagline .pill { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.stats div { background: var(--card); border-radius: 18px; padding: 12px 6px; text-align: center; }
.stats b { display: block; font-size: 18px; font-weight: 600; }
.stats span { font-size: 11.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 8px; margin-bottom: 14px; }
.actions button { flex: 1; min-width: 0; padding: 12px 6px; font-size: 14.5px; white-space: nowrap; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--card-2); border-radius: 999px; padding: 3px; }
.stepper button { width: 32px; height: 32px; padding: 0; font-size: 18px; }
.stepper span { font-size: 14px; min-width: 62px; text-align: center; }
.steps { margin: 0; padding-left: 22px; }
.steps li { padding: 6px 0; line-height: 1.5; }
.steps li::marker { color: var(--muted); font-weight: 600; }

/* Planas */
.day.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.day h3 .muted { font-weight: 400; margin-left: 4px; }
.plan-item { display: flex; align-items: center; gap: 12px; padding: 10px 0 0; margin-top: 10px; border-top: 1px solid var(--line); cursor: pointer; }
.thumb.sm { width: 46px; height: 46px; border-radius: 12px; font-size: 20px; }
.pick-row { display: flex; align-items: center; gap: 12px; }
#pick-list { max-height: 60vh; overflow-y: auto; }
#pick-list .prod:first-child { border-top: 0; }
#btn-plan-shop { margin: 0 0 12px; }
.empty .wide { margin-top: 20px; }

/* Pirkiniai */
.shop-add { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 18px; padding: 4px 16px; margin-bottom: 12px; }
.shop-add span { font-size: 22px; color: var(--muted); }
.shop-add input { background: none; margin: 0; padding: 12px 0; }
.shop-add input:focus { border-color: transparent; }
#shop-empty { padding: 30px 20px; }
#shop-card:has(#shop-list:empty) { display: none; }
.shop-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.shop-item:first-child { border-top: 0; }
.shop-name { flex: 1; }
.check { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--muted); font-size: 14px; color: #1b1816; flex: none; }
.shop-item.done .check { background: var(--accent); border-color: var(--accent); }
.shop-item.done .shop-name { text-decoration: line-through; color: var(--muted); }
.settings-link { justify-content: space-between; margin: 0 0 12px; padding: 16px 18px; border-radius: var(--radius); background: var(--card); }

#plan-label { text-transform: none; font-size: 17px; text-align: center; }

/* Vanduo */
.glasses { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 12px; }
.glass { width: 100%; height: 46px; padding: 0; border-radius: 12px; background: var(--card-2); }
.glass svg { width: 26px; height: 26px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linejoin: round; }
.glass .fill { fill: transparent; stroke: none; }
.glass.on svg { stroke: #7cc4ff; }
.glass.on .fill { fill: #7cc4ff; }

/* Savaitė */
.weekchart { width: 100%; height: auto; margin: 14px 0 6px; }
.weekchart rect { fill: var(--card-2); }
.weekchart rect.cur { fill: var(--accent); }
.weekchart rect.over { fill: var(--danger); opacity: .8; }
.weekchart line { stroke: var(--cream); stroke-dasharray: 4 4; opacity: .5; }
.weekchart text { fill: var(--muted); font-size: 11px; text-anchor: middle; text-transform: capitalize; }
#week p { margin: 0; }

/* Greitas pridėjimas */
.repeat { width: 100%; justify-content: flex-start; margin-top: 10px; padding: 10px 14px; background: var(--card-2); border-radius: 14px; font-size: 14px; color: var(--muted); }
.add-top { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-top .big { flex-direction: column; gap: 6px; padding: 16px 8px; font-size: 14.5px; border-radius: 18px; }
.add-top svg.i { width: 26px; height: 26px; }
#freq-list .prod:first-child { border-top: 0; }
.label-btn { margin: 10px 0 6px; }
#pf-status:empty, #plate-status:empty { display: none; }

/* Pasiūlymai, dalijimasis, sinchronizacija */
.suggest-btn { margin: 0 0 12px; padding: 15px; border-radius: var(--radius); background: var(--card); }
.sg-card { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.sg-card:first-child { border-top: 0; }
.sg-why { margin-top: 4px; color: var(--text); opacity: .85; }
.hero .share { left: auto; right: 16px; }
.sync-code { font: 600 22px/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .06em; text-align: center; background: var(--card-2); border-radius: 16px; padding: 16px 8px; margin: 10px 0; user-select: all; }
#sync-box p { margin: 6px 0; }
#sg-status:empty { display: none; }
