:root {
  --bg: #f6f6f8; --card: #ffffff; --text: #1b1b1f; --muted: #858893; --line: #e2e3e8; --we: #ececf0;
  --red: #d93025; --accent: #2d6be0;
  --R: #FBB33B; --R-t: #000000;
  --O: #0277C4; --O-t: #ffffff;
  --N: #2E1A47; --N-t: #ffffff;
  --VOL: #D9DDE3; --VOL-t: #5f6670;
  --DOV: #2E9E5B; --DOV-t: #ffffff;
  --NEM: #E8742A; --NEM-t: #ffffff;
  --hol-bg: #FDE3E3; --hol-line: #E02424;
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111114; --card: #1c1c22; --text: #ececf1; --muted: #8b8e98; --line: #2c2c34; --we: #16161b;
    --red: #ff5b50; --accent: #5b92ff;
    --VOL: #3a3e47; --VOL-t: #a9aeb8; --N: #3a2259;
    --hol-bg: #4A1F24; --hol-line: #FF3B3B;
  }
}
:root[data-theme="dark"] {
    --bg: #111114; --card: #1c1c22; --text: #ececf1; --muted: #8b8e98; --line: #2c2c34; --we: #16161b;
    --red: #ff5b50; --accent: #5b92ff;
    --VOL: #3a3e47; --VOL-t: #a9aeb8; --N: #3a2259;
    --hol-bg: #4A1F24; --hol-line: #FF3B3B;
  }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  overflow-x: hidden; width: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
  padding-top: env(safe-area-inset-top);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 4px; padding: 10px 12px 6px; }
.top .ttl { flex: 1; text-align: center; min-width: 0; }
.top .crew { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .2px; }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.15; }
.nav-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; font-size: 28px; line-height: 1; }
.nav-btn:active { background: var(--line); }
.today-btn { border: 1.5px solid var(--red); color: var(--red); background: transparent; border-radius: 18px; padding: 5px 14px; font-weight: 600; font-size: 14px; }
body.settings-mode .nav-btn, body.settings-mode .today-btn { visibility: hidden; }

main { flex: 1; overflow-y: auto; padding-bottom: 88px; }
.view { display: none; }
.view.active { display: block; }

/* ---------- calendar ---------- */
.wd-head, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 0 8px; }
.wd-head span { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.wd-head .we { opacity: .7; }
.grid { touch-action: pan-y; }
.grid.slide-l { animation: slideL .22s ease-out; }
.grid.slide-r { animation: slideR .22s ease-out; }
@keyframes slideL { from { transform: translateX(28px); opacity: .3; } }
@keyframes slideR { from { transform: translateX(-28px); opacity: .3; } }

.day {
  min-width: 0; overflow: hidden;
  position: relative; min-height: 74px; border: 0; border-radius: 10px; padding: 5px 3px 4px;
  background: var(--card); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.day:active { filter: brightness(.94); }
.day .num { font-size: 14px; font-weight: 600; line-height: 1.1; }
.day.we { background: var(--we); }
.day.we .num { color: var(--muted); }
.day.out { opacity: .38; }
.day.today { box-shadow: inset 0 0 0 2.5px var(--hol-line); }
.day.hol { background: var(--hol-bg); }
.day.hol .num { color: var(--hol-line); font-weight: 800; }
.day .hshort { font-size: 8.5px; line-height: 1.05; color: var(--hol-line); font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; max-width: 100%; }
.hdot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--hol-line); }
.nmark { position: absolute; top: 5px; left: 5px; font-size: 9px; line-height: 1; color: var(--muted); }

.pill {
  position: relative; width: 100%; border-radius: 6px; padding: 3px 0 2px;
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.pill b { font-size: 15px; }
.pill small { font-size: 9.5px; opacity: .88; letter-spacing: -.2px; }
.pill.hol { box-shadow: inset 0 0 0 3px var(--hol-line); }
.pill.ov::after { content: ""; position: absolute; top: 3px; right: 3px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.p-R { background: var(--R); color: var(--R-t); }
.p-O { background: var(--O); color: var(--O-t); }
.p-N { background: var(--N); color: var(--N-t); }
.p-DOV { background: var(--DOV); color: var(--DOV-t); }
.p-NEM { background: var(--NEM); color: var(--NEM-t); }
.p-VOL { background: var(--VOL); color: var(--VOL-t); }
.pill.p-NEM b { font-size: 12px; padding: 1px 0; }
.pill.solo { padding: 6px 0 5px; }

.month-foot { padding: 12px 12px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card); border-radius: 14px; padding: 4px 10px; font-size: 13px; }
.chip b { font-weight: 700; }
.hol-list { margin: 12px 0 0; padding: 0; list-style: none; }
.hol-list li { display: flex; min-width: 0; gap: 10px; padding: 6px 2px; border-top: 1px solid var(--line); font-size: 14px; }
.hol-list li:first-child { border-top: 0; }
.hol-list .d { color: var(--red); font-weight: 700; min-width: 44px; }
.hol-list .h { margin-left: auto; color: var(--muted); white-space: nowrap; }
.legend { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 4px; margin: 10px 0 2px; font-size: 10px; letter-spacing: -.2px; color: var(--muted); white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.legend span { display: inline-flex; align-items: center; gap: 2px; }
.legend i { display: inline-block; min-width: 18px; height: 16px; border-radius: 4px; font-style: normal; font-weight: 700; font-size: 10px; line-height: 16px; text-align: center; padding: 0 2px; }
.legend .lh { background: var(--hol-bg); color: var(--hol-line); box-shadow: inset 0 0 0 2px var(--hol-line); }

/* ---------- sheet ---------- */
.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0; border: 0; border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); background: var(--card); color: var(--text);
  max-height: 92dvh;
}
.sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { margin: 0; font-size: 19px; }
.sheet h2::first-letter { text-transform: uppercase; }
.sheet .hname { color: var(--red); font-weight: 600; margin-top: 4px; }
.sheet .meta { color: var(--muted); font-size: 14px; margin: 6px 0 2px; }
.sheet .hours { font-size: 14px; margin: 2px 0 12px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice { border: 0; border-radius: 10px; padding: 12px 4px; font-weight: 700; font-size: 14px; }
.choice.active { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--text); }
.sheet label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 4px; }
.sheet textarea { width: 100%; min-height: 64px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 11px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .4; }

/* ---------- souhrn ---------- */
#view-souhrn, #view-nastaveni { padding: 4px 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card); border-radius: 12px; padding: 12px; }
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .v small { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat .l { font-size: 13px; color: var(--muted); }
.stat.wide { grid-column: span 2; }
.counts { display: flex; gap: 8px; margin-top: 6px; }
.counts span { flex: 1; text-align: center; border-radius: 8px; padding: 6px 0; font-weight: 700; }
.card { background: var(--card); border-radius: 12px; padding: 12px; margin-top: 10px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card p.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- nastavení ---------- */
.cyc-head, .cyc-row { display: grid; grid-template-columns: 34px repeat(7, 1fr) 30px; gap: 3px; align-items: center; }
.cyc-head span { text-align: center; font-size: 11px; color: var(--muted); }
.cyc-row { margin-top: 4px; }
.cyc-row input, .cyc-row select, .field input, .field select {
  border: 1px solid var(--line); border-radius: 7px; background: var(--bg); padding: 6px 2px; text-align: center; width: 100%; min-width: 0;
}
.cyc-row select { appearance: none; -webkit-appearance: none; font-weight: 700; padding: 7px 0; }
.cyc-row select.s-R { background: var(--R); color: var(--R-t); }
.cyc-row select.s-O { background: var(--O); color: var(--O-t); }
.cyc-row select.s-N { background: var(--N); color: var(--N-t); }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 18px; padding: 4px; }
.row-btns { display: flex; gap: 8px; margin-top: 10px; }
.field { display: grid; grid-template-columns: 1fr 92px 72px; gap: 6px; align-items: center; margin-top: 6px; font-size: 14px; }
.field.two { grid-template-columns: 1fr 164px; }
.field-head { display: grid; grid-template-columns: 1fr 92px 72px; gap: 6px; font-size: 11px; color: var(--muted); }
.field-head span:not(:first-child) { text-align: center; }
.warn { color: var(--red); font-size: 12.5px; margin-top: 6px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }
.ver { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0 8px; }

/* ---------- tabs + toast ---------- */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 0 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tabs .ti { font-size: 19px; line-height: 1.2; }
.tabs button.active { color: var(--red); font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 20px; font-size: 14px;
  transition: .2s; pointer-events: none; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
