/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --radius:    12px;
  --shadow:    0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);

  /* Person colours */
  --c-joey: #3b82f6;
  --c-jack: #22c55e;
  --c-matt: #ef4444;
  --c-nick: #8b5cf6;
  --c-sam:  #f97316;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

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

/* ===== Layout ===== */
.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.hidden { display: none !important; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.secondary-card {
  background: transparent;
  box-shadow: none;
  padding: 0;
}

/* ===== Landing ===== */
.landing-hero {
  text-align: center;
  padding: 32px 16px 24px;
}

.mountain-icon { font-size: 52px; margin-bottom: 8px; }

h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ===== Person buttons ===== */
.person-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.person-btn {
  padding: 14px 10px;
  border-radius: 10px;
  border: 2px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s, opacity 0.1s;
  text-align: center;
}

.person-btn:active { transform: scale(0.96); opacity: 0.85; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}

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

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: #eff6ff; }

.full-width { width: 100%; }

/* ===== Editor header ===== */
.editor-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding-top: 8px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.cal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-top: 8px;
}

/* ===== Calendars container ===== */
.calendars-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

/* ===== Month block ===== */
.month-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.month-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  text-align: center;
}

/* ===== Calendar grid ===== */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.day-hdr {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  padding: 4px 0;
  letter-spacing: 0.3px;
}

/* ===== Day cells — editor mode ===== */
.day-cell {
  min-height: 40px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px 3px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  background: transparent;
}

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

.day-cell:not(.empty):hover { background: var(--border); }

.day-num {
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 2px;
}

/* Editor: selected day */
.day-cell.selected .day-num {
  color: #fff;
  font-weight: 700;
}

.day-cell.selected {
  border-radius: 6px;
}

/* ===== Day cells — viewer mode ===== */
.day-cell.viewer {
  cursor: default;
  min-height: 44px;
}

.day-cell.viewer:hover { background: transparent; }

.dot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  justify-content: center;
  margin-top: 1px;
}

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

/* ===== Save bar ===== */
.save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 100;
}

.save-bar-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.save-count {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

/* ===== Status card ===== */
.status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-chip.done { background: #f0fdf4; }
.status-chip.pending-chip { background: #fefce8; }

/* ===== Best weeks card ===== */
.best-weeks-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.week-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.week-item:last-child { margin-bottom: 0; }

.week-item.perfect {
  border-color: #86efac;
  background: #f0fdf4;
}

.week-dates {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.week-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-perfect { background: #16a34a; color: #fff; }
.badge-conflicts { background: #fef3c7; color: #92400e; }

.week-who {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.who-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
}

.who-tag.free {
  background: #e2e8f0;
  color: #475569;
}

/* ===== Legend ===== */
.legend-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ===== Today highlight ===== */
.day-cell.today .day-num {
  color: var(--primary);
  font-weight: 800;
}

/* ===== No data state ===== */
.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 12px 0 4px;
}

/* ===== Desktop: side-by-side months ===== */
@media (min-width: 900px) {
  .view {
    max-width: 960px;
  }

  .calendars-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
  }

  .person-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
