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

:root {
  --bg:           #f0f2f5;
  --surface:      #ffffff;
  --surface-alt:  #f8f9fa;
  --text:         #111827;
  --muted:        #9ca3af;
  --border:       #e5e7eb;
  --today-bg:     #dbeafe;
  --today-border: #3b82f6;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html {
  font-size: 18px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  height: 2rem;
  border-bottom: 1px solid var(--border);
}

#calendar {
  height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}

/* ── Two-week layout container ──────────────────── */

.twoweek-view {
  display: flex;
  flex: 1;
  gap: 4px;
  padding: 4px;
}

/* ── Left panel: progressive day columns ────────── */

.day-col {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.day-col.today {
  background: var(--today-bg);
  border-color: var(--today-border);
}

.day-header {
  padding: 0.4rem 0.6rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.day-subdate {
  font-size: 0.75em;
  font-weight: 400;
  color: var(--muted);
  margin-top: 1px;
}

.day-col.today .day-subdate {
  color: var(--today-border);
}

.day-col.today .day-header {
  color: var(--today-border);
}

.day-label-large  { font-size: 1.4rem; }
.day-label-medium { font-size: 1.15rem; }

.events-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.event-block {
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  line-height: 1.3;
  overflow-wrap: break-word;
  color: #fff;
}

.event-block.tentative {
  opacity: 0.6;
  outline: 1px dashed currentColor;
}

.event-block.allday {
  margin-bottom: 2px;
}

.event-time     { font-size: 0.7em; opacity: 0.85; }
.event-location { font-size: 0.7em; opacity: 0.75; }

/* ── Right panel: 3-week stacked grid ───────────── */

.right-panel {
  flex: 1;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: 1.5rem repeat(3, 1fr);
  flex: 1;
  gap: 2px;
}

.week-grid-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-cell {
  background: var(--surface-alt);
  border-radius: 4px;
  padding: 0.2rem 0.3rem;
  overflow: hidden;
  min-height: 0;
  border: 1px solid transparent;
}

.week-cell.today {
  background: var(--today-bg);
  border-color: var(--today-border);
}

.week-cell-date {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}

.week-cell.today .week-cell-date {
  color: var(--today-border);
  font-weight: 700;
}

.week-event {
  font-size: 0.65rem;
  line-height: 1.2;
  border-radius: 2px;
  padding: 1px 3px;
  margin-bottom: 1px;
  overflow-wrap: break-word;
  color: #fff;
}

.week-event-more {
  font-size: 0.6rem;
  color: var(--muted);
}

/* ── Section title ──────────────────────────────── */

.section-title {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  padding: 0 2px 4px;
}

/* ── Left section wrapper ───────────────────────── */

.left-section {
  display: flex;
  flex-direction: column;
  flex: 0 0 57%;
  min-width: 0;
}

.left-days {
  display: flex;
  flex: 1;
  gap: 4px;
  min-height: 0;
}

/* ── Day column width classes (desktop) ─────────── */

.day-col-today    { flex: 0 0 43.9%; }  /* 25/57 of total */
.day-col-tomorrow { flex: 0 0 31.6%; }  /* 18/57 of total */
.day-col-day2     { flex: 1; }          /* remainder */

/* ── Mobile layout (≤768px) ─────────────────────── */

@media (max-width: 768px) {

  /* Allow the page to scroll vertically */
  html, body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }

  #calendar {
    height: auto;
  }

  /* Stack everything in a single column */
  .twoweek-view {
    flex-direction: column;
    gap: 8px;
    overflow: visible;
  }

  /* Left section stretches full width */
  .left-section {
    flex: none;
    width: 100%;
  }

  /* Day cards stack vertically */
  .left-days {
    flex-direction: column;
    gap: 8px;
  }

  /* Each day card is full width, fixed height so they don't dominate */
  .day-col-today,
  .day-col-tomorrow,
  .day-col-day2 {
    flex: none;
    width: 100%;
    max-height: 220px;
  }

  /* Slightly larger label on mobile since cards are full width */
  .day-label-large  { font-size: 1.2rem; }
  .day-label-medium { font-size: 1rem; }

  /* Right panel stretches full width below the day cards */
  .right-panel {
    flex: none;
    width: 100%;
    min-height: 280px;
  }

  /* Slightly larger date numbers in grid cells on mobile */
  .week-cell-date {
    font-size: 0.8rem;
  }

  /* Event text in grid can be a bit tighter */
  .week-event {
    font-size: 0.6rem;
  }
}
