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

:root {
  --primary: #5c6bc0;
  --primary-dark: #3949ab;
  --primary-light: #e8eaf6;
  --danger: #e53935;
  --danger-light: #ffebee;
  --success: #43a047;
  --bg: #f0f2f8;
  --surface: #ffffff;
  --text: #1a2332;
  --text-muted: #6b7a99;
  --border: #dde1ef;
  --shadow: 0 2px 12px rgba(92,107,192,0.10);
  --shadow-lg: 0 8px 32px rgba(92,107,192,0.18);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(57,73,171,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-display {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: #fff;
  color: var(--primary-dark);
}
.btn-primary:hover { background: var(--primary-light); }

.btn-primary.dark {
  background: var(--primary);
  color: #fff;
}
.btn-primary.dark:hover { background: var(--primary-dark); }

.btn-secondary {
  background: #f1f3f9;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #ffcdd2;
}
.btn-danger:hover { background: #ffcdd2; }

.btn-full { width: 100%; margin-top: 8px; padding: 11px; font-size: 0.95rem; }

.btn-admin {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
}
.btn-admin:hover { background: rgba(255,255,255,0.28); }

.btn-admin-danger {
  background: #4a0000;
  color: #ff8a80;
  border: 1px solid #7f0000;
}
.btn-admin-danger:hover { background: #7f0000; color: #fff; }

.admin-badge {
  background: #ff1744;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
}

/* ── Main / Calendar ── */
main {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 20px;
}

.site-intro {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 24px;
  margin-bottom: 20px;
  border-left: 4px solid var(--primary);
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.site-intro p { margin: 0; }
.site-intro strong { color: var(--text-primary); }

.calendar-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calendar-top-bar {
  background: var(--primary);
  padding: 12px 16px 0;
}

.day-labels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-labels span {
  text-align: center;
  color: rgba(255,255,255,0.8);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding-bottom: 10px;
}

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

/* ── Day Cell ── */
.day-cell {
  background: var(--surface);
  min-height: 110px;
  padding: 8px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.day-cell:hover { background: #f7f8fc; }
.day-cell:hover .add-hint { opacity: 1; }

.day-cell.empty {
  background: #f9fafc;
  cursor: default;
}

.day-cell.today {
  background: var(--primary-light);
}
.day-cell.today:hover { background: #dde0f5; }

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.day-number {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.day-cell.today .day-number {
  background: var(--primary);
  color: #fff;
}

.day-month-label {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.add-hint {
  font-size: 0.68rem;
  color: var(--primary);
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow: hidden;
}

/* ── Event Pill ── */
.event-pill {
  display: block;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter 0.12s, transform 0.12s;
}

.event-pill:hover {
  filter: brightness(0.92);
  transform: translateX(1px);
}

.pill-0 { background: #e8eaf6; color: #3949ab; }
.pill-1 { background: #e0f7fa; color: #00838f; }
.pill-2 { background: #f3e5f5; color: #7b1fa2; }
.pill-3 { background: #fff8e1; color: #f57f17; }
.pill-4 { background: #e8f5e9; color: #2e7d32; }
.pill-5 { background: #fce4ec; color: #c62828; }

.more-events {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 2px 4px;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 28px;
  position: relative;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.modal-subtitle {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 16px;
  text-transform: capitalize;
}

/* ── Tabs ── */
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-btn:hover { color: var(--primary); }

/* ── Fields ── */
.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-label:first-of-type { margin-top: 0; }

.hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.75;
}

.required { color: var(--danger); }

.field {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.925rem;
  background: #fafbff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92,107,192,0.15);
  background: #fff;
}

.textarea { resize: vertical; min-height: 80px; }

.error-msg {
  color: var(--danger);
  font-size: 0.825rem;
  margin-top: 8px;
  min-height: 18px;
}

/* ── Event Detail ── */
.detail-date {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: capitalize;
}

.detail-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.detail-creator {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.detail-creator strong { color: var(--text); }

.participants-section { margin-bottom: 20px; }

.participants-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.participants-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.participants-list li {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 500;
}

.no-participants {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-actions .btn { flex: 1; min-width: 120px; margin-top: 0; }

.auth-prompt {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

.hidden { display: none !important; }

/* ── Time row ── */
.time-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}
.time-col { flex: 1; }
.time-col .field-label { margin-top: 0; }

/* ── Recurrence day checkboxes ── */
.day-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.day-checkboxes label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--primary-light);
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.day-checkboxes label:hover { background: #d0d4f0; }
.day-checkboxes input[type="checkbox"] { accent-color: var(--primary); width: 14px; height: 14px; }

/* ── Pill time + recur indicators ── */
.pill-time {
  font-weight: 700;
  opacity: 0.85;
  font-size: 0.68rem;
}
.pill-recur {
  opacity: 0.65;
  font-size: 0.68rem;
}

/* ── Recurrence badge in detail ── */
.recurrence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 20px;
  padding: 3px 10px;
  margin-bottom: 12px;
}
.detail-time {
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Tag filter bar ── */
.tag-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  margin-bottom: 16px;
}

.tag-filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.tag-chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--bg);
  color: var(--text-muted);
  transition: all 0.15s;
}

.tag-chip:hover { border-color: var(--primary); color: var(--primary); }
.tag-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tag-chip[data-tag="sport"].active { background: #2e7d32; border-color: #2e7d32; }
.tag-chip[data-tag="sport"]:hover { border-color: #2e7d32; color: #2e7d32; }
.tag-chip[data-tag="afterwork"].active { background: #f57f17; border-color: #f57f17; }
.tag-chip[data-tag="afterwork"]:hover { border-color: #f57f17; color: #f57f17; }
.tag-chip[data-tag="airsoft"].active { background: #c62828; border-color: #c62828; }
.tag-chip[data-tag="airsoft"]:hover { border-color: #c62828; color: #c62828; }

.tag-chip-reset {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  transition: all 0.15s;
}
.tag-chip-reset:hover { background: var(--bg); color: var(--text); }

/* ── Tag checkboxes (profile + create event) ── */
.tag-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.tag-checkboxes label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--primary-light);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
  border: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.tag-checkboxes label:hover { background: #d0d4f0; }
.tag-checkboxes input[type="checkbox"] { accent-color: var(--primary); width: 14px; height: 14px; }

/* ── Tag badges in event pill ── */
.pill-tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0,0,0,0.12);
  margin-left: 3px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* ── Tag badges in event detail ── */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.detail-tag-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.tag-sport { background: #e8f5e9; color: #2e7d32; }
.tag-afterwork { background: #fff8e1; color: #f57f17; }
.tag-airsoft { background: #fce4ec; color: #c62828; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .day-cell { min-height: 72px; padding: 5px; }
  .day-number { font-size: 0.8rem; width: 22px; height: 22px; }
  .add-hint { display: none; }
  .header-title h1 { font-size: 1rem; }
  main { margin: 16px auto; padding: 0 10px; }
}
