:root {
  --bg:#f2f4f7; --card:#ffffff; --text:#14171c; --muted:#646b76; --line:#e3e7ec;
  --accent:#ff3d68; --accent-soft:#ffe3ea; --btn:#14171c; --btn-text:#d9ff3f;
  --sage:#14b86a; --sage-soft:#dff7ea; --honey:#ff9f1a; --honey-soft:#fff0d9; --plum:#2f80ff; --plum-soft:#e2edff;
  --lime:#b8e600; --danger:#d93636; --warn:#c77700; --ring-bg:#e8ebef; --shadow:0 8px 24px #0f172a0d; color-scheme:light;
}
@media (prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) {
    --bg:#0d0f12; --card:#171a1f; --text:#f3f5f7; --muted:#9aa3ad; --line:#262b32;
    --accent:#ff4f78; --accent-soft:#3a1822; --btn:#d9ff3f; --btn-text:#0d0f12;
    --sage:#2ee68a; --sage-soft:#123324; --honey:#ffb23f; --honey-soft:#3a2a10; --plum:#5d9cff; --plum-soft:#152542;
    --lime:#d9ff3f; --danger:#ff6b6b; --warn:#ffb23f; --ring-bg:#252a31; --shadow:none; color-scheme:dark;
  }
}
:root[data-theme="dark"] {
  --bg:#0d0f12; --card:#171a1f; --text:#f3f5f7; --muted:#9aa3ad; --line:#262b32;
  --accent:#ff4f78; --accent-soft:#3a1822; --btn:#d9ff3f; --btn-text:#0d0f12;
  --sage:#2ee68a; --sage-soft:#123324; --honey:#ffb23f; --honey-soft:#3a2a10; --plum:#5d9cff; --plum-soft:#152542;
  --lime:#d9ff3f; --danger:#ff6b6b; --warn:#ffb23f; --ring-bg:#252a31; --shadow:none; color-scheme:dark;
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
[hidden] { display:none !important; }
html { background:var(--bg); }
body { margin:0; background:var(--bg); color:var(--text); font:15px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; font-variant-numeric:tabular-nums; padding-bottom:calc(96px + env(safe-area-inset-bottom)); }
button,input,select,textarea { font:inherit; color:inherit; }
button,a,input,select,label { touch-action:manipulation; }
button { cursor:pointer; transition:transform .15s, background .15s; }
button:active { transform:scale(.97); }
:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
h2 { font-size:16px; font-weight:750; margin:0 0 12px; }
.svg-library { position:absolute; width:0; height:0; overflow:hidden; }
.ui-icon { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; flex-shrink:0; }
.muted { color:var(--muted); }
.small { font-size:13px; }

main,.top { max-width:760px; margin:0 auto; padding:0 16px; }
.top { display:flex; justify-content:space-between; align-items:center; gap:10px; padding-top:calc(18px + env(safe-area-inset-top)); padding-bottom:14px; }
.brand { display:flex; align-items:center; gap:10px; text-decoration:none; color:var(--text); font-size:25px; font-weight:850; letter-spacing:-.6px; line-height:1; }
.brand img { border-radius:14px; }
.brand-light { color:var(--accent); }
.brand small { display:block; margin-top:5px; font-size:11px; font-weight:500; letter-spacing:.2px; color:var(--muted); }
.top-actions { display:flex; gap:8px; align-items:center; }
.chip-btn { border:1px solid var(--line); background:var(--card); border-radius:20px; padding:8px 12px; min-height:40px; font-size:13px; }
.sync-dot { display:flex; align-items:center; gap:6px; border:1px solid var(--line); background:var(--card); border-radius:20px; padding:8px 11px; min-height:40px; }
.sync-dot .ui-icon { width:17px; height:17px; }
.sync-dot::after { content:""; width:7px; height:7px; border-radius:50%; background:var(--muted); opacity:.5; }
.sync-dot.ok::after { background:var(--sage); opacity:1; }
.sync-dot.busy::after { background:var(--warn); opacity:1; animation:pulse 1s infinite; }
.sync-dot.err::after { background:var(--danger); opacity:1; }
@keyframes pulse { 50% { opacity:.3; } }

.card { background:var(--card); border:1px solid var(--line); border-radius:22px; padding:18px; margin-bottom:14px; box-shadow:var(--shadow); min-width:0; }
.card-head { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:10px; }
.card-head h2 { margin:0; }
.pill { font-size:12px; padding:4px 10px; border-radius:20px; background:var(--accent-soft); color:var(--text); white-space:nowrap; }

.day-nav { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; }
.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:42px; height:42px; border-radius:14px; border:1px solid var(--line); background:var(--card); padding:0; }
.icon-btn:disabled { opacity:.35; }
.day-label { flex:1; border:none; background:none; font-weight:750; font-size:16px; padding:8px; }

.hero { display:flex; gap:18px; align-items:center; }
.ring-wrap { position:relative; width:150px; height:150px; flex-shrink:0; }
.ring { width:100%; height:100%; transform:rotate(-90deg); }
.ring circle { fill:none; stroke-width:11; stroke-linecap:round; }
.ring-bg { stroke:var(--ring-bg); }
.ring-fg { stroke:var(--sage); transition:stroke-dasharray .5s; }
.ring-fg.over { stroke:var(--accent); }
.ring-center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; }
.ring-center strong { font-size:32px; font-weight:850; line-height:1; letter-spacing:-1px; }
.ring-center span { font-size:12px; color:var(--muted); margin-top:4px; max-width:100px; }
.hero-side { flex:1; min-width:0; }
.hero-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; margin-bottom:12px; }
.hero-stats div { background:var(--bg); border-radius:14px; padding:8px; text-align:center; }
.hero-stats span { display:block; font-size:11px; color:var(--muted); }
.hero-stats strong { font-size:17px; font-weight:800; }
.macro { margin-bottom:8px; }
.macro-top { display:flex; justify-content:space-between; font-size:12px; }
.macro-top b { font-weight:750; }
.bar { height:8px; border-radius:6px; background:var(--ring-bg); overflow:hidden; margin-top:3px; }
.bar i { display:block; height:100%; border-radius:6px; }
.m-p i { background:var(--sage); } .m-c i { background:var(--honey); } .m-f i { background:var(--plum); }

.add-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.add-btn { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; min-height:76px; border:1px solid var(--line); border-radius:18px; background:var(--bg); padding:10px 6px; font-size:13px; font-weight:650; text-align:center; cursor:pointer; }
.add-btn.main { grid-column:1 / -1; flex-direction:row; min-height:64px; background:var(--btn); color:var(--btn-text); border-color:transparent; font-size:17px; font-weight:800; }
.add-btn.main .ui-icon { width:26px; height:26px; }
.add-btn:active { transform:scale(.97); }

.meal-group h3 { font-size:13px; text-transform:uppercase; letter-spacing:1px; color:var(--muted); margin:18px 4px 8px; display:flex; justify-content:space-between; }
.meal { display:flex; gap:12px; align-items:center; width:100%; text-align:left; border:1px solid var(--line); background:var(--card); border-radius:18px; padding:10px; margin-bottom:8px; }
.meal img, .meal .ph { width:58px; height:58px; border-radius:14px; object-fit:cover; flex-shrink:0; background:var(--accent-soft); display:flex; align-items:center; justify-content:center; color:var(--accent); }
.meal-txt { flex:1; min-width:0; }
.meal-txt b { display:block; font-weight:750; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.meal-txt span { font-size:12px; color:var(--muted); }
.meal-kcal { font-weight:850; font-size:17px; white-space:nowrap; }
.meal-kcal small { font-weight:500; font-size:11px; color:var(--muted); }
.empty { text-align:center; color:var(--muted); padding:18px 10px; font-size:14px; }

.bars { display:flex; align-items:flex-end; gap:8px; height:130px; padding-top:16px; position:relative; }
.bars .col { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; height:100%; gap:4px; font-size:11px; color:var(--muted); background:none; border:none; padding:0; }
.bars .col i { display:block; width:100%; max-width:34px; border-radius:8px 8px 4px 4px; background:var(--sage); min-height:3px; }
.bars .col.over i { background:var(--accent); }
.bars .col.sel span { color:var(--text); font-weight:800; }
.bars .goal-line { position:absolute; left:0; right:0; border-top:2px dashed var(--line); pointer-events:none; }

.hist-day { display:flex; justify-content:space-between; align-items:center; width:100%; border:none; border-bottom:1px solid var(--line); background:none; padding:12px 4px; text-align:left; gap:10px; }
.hist-day b { font-weight:750; }
.hist-day span { font-size:12px; color:var(--muted); }
.hist-thumbs { display:flex; gap:4px; }
.hist-thumbs img { width:30px; height:30px; border-radius:8px; object-fit:cover; }

.inline-form, .ex-form { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px; }
.inline-form input, .ex-form input, .ex-form select { flex:1 1 90px; min-width:0; }
input[type=text], input[type=date], input[type=number], select, textarea {
  border:1px solid var(--line); background:var(--bg); border-radius:14px; padding:10px 12px; min-height:44px; width:100%; }
textarea { min-height:90px; resize:vertical; }
button.primary, .primary { background:var(--btn); color:var(--btn-text); border:none; border-radius:14px; padding:10px 18px; min-height:44px; font-weight:800; }
.row-btns { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.row-btns button, .file-btn { border:1px solid var(--line); background:var(--bg); border-radius:14px; padding:10px 14px; min-height:44px; font-weight:650; display:inline-flex; align-items:center; cursor:pointer; }
.row-btns button.primary { background:var(--btn); color:var(--btn-text); border-color:transparent; }
.ghost { border:1px solid var(--line); background:transparent; border-radius:14px; padding:10px 14px; min-height:44px; font-weight:650; }
.danger-txt { color:var(--danger); }
.mini-list .row { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:9px 2px; border-bottom:1px solid var(--line); font-size:14px; }
.mini-list .row button { border:none; background:none; color:var(--muted); padding:6px; min-width:36px; min-height:36px; }
.chart svg { width:100%; height:auto; display:block; }
.warn-box { background:var(--honey-soft); border-radius:14px; padding:10px 12px; font-size:13px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px 12px; }
.form-grid label span { display:block; font-size:12px; color:var(--muted); margin-bottom:3px; }
.calc-box { margin-top:14px; background:var(--sage-soft); border-radius:16px; padding:12px 14px; font-size:13px; }
.calc-box b { font-size:20px; }
.code { font-weight:750; word-break:break-all; background:var(--bg); padding:8px 12px; border-radius:12px; margin:8px 0; }

.tabs { position:fixed; left:0; right:0; bottom:0; display:flex; justify-content:center; gap:4px; background:var(--card); border-top:1px solid var(--line); padding:6px 8px calc(6px + env(safe-area-inset-bottom)); z-index:5; }
.tabs button { flex:1; max-width:150px; display:flex; flex-direction:column; align-items:center; gap:2px; border:none; background:none; color:var(--muted); font-size:11px; font-weight:650; padding:6px 2px; border-radius:14px; min-height:52px; }
.tabs button.active { color:var(--accent); background:var(--accent-soft); }

.sheet-backdrop { position:fixed; inset:0; background:#2a1d1580; z-index:20; display:flex; align-items:flex-end; justify-content:center; }
.sheet { background:var(--card); width:100%; max-width:640px; max-height:92vh; max-height:92dvh; border-radius:24px 24px 0 0; display:flex; flex-direction:column; padding-bottom:env(safe-area-inset-bottom); }
.sheet-head { display:flex; justify-content:space-between; align-items:center; padding:14px 16px 8px; gap:10px; }
.sheet-head h2 { margin:0; font-size:18px; }
.sheet-body { overflow-y:auto; padding:4px 16px 18px; -webkit-overflow-scrolling:touch; }
@media (min-width:700px) { .sheet-backdrop { align-items:center; } .sheet { border-radius:24px; } }

.photo-prev { width:100%; max-height:240px; object-fit:cover; border-radius:18px; display:block; margin-bottom:10px; }
.loading { display:flex; flex-direction:column; align-items:center; gap:10px; padding:24px 10px; text-align:center; color:var(--muted); }
.spinner { width:34px; height:34px; border-radius:50%; border:4px solid var(--accent-soft); border-top-color:var(--accent); animation:spin 1s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.chips { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0; }
.chips button { border:1px solid var(--line); background:var(--bg); border-radius:20px; padding:6px 12px; min-height:36px; font-size:13px; }
.chips button.on { background:var(--accent-soft); border-color:var(--accent); font-weight:750; }
.item { border:1px solid var(--line); border-radius:18px; padding:10px 12px; margin-bottom:8px; background:var(--bg); }
.item-top { display:flex; justify-content:space-between; gap:8px; align-items:flex-start; }
.item-name { font-weight:750; border:none; background:none; padding:0; text-align:left; flex:1; min-width:0; }
.item-kcal { font-weight:850; white-space:nowrap; }
.item-del { border:none; background:none; color:var(--muted); padding:2px; min-width:32px; min-height:32px; }
.badges { display:flex; gap:5px; flex-wrap:wrap; margin-top:3px; }
.badge { font-size:11px; border-radius:10px; padding:1px 8px; background:var(--honey-soft); }
.badge.low { background:var(--accent-soft); }
.grams { display:flex; align-items:center; gap:8px; margin-top:8px; }
.grams input[type=range] { flex:1; accent-color:var(--accent); min-width:0; }
.grams .g-input { width:76px; flex:none; text-align:center; padding:6px; min-height:38px; }
.g-step { width:38px; height:38px; border-radius:12px; border:1px solid var(--line); background:var(--card); display:inline-flex; align-items:center; justify-content:center; padding:0; flex:none; }
.item-meta { font-size:12px; color:var(--muted); margin-top:4px; }
.per100 { display:grid; grid-template-columns:repeat(4,1fr); gap:6px; margin-top:8px; }
.per100 label span { font-size:11px; color:var(--muted); display:block; }
.per100 input { padding:6px 8px; min-height:38px; }
.totals { display:flex; justify-content:space-between; align-items:center; gap:10px; background:var(--accent-soft); border-radius:16px; padding:12px 14px; margin:12px 0; font-size:13px; }
.totals b { font-size:22px; }
.sheet-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.sheet-actions .primary { flex:1; min-height:52px; font-size:16px; }
.note-box { font-size:13px; color:var(--muted); background:var(--bg); border-radius:14px; padding:8px 12px; margin:6px 0; }
.search-res button { display:flex; justify-content:space-between; width:100%; border:none; border-bottom:1px solid var(--line); background:none; padding:10px 4px; text-align:left; gap:10px; }
.recent-meal { display:flex; gap:10px; align-items:center; width:100%; border:none; border-bottom:1px solid var(--line); background:none; padding:10px 2px; text-align:left; }
.recent-meal img, .recent-meal .ph { width:44px; height:44px; border-radius:12px; object-fit:cover; background:var(--accent-soft); flex:none; }
video.scan { width:100%; border-radius:18px; background:#000; max-height:50vh; object-fit:cover; }

.toast { position:fixed; left:50%; bottom:calc(84px + env(safe-area-inset-bottom)); transform:translateX(-50%); background:var(--text); color:var(--bg); border-radius:16px; padding:10px 16px; font-size:14px; z-index:30; max-width:calc(100% - 32px); display:flex; gap:12px; align-items:center; }
.toast button { background:none; border:none; color:inherit; font-weight:800; text-decoration:underline; padding:4px; }

@media (max-width:520px) {
  .hero { flex-direction:column; align-items:stretch; }
  .ring-wrap { margin:0 auto; }
  .form-grid { grid-template-columns:1fr; }
  .add-grid { grid-template-columns:repeat(2,1fr); }
  .brand { font-size:22px; }
  .brand small { display:none; }
}

/* ---- sportovní styl ---- */
.brand { font-style:italic; font-weight:900; text-transform:uppercase; letter-spacing:-.5px; }
.brand-light { color:var(--accent); }
h2 { text-transform:uppercase; letter-spacing:.6px; font-size:14px; font-weight:850; }
.card { border-radius:20px; }
.ring circle { stroke-width:13; }
.ring-fg { stroke:url(#ringGrad); }
.ring-fg.over { stroke:var(--accent); }
.ring-center strong { font-size:36px; font-style:italic; font-weight:900; }
.hero-stats strong, .meal-kcal, .item-kcal, .totals b, .calc-box b { font-style:italic; font-weight:900; }
.hero-stats span, .meal-group h3, .ring-center span { text-transform:uppercase; letter-spacing:.8px; font-weight:700; }
.hero-stats span { font-size:10px; }
.add-btn.main { text-transform:uppercase; letter-spacing:.5px; font-style:italic; font-weight:900; }
.bars .col i { background:linear-gradient(180deg,var(--sage),#0fa37a); }
.bars .col.over i { background:linear-gradient(180deg,var(--accent),#ff7a3d); }
.tabs button.active { color:var(--text); background:var(--lime); }
:root[data-theme="dark"] .tabs button.active, .tabs button.active { color:#0d0f12; }
.pill { background:var(--lime); color:#0d0f12; font-weight:800; }
.day-label { text-transform:uppercase; letter-spacing:.6px; font-weight:900; font-style:italic; }
.totals { background:var(--btn); color:var(--btn-text); }
.totals b { font-size:26px; }
input.item-name { border:none; background:transparent; padding:2px 0; min-height:34px; font-weight:800; font-size:15px; border-bottom:1px dashed var(--line); border-radius:0; }
.photo-prev { max-height:200px; }

/* ---- zámek PIN ---- */
body.locked main, body.locked .tabs, body.locked .top { display:none !important; }
.lock { position:fixed; inset:0; z-index:40; background:var(--bg); display:flex; align-items:center; justify-content:center; padding:calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); overflow-y:auto; }
.lock-box { width:100%; max-width:320px; text-align:center; display:flex; flex-direction:column; align-items:center; gap:6px; }
.lock-box img { border-radius:20px; }
.lock-box h1 { font-size:22px; font-weight:900; font-style:italic; text-transform:uppercase; margin:10px 0 0; }
.lock-box p { margin:0; }
.pin-dots { display:flex; gap:12px; justify-content:center; min-height:22px; margin:14px 0 4px; }
.pin-dots i { width:16px; height:16px; border-radius:50%; border:2px solid var(--muted); }
.pin-dots i.on { background:var(--lime); border-color:var(--lime); }
.lock-err { color:var(--danger); font-size:14px; font-weight:700; min-height:21px; }
.keypad { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; width:100%; margin:6px 0 14px; }
.keypad button { height:62px; border-radius:18px; border:1px solid var(--line); background:var(--card); font-size:24px; font-weight:800; }
.keypad button.ok { background:var(--btn); color:var(--btn-text); border-color:transparent; font-size:18px; }
.keypad button:disabled { opacity:.4; }
.lock.shake .pin-dots { animation:shake .35s; }
@keyframes shake { 25% { transform:translateX(-8px); } 75% { transform:translateX(8px); } }

/* ---- jednoduchá úvodní obrazovka ---- */
.big-photo { display:flex; min-height:78px; margin:0 0 10px; border-radius:22px; font-size:20px; box-shadow:0 10px 30px #d9ff3f22; }
.big-photo .ui-icon { width:30px; height:30px; }
.add-row { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:16px; }
.add-link { display:flex; flex-direction:column; align-items:center; gap:4px; border:1px solid var(--line); background:var(--card); border-radius:16px; padding:10px 4px; min-height:62px; font-size:12px; font-weight:700; color:var(--text); cursor:pointer; text-align:center; }
.add-link .ui-icon { width:20px; height:20px; }
.macro-line { text-align:center; margin-top:4px; }
.limit-input { display:flex; align-items:center; gap:10px; }
.limit-input input { font-size:28px; font-weight:900; font-style:italic; max-width:200px; min-height:56px; }
.limit-input span { font-weight:800; color:var(--muted); }
.limit-card { border-color:var(--lime); }
details.more { margin-top:12px; border-top:1px solid var(--line); padding-top:10px; }
details.more summary { cursor:pointer; font-weight:750; color:var(--muted); padding:8px 0; min-height:40px; }
details.more[open] summary { color:var(--text); }
details.more .form-grid { margin-top:8px; }
label.check { display:flex; align-items:center; gap:10px; grid-column:1 / -1; }
label.check input { width:22px; height:22px; accent-color:var(--accent); }
label.check span { margin:0 !important; font-size:14px !important; color:var(--text) !important; }
.left-after { font-weight:800; }
.totals { flex-wrap:wrap; }
.hero-stats { grid-template-columns:repeat(auto-fit,minmax(0,1fr)); }
button.item-kcal { border:none; background:none; padding:0 2px; color:var(--text); font-size:15px; text-decoration:underline dotted var(--muted); text-underline-offset:4px; }
