/* Spíž – vizuální styl „spížní štítek“: teplý papír, inkoust, barvy stavu jako razítka. */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/fraunces-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/fraunces-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --paper: #f4ede0;
  --paper-2: #ebe2cf;
  --card: #fffbf3;
  --ink: #1f1a13;
  --ink-2: #5d5344;
  --ink-3: #8b806d;
  --line: #e0d4bc;
  --tomato: #b9391f;
  --tomato-bg: #f7dfd6;
  --mustard: #a86f06;
  --mustard-bg: #f5e6c2;
  --sage: #3f6b47;
  --sage-bg: #dde9d8;
  --accent: #23453a;
  --accent-2: #2f5c4d;
  --accent-ink: #fffbf3;
  --shadow: 0 1px 0 rgb(70 45 10 / 0.06), 0 10px 26px -16px rgb(70 45 10 / 0.35);
  --shadow-lift: 0 2px 0 rgb(70 45 10 / 0.05), 0 18px 40px -18px rgb(70 45 10 / 0.45);
  --radius: 16px;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 140ms;
  --normal: 260ms;
  --glow: rgb(255 255 255 / 0.45);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16120d;
    --paper-2: #221c15;
    --card: #1e1912;
    --ink: #f2e9d9;
    --ink-2: #c1b49c;
    --ink-3: #8f836e;
    --line: #3a3126;
    --tomato: #e8664c;
    --tomato-bg: #3b1d14;
    --mustard: #e2a83d;
    --mustard-bg: #3a2b0f;
    --sage: #86b58e;
    --sage-bg: #1d2c1f;
    --accent: #8cc4a6;
    --accent-2: #a6d6bb;
    --accent-ink: #10201a;
    --shadow: 0 1px 0 rgb(0 0 0 / 0.4), 0 12px 28px -18px rgb(0 0 0 / 0.8);
    --shadow-lift: 0 18px 40px -18px rgb(0 0 0 / 0.9);
    --glow: rgb(226 168 61 / 0.07);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 500px at 85% -10%, var(--glow), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .1 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font: 16px/1.45 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid color-mix(in oklab, var(--accent) 55%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot {
  min-height: 100dvh; display: grid; place-items: center;
  font: 600 44px var(--font-display); letter-spacing: -0.02em; color: var(--ink-3);
}
.boot.error { font: 16px var(--font-body); text-align: center; padding: 24px; gap: 12px; }

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom));
}

/* ---------- Záhlaví ---------- */
.eyebrow {
  font: 650 12px/1.2 var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.title {
  margin: 4px 0 14px;
  font: 650 42px/1 var(--font-display);
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 96, "SOFT" 60;
}
.title em { font-style: italic; font-weight: 400; color: var(--ink-2); }
.title-sm { margin: 0; font: 650 24px/1.1 var(--font-display); letter-spacing: -0.015em; }
.section-title {
  margin: 28px 2px 10px;
  font: 600 21px/1.2 var(--font-display);
  letter-spacing: -0.01em;
}

/* ---------- Počítadla stavu ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  position: relative;
  border: 1.5px solid transparent;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 10px 12px 9px;
  text-align: left;
  transition: transform var(--fast) var(--ease), border-color var(--fast);
}
.stat b { display: block; font: 600 32px/1 var(--font-display); font-variant-numeric: lining-nums; }
.stat span { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.stat.expired b { color: var(--tomato); }
.stat.today b { color: var(--mustard); }
.stat.soon b { color: var(--sage); }
.stat[aria-pressed="true"] { border-color: currentColor; transform: translateY(-1px); }
.stat.expired[aria-pressed="true"] { color: var(--tomato); background: var(--tomato-bg); }
.stat.today[aria-pressed="true"] { color: var(--mustard); background: var(--mustard-bg); }
.stat.soon[aria-pressed="true"] { color: var(--sage); background: var(--sage-bg); }
.stat:active { transform: scale(0.97); }

/* ---------- Hledání a filtry ---------- */
.toolbar { display: flex; gap: 8px; margin-top: 14px; }
.search { position: relative; flex: 1; }
.search .icon { position: absolute; left: 13px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 48px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); padding: 0 14px 0 42px;
  font-size: 16px;
}
.search input:focus { border-color: var(--accent-2); outline: none; }
.icon-btn {
  display: inline-grid; place-items: center;
  min-width: 48px; height: 48px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink-2);
}
.icon-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.select-wrap select {
  height: 48px; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); padding: 0 12px; font-size: 15px; max-width: 150px;
}

.tabs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 12px -16px 0; padding: 2px 16px 4px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab, .chip {
  flex: none; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: transparent;
  font-size: 14px; font-weight: 650; color: var(--ink-2);
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}
.chip { background: var(--card); }
.tab[aria-selected="true"], .chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Seznam ---------- */
.group-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 22px 4px 8px;
  font: italic 500 16px/1.2 var(--font-display);
  color: var(--ink-2);
}
.group-title small { font: 650 12px var(--font-body); color: var(--ink-3); }
.list { display: grid; gap: 8px; }
.card {
  --state: var(--line);
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center;
  width: 100%; padding: 10px 14px 10px 16px;
  border: 0; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
  text-align: left;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast);
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--state); }
.card:hover { box-shadow: var(--shadow-lift); }
.card:active { transform: scale(0.985); }
.card[data-state="expired"] { --state: var(--tomato); }
.card[data-state="today"] { --state: var(--mustard); }
.card[data-state="soon"] { --state: var(--sage); }
.thumb {
  width: 54px; height: 54px; border-radius: 13px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--paper-2); font-size: 27px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-body { min-width: 0; }
.name {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 17px/1.25 var(--font-display); letter-spacing: -0.005em;
}
.meta { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due { min-width: 56px; text-align: right; color: var(--ink-2); }
.due b { display: block; font: 600 24px/1 var(--font-display); font-variant-numeric: lining-nums; }
.due small { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.card[data-state="expired"] .due { color: var(--tomato); }
.card[data-state="today"] .due { color: var(--mustard); }
.card[data-state="soon"] .due { color: var(--sage); }

.empty { padding: 56px 20px; text-align: center; color: var(--ink-2); }
.empty .big { display: block; margin-bottom: 6px; font: 600 24px var(--font-display); color: var(--ink); }

/* ---------- Spodní lišta ---------- */
.navbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; justify-content: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.navbar-inner {
  pointer-events: auto;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  width: min(420px, 100%); padding: 6px;
  border-radius: 24px;
  background: color-mix(in oklab, var(--card) 86%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: var(--shadow-lift);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px; border-radius: 18px; text-decoration: none;
  font-size: 12px; font-weight: 650; color: var(--ink-3);
}
.nav-btn[aria-current="page"] { color: var(--ink); background: var(--paper-2); }
.fab {
  display: grid; place-items: center;
  width: 66px; height: 66px; margin-top: -30px;
  border-radius: 24px; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 14px 28px -12px color-mix(in oklab, var(--accent) 80%, black), inset 0 1px 0 rgb(255 255 255 / 0.18);
  transition: transform var(--fast) var(--ease);
}
.fab:active { transform: translateY(2px) scale(0.95); }

/* ---------- Tlačítka a formuláře ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px;
  border: 1.5px solid var(--line); border-radius: 15px;
  background: var(--card); font-weight: 700; font-size: 16px;
  transition: transform var(--fast) var(--ease), background var(--fast);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--tomato); border-color: color-mix(in oklab, var(--tomato) 45%, var(--line)); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 17px; border-radius: 18px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.stack { display: grid; gap: 10px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > .label { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; color: var(--ink-2); }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%; min-height: 48px;
  border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--card); padding: 0 13px; font-size: 16px;
}
.field textarea { padding: 10px 13px; min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-2); outline: none; }
.hint { font-size: 13px; color: var(--ink-3); }
.error-text { font-size: 13px; color: var(--tomato); font-weight: 600; }

.stepper {
  display: inline-grid; grid-template-columns: 48px minmax(56px, auto) 48px; align-items: center;
  border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card);
}
.stepper button { height: 48px; border: 0; background: transparent; color: var(--ink); }
.stepper button:active { background: var(--paper-2); }
.stepper output { text-align: center; font: 600 20px var(--font-display); font-variant-numeric: lining-nums; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.switch {
  appearance: none; flex: none;
  width: 50px; height: 30px; margin: 0; border-radius: 999px;
  background: var(--line); position: relative; cursor: pointer;
  transition: background var(--normal) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--card); box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform var(--normal) var(--ease);
}
.switch:checked { background: var(--sage); }
.switch:checked::after { transform: translateX(20px); }

.panel { padding: 16px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 10px; }
.divider { height: 1px; margin: 12px 0; background: var(--line); }

/* ---------- Detail (spodní list) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgb(20 14 6 / 0.45);
  animation: fade-in var(--normal) var(--ease);
}
.sheet {
  position: fixed; inset: auto 0 0 0; z-index: 31;
  max-width: 640px; max-height: 92dvh; margin: 0 auto; overflow-y: auto;
  padding: 6px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--card);
  box-shadow: 0 -20px 40px -20px rgb(0 0 0 / 0.35);
  animation: slide-up 320ms var(--ease);
}
.grabber { width: 42px; height: 5px; margin: 6px auto 14px; border-radius: 3px; background: var(--line); }
.sheet-photo { height: 150px; margin-bottom: 14px; border-radius: 18px; background: var(--paper-2); display: grid; place-items: center; font-size: 64px; overflow: hidden; }
.sheet-photo img { width: 100%; height: 100%; object-fit: contain; }
.sheet h2 { margin: 0; font: 650 26px/1.15 var(--font-display); letter-spacing: -0.015em; }
.sheet .sub { margin-top: 4px; color: var(--ink-2); font-size: 14px; }
.date-block {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 16px 0; padding: 14px 16px; border-radius: 16px; background: var(--paper-2);
}
.date-block .when { font: 600 24px/1.1 var(--font-display); }
.date-block[data-state="expired"] { background: var(--tomato-bg); color: var(--tomato); }
.date-block[data-state="today"] { background: var(--mustard-bg); color: var(--mustard); }
.date-block[data-state="soon"] { background: var(--sage-bg); color: var(--sage); }
.date-block .kind { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.action {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 13px 6px; border: 0; border-radius: 16px;
  background: var(--paper); font-size: 13px; font-weight: 700; color: var(--ink);
  transition: transform var(--fast) var(--ease), background var(--fast);
}
.action:active { transform: scale(0.96); background: var(--paper-2); }
.action.good { color: var(--sage); }
.action.bad { color: var(--tomato); }

/* ---------- Přidávání ---------- */
.add-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.add-top .title-sm { flex: 1; }
.pill { padding: 5px 10px; border-radius: 999px; background: var(--sage-bg); color: var(--sage); font-size: 13px; font-weight: 700; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--paper-2); margin-bottom: 14px; }
.segmented button { min-height: 42px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.scanner { position: relative; aspect-ratio: 3 / 4; max-height: 56dvh; width: 100%; border-radius: 24px; overflow: hidden; background: #0d0b08; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 30% 10%;
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgb(0 0 0 / 0.38);
  border: 3px solid rgb(255 255 255 / 0.92);
}
.scan-frame::after {
  content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px;
  background: #ff7a5c; box-shadow: 0 0 12px #ff7a5c;
  animation: scan 1.8s ease-in-out infinite alternate;
}
.scan-hint { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; color: #fff; font-weight: 650; text-shadow: 0 1px 6px rgb(0 0 0 / 0.6); }
.scan-torch { position: absolute; top: 12px; right: 12px; background: rgb(0 0 0 / 0.45); border: 0; color: #fff; }
.scanner .message { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: #f2e9d9; }

.product-head { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; margin-bottom: 18px; }
.product-head .thumb { width: 64px; height: 64px; border-radius: 16px; font-size: 32px; }
.ai-box {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 12px; border-radius: 16px;
  background: var(--sage-bg); color: var(--sage); font-weight: 650;
}
.ai-box.warn { background: var(--mustard-bg); color: var(--mustard); }
.ai-box q { color: var(--ink-2); font-weight: 500; }
.suggestions { display: grid; gap: 6px; margin: -8px 0 16px; }
.suggestion { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 13px; background: var(--card); text-align: left; }
.suggestion .thumb { width: 36px; height: 36px; border-radius: 9px; font-size: 18px; }
.sticky-save {
  position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 5;
  margin-top: 20px; padding-top: 8px;
}

.spinner {
  display: inline-block; width: 20px; height: 20px; flex: none;
  border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.center { display: grid; place-items: center; gap: 12px; min-height: 40dvh; color: var(--ink-2); text-align: center; }

/* ---------- Oznámení ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(104px + env(safe-area-inset-bottom)); z-index: 40; display: grid; justify-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
body.no-scroll .toasts { bottom: auto; top: calc(16px + env(safe-area-inset-top)); }
.toast {
  max-width: 420px; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper);
  font-weight: 650; box-shadow: var(--shadow-lift);
  animation: toast-in var(--normal) var(--ease);
}
.toast.error { background: var(--tomato); color: #fff; }

@keyframes spin { to { rotate: 360deg; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes scan { from { transform: translateY(-34px); } to { transform: translateY(34px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
@media (min-width: 700px) {
  .title { font-size: 52px; }
  .list { grid-template-columns: 1fr 1fr; }
}
