* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f2ee;
  color: #2a2a2a;
}

.hidden { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.overlay-card {
  background: white;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.overlay-card h2 { margin-top: 0; }

.overlay-card select,
.overlay-card input[type="text"] {
  width: 100%;
  padding: 10px;
  margin: 8px 0;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}

.or-divider {
  text-align: center;
  color: #999;
  margin: 8px 0;
  font-size: 13px;
}

.overlay-card button {
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  border: none;
  border-radius: 8px;
  background: #5b3fa0;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.overlay-card button:active { opacity: 0.85; }

header {
  background: #5b3fa0;
  color: white;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 18px;
  margin: 0;
}

.link-btn {
  background: none;
  border: none;
  color: #e6dfff;
  text-decoration: underline;
  font-size: 13px;
  padding: 0;
  cursor: pointer;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 10px;
}

.month-nav h2 {
  margin: 0;
  font-size: 16px;
  min-width: 160px;
  text-align: center;
}

.month-nav button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
}

.current-user {
  text-align: center;
  font-size: 13px;
  margin-top: 8px;
  opacity: 0.9;
}

main {
  padding: 12px;
  max-width: 700px;
  margin: 0 auto;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: #888;
  padding: 6px 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-cell {
  aspect-ratio: 1 / 1;
  background: white;
  border-radius: 10px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid #eee;
  cursor: pointer;
  position: relative;
}

.day-cell.empty {
  background: transparent;
  border: none;
  cursor: default;
}

.day-cell.past {
  opacity: 0.45;
  cursor: default;
}

.day-cell .date-num {
  font-size: 13px;
  font-weight: 600;
}

.day-cell.today .date-num {
  color: #5b3fa0;
}

.day-cell .serving-count {
  margin-top: 4px;
  font-size: 10px;
  background: #eee7ff;
  color: #5b3fa0;
  border-radius: 8px;
  padding: 1px 6px;
}

.day-cell.selected {
  box-shadow: 0 0 0 2px #b7a4e8;
}

.day-cell.no-mass {
  background: transparent;
  border: 1px dashed #e5e5e5;
  cursor: default;
}

.day-cell.no-mass .date-num {
  color: #bbb;
  font-weight: 400;
}

/* Mass date, not yet answered: gold */
.day-cell.mass-date {
  background: #fffbea;
  border: 2px solid #e8c96a;
}

.day-cell.mass-date::after {
  content: '✝';
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 9px;
  color: #c9a94a;
}

/* You're serving: solid green */
.day-cell.mass-date.serving-me {
  background: #2e9e5b;
  border-color: #2e9e5b;
}

.day-cell.serving-me .date-num {
  color: white;
}

.day-cell.serving-me::before {
  content: '✓';
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 11px;
  font-weight: 700;
  color: white;
}

.day-cell.serving-me::after {
  color: rgba(255,255,255,0.7);
}

.day-cell.serving-me .serving-count {
  background: rgba(255,255,255,0.9);
  color: #2e9e5b;
}

/* You can't serve: solid red */
.day-cell.mass-date.not-serving-me {
  background: #c0392b;
  border-color: #c0392b;
}

.day-cell.not-serving-me .date-num {
  color: white;
}

.day-cell.not-serving-me::before {
  content: '✗';
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 11px;
  font-weight: 700;
  color: white;
}

.day-cell.not-serving-me::after {
  color: rgba(255,255,255,0.7);
}

.day-cell.not-serving-me .serving-count {
  background: rgba(255,255,255,0.9);
  color: #c0392b;
}

.detail-actions {
  margin-top: 10px;
}

.small-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: #5b3fa0;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.small-btn.secondary {
  background: #fdf3f2;
  color: #c0392b;
  border: 1px solid #e8c4c0;
}

.reason-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.reason-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
}

.day-detail {
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 14px;
  border: 1px solid #e5e0f5;
}

.day-detail h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: #5b3fa0;
}

.day-detail p {
  margin: 0;
  font-size: 14px;
  color: #444;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #666;
}

.hint.hint-top {
  background: #eee7ff;
  border: 1px solid #d8c9f5;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 600;
  color: #3a2a66;
  text-align: center;
}

.legend-top {
  background: white;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.legend-top .swatch {
  width: 16px;
  height: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}

.swatch.gold { background: #fffbea; border: 2px solid #e8c96a; }
.swatch.green { background: #2e9e5b; }
.swatch.red { background: #c0392b; }

.day-cell.unsaved {
  outline: 2px dashed #5b3fa0;
  outline-offset: 2px;
}

.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 15px;
  font-weight: 600;
}

.save-bar-btns {
  display: flex;
  gap: 10px;
}

.bar-btn {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  background: #2e9e5b;
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.bar-btn.secondary {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  font-weight: 500;
}

.bar-btn:disabled { opacity: 0.6; }

#saved-modal h2 {
  color: #2e9e5b;
}

#saved-summary {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  max-height: 220px;
  overflow-y: auto;
}

#saved-summary li {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 15px;
}

#saved-summary .resp-serving { color: #2e9e5b; font-weight: 700; }
#saved-summary .resp-not { color: #c0392b; font-weight: 700; }
#saved-summary .resp-clear { color: #888; font-weight: 600; }

.hint {
  text-align: center;
  font-size: 12px;
  color: #999;
  margin-top: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  margin: 14px 0;
}

.toggle-row input {
  width: 20px;
  height: 20px;
}

#modal-members-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  max-height: 160px;
  overflow-y: auto;
}

#modal-members-list li {
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

@media (max-width: 400px) {
  .day-cell .date-num { font-size: 11px; }
  .day-cell .serving-count { font-size: 9px; }
}
