:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e4ded2;
  --accent: #2f6f8f;
  --accent-ink: #ffffff;
  --open: #b4561f;
  --open-bg: #fbe9dc;
  --warn: #9a6a00;
  --warn-bg: #fdf1cf;
  --late: #b3261e;
  --late-bg: #fbe1df;
  --toast-action: #8fd0ee;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191d;
    --surface: #1f2328;
    --ink: #eceae4;
    --muted: #9aa0a8;
    --line: #2e333a;
    --accent: #6fb3d3;
    --accent-ink: #0d1a21;
    --open: #f0a06c;
    --open-bg: #3a2618;
    --warn: #e9c35c;
    --warn-bg: #362b0f;
    --late: #f28b82;
    --late-bg: #3d1d1b;
    --toast-action: #1f5a76;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) max(16px, calc((100% - 608px) / 2)) 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}

.top h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }

.pocet { color: var(--muted); font-weight: 400; font-size: 1rem; margin-left: 4px; }

.offline {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--warn);
  background: var(--warn-bg);
  padding: 2px 8px;
  border-radius: 99px;
}

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

.skupina { margin: 14px 0 6px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

ul.polozky {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

ul.polozky li { display: flex; align-items: center; border-top: 1px solid var(--line); }

ul.polozky li:first-child { border-top: 0; }

.polozka {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 8px 12px 16px;
  background: none;
  border: 0;
  text-align: left;
  min-height: 56px;
  justify-content: center;
}

.polozka .nazev { font-weight: 500; overflow-wrap: anywhere; }

.polozka .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.85rem; color: var(--muted); }

.stitek { padding: 1px 8px; border-radius: 99px; font-size: 0.78rem; font-weight: 500; }

.stitek.otevrene { color: var(--open); background: var(--open-bg); }
.stitek.brzy { color: var(--warn); background: var(--warn-bg); }
.stitek.prosle { color: var(--late); background: var(--late-bg); }

.stepper { display: flex; align-items: center; padding-right: 8px; }

.stepper button {
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--accent);
}

.stepper button:active { background: var(--line); }

.stepper .kusy { min-width: 2.2ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

.prazdno { text-align: center; color: var(--muted); padding: 48px 16px; }

.pridat {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}

.pridat input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.08);
}

.pridat button {
  width: 52px;
  height: 52px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.8rem;
  line-height: 1;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
}

input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  background: var(--surface);
  color: var(--ink);
}

dialog::backdrop { background: rgb(0 0 0 / 0.4); }

dialog h2 { margin: 0 0 12px; font-size: 1.2rem; outline: none; }

dialog form { display: flex; flex-direction: column; gap: 12px; }

dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }

dialog input[type="text"], dialog input[type="number"], dialog input[type="date"] {
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 1rem;
  width: 100%;
}

.radek { display: flex; gap: 10px; }
.pocet-pole { width: 88px; flex: none; }
.poznamka-pole { flex: 1; min-width: 0; }

dialog label.prepinac { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); font-size: 1rem; }
.prepinac input { width: 22px; height: 22px; accent-color: var(--open); }

.rychle { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }

.rychle button {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.akce { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.akce .mezera { flex: 1; }

.akce button {
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.akce .hlavni { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.akce .nebezpecne { color: var(--late); border-color: transparent; background: none; padding: 0 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.95rem;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
}

.toast button { border: 0; background: none; color: var(--toast-action); font-weight: 600; padding: 6px 8px; }

body.login { display: grid; place-items: center; padding: 16px; }

.login-box {
  width: min(360px, 100%);
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  text-align: center;
}

.login-box h1 { margin: 8px 0 20px; }
.login-box form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.login-box label { font-size: 0.85rem; color: var(--muted); }

.login-box input {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.login-box button {
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  margin-top: 6px;
}

.chyba { margin: 0; color: var(--late); font-size: 0.9rem; }

@media (prefers-reduced-motion: no-preference) {
  ul.polozky li { transition: background-color 0.2s; }
  .toast { animation: vyjet 0.2s ease-out; }
  @keyframes vyjet { from { opacity: 0; transform: translate(-50%, 8px); } }
}
