:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --border: rgba(60, 60, 67, 0.16);
  --border-strong: rgba(60, 60, 67, 0.24);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --primary: #0071e3;
  --primary-light: #e7f2ff;
  --green: #248a3d;
  --green-light: #e6f6e9;
  --amber: #b35a00;
  --amber-light: #fff1e2;
  --red: #b3261e;
  --red-light: #fdecec;
  --purple: #6e4fd6;
  --purple-light: #f1edff;
  --blue: #0a84ff;
  --blue-light: #e8f3ff;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "SF Pro Text", "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(1200px 380px at 20% -12%, rgba(10, 132, 255, 0.14), transparent 64%),
    radial-gradient(900px 340px at 90% -18%, rgba(110, 79, 214, 0.1), transparent 62%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 20px 24px 10px;
  background: rgba(245, 245, 247, 0.72);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(60, 60, 67, 0.12);
}

header h1 {
  font-size: clamp(1.45rem, 1.2rem + 0.8vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

header p {
  margin-top: 2px;
  font-size: 0.86rem;
  color: var(--muted);
}

.tabs {
  display: inline-flex;
  gap: 2px;
  margin-top: 14px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(120, 120, 128, 0.12);
}

.tab-btn {
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  min-height: 34px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.tab-btn.active {
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.6);
  color: #404047;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tag-olg { background: var(--blue-light); color: #005bb8; }
.tag-polish { background: var(--red-light); color: #9e201a; }
.tag-guides { background: var(--green-light); color: #1e7434; }
.tag-csac { background: var(--purple-light); color: #5b41b5; }
.tag-church { background: #ffe0b2; color: #5d2600; }
.tag-dance  { background: #f8bbd0; color: #6a0032; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 16px;
}

.filter-bar span {
  margin-right: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.filter-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #4f4f56;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  min-height: 30px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.filter-btn:hover {
  border-color: rgba(0, 113, 227, 0.45);
  color: #005fc0;
}

.filter-btn.active { border-color: transparent; }
.filter-btn.active.f-all { background: #1d1d1f; color: #fff; }
.filter-btn.active.f-olg { background: #0a84ff; color: #fff; }
.filter-btn.active.f-polish { background: #d4473a; color: #fff; }
.filter-btn.active.f-guides { background: #248a3d; color: #fff; }
.filter-btn.active.f-csac { background: #6e4fd6; color: #fff; }
.filter-btn.active.f-church { background: #8b4513; color: #fff; }
.filter-btn.active.f-dance  { background: #ad1457; color: #fff; }

.filter-btn.active.fk-all { background: #1d1d1f; color: #fff; }
.filter-btn.active.fk-anais { background: #ba4d18; color: #fff; }
.filter-btn.active.fk-adelaide { background: #0a84ff; color: #fff; }
.filter-btn.active.fk-kuba { background: #6e4fd6; color: #fff; }

.month-section { margin-bottom: 34px; }

.month-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.month-name {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.cal-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
}

.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  background: rgba(0, 113, 227, 0.1);
  border-bottom: 1px solid var(--border);
}

.cal-dow-cell {
  text-align: center;
  padding: 8px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #2a2a2e;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  border-top: 1px solid var(--border);
}

.cal-week:first-child { border-top: none; }

.cal-day {
  min-height: 88px;
  padding: 8px 6px;
  border-right: 1px solid var(--border);
  vertical-align: top;
  position: relative;
  background: rgba(255, 255, 255, 0.72);
}

.cal-day:last-child { border-right: none; }
.cal-day.empty { background: rgba(245, 245, 247, 0.68); }
.cal-day.today { background: var(--primary-light); }

.cal-day-num {
  margin-bottom: 5px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  line-height: 1;
}

.cal-day.today .cal-day-num { color: #005fc0; }
.cal-day.sunday .cal-day-num { color: #a1271f; }

.cal-event-pill {
  display: block;
  margin-bottom: 4px;
  padding: 3px 6px;
  border-radius: 7px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-event-pill:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.cal-event-pill.org-olg { background: var(--blue-light); color: #005bb8; }
.cal-event-pill.org-polish { background: var(--red-light); color: #9e201a; }
.cal-event-pill.org-guides { background: var(--green-light); color: #1e7434; }
.cal-event-pill.org-csac { background: var(--purple-light); color: #5b41b5; }
.cal-event-pill.org-church { background: #fff3e0; color: #3e1a00; }
.cal-event-pill.org-dance  { background: #fce4ec; color: #5c0022; }
.cal-event-pill.urgent-pill { outline: 1.5px solid #c83c31; }
.cal-event-pill.soon-pill { outline: 1.5px solid #be6a0f; }

.popover {
  display: none;
  position: fixed;
  z-index: 500;
  max-width: 300px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  pointer-events: none;
}

.popover.open { display: block; }

.popover-title {
  margin-bottom: 4px;
  font-size: 0.9rem;
  font-weight: 680;
}

.popover-meta {
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.popover-action {
  display: inline-block;
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 0.77rem;
  background: var(--amber-light);
  color: #a05400;
}

.checklist-section {
  margin-bottom: 28px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
}

.checklist-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  line-height: 1.4;
}

.checklist-item:last-child { border-bottom: none; }

.checklist-item input[type=checkbox] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.checklist-item label { cursor: pointer; }
.checklist-item.done label { color: var(--muted); text-decoration: line-through; }

.stream-section {
  margin-bottom: 26px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-1);
}

.stream-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.stream-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.kid-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.subject-group { margin-bottom: 18px; }
.subject-group:last-child { margin-bottom: 0; }

.subject-label {
  margin-bottom: 8px;
  padding-left: 2px;
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.activity-card {
  position: relative;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.activity-card:hover {
  border-color: rgba(0, 113, 227, 0.38);
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.14);
  transform: translateY(-1px);
}

.activity-card.opened {
  border-color: rgba(36, 138, 61, 0.48);
  background: var(--green-light);
}

.opened-check {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.72rem;
  color: #1e7434;
  font-weight: 700;
}

.activity-card.opened .opened-check { display: block; }

.activity-icon {
  display: block;
  margin-bottom: 8px;
  font-size: 1.4rem;
}

.activity-title {
  margin-bottom: 4px;
  font-size: 0.88rem;
  font-weight: 680;
  line-height: 1.3;
}

.activity-topic {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.activity-source {
  margin-top: 8px;
  color: #0066cc;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 17, 20, 0.46);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
}

.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-2);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-topic {
  font-size: 0.82rem;
  color: var(--muted);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

.modal-close:hover {
  background: rgba(242, 242, 247, 0.96);
  color: var(--text);
}

.modal-body {
  position: relative;
  flex: 1;
  overflow: hidden;
  min-height: 480px;
}

.modal-body iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-footer a {
  color: #0066cc;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.modal-footer a:hover { text-decoration: underline; }

.opened-badge {
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--green-light);
  color: #1e7434;
  font-size: 0.78rem;
  font-weight: 600;
}

@media (max-width: 900px) {
  main { padding: 16px; }
  header { padding: 14px 14px 8px; }
  .stream-section { padding: 14px; }
  .cal-day { min-height: 74px; }
}

@media (max-width: 640px) {
  .tab-btn {
    padding: 8px 12px;
    font-size: 0.86rem;
  }

  .month-name { font-size: 1rem; }

  .cal-dow-row,
  .cal-week {
    grid-template-columns: repeat(7, minmax(46px, 1fr));
  }

  .cal-day {
    min-height: 58px;
    padding: 4px;
  }

  .cal-event-pill {
    font-size: 0.6rem;
    padding: 2px 4px;
  }

  .activity-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  .modal {
    border-radius: 16px;
    max-height: 94vh;
  }

  .modal-body { min-height: 55vh; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ══════════════════════════════════════════════
   DARK THEME
   ══════════════════════════════════════════════ */
html.dark {
  --bg: #111113;
  --bg-elevated: #1c1c1e;
  --surface: rgba(44, 44, 46, 0.78);
  --surface-strong: #2c2c2e;
  --border: rgba(210, 210, 215, 0.12);
  --border-strong: rgba(210, 210, 215, 0.22);
  --text: #f5f5f7;
  --muted: #8e8e93;
  --primary: #0a84ff;
  --primary-light: #0a2d5a;
  --green: #30d158;
  --green-light: #0c3520;
  --amber: #ff9f0a;
  --amber-light: #3c2800;
  --red: #ff453a;
  --red-light: #3d0e0d;
  --purple: #bf5af2;
  --purple-light: #281a4f;
  --blue: #0a84ff;
  --blue-light: #092d57;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.28);
  --shadow-2: 0 12px 40px rgba(0,0,0,0.55);
}

html.dark body {
  background:
    radial-gradient(1200px 380px at 20% -12%, rgba(10, 84, 200, 0.18), transparent 64%),
    radial-gradient(900px 340px at 90% -18%, rgba(110, 79, 214, 0.14), transparent 62%),
    var(--bg);
}

html.dark header {
  background: rgba(17, 17, 19, 0.78);
  border-bottom-color: rgba(210, 210, 215, 0.10);
}

html.dark .tab-btn:hover:not(.active) {
  background: rgba(44, 44, 46, 0.7);
  color: #c7c7cc;
}

html.dark .filter-btn {
  background: rgba(44, 44, 46, 0.9);
  color: #aeaeb2;
}

html.dark .filter-btn.active.f-all,
html.dark .filter-btn.active.fk-all {
  background: #f5f5f7;
  color: #111113;
}

html.dark .cal-dow-cell { color: #aeaeb2; }

html.dark .cal-day { background: rgba(28, 28, 30, 0.72); }
html.dark .cal-day.empty { background: rgba(17, 17, 19, 0.68); }

html.dark .cal-event-pill.org-olg   { color: #5ab0ff; }
html.dark .cal-event-pill.org-polish { color: #ff6b63; }
html.dark .cal-event-pill.org-guides { color: #4cd964; }
html.dark .cal-event-pill.org-csac   { color: #b07bff; }
html.dark .cal-event-pill.org-church { background: #3e2000; color: #ffb347; }
html.dark .cal-event-pill.org-dance  { background: #3e0020; color: #ff80ab; }

html.dark .tag-olg    { color: #5ab0ff; }
html.dark .tag-polish { color: #ff6b63; }
html.dark .tag-guides { color: #4cd964; }
html.dark .tag-csac   { color: #b07bff; }
html.dark .tag-church { color: #ffb347; }
html.dark .tag-dance  { color: #f48fb1; }

html.dark .popover {
  background: rgba(28, 28, 30, 0.92);
  border-color: rgba(210, 210, 215, 0.2);
}

html.dark .stream-section { background: rgba(28, 28, 30, 0.82); }

html.dark .modal {
  background: rgba(28, 28, 30, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
}

html.dark .modal-close { background: rgba(44, 44, 46, 0.95); }
html.dark .modal-close:hover { background: rgba(58, 58, 62, 0.96); }

html.dark .modal-footer a,
html.dark .activity-source { color: #4da3ff; }

html.dark .popover-action { color: #f0a340; }

/* ── Theme toggle button ── */
.theme-btn {
  position: absolute;
  top: 20px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.theme-btn:hover { border-color: var(--border-strong); }

/* ── Smooth theme transition ── */
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    color 0.2s ease,
    box-shadow 0.25s ease !important;
}
