:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --text: #1c1e21;
  --text-muted: #8a8f98;
  --border: #e3e5e8;
  --weekend-bg: #eceef1;
  --today-ring: #1c1e21;
  --accent: #12305c;

  --wa1: #1565c0;
  --wa2: #2e7d32;
  --wa3: #e65100;
  --wa4: #6a1b9a;
  --gray-shift: #8a8f98;

  --pill-radius: 8px;
  --card-radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --surface: #1a1c20;
    --text: #eef0f2;
    --text-muted: #9296a0;
    --border: #2a2d33;
    --weekend-bg: #1f2126;
    --today-ring: #ffffff;
    --gray-shift: #5b5f68;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: calc(env(safe-area-inset-top) + 14px) 16px 8px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.month-title {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  text-transform: capitalize;
}

.icon-btn {
  border: none;
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.icon-btn:active { opacity: 0.7; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  min-height: 34px;
}

.nav-btn {
  border: none;
  background: var(--surface);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.nav-btn:active { opacity: 0.7; }

.filter-hint {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 6px 6px 14px;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
}

.filter-hint[hidden] { display: none; }

#filterHintText {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clear-filter-btn {
  border: none;
  background: var(--bg);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.clear-filter-btn:active { opacity: 0.7; }

main {
  flex: 1;
  padding: 4px 8px 16px;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 4px;
  margin-bottom: 4px;
}

.weekday-row span {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.weekday-row span.weekend { color: var(--text); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.day-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px 4px 8px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.day-cell:nth-child(7n) { border-right: none; }

.day-cell.weekend { background: var(--weekend-bg); }

.day-cell.outside .date-num,
.day-cell.outside .shift-pill { opacity: 0.38; }

.date-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.day-cell.today .date-num {
  background: var(--today-ring);
  color: var(--surface);
}

.shift-pill {
  border: none;
  border-radius: var(--pill-radius);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 2px;
  width: 100%;
  text-align: center;
  letter-spacing: 0.01em;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.shift-pill:active { transform: scale(0.94); }

.shift-pill.dimmed {
  background: var(--gray-shift) !important;
  opacity: 0.55;
}

.app-footer {
  text-align: center;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 14px);
  color: var(--text-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------ */
/* Abo-Dialog                                                          */
/* ------------------------------------------------------------------ */

.subscribe-dialog {
  border: none;
  border-radius: var(--card-radius);
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: min(88vh, 720px);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.subscribe-dialog::backdrop {
  background: rgba(0,0,0,0.45);
}

.subscribe-dialog form {
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 16px);
  overflow-y: auto;
  max-height: min(88vh, 720px);
}

.subscribe-dialog h2 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 800;
}

.subscribe-intro {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.subscribe-recommended {
  background: var(--bg);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.subscribe-recommended-label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.subscribe-primary-btn {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  padding: 12px;
  border-radius: 12px;
}

.subscribe-primary-btn:active { opacity: 0.85; }

.subscribe-copy-btn,
.subscribe-item-copy {
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 9px;
  border-radius: 10px;
}

.subscribe-copy-btn:active,
.subscribe-item-copy:active { opacity: 0.7; }

.subscribe-divider {
  margin: 4px 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.subscribe-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subscribe-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg);
}

.subscribe-item-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.subscribe-item-link {
  flex: 1;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  min-width: 0;
}

.subscribe-help {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.subscribe-close-btn {
  display: block;
  width: 100%;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  padding: 11px;
  border-radius: 12px;
}

.subscribe-close-btn:active { opacity: 0.7; }

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%);
  background: var(--today-ring);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.copy-toast.visible { opacity: 1; }

@media (max-width: 380px) {
  .day-cell { min-height: 80px; padding: 5px 3px 6px; }
  .shift-pill { font-size: 10px; padding: 3px 1px; }
  .month-title { font-size: 24px; }
}
