:root {
  --green: #2d6a4f;
  --green-dark: #1f4d38;
  --green-light: #d8f3dc;
  --bg: #f7f7f5;
  --card: #ffffff;
  --text: #1b1b1b;
  --muted: #4b5563;          /* B10: kontrast 7,5:1 na bílé */
  --red: #b91c1c;
  --amber: #b45309;
  --blue: #2563eb;
  --border: #dddddd;
  --line: #ececec;
  --chip-done-bg: #ededed;
  --chip-done-text: #374151;
  --skeleton: #e8e8e6;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  --ring-track: #e8e8e6;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --green: #4ca87c;
    --green-dark: #3a8a63;
    --green-light: #1e3a2c;
    --bg: #101211;
    --card: #1c1f1d;
    --text: #eceeed;
    --muted: #a5adb8;        /* ≥4,5:1 na --card */
    --red: #f87171;
    --amber: #fbbf24;
    --blue: #60a5fa;
    --border: #3a3f3c;
    --line: #2c302e;
    --chip-done-bg: #2a2e2c;
    --chip-done-text: #c3c9c6;
    --skeleton: #262a28;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    --ring-track: #2c302e;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
.view { max-width: 520px; margin: 0 auto; padding: 16px; padding-bottom: 24px; }
/* A2: dnešek má fixní akční lištu + taby → obsah dostane rezervu, nic není překryté */
#view-today { padding-bottom: calc(148px + env(safe-area-inset-bottom)); }
#view-overview, #view-profile, #view-repeat, #view-review { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
h2 { font-size: 1.3rem; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.error { color: var(--red); min-height: 1.2em; margin-top: 8px; }

input, select, button, textarea {
  font: inherit; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: var(--text); width: 100%;
}
button { cursor: pointer; width: auto; min-height: 44px; }  /* A3 */
button.primary { background: var(--green); color: #fff; border: none; font-weight: 600; }
button.secondary { background: var(--chip-done-bg); border: none; }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row > * { flex: 1; }

/* ---------- login ---------- */
.login-box { margin-top: 12vh; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { font-size: 2rem; }
.profile-chips { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; min-height: 0; }
.profile-chip {
  border: 1.5px solid var(--green); color: var(--green); background: transparent;
  border-radius: 999px; padding: 10px 20px; font-weight: 600; font-size: 1rem;
}
.profile-chip.selected { background: var(--green); color: #fff; }
.pass-wrap { position: relative; }
.pass-wrap input { width: 100%; padding-right: 52px; }
.pass-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 1.1rem; padding: 8px 10px; min-height: 44px; min-width: 44px;
}

/* ---------- den / hlavička ---------- */
.day-nav { display: flex; align-items: center; gap: 4px; }
.day-nav button {
  background: var(--chip-done-bg); border: none; border-radius: 10px;
  min-width: 44px; min-height: 44px; padding: 6px 12px; font-size: 1.4rem; line-height: 1;  /* A3/A6 */
}
#today-title {
  background: none; border: none; font-size: 1.25rem; font-weight: 700; color: var(--text);
  padding: 8px 4px; min-height: 44px; text-align: left; flex: 1;
}
#today-title .sub { display: block; font-size: 0.72rem; font-weight: 500; color: var(--muted); }

/* ---------- karta bilance (B1) ---------- */
.balance-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.ring-wrap { display: flex; justify-content: center; margin-bottom: 6px; }
.ring { position: relative; width: 168px; height: 168px; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .track { stroke: var(--ring-track); }
.ring .bar { stroke: var(--green); transition: stroke-dashoffset 0.5s; stroke-linecap: round; }
.ring .bar.over { stroke: var(--amber); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.ring-center .num { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.ring-center .lbl { font-size: 0.75rem; color: var(--muted); }
.balance-row { display: flex; justify-content: space-around; text-align: center; margin: 4px 0 2px; }
.balance-row .val { font-size: 1.02rem; font-weight: 700; }
.balance-row .cap { font-size: 0.72rem; color: var(--muted); }
.breakdown { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--muted); }
.protein-block { margin-top: 12px; }
.protein-block .head { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 4px; }
.mini-bar { height: 8px; background: var(--ring-track); border-radius: 4px; overflow: hidden; }
.mini-bar > div { height: 100%; background: var(--blue); border-radius: 4px; transition: width 0.3s; }
.mini-bar > div.full { background: var(--green); }
.fasting-chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 0.85rem; color: var(--muted); box-shadow: var(--shadow);
}

/* ---------- karty a jídla ---------- */
.meal-card {
  background: var(--card); border-radius: var(--radius); padding: 12px;
  box-shadow: var(--shadow); margin-bottom: 10px;
  display: flex; gap: 12px; align-items: center; width: 100%;
  border: none; text-align: left; font: inherit; color: var(--text);
}
.meal-card img, .meal-card .noimg { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.meal-card .noimg { background: var(--chip-done-bg); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.meal-card .info { flex: 1; min-width: 0; }
.meal-card .kj { font-weight: 700; white-space: nowrap; }
.conf-low { color: var(--red); }
.conf-medium { color: var(--amber); }
.conf-high { color: var(--green); }

.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
code { background: var(--chip-done-bg); padding: 8px; border-radius: 8px; word-break: break-all; display: block; }

  background: var(--green-light); border: 1px solid var(--green); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; cursor: pointer;
}

/* ---------- chipy (B2) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  border-radius: 999px; padding: 10px 14px; font-size: 0.85rem; width: auto; min-height: 44px;  /* A3 */
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.add { background: transparent; border: 1.5px dashed var(--green); color: var(--green); font-weight: 600; }
.chip.done { background: var(--chip-done-bg); color: var(--chip-done-text); border: none; }
.chip.done .time { color: var(--muted); font-size: 0.75rem; }
.chip .x { margin-left: 2px; color: var(--muted); }
.logged-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 6px; }
.water-bar { height: 10px; background: var(--ring-track); border-radius: 5px; overflow: hidden; }
#water-fill { height: 100%; width: 0%; background: var(--blue); border-radius: 5px; transition: width 0.3s; }
.info-btn {
  background: none; border: none; color: var(--muted); font-size: 1.05rem;
  padding: 8px; min-width: 44px; min-height: 44px; vertical-align: middle;
}
.info-sheet h4 { font-size: 0.9rem; margin: 10px 0 2px; }
.info-sheet p { font-size: 0.88rem; color: var(--muted); margin: 0 0 2px; }
.info-sheet .scale { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted); padding: 2px 2px 0; }
.feel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.feel-grid select { padding: 8px 10px; min-height: 44px; }

/* ---------- akční lišta (A1/A2) ---------- */
#actionbar {
  position: fixed; bottom: calc(58px + env(safe-area-inset-bottom)); left: 0; right: 0; z-index: 9;
  display: flex; gap: 8px; padding: 10px 12px;
  max-width: 520px; margin: 0 auto;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
#actionbar .act-primary {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green); color: #fff; border: none; border-radius: 999px;
  min-height: 52px; font-weight: 700; font-size: 1rem; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
#actionbar .act-mini {
  width: 52px; min-width: 52px; min-height: 52px; border-radius: 999px; border: none;
  background: var(--card); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  font-size: 1.25rem; display: flex; align-items: center; justify-content: center; padding: 0;
}

/* ---------- review ---------- */
.review-photo { width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--radius); margin-bottom: 10px; }
.loading { text-align: center; padding: 30px 0; font-size: 1.1rem; }
.item-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 0;
  border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
.item-row .name { flex: 1; min-width: 0; }
.item-row .grams-btn {
  background: var(--chip-done-bg); border: none; border-radius: 8px;
  padding: 6px 10px; min-height: 40px; font-size: 0.85rem; white-space: nowrap; color: var(--text);
}
.item-row .ikj { white-space: nowrap; font-weight: 600; font-size: 0.85rem; }
.item-row .idel { background: none; border: none; color: var(--muted); font-size: 1rem; min-width: 44px; min-height: 44px; padding: 0; }
.question {
  background: var(--green-light); border-radius: var(--radius); padding: 12px; margin: 12px 0;
  display: flex; flex-direction: column; gap: 8px;
}
.portion { margin: 14px 0 6px; }
.portion input { width: 100%; padding: 0; min-height: 44px; }

/* ---------- přehled (B5) ---------- */
.streak { font-size: 0.95rem; font-weight: 600; margin-bottom: 10px; }
.chart-wrap { position: relative; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--green); min-height: 2px; }
.chart .bar.over { background: #dc2626; }
@media (prefers-color-scheme: dark) { .chart .bar.over { background: #ef4444; } }
.chart .lbl { font-size: 0.6rem; color: var(--muted); }
.goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--amber); pointer-events: none; }
.goal-line span {
  position: absolute; right: 0; top: -18px; font-size: 0.65rem; color: var(--amber);
  background: var(--card); padding: 1px 5px; border-radius: 6px;
}
.week-avg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 0.88rem; }
.week-avg .h { font-weight: 700; margin-bottom: 2px; }
.weight-chart { width: 100%; height: auto; display: block; }
.empty-state { text-align: center; color: var(--muted); padding: 26px 12px; font-size: 0.95rem; }

/* ---------- skeletony (A7) ---------- */
@keyframes pulse { 0% { opacity: 0.55; } 50% { opacity: 1; } 100% { opacity: 0.55; } }
.skel { background: var(--skeleton); border-radius: 10px; animation: pulse 1.2s ease-in-out infinite; }
.skel-card { height: 84px; margin-bottom: 10px; border-radius: var(--radius); }
.skel-ring { width: 168px; height: 168px; border-radius: 50%; margin: 0 auto 6px; }
.skel-line { height: 14px; margin: 8px auto; width: 60%; }

/* ---------- bottom sheet (A4) ---------- */
#sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 40;
  opacity: 0; transition: opacity 0.2s;
}
#sheet-backdrop.open { opacity: 1; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 520px; margin: 0 auto;
  background: var(--card); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.22s ease-out;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.25);
}
#sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 12px; }
.sheet-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 10px; }
.sheet-msg { font-size: 0.95rem; margin-bottom: 14px; color: var(--text); }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet-actions > * { flex: 1; }
.preset-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.preset-chips .chip.add.selected { background: var(--green); color: #fff; border-style: solid; }
.stepper { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 10px 0; }
.stepper button {
  width: 52px; height: 52px; min-height: 52px; border-radius: 50%; border: 1.5px solid var(--green);
  background: transparent; color: var(--green); font-size: 1.5rem; line-height: 1; padding: 0;
}
.stepper .val { font-size: 1.5rem; font-weight: 700; min-width: 80px; text-align: center; }
.sheet-photo { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; margin-bottom: 10px; }
.sheet-items { margin-bottom: 6px; }
.sheet-items .item-row { min-height: auto; padding: 7px 0; }

/* ---------- onboarding (C2) ---------- */
#onboarding {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.onb-box {
  background: var(--card); border-radius: 18px 18px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  max-width: 520px; width: 100%; position: relative;
}
.onb-box h3 { margin-bottom: 12px; font-size: 1.15rem; }
.onb-step { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.onb-step:last-of-type { border-bottom: none; }
.onb-step .n {
  width: 30px; height: 30px; border-radius: 50%; background: var(--green-light); color: var(--green);
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
@media (prefers-color-scheme: dark) { .onb-step .n { color: #8ed3b0; } }
.onb-step .t { font-size: 0.92rem; }
.onb-step .t b { display: block; margin-bottom: 2px; }
.onb-step button { display: block; margin-top: 8px; padding: 8px 14px; font-size: 0.85rem; min-height: 40px; }
.onb-close {
  position: absolute; top: 6px; right: 6px; background: none; border: none;
  font-size: 1.2rem; color: var(--muted); min-width: 44px; min-height: 44px;
}

/* ---------- přepínač (C1) ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; z-index: 2; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 16px; background: var(--border); transition: background 0.2s;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- tabbar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar button {
  flex: 1; background: none; border: none; padding: 8px 0 6px; min-height: 56px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 1.2rem; color: var(--muted); border-radius: 0;
}
#tabbar button span { font-size: 0.7rem; }
#tabbar button.active { color: var(--green); font-weight: 600; }
