:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-muted: #6b6b6f;
  --border: #e6e5e1;
  --accent: #1a56db;
  --accent-hover: #143fa8;
  --radius: 12px;

  --closed: #dc2626;
  --closed-bg: #fdecec;
  --half-day: #d97706;
  --half-day-bg: #fdf1de;
  --ptc: #2563eb;
  --ptc-bg: #eaf1fd;
  --remote: #7c3aed;
  --remote-bg: #f2ecfc;
  --special: #0d9488;
  --special-bg: #e4f5f3;
  --milestone: #16a34a;
  --milestone-bg: #e8f7ec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1b1b1d;
    --text: #f2f2f0;
    --text-muted: #a3a3a6;
    --border: #2c2c2e;

    --closed-bg: #3a1c1c;
    --half-day-bg: #3a2c14;
    --ptc-bg: #17233d;
    --remote-bg: #271b3d;
    --special-bg: #113230;
    --milestone-bg: #123420;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

a {
  color: var(--accent);
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 48px 0 32px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.site-header h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 38px);
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 17px;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-icon {
  font-size: 15px;
  line-height: 1;
}

.cta-hint {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 56ch;
}

/* Toolbar (view toggle + legend) */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 32px 0 20px;
}

.view-toggle {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: var(--surface);
}

.view-toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.view-toggle-btn.is-active {
  background: var(--text);
  color: var(--bg);
}

/* Legend / filters */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

.legend-item.is-active {
  border-color: var(--text);
  color: var(--text);
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.dot-all { background: linear-gradient(135deg, var(--closed), var(--ptc), var(--milestone)); }
.dot-closed { background: var(--closed); }
.dot-half-day { background: var(--half-day); }
.dot-ptc { background: var(--ptc); }
.dot-remote { background: var(--remote); }
.dot-special { background: var(--special); }
.dot-milestone { background: var(--milestone); }

/* Calendar list */

.calendar-list {
  margin-bottom: 40px;
}

.month-heading {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.month-heading:first-child {
  padding-top: 0;
}

.event-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
}

.event-card.is-hidden {
  display: none;
}

.event-date {
  flex: none;
  width: 92px;
  padding-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.event-date .weekday {
  display: block;
  font-weight: 400;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.event-body {
  flex: 1;
  min-width: 0;
}

.event-title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 600;
}

.event-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.event-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.tag-closed { color: var(--closed); background: var(--closed-bg); }
.tag-half-day { color: var(--half-day); background: var(--half-day-bg); }
.tag-ptc { color: var(--ptc); background: var(--ptc-bg); }
.tag-remote { color: var(--remote); background: var(--remote-bg); }
.tag-special { color: var(--special); background: var(--special-bg); }
.tag-milestone { color: var(--milestone); background: var(--milestone-bg); }

/* Add-to-calendar dropdown (used for the CTA button and each event row) */

.cal-dropdown {
  position: relative;
}

.cal-dropdown.event-add-dropdown {
  flex: none;
  align-self: center;
}

.cal-dropdown > summary {
  list-style: none;
}

.cal-dropdown > summary::-webkit-details-marker {
  display: none;
}

.cta-dropdown > summary::after {
  content: "\25BE";
  font-size: 10px;
  margin-left: 4px;
}

.cta-dropdown .cal-menu {
  left: 0;
  right: auto;
}

.event-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.event-add::-webkit-details-marker {
  display: none;
}

.event-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.event-add::after {
  content: "\25BE";
  font-size: 10px;
  margin-left: 2px;
}

.cal-dropdown[open] .event-add {
  border-color: var(--accent);
  color: var(--accent);
}

.cal-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cal-menu-wide {
  min-width: 260px;
}

.cal-menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}

.cal-menu-item:hover {
  background: var(--bg);
}

.cal-menu-item-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

/* Source note */

.source-note {
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding: 20px 0;
}

/* Ad slot */

.ad-slot {
  margin: 24px 0 48px;
}

.ad-slot-inner {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Month view */

.month-view {
  margin-bottom: 40px;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}

.month-label {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  min-width: 180px;
  text-align: center;
}

.month-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.month-nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.month-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.month-nav-btn:disabled:hover {
  border-color: var(--border);
  color: var(--text);
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 8px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.month-cell {
  background: var(--surface);
  min-height: 88px;
  min-width: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.month-cell.is-outside {
  background: var(--bg);
}

.month-cell.is-outside .cell-day {
  color: var(--text-muted);
  opacity: 0.5;
}

.month-cell.is-today .cell-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.cell-day {
  font-size: 12px;
  font-weight: 600;
}

.cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cell-event {
  display: block;
  width: 100%;
  border: none;
  margin: 0;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  text-align: left;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  cursor: pointer;
}

.cell-event.is-hidden {
  display: none;
}

.cell-event-closed { color: var(--closed); background: var(--closed-bg); }
.cell-event-half-day { color: var(--half-day); background: var(--half-day-bg); }
.cell-event-ptc { color: var(--ptc); background: var(--ptc-bg); }
.cell-event-remote { color: var(--remote); background: var(--remote-bg); }
.cell-event-special { color: var(--special); background: var(--special-bg); }
.cell-event-milestone { color: var(--milestone); background: var(--milestone-bg); }

@media (max-width: 560px) {
  .month-cell {
    min-height: 64px;
    padding: 4px;
  }
  .cell-event {
    font-size: 0;
    padding: 0;
    height: 6px;
    width: 6px;
    border-radius: 50%;
  }
  .month-weekdays span {
    font-size: 10px;
  }
}

/* Event modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

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

.modal {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-title {
  margin: 8px 0 4px;
  font-size: 19px;
  font-weight: 700;
}

.modal-date {
  margin: 0 0 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.modal-desc {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-muted);
}

.modal-add-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-add-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.modal-add-option:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.modal-add-option .btn-icon {
  flex: none;
  width: 18px;
  text-align: center;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 40px;
  font-size: 12.5px;
  color: var(--text-muted);
}

@media (max-width: 520px) {
  .event-card {
    flex-wrap: wrap;
  }
  .event-add {
    margin-left: 108px;
  }
}
