:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --border: #dde4e2;
  --text: #0f1a18;
  --text-2: #43514e;
  --muted: #6f7d7a;
  --accent: #0e9f8e;
  --accent-2: #0b8577;
  --accent-soft: #dcf3ef;
  --accent-ink: #fff;
  --late: #d93f3f;
  --late-soft: #fde8e7;
  --due: #b86e00;
  --due-soft: #fff1d6;
  --ok: #1f8a4c;
  --ok-soft: #e1f4e8;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(15 26 24 / 6%), 0 2px 8px rgb(15 26 24 / 5%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1312;
    --surface: #161d1c;
    --surface-2: #1f2827;
    --border: #2b3634;
    --text: #e9efed;
    --text-2: #b9c5c2;
    --muted: #8b9a97;
    --accent: #22b5a2;
    --accent-2: #3cc7b4;
    --accent-soft: #143a35;
    --accent-ink: #04201c;
    --late: #ff7a72;
    --late-soft: #3d1c1b;
    --due: #f2b649;
    --due-soft: #3a2c10;
    --ok: #5fcf8c;
    --ok-soft: #173326;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
button, a, label, input, select, textarea, summary, [data-act] { touch-action: manipulation; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 4px;
  max-width: 720px; margin: 0 auto;
}
.top h1 { font-size: 18px; line-height: 1.2; margin: 0; display: flex; gap: 8px; align-items: center; letter-spacing: -0.01em; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px 16px; }
h2 { font-size: 20px; margin: 18px 0 10px; letter-spacing: -0.01em; }
h3 { font-size: 16px; margin: 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px 0; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* ---------- tlačidlá a formuláre ---------- */
button { font: inherit; color: inherit; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 10px 14px; font-weight: 600; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--late); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.link { background: none; border: 0; color: var(--accent-2); font-weight: 600; padding: 6px 4px; cursor: pointer; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; font-size: 18px;
}
label.f { display: block; font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 14px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.inline-num { width: 84px; text-align: center; }
.inline-time { width: 120px; }
.frow { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.frow > label { flex: 1; min-width: 0; line-height: 1.3; }
.frow > input { flex: none; }
.frow .unit { width: 48px; flex: none; color: var(--text-2); }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; padding: 6px 0; }

/* segmentový prepínač */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; font-size: 14px; font-weight: 600;
  color: var(--text-2); cursor: pointer; min-height: 40px; line-height: 1.2;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* čipy */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 7px 12px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
  min-height: 38px; color: var(--text-2);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip small { font-weight: 500; color: var(--muted); }
.chip .x { margin-left: 2px; opacity: 0.6; }

/* ---------- karty ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.banner { border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 10px; align-items: center; margin: 8px 0; font-weight: 600; }
.banner.late { background: var(--late-soft); color: var(--late); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.info { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.banner .grow { line-height: 1.3; }

.av {
  --c: var(--accent); flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 22px; background: color-mix(in srgb, var(--c) 22%, var(--surface)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent);
}
.av.sm { width: 28px; height: 28px; font-size: 16px; }
.av.lg { width: 52px; height: 52px; font-size: 30px; }

/* ---------- Dnes ---------- */
.daybar { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.daybar .title { flex: 1; text-align: center; border: 0; background: none; font-weight: 700; font-size: 17px; cursor: pointer; padding: 6px; }
.daybar .title small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }

.group { margin: 16px 0 6px; }
.group-h { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; }
.group-h .t { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.group-h .lbl { font-weight: 600; color: var(--text-2); }
.group-h .grow { min-width: 0; }
.tag { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.tag.late { background: var(--late-soft); color: var(--late); }
.tag.due { background: var(--due-soft); color: var(--due); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.mute { background: var(--surface-2); color: var(--muted); }

.dose {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; cursor: pointer; box-shadow: var(--shadow); position: relative;
}
.dose + .dose { margin-top: 8px; }
.dose .main { flex: 1; min-width: 0; }
.dose .name { font-weight: 700; font-size: 16px; line-height: 1.25; }
.dose .name .dz { font-weight: 600; color: var(--text-2); }
.dose .sub { font-size: 14px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.dose .st { font-size: 13px; font-weight: 700; margin-top: 4px; }
.dose.st-late { border-color: color-mix(in srgb, var(--late) 45%, var(--border)); background: color-mix(in srgb, var(--late-soft) 55%, var(--surface)); }
.dose.st-late .st { color: var(--late); }
.dose.st-due { border-color: color-mix(in srgb, var(--due) 45%, var(--border)); }
.dose.st-due .st { color: var(--due); }
.dose.st-given .st { color: var(--ok); }
.dose.st-given, .dose.st-skipped { box-shadow: none; }
.dose.st-given .name, .dose.st-skipped .name { color: var(--text-2); }
.dose.st-skipped .st, .dose.st-unknown .st { color: var(--muted); }

.chk {
  flex: none; width: 48px; height: 48px; border-radius: 50%; border: 2.5px solid var(--border); background: var(--surface);
  display: grid; place-items: center; font-size: 24px; font-weight: 800; color: transparent; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chk:hover { border-color: var(--accent); color: color-mix(in srgb, var(--accent) 40%, transparent); }
.st-late .chk { border-color: var(--late); }
.st-due .chk { border-color: var(--due); }
.chk.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.chk.skip { background: var(--surface-2); border-color: var(--border); color: var(--muted); font-size: 20px; }
.chk.busy { opacity: 0.5; pointer-events: none; }

.prn .next { font-size: 13px; font-weight: 700; margin-top: 4px; }
.prn .next.ok { color: var(--ok); }
.prn .next.wait { color: var(--due); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 6px; }

/* ---------- Lieky ---------- */
.person-h { display: flex; gap: 12px; align-items: center; }
.person-h .meta { font-size: 13px; color: var(--muted); }
.person-note { font-size: 14px; margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--due-soft); color: var(--text); }
.med { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); cursor: pointer; }
.med:first-of-type { margin-top: 10px; }
.med .main { flex: 1; min-width: 0; }
.med .name { font-weight: 700; }
.med .sched { font-size: 14px; color: var(--text-2); }
.med .stat { font-size: 13px; color: var(--muted); margin-top: 2px; }
.med.ended .name, .med.ended .sched { color: var(--muted); }
.chev { color: var(--muted); font-size: 20px; }
details.more { margin-top: 8px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 0; list-style: none; }
details.more summary::before { content: '▸ '; }
details.more[open] summary::before { content: '▾ '; }

/* ---------- História ---------- */
.day-h { font-weight: 700; color: var(--text-2); margin: 18px 2px 6px; font-size: 14px; text-transform: capitalize; }
.hist { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; }
.hist + .hist { margin-top: 6px; }
.hist .t { font-weight: 800; font-variant-numeric: tabular-nums; width: 48px; flex: none; }
.hist .main { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; }
.hist .sub { font-size: 13px; color: var(--muted); }
.hist.skipped .t, .hist.skipped .main b { color: var(--muted); text-decoration: line-through; }

/* ---------- spodné záložky ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding: 4px 4px env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 160px; border: 0; background: none; padding: 6px 4px 6px; display: flex; flex-direction: column;
  align-items: center; gap: 1px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; position: relative;
}
.tabs button .ico { font-size: 22px; line-height: 1.1; filter: grayscale(1); opacity: 0.75; }
.tabs button.active { color: var(--accent-2); }
.tabs button.active .ico { filter: none; opacity: 1; }
.tabs .dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--late); border: 2px solid var(--surface); }

/* ---------- spodný panel (dialog) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh;
  border-radius: 22px 22px 0 0; background: var(--bg); color: var(--text); overflow: auto; overscroll-behavior: contain;
}
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 22px; } }
dialog.sheet::backdrop { background: rgb(0 0 0 / 40%); }
dialog.sheet[open] { animation: up 0.18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-in { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet-h { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-h h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.sheet-h .x { margin-left: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.actions .btn { flex: 1; }
.warn { background: var(--due-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.err { background: var(--late-soft); color: var(--late); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0; font-weight: 600; }
.preview { font-size: 14px; color: var(--text-2); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.emoji-grid button { font-size: 24px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.emoji-grid button.on { border: 2px solid var(--accent); background: var(--accent-soft); }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.colors button.on { box-shadow: 0 0 0 2px var(--text); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 14px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100;
  display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); width: max-content;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--accent); font-weight: 800; cursor: pointer; padding: 4px; }
@media (prefers-color-scheme: dark) { #toast button { color: var(--accent-ink); background: var(--accent); border-radius: 8px; padding: 4px 8px; } }

/* ---------- prihlásenie ---------- */
.login { max-width: 360px; margin: 10vh auto 0; text-align: center; }
.login img { width: 72px; height: 72px; margin-bottom: 8px; }
.login form { margin-top: 18px; display: grid; gap: 10px; }

.footer-note { font-size: 12px; color: var(--muted); text-align: center; margin: 24px 8px 8px; }
