:root {
  --green: #6fa82f;
  --green-dark: #5a8a26;
  --green-soft: #eaf3df;
  --cream: #f8f6f0;
  --card: #ffffff;
  --ink: #2c2e29;
  --muted: #8a8d83;
  --line: #ece9e0;
  --warn: #d98324;
  --danger: #d4543a;
  --shadow: 0 4px 18px rgba(60, 70, 40, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }
.err { color: var(--danger); font-size: 14px; margin-top: 8px; }

/* ───── buttons ───── */
button { font-family: inherit; cursor: pointer; border: none; }
.btn-primary {
  background: var(--green); color: #fff; border-radius: 14px;
  padding: 14px 18px; font-size: 16px; font-weight: 700; width: 100%;
  box-shadow: 0 3px 10px rgba(111,168,47,.28); transition: transform .06s, background .2s;
}
.btn-primary:active { transform: scale(.98); background: var(--green-dark); }
.btn-primary.big { padding: 16px; font-size: 17px; }
.btn-secondary {
  background: var(--green-soft); color: var(--green-dark); border-radius: 14px;
  padding: 13px; font-size: 15px; font-weight: 700; width: 100%; margin-bottom: 10px;
}
.btn-ghost { background: transparent; color: var(--muted); padding: 12px; width: 100%; font-size: 15px; }
.link-btn { background: none; color: var(--green-dark); font-size: 14px; font-weight: 600; padding: 4px; }
.icon-btn { background: rgba(255,255,255,.25); color: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; }
.chip { background: var(--green-soft); color: var(--green-dark); border-radius: 20px; padding: 9px 16px; font-weight: 700; font-size: 15px; }
.chip.ghost { background: #f0eee6; color: var(--muted); }

/* ───── screens ───── */
.screen { min-height: 100vh; min-height: 100dvh; }

/* login */
#view-login, #view-onboard { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 26px; width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: 92px; height: 92px; }
.login-card h1 { margin: 12px 0 2px; font-size: 26px; }
.login-card input { width: 100%; padding: 14px; margin: 18px 0 12px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; }

/* onboarding */
.onboard-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 22px; width: 100%; max-width: 460px; }
.onboard-card h1 { margin: 0 0 4px; font-size: 24px; }
.onboard-card label, .modal-card label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 14px; }
.onboard-card input, .onboard-card select, .modal-card input, .modal-card select, .modal-card textarea {
  width: 100%; padding: 12px; margin-top: 5px; border: 1.5px solid var(--line); border-radius: 11px; font-size: 16px; background: #fff; color: var(--ink);
}
.onboard-card .row { display: flex; gap: 12px; }
.onboard-card .row label { flex: 1; }
label.check { display: flex; align-items: center; gap: 9px; margin-top: 18px; font-size: 14px; color: var(--ink); }
label.check input { width: auto; margin: 0; }
.preview-box { background: var(--green-soft); border-radius: 12px; padding: 14px; margin-top: 18px; font-size: 14px; line-height: 1.6; }
.preview-box b { color: var(--green-dark); }
#ob-save, #ob-preview ~ #ob-save { margin-top: 18px; }

/* ───── topbar ───── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff; padding: calc(env(safe-area-inset-top) + 12px) 14px 12px;
}
.topbar-logo { width: 38px; height: 38px; background: #fff; border-radius: 50%; padding: 2px; }
.topbar-title { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.topbar-title span { font-weight: 800; font-size: 18px; }
.topbar-title small { opacity: .85; font-size: 12px; }

.content { padding: 16px 14px 96px; max-width: 600px; margin: 0 auto; }
.tab { animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ───── hero / ring ───── */
.hero-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; text-align: center; }
.ring-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-big { font-size: 42px; font-weight: 800; color: var(--ink); }
.ring-big.over { color: var(--danger); }
.ring-label { font-size: 13px; color: var(--muted); }
.hero-stats { display: flex; justify-content: space-around; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats b { font-size: 19px; }
.hero-stats small { color: var(--muted); font-size: 12px; }

/* macros */
.macros { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 14px; }
.macro { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.m-label { width: 78px; font-size: 13px; color: var(--muted); }
.m-bar { flex: 1; height: 9px; background: #f0eee6; border-radius: 6px; overflow: hidden; }
.m-bar i { display: block; height: 100%; width: 0; border-radius: 6px; transition: width .4s; }
#mb-p { background: #6fa82f; } #mb-c { background: #e2b13c; } #mb-f { background: #d98364; }
.m-val { width: 52px; text-align: right; font-size: 13px; font-weight: 700; }

/* coach */
.coach-box { background: linear-gradient(135deg,#fff,#f4f8ed); border: 1px solid var(--green-soft); border-radius: var(--radius); padding: 16px; margin-top: 14px; box-shadow: var(--shadow); }
.coach-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--green-dark); }
.coach-text { margin: 8px 0 0; color: var(--ink); font-size: 15px; line-height: 1.55; }

/* cards / lists */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card-head h3 { margin: 0; font-size: 16px; }
.btn-primary.big { margin-top: 14px; }
.water-btns { display: flex; gap: 10px; margin-top: 8px; }
.list { list-style: none; margin: 6px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: none; }
.li-main { flex: 1; min-width: 0; }
.li-main b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-main small { color: var(--muted); font-size: 12px; }
.li-kcal { font-weight: 800; color: var(--green-dark); white-space: nowrap; }
.li-del { background: none; color: var(--muted); font-size: 18px; padding: 4px 6px; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; text-align: center; }

/* weight */
.weight-input { display: flex; gap: 10px; }
.weight-input input { flex: 1; padding: 12px; border: 1.5px solid var(--line); border-radius: 11px; font-size: 16px; }
.weight-input button { width: auto; padding: 12px 22px; }
.weight-summary { margin-top: 12px; font-size: 14px; line-height: 1.7; }
.weight-summary .badge { display: inline-block; background: var(--green-soft); color: var(--green-dark); border-radius: 8px; padding: 2px 9px; font-weight: 700; }
.weight-summary .badge.warn { background: #fbeede; color: var(--warn); }

/* ───── bottom nav ───── */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 14px rgba(0,0,0,.05);
}
.nav-btn { flex: 1; background: none; padding: 9px 0 7px; font-size: 22px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nav-btn span { font-size: 11px; font-weight: 600; }
.nav-btn.active { color: var(--green-dark); }

/* ───── modal ───── */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(30,32,28,.5); display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px); max-height: 92vh; overflow-y: auto; animation: slideup .25s; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h3 { margin: 0; }
.modal-close { background: #f0eee6; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; color: var(--muted); }
.photo-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed var(--green); border-radius: 14px; padding: 22px; background: var(--green-soft); color: var(--green-dark); font-weight: 700; cursor: pointer; }
.photo-drop img { max-width: 100%; max-height: 220px; border-radius: 12px; margin-top: 8px; }
.modal-card textarea { min-height: 70px; resize: vertical; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions button { flex: 1; }
.loading { text-align: center; color: var(--green-dark); font-weight: 700; padding: 16px; }

/* analysis result */
.an-total { background: var(--green-soft); border-radius: 12px; padding: 14px; text-align: center; margin-bottom: 12px; }
.an-total .kc { font-size: 34px; font-weight: 800; color: var(--green-dark); }
.an-macros { display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.an-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.an-item input { width: 70px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; text-align: right; font-size: 14px; }
.an-note { font-size: 13px; color: var(--muted); margin-top: 10px; font-style: italic; }
.an-clarify { background: #fbf3e3; border: 1px solid #f0d9a8; border-radius: 12px; padding: 13px; margin-bottom: 12px; }
.an-q { margin: 0 0 9px; font-weight: 700; color: var(--warn); font-size: 15px; }
.an-clarify-row { display: flex; gap: 8px; }
.an-clarify-row input { flex: 1; padding: 10px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 15px; }
.an-clarify-row button { width: auto; padding: 10px 16px; font-size: 14px; }
.an-clarify small { display: block; margin-top: 8px; }
.conf { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 700; }
.conf.vysoka { background: #e3f1d4; color: var(--green-dark); }
.conf.stredni { background: #fbeede; color: var(--warn); }
.conf.nizka { background: #f7ddd6; color: var(--danger); }

/* ───── mikrofon FAB ───── */
.mic-fab {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 70px); z-index: 40;
  width: 60px; height: 60px; border-radius: 50%; font-size: 26px;
  background: linear-gradient(135deg, var(--green), var(--green-dark)); color: #fff;
  box-shadow: 0 6px 18px rgba(111,168,47,.45); display: flex; align-items: center; justify-content: center;
  transition: transform .08s;
}
.mic-fab:active { transform: scale(.92); }

.voice-card { text-align: center; }
.voice-stage { padding: 14px 0 6px; }
.voice-orb {
  width: 108px; height: 108px; border-radius: 50%; font-size: 44px; margin: 0 auto 14px; display: block;
  background: var(--green-soft); color: var(--green-dark); border: 3px solid var(--green);
  transition: transform .1s;
}
.voice-orb:active { transform: scale(.95); }
.voice-orb.recording { background: #fdeceA; border-color: var(--danger); color: var(--danger); animation: pulse 1.1s infinite; }
.voice-orb.busy { opacity: .6; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(212,84,58,.45); } 70% { box-shadow: 0 0 0 22px rgba(212,84,58,0); } 100% { box-shadow: 0 0 0 0 rgba(212,84,58,0); } }
.voice-status { color: var(--muted); font-size: 14px; min-height: 20px; }
.voice-transcript { background: #f3f1e9; border-radius: 12px; padding: 12px; margin-top: 6px; font-size: 15px; text-align: left; }
.voice-transcript b { color: var(--muted); font-weight: 600; font-size: 12px; display: block; margin-bottom: 3px; }
.voice-reply { background: var(--green-soft); border-radius: 12px; padding: 14px; margin-top: 10px; font-size: 15px; color: var(--ink); text-align: left; line-height: 1.5; }

/* ───── čárový kód ───── */
.bc-reader { width: 100%; border-radius: 14px; overflow: hidden; background: #000; min-height: 220px; }
.bc-reader video { width: 100% !important; border-radius: 14px; }
.bc-product { text-align: center; margin-bottom: 6px; }
.bc-product b { display: block; font-size: 18px; }
.bc-product small { color: var(--muted); font-size: 13px; }
.bc-per100 { text-align: center; font-size: 13px; color: var(--muted); background: #f3f1e9; border-radius: 10px; padding: 9px; margin-bottom: 12px; }
.bc-per100 b { color: var(--ink); }
.bc-grams-l { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.bc-grams-l input { width: 100%; padding: 12px; margin-top: 5px; border: 1.5px solid var(--green); border-radius: 11px; font-size: 18px; font-weight: 700; text-align: center; }

/* toast */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 24px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); animation: fade .2s; }
