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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f0ec;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  color: #1a1a18;
}

/* ── Header ─────────────────────────────────────────────── */
#site-header {
  width: 100%; max-width: 1100px;
  border-radius: 12px 12px 0 0;
  padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
#site-name { font-size: 20px; font-weight: 600; color: white; }
#site-sub { font-size: 12px; color: rgba(255,255,255,0.65); margin-top: 2px; }
#legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: rgba(255,255,255,0.9); font-weight: 500; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Lock screen ─────────────────────────────────────────── */
#lock-screen {
  width: 100%; max-width: 1100px;
  background: white; border-radius: 0 0 12px 12px;
  border: 0.5px solid #ddd; border-top: none;
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 24px; text-align: center;
}
.lock-icon { font-size: 40px; color: #aaa; margin-bottom: 16px; }
.lock-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.lock-sub { font-size: 14px; color: #666; margin-bottom: 24px; }
.pw-row { display: flex; gap: 8px; width: 100%; max-width: 320px; }
#pw-input {
  flex: 1; padding: 10px 14px; border: 1px solid #ddd;
  border-radius: 8px; font-size: 15px; background: #fafafa; outline: none;
}
#pw-input:focus { border-color: #378add; background: white; }
#pw-btn {
  padding: 10px 20px; background: #1a3a2a; color: white;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 500; cursor: pointer;
}
#pw-btn:hover { opacity: 0.85; }
#pw-error { font-size: 13px; color: #c0392b; margin-top: 10px; display: none; }

/* ── Calendar wrapper ────────────────────────────────────── */
#cal-wrapper {
  display: none; width: 100%; max-width: 1100px;
  background: white; border-radius: 0 0 12px 12px;
  border: 0.5px solid #ddd; border-top: none; overflow: hidden;
}

/* ── Nav ─────────────────────────────────────────────────── */
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 0.5px solid #e8e8e4;
}
#month-label { font-size: 17px; font-weight: 600; }
.nav-btns { display: flex; gap: 8px; }
.nav-btn {
  background: white; border: 0.5px solid #ccc; border-radius: 7px;
  padding: 6px 14px; font-size: 13px; color: #444; cursor: pointer;
}
.nav-btn:hover { background: #f4f4f0; }
#btn-today { font-weight: 500; color: #1a3a2a; border-color: #1a3a2a; }

/* ── Spinner ─────────────────────────────────────────────── */
#loading-spinner {
  display: none; align-items: center; justify-content: center;
  padding: 40px; font-size: 14px; color: #888; gap: 10px;
}
.spinner-ring {
  width: 20px; height: 20px; border: 2px solid #eee;
  border-top-color: #639922; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Calendar grid ───────────────────────────────────────── */
#cal-grid { width: 100%; }

/* Day-of-week header row */
.dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 0.5px solid #e8e8e4;
  background: #fafaf8;
}
.dow-cell {
  text-align: center; font-size: 11px; font-weight: 600;
  color: #888; padding: 8px 4px;
  text-transform: uppercase; letter-spacing: 0.6px;
}

/* Each week is its own grid */
.week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: 28px auto; /* date number row + events area */
  border-bottom: 0.5px solid #e8e8e4;
  position: relative;
  min-height: 100px;
}

/* Day number cells — top row */
.day-num-cell {
  grid-row: 1;
  border-right: 0.5px solid #e8e8e4;
  padding: 4px 6px;
  font-size: 12px; color: #555;
}
.day-num-cell:last-child { border-right: none; }
.day-num-cell.other-month { background: #fafaf8; color: #ccc; }

.day-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; font-size: 12px;
}
.day-num.today { background: #1a3a2a; color: white; font-weight: 600; }

/* Events area spans all 7 columns, row 2 */
.week-events {
  grid-row: 2;
  grid-column: 1 / 8;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: relative;
  padding-bottom: 4px;
}

/* Vertical separators in events area */
.week-events::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent calc(100% / 7 - 0.5px),
    #e8e8e4 calc(100% / 7 - 0.5px),
    #e8e8e4 calc(100% / 7)
  );
  pointer-events: none;
  z-index: 0;
}

/* Each event row is a full-width grid layer */
.event-row {
  grid-column: 1 / 8;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: 20px;
  margin: 1px 0;
  position: relative;
  z-index: 1;
}

/* Event pill — spans N columns via grid-column */
.event-pill {
  height: 18px;
  margin: 0 2px 0 2px;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 11px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 18px; cursor: default;
  position: relative; z-index: 2;
}

/* Overflow badge */
.overflow-row {
  grid-column: 1 / 8;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: relative; z-index: 1;
}
.overflow-cell {
  font-size: 10px; color: #888; font-weight: 500;
  padding: 1px 6px;
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer { margin-top: 16px; font-size: 12px; color: #aaa; text-align: center; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  body { padding: 0 0 32px; }
  #site-header { border-radius: 0; padding: 14px 16px; }
  #cal-wrapper, #lock-screen { border-radius: 0; }
  .event-pill { font-size: 10px; }
  #site-name { font-size: 17px; }
}
