:root {
  /* Brand / Buttons */
  --rsak-primary: #efd81b;
  --rsak-primary-contrast: #111315;
  --rsak-disabled-bg: #111315;
  --rsak-disabled-fg: #ffffff;

  /* Surfaces */
  --rsak-page-bg: #111315;
  --rsak-card: #ffffff;
  --rsak-card-2: #f3f4f6;
  --rsak-border: #e5e7eb;

  /* Text */
  --rsak-text: #111111;
  --rsak-muted: #374151;

  /* Layout */
  --rsak-radius: 16px;
  --rsak-gap: 10px;

  /* Form field rounding */
  --rsak-field-radius: 18px;
}

.rsak {
  max-width: 980px;
  margin: 0 auto;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--rsak-page-bg);
  padding: 14px;
  border-radius: calc(var(--rsak-radius) + 6px);
}

/* Header */
.rsak-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--rsak-border);
  border-radius: var(--rsak-radius);
  background: var(--rsak-card);
}

.rsak-title {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.2px;
  color: var(--rsak-text);
}

.rsak-nav {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--rsak-border);
  background: var(--rsak-card-2);
  color: var(--rsak-text);
  cursor: pointer;
  font-size: 20px;
}
.rsak-nav:hover {
  filter: brightness(0.98);
}
.rsak-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Grid */
.rsak-grid {
  display: grid;
  grid-template-columns: 98px repeat(7, 1fr);
  gap: var(--rsak-gap);
  padding: 12px;
  border: 1px solid var(--rsak-border);
  border-radius: var(--rsak-radius);
  background: var(--rsak-card);
}

/* Header cells */
.rsak-cell {
  border: 1px solid var(--rsak-border);
  border-radius: 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rsak-card);
  color: var(--rsak-text);
  font-weight: 800;
  font-size: 1.02rem;
}

/* Flag header layout */
.rsak-head {
  flex-direction: column;
  gap: 4px;
  padding: 6px 4px;
}
.rsak-flag {
  font-size: 1.15rem;
  line-height: 1;
  transform: translateY(1px);
}
.rsak-flag--empty {
  visibility: hidden;
}
.rsak-hlabel {
  font-weight: 900;
  letter-spacing: 0.2px;
}

/* Week label column */
.rsak-weekcol {
  text-align: center;
  padding: 0 8px;
  line-height: 1.2;
  color: var(--rsak-muted);
}

/* Day buttons */
.rsak-day {
  border: 1px solid var(--rsak-border);
  border-radius: 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rsak-card);
  color: var(--rsak-text);
  cursor: pointer;
  font-weight: 650;
  font-size: 1.05rem;
  transition: transform 0.05s ease, border-color 0.15s ease;
  user-select: none;
}
.rsak-day:hover {
  border-color: #cbd5e1;
}
.rsak-day:active {
  transform: scale(0.99);
}
.rsak-day.is-out {
  opacity: 0.45;
}
.rsak-day.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.rsak-day.is-disabled:hover {
  border-color: var(--rsak-border);
}
.rsak-day.is-selected {
  background: #111;
  border-color: #111;
  color: #fff;
}

/* Actions */
.rsak-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--rsak-border);
  border-radius: var(--rsak-radius);
  background: var(--rsak-card);
}

.rsak-selected {
  font-size: 1.02rem;
  color: var(--rsak-muted);
}

/* Buttons */
.rsak-primary {
  border: 0;
  border-radius: 16px;
  padding: 16px 22px;
  font-weight: 800;
  cursor: pointer;
  background: var(--rsak-primary);
  color: var(--rsak-primary-contrast);
  font-size: 16px;
  min-height: 54px;
}

/* Modal */
.rsak-modal {
  display: none;
}
.rsak-modal.is-open {
  display: block;
}

.rsak-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.rsak-modal-card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(580px, calc(100vw - 24px));
  background: var(--rsak-card);
  border-radius: 18px;
  border: 1px solid var(--rsak-border);
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  color: var(--rsak-text);
}

.rsak-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.rsak-modal-title {
  font-weight: 900;
  font-size: 28px;
}

/* Close button */
.rsak-x {
  border: 1px solid var(--rsak-border);
  background: var(--rsak-card-2);
  border-radius: 12px;
  width: 46px;
  height: 46px;
  font-size: 26px;
  cursor: pointer;
}

/* Accessibility helpers */
.rsak-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Honeypot */
.rsak-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Form layout */
.rsak-form {
  display: grid;
  gap: 12px;
}

.rsak-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

/* Inputs/Selects */
.rsak-form input:not([type="checkbox"]),
.rsak-form select {
  width: 100%;
  box-sizing: border-box;
  height: 54px;
  border-radius: var(--rsak-field-radius);
  border: 1px solid var(--rsak-border);
  padding: 0 14px;
  background: var(--rsak-card);
  color: var(--rsak-text);
  font-size: 18px;
}

.rsak-form input::placeholder {
  color: #6b7280;
  opacity: 1;
}

.rsak-form-dates {
  margin-top: 8px;
  padding: 14px;
  border: 1px dashed var(--rsak-border);
  border-radius: 12px;
  background: #f9fafb;
  color: var(--rsak-muted);
  font-size: 20px;
}

.rsak-msg {
  margin-top: 10px;
  font-size: 16px;
}

/* Consent */
.rsak-consent {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-size: 16px;
  color: var(--rsak-muted);
  margin-top: 6px;
}
.rsak-consent input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0 0;
  flex: 0 0 auto;
}

/* Success screen */
.rsak-success {
  display: grid;
  gap: 14px;
  padding: 6px 2px;
}
.rsak-success[hidden] {
  display: none !important;
}

.rsak-success-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 18px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.rsak-success-text {
  font-size: 18px;
  line-height: 1.5;
  color: #111;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 14px;
}

/* Responsive */
@media (max-width: 760px) {
  .rsak-grid {
    grid-template-columns: 70px repeat(7, 1fr);
    gap: 6px;
    padding: 10px;
  }
  .rsak-cell,
  .rsak-day {
    min-height: 40px;
    border-radius: 12px;
  }
  .rsak-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .rsak-primary {
    width: 100%;
  }
  .rsak-form-row {
    grid-template-columns: 1fr;
  }
}

/* Desktop tuning */
@media (min-width: 992px) {
  .rsak {
    max-width: 1100px;
  }

  .rsak-title {
    font-size: 1.35rem;
  }
  .rsak-nav {
    width: 46px;
    height: 46px;
    font-size: 22px;
  }

  /* Breitere Wochen-Spalte (FR Labels) */
  .rsak-grid {
    grid-template-columns: 140px repeat(7, 1fr);
    gap: 10px;
    padding: 14px;
  }

  .rsak-day {
    min-height: 52px;
    font-size: 1.15rem;
  }

  .rsak-cell,
  .rsak-weekcol,
  .rsak-hlabel {
    font-size: 20px;
    line-height: 1.1;
  }

  .rsak-flag {
    font-size: 26px;
    line-height: 1;
  }

  .rsak-cell {
    min-height: 64px;
  }
  .rsak-head {
    gap: 4px;
    padding: 8px 6px;
  }

  .rsak-selected {
    font-size: 1.05rem;
  }
}

/* -------------------------
   Hard overrides (Theme/Elementor)
------------------------- */

/* Button + Checkbox sichtbar & konsistent */
.rsak .rsak-primary,
.rsak .rsak-form button[type="submit"].rsak-primary {
  appearance: none !important;
  -webkit-appearance: none !important;
  background: var(--rsak-primary) !important;
  color: var(--rsak-primary-contrast) !important;
  border: 0 !important;
  opacity: 1 !important;
}

.rsak .rsak-primary:disabled {
  background: var(--rsak-disabled-bg) !important;
  color: var(--rsak-disabled-fg) !important;
  opacity: 1 !important;
  cursor: not-allowed;
}

.rsak .rsak-primary:hover:not(:disabled) {
  background: var(--rsak-primary) !important;
  color: var(--rsak-primary-contrast) !important;
  filter: brightness(0.95);
}

.rsak .rsak-consent input[type="checkbox"] {
  appearance: auto !important;
  -webkit-appearance: checkbox !important;
  accent-color: var(--rsak-primary);
  opacity: 1 !important;
}

/* Modal immer über allem */
.rsak .rsak-modal.is-open {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
}
.rsak .rsak-modal-backdrop {
  z-index: 2147483646;
}
.rsak .rsak-modal-card {
  z-index: 2147483647;
}

/* Alter + Geschlecht: robust gegen Theme-Regeln */
.rsak .rsak-form-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 14px !important;
}
.rsak .rsak-form-row > #rsak-age,
.rsak .rsak-form-row > #rsak-gender {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* Wochen-Überschriften: umbrechen & kleiner */
.rsak .rsak-weeklabel {
  display: block !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  padding: 6px 8px !important;
  line-height: 1.1 !important;
  font-weight: 900;
  font-size: 0.9rem !important;
  text-align: center;
}
@media (min-width: 992px) {
  .rsak .rsak-weeklabel {
    font-size: 16px !important;
  }
}
