:root {
  --gutter-w: 52px;
  --hour-h: 60px;
  --border: #e0e0e0;
  --today-color: #1a73e8;
  --event-color: #1a73e8;
  --task-color: #0f9d58;
  --text: #202124;
  --text-muted: #70757a;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Header ─────────────────────────────── */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
}

#header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#app-name {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: -0.5px;
  user-select: none;
}

#nav { display: flex; }

#nav button {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 10px;
  color: var(--text);
  line-height: 1;
}

#nav button:first-child  { border-radius: 4px 0 0 4px; }
#nav #btn-today          { border-left: none; border-radius: 0; font-size: 13px; }
#nav button:last-child   { border-left: none; border-radius: 0 4px 4px 0; }
#nav button:hover        { background: #f1f3f4; }

#week-label {
  font-size: 18px;
  font-weight: 400;
  user-select: none;
}

#account-status {
  font-size: 13px;
  color: var(--text-muted);
}

#account-status a {
  color: var(--today-color);
  text-decoration: none;
}

/* ── Connect banner ──────────────────────── */

#connect-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: #e8f0fe;
  border-bottom: 1px solid #c5cfe8;
  font-size: 13px;
  flex-shrink: 0;
}

#connect-banner a {
  color: var(--today-color);
  font-weight: 500;
  text-decoration: none;
}

#connect-banner a:hover { text-decoration: underline; }

/* ── Calendar shell ──────────────────────── */

#calendar {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Day name + date number headers */
#col-headers {
  display: grid;
  grid-template-columns: var(--gutter-w) 1fr;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#col-headers-gutter {
  border-right: 1px solid var(--border);
}

#col-headers-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.day-header {
  text-align: center;
  padding: 6px 4px 8px;
  border-right: 1px solid var(--border);
  user-select: none;
}

.day-header:last-child { border-right: none; }

.day-name {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.date-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 400;
  margin-top: 2px;
}

.day-header.today .date-num {
  background: var(--today-color);
  color: #fff;
}

/* All-day row */
#allday-row {
  display: grid;
  grid-template-columns: var(--gutter-w) 1fr;
  border-bottom: 1px solid var(--border);
  min-height: 32px;
  flex-shrink: 0;
}

#allday-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  padding: 4px 6px 0;
  border-right: 1px solid var(--border);
}

#allday-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.allday-col {
  border-right: 1px solid var(--border);
  padding: 2px;
  min-height: 30px;
}

.allday-col:last-child { border-right: none; }

/* Timed scroll area — both gutter and grid scroll together */
#timed-scroll {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: var(--gutter-w) 1fr;
}

#time-gutter {
  border-right: 1px solid var(--border);
  position: relative;
  height: calc(24 * var(--hour-h));
}

.time-label {
  position: absolute;
  right: 6px;
  font-size: 10px;
  color: var(--text-muted);
  transform: translateY(-50%);
  white-space: nowrap;
  user-select: none;
}

#timed-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: calc(24 * var(--hour-h));
}

.timed-col {
  border-right: 1px solid var(--border);
  position: relative;
}

.timed-col:last-child { border-right: none; }

.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
  pointer-events: none;
}

.half-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed #f0f0f0;
  pointer-events: none;
}

/* ── Calendar items ──────────────────────── */

.cal-event {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  cursor: pointer;
  background: var(--event-color);
  color: #fff;
  z-index: 1;
}

.cal-event.type-task { background: var(--task-color); }

.allday-event {
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12px;
  overflow: hidden;
  cursor: pointer;
  background: var(--event-color);
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.allday-event.type-task { background: var(--task-color); }
