:root {
  color-scheme: light;
  --bg-main: #f8fafc;
  --bg-surface: rgba(255, 255, 255, 0.85);
  --border-color: rgba(226, 232, 240, 0.8);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  /* Solid Spreadsheet-Style Colors */
  --cat-1-bg: #74a141; /* Solid Green */
  --cat-1-border: #5a8232;
  --cat-1-text: #ffffff;
  
  --cat-2-bg: #2e75b6; /* Solid Blue */
  --cat-2-border: #1f4e79;
  --cat-2-text: #ffffff;
  
  --cat-3-bg: #843c0c; /* Deep Brown/Red */
  --cat-3-border: #5b2a08;
  --cat-3-text: #ffffff;
  
  --cat-5-bg: #ed7d31; /* Solid Orange */
  --cat-5-border: #c65911;
  --cat-5-text: #ffffff;
  
  --cat-6-bg: #5b9bd5; /* Bright Blue */
  --cat-6-border: #2e75b6;
  --cat-6-text: #ffffff;
  
  --cat-7-bg: #7030a0; /* Purple */
  --cat-7-border: #4d216d;
  --cat-7-text: #ffffff;

  --cat-0-bg: #f8fafc;
  --cat-0-border: #e2e8f0;
  --cat-0-text: #334155;
}

/* SOLID COLOR PILLS */
.cat-1 { background-color: var(--cat-1-bg); border-color: var(--cat-1-border); color: var(--cat-1-text); }
.cat-2 { background-color: var(--cat-2-bg); border-color: var(--cat-2-border); color: var(--cat-2-text); }
.cat-3 { background-color: var(--cat-3-bg); border-color: var(--cat-3-border); color: var(--cat-3-text); }
.cat-4 { background-color: var(--cat-1-bg); border-color: var(--cat-1-border); color: var(--cat-1-text); }
.cat-5 { background-color: var(--cat-5-bg); border-color: var(--cat-5-border); color: var(--cat-5-text); }
.cat-6 { background-color: var(--cat-6-bg); border-color: var(--cat-6-border); color: var(--cat-6-text); }
.cat-7 { background-color: var(--cat-7-bg); border-color: var(--cat-7-border); color: var(--cat-7-text); }
.cat-0 { background-color: var(--cat-0-bg); border-color: var(--cat-0-border); color: var(--cat-0-text); }


body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, hsla(253,16%,7%,0.03) 0, transparent 50%), 
    radial-gradient(at 50% 0%, hsla(225,39%,30%,0.03) 0, transparent 50%), 
    radial-gradient(at 100% 0%, hsla(339,49%,30%,0.03) 0, transparent 50%);
  font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  overscroll-behavior: none; /* Prevents accidental pull-to-refresh */
}

* { box-sizing: border-box; }

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.app-shell {
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 24px rgba(0,0,0,0.02);
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: white;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  white-space: nowrap;
}

.toolbar-btn:hover { background: #f1f5f9; transform: translateY(-1px); }
.toolbar-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.range-label {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

.content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0; /* Important for inner flex scrolling */
  width: 100%;
}

.sidebar { 
  display: none; /* Hidden requested sidebar cleanup */
  flex-direction: column; 
  gap: 16px; 
  flex: 0 0 250px;
}

.calendar-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.calendar-root {
  background: var(--bg-surface);
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
}

/* ================================= */
/* FLEX TIMELINE                     */
/* ================================= */
.timeline-matrix {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: white;
  min-width: 900px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 24px rgba(0,0,0,0.02);
  overflow: hidden;
}

.timeline-row {
  display: flex;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}

.timeline-row:last-child {
  border-bottom: none;
}

.timeline-cell {
  flex: 1;
  border-right: 1px solid var(--border-color);
  min-height: 50px;
}

.timeline-cell.weekend {
  background: #f8fafc;
  opacity: 0.6;
}

.timeline-row-header {
  flex: 0 0 160px;
  background: white;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text-main);
  border-right: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  position: sticky;
  left: 0;
  z-index: 20;
}

.timeline-col-header {
  background: #f8fafc;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.timeline-event-bar {
  position: absolute;
  height: 70px;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 20px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 0.1s;
}

/* ================================= */
/* RESPONSIVE PIVOT                  */
/* ================================= */
@media (max-width: 900px) {
  .toolbar {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    height: auto;
  }
  
  .toolbar-left, .toolbar-right {
    justify-content: center;
    width: 100%;
  }

  .toolbar-center {
    order: -1;
    margin-bottom: 8px;
    text-align: center;
    width: 100%;
  }

  .calendar-root {
    padding: 8px;
  }

  .timeline-matrix {
    min-width: 0;
    border: none;
    box-shadow: none;
  }
  
  .timeline-row-header {
    flex: 0 0 100px;
    font-size: 13px;
  }
}

.timeline-matrix {
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
}

.timeline-matrix.grabbing {
    cursor: grabbing;
}

.timeline-matrix * {
    -webkit-user-drag: none;
}

@media (max-width: 600px) {
    .toolbar-btn {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .view-switcher {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }
}

.timeline-event-bar:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  z-index: 15;
}

/* ================================= */
/* FLEX MONTHLY GRID                 */
/* ================================= */
.month-flex-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 800px;
}

.month-cell {
  flex: 0 0 calc(14.28% - 10.3px); /* approx for gap */
  min-height: 130px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
}

.month-cell.weekend {
  flex: 0 0 calc(7.14% - 10.3px);
}

