:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2421;
  --muted: #66736e;
  --line: #e1e6e3;
  --accent: #1f8a6b;
  --accent-soft: #e3f3ed;
  --danger: #c2413a;
  --warn: #b7791f;
  --glucose: #d9653b;
  --bp-sys: #3b6fd9;
  --bp-dia: #8aa8ea;
  --weight: #8a4fd0;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --card: #1b2220;
    --text: #e6ece9;
    --muted: #93a19b;
    --line: #2c3632;
    --accent: #3cbf96;
    --accent-soft: #1d3a31;
    --danger: #ec6a62;
    --warn: #e0a84a;
    --glucose: #f08a5d;
    --bp-sys: #6f97f0;
    --bp-dia: #a4bdf3;
    --weight: #b083ea;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

[hidden] { display: none !important; }

header.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

header.top h1 { font-size: 18px; margin: 0; }

.datenav { display: flex; align-items: center; gap: 4px; }
.datenav button { min-width: 40px; }
.datenav .label { font-weight: 600; min-width: 110px; text-align: center; }

main { padding: 16px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.card h2 { font-size: 16px; margin: 0 0 12px; }
.card h2 small { color: var(--muted); font-weight: 400; }

button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button:disabled { opacity: 0.55; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }
.grow { flex: 1; }

label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }

input, select, textarea {
  font: inherit;
  font-size: 16px; /* zabrání zoomu na iPhonu */
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

textarea { min-height: 96px; resize: vertical; }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick button { flex-direction: column; padding: 12px 6px; font-weight: 600; }
.quick button span { font-size: 22px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.list .time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; }
.list .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.list .meta { color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.empty { color: var(--muted); font-size: 14px; margin: 0; }

.faces { display: flex; gap: 6px; }
.faces button { flex: 1; font-size: 24px; padding: 8px 0; }
.faces button.on { background: var(--accent-soft); border-color: var(--accent); }

.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.totals div { background: var(--bg); border-radius: 10px; padding: 8px 4px; }
.totals b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.totals span { font-size: 12px; color: var(--muted); }

.meal { border-top: 1px solid var(--line); padding: 12px 0; }
.meal:first-of-type { border-top: 0; }
.meal-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.meal-head .t { font-weight: 600; }
.meal-text { margin: 4px 0 6px; }
.meal-sum { font-size: 14px; color: var(--muted); }
.meal-sum b { color: var(--text); }
.meal-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.meal-actions button { padding: 6px 10px; font-size: 14px; }
.ai-comment { font-size: 14px; background: var(--accent-soft); border-radius: 10px; padding: 8px 10px; margin-top: 8px; }

table.items { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; font-variant-numeric: tabular-nums; }
table.items th, table.items td { padding: 4px 3px; text-align: right; border-bottom: 1px solid var(--line); }
table.items th:first-child, table.items td:first-child { text-align: left; }
table.items th { color: var(--muted); font-weight: 500; }

.compose-row { display: flex; gap: 8px; align-items: flex-start; }
.mic {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 22px;
  padding: 0;
}
.mic.rec { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; flex: 1; }
.seg button.on { background: var(--accent); color: #fff; }

.chart-wrap { position: relative; height: 220px; }

nav.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
nav.tabs button {
  flex: 1;
  border: 0;
  border-radius: 0;
  background: transparent;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  padding: 8px 0 10px;
  color: var(--muted);
}
nav.tabs button span { font-size: 22px; }
nav.tabs button.on { color: var(--accent); font-weight: 600; }

dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 18px;
  width: min(480px, calc(100vw - 24px));
  background: var(--card);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog h3 { margin: 0 0 6px; }
dialog .actions { display: flex; gap: 8px; margin-top: 16px; }
dialog .actions .spacer { flex: 1; }

.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { text-align: center; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.warn-text { color: var(--warn); }
