:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1d1f23;
  --muted: #62666e;
  --border: #dedad0;
  --accent: #1f5c99;
  --accent-text: #ffffff;
  --today: #fff6dc;
  --holiday: #8a3a66;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #15171b;
  --surface: #1e2126;
  --surface-2: #272b31;
  --text: #e9e7e2;
  --muted: #a0a4ab;
  --border: #353a42;
  --accent: #6ea5dc;
  --accent-text: #0f1a26;
  --today: #33301f;
  --holiday: #d39cbc;
  --shadow: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); }

svg { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ---------- Hlavička ---------- */

.site-header { padding: 28px 0 8px; }
.site-header .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; }
.site-header h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.15; letter-spacing: -0.01em; }
.site-header__lead { margin: 4px 0 0; color: var(--muted); }

.button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-size: 0.95rem; text-decoration: none; cursor: pointer;
}
.button--ghost { background: transparent; color: var(--accent); }
.button:hover { filter: brightness(1.05); }

.site-header__actions { display: flex; gap: 8px; align-items: center; }
.theme-toggle {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.subscribe-help {
  margin: 12px 0 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); font-size: 0.95rem;
}
.subscribe-help p { margin: 0 0 6px; }
.subscribe-help__list { list-style: none; margin: 8px 0 10px; padding: 0; }
.subscribe-help__list li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  padding: 6px 8px; border-radius: 8px;
}
.subscribe-help__list li:nth-child(odd) { background: var(--surface-2); }
.subscribe-help__list li.is-highlighted { box-shadow: inset 0 0 0 1px var(--accent); }
.subscribe-help__name { flex: 1 1 160px; }
.subscribe-help__filtered { padding: 0 0 10px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.subscribe-help__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.subscribe-help__row .subscribe-help__hint { flex: 1 1 260px; }
.button:disabled { opacity: 0.5; cursor: default; }
.filters__summary .link-button { margin-left: 8px; }
.subscribe-help__hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.button--small { padding: 4px 10px; font-size: 0.85rem; }

/* ---------- Filtry ---------- */

.filters {
  margin: 16px 0; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters__row { display: flex; gap: 6px 12px; align-items: baseline; margin-bottom: 10px; }
.filters__label { flex: 0 0 72px; margin: 0; font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filters__tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 12px; }
.filters__summary { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  --chip-color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  font: inherit; font-size: 0.9rem; cursor: pointer; user-select: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.chip:hover { border-color: var(--chip-color); }
.chip--plain { padding-left: 10px; }
.chip--all { padding-left: 10px; }
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--chip-color) 12%, var(--surface));
  border-color: var(--chip-color); box-shadow: inset 0 0 0 1px var(--chip-color);
}
.chip:focus-visible, .view-switch button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--chip-color); flex: none; }

.source-icon { display: inline-block; flex: none; width: 22px; height: 22px; }
.source-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.source-icon--small { width: 17px; height: 17px; }

/* ikona kategorie: jednobarevné SVG jako maska, barva podle kategorie */
.cat-icon {
  display: inline-block; flex: none; width: 16px; height: 16px; background: var(--chip-color);
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}

.search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 220px; max-width: 360px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--muted);
}
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; outline: none; }

.view-switch { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.view-switch button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.9rem;
  padding: 5px 14px; border-radius: 6px; cursor: pointer;
}
.view-switch button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- Stav zdrojů ---------- */

.status {
  margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius);
  background: #fff3e0; color: #7a4a00; border: 1px solid #f0d2a2; font-size: 0.9rem;
}
:root[data-theme="dark"] .status { background: #3a2c12; color: #f2cf93; border-color: #5a4520; }

/* ---------- Seznam ---------- */

.day { margin: 0 0 18px; }
.day__heading {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  margin: 0 0 8px; padding: 4px 2px; font-size: 1rem; font-weight: 700;
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.day__relative { font-size: 0.8rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.day__holiday { font-size: 0.85rem; font-weight: 500; color: var(--holiday); }

.event {
  display: grid; grid-template-columns: 92px 1fr; gap: 4px 14px;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--icon-color, var(--accent));
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.event__time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.95rem; }
.event__time small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.event__body { min-width: 0; }
.event__title { margin: 0; font-size: 1.02rem; line-height: 1.35; }
.event__title a { color: inherit; text-decoration: none; }
.event__title a:hover { text-decoration: underline; }
.event__note { margin: 6px 0 0; font-size: 0.9rem; white-space: pre-line; }
.event__meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 0.85rem; color: var(--muted); align-items: center; }
.event__source { display: inline-flex; align-items: center; gap: 6px; }
.event__tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 7px 0 5px; border-radius: 4px;
  font-size: 0.75rem; line-height: 1.6; background: var(--surface-2); color: var(--text);
}
.tag .cat-icon { width: 12px; height: 12px; }
.event__details { margin-top: 6px; font-size: 0.9rem; }
.event__details summary { cursor: pointer; color: var(--accent); width: fit-content; }
.event__details p { margin: 6px 0 0; white-space: pre-line; color: var(--muted); }
.event--cancelled .event__title { text-decoration: line-through; color: var(--muted); }
.event--cancelled .event__time::after { content: "Zrušeno"; display: block; font-size: 0.75rem; color: #b3261e; font-weight: 600; }
.event--past { opacity: 0.7; }
.day--empty { margin-bottom: 10px; }
.day--empty .day__heading { position: static; color: var(--muted); font-weight: 600; }

.more { display: flex; justify-content: center; margin: 8px 0 24px; }

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

/* ---------- Měsíc ---------- */

.month__nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.month__nav h2 { margin: 0; font-size: 1.25rem; text-transform: capitalize; }
.month__nav-buttons { display: flex; gap: 6px; }
.icon-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
}
.icon-button--text { width: auto; padding: 0 14px; border-radius: 8px; font-size: 0.9rem; }

.month__grid { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.month__weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); }
.month__weekday { padding: 6px 8px; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }

/* týden = mřížka 7 sloupců; řádek 1 je hlavička dne, další řádky jsou pruhy akcí,
   buňky dne leží pod nimi přes celou výšku (klik na pruh propadne na den pod ním) */
.month__week {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: 28px repeat(3, 22px) minmax(22px, 1fr);
  min-height: 118px; border-top: 1px solid var(--border);
}
.month__day {
  grid-row: 1 / -1; background: var(--surface); padding: 5px 6px; display: flex; flex-direction: column; gap: 3px;
  border: 0; border-left: 1px solid var(--border); font: inherit; color: inherit; text-align: left; cursor: pointer; min-width: 0;
}
.month__day:first-child { border-left: 0; }
.month__day:hover { background: var(--surface-2); }
.month__day--other { background: var(--bg); color: var(--muted); }
.month__day--today { background: var(--today); }
.month__day--selected { box-shadow: inset 0 0 0 2px var(--accent); }
.month__day-head { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.month__day-number { font-size: 0.85rem; font-weight: 600; flex: none; }
.month__day--holiday .month__day-number { color: var(--holiday); }
.month__day-holiday { min-width: 0; font-size: 0.7rem; color: var(--holiday); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.month__pill {
  position: relative; z-index: 1; pointer-events: none; align-self: center;
  display: flex; align-items: center; gap: 4px; min-width: 0; margin: 0 4px;
  font-size: 0.75rem; line-height: 1.35; padding: 1px 6px 1px 2px; border-radius: 6px;
  background: color-mix(in srgb, var(--icon-color) 14%, var(--surface));
  white-space: nowrap; overflow: hidden;
}
.month__pill--multi { background: color-mix(in srgb, var(--icon-color) 24%, var(--surface)); font-weight: 600; }
.month__pill--before { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.month__pill--after { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.month__pill .source-icon { width: 14px; height: 14px; }
.month__pill span { overflow: hidden; text-overflow: ellipsis; }
.month__pill--cancelled span { text-decoration: line-through; opacity: 0.7; }
.month__more { margin-top: auto; font-size: 0.72rem; color: var(--muted); padding-left: 2px; }
.month__dots { display: none; flex-wrap: wrap; gap: 3px; }
.month__dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--icon-color); }
.month__selected { margin-top: 18px; }

/* ---------- Patička ---------- */

.site-footer { margin-top: 40px; padding: 20px 0 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.site-footer p { margin: 0 0 6px; }

/* ---------- Mobil ---------- */

@media (max-width: 640px) {
  .filters__row { flex-direction: column; gap: 6px; }
  .filters__label { flex: none; }
  .search { max-width: none; }
  .event { grid-template-columns: 1fr; }
  .event__time small { display: inline; margin-left: 6px; }
  .month__week { grid-template-rows: auto; min-height: 58px; }
  .month__day { padding: 4px; }
  .month__pill, .month__more, .month__day-holiday { display: none; }
  .month__dots { display: flex; }
  .month__weekday { padding: 4px; text-align: center; }
}
