:root {
  color-scheme: light;
  --ink: #1c1915;
  --muted: #6d655c;
  --line: #e3dbd0;
  --paper: #f6f3ec;
  --card: #fffcf7;
  --sidebar: #1d2b25;
  --sidebar-ink: #f4efe6;
  --sidebar-muted: #b7c3bb;
  --today: #c4552a;
  --hour: 48px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100%;
}

button, input { font: inherit; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  min-height: 100vh;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--sidebar-muted);
}

.brand h1 {
  margin: 6px 0 18px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.sidebar button {
  background: transparent;
  color: var(--sidebar-ink);
  border: 1px solid rgba(244, 239, 230, 0.25);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.sidebar button:hover { background: rgba(255, 255, 255, 0.06); }

.calendar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}

.calendar-list li { margin: 2px 0; }

.calendar-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.calendar-list label:hover { background: rgba(255, 255, 255, 0.05); }

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  flex: none;
}

.calendar-list .meta { display: flex; flex-direction: column; min-width: 0; }
.calendar-list .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.calendar-list .type {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.refresh { margin-top: 12px; }

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

body.has-detail .stage { margin-right: 304px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 20px 8px;
  min-width: 0;
}

.nav, .modes { display: flex; align-items: center; gap: 8px; }

.nav h2 {
  margin: 0 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  min-width: 0;
}

.modes { flex: none; }

.toolbar button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--ink);
}

.nav button[aria-label] {
  width: 34px;
  padding: 6px 0;
  font-size: 20px;
  line-height: 1;
}

.modes button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.banner {
  margin: 0 20px 8px;
  padding: 8px 12px;
  background: #f8e7cf;
  border-radius: 8px;
  color: #6a3d12;
}

.calendar {
  flex: 1;
  min-height: 0;
  margin: 0 16px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.empty, .loading, .error {
  margin: auto;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.month {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.dow, .month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.dow span {
  padding: 10px 8px 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.month-grid {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.week-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex: 1;
  min-height: 72px;
}

.day-cell {
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 88px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.day-cell:nth-child(7n) { border-right: 0; }

.day-cell.is-outside { background: #f7f4ee; color: #9a9288; }

.day-number {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 99px;
  display: grid;
  place-items: center;
  font-size: 13px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.day-cell.is-today .day-number {
  background: var(--today);
  color: white;
}

.chip, .block {
  border: 0;
  border-left: 3px solid var(--chip, #2f6f4e);
  background: var(--chip-fill, rgba(47, 111, 78, 0.16));
  color: var(--ink);
  border-radius: 4px;
  text-align: left;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chip.is-free, .block.is-free {
  background: var(--chip-fill);
  outline: 1px dashed var(--chip, #2f6f4e);
  outline-offset: -2px;
}

.span-spacer { flex: none; }

.span-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  display: grid;
  row-gap: 2px;
  z-index: 1;
  pointer-events: none;
}

.span-layer .chip {
  pointer-events: auto;
  min-width: 0;
  margin: 0 3px;
}

.span-layer.in-agenda {
  position: relative;
  top: auto;
  padding: 4px 0 6px;
}

.chip.is-cancelled, .block.is-cancelled { text-decoration: line-through; opacity: 0.7; }

.more {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 4px;
  cursor: pointer;
  font-size: 12px;
}

.agenda {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.day-heads, .all-day, .time-scroll {
  display: grid;
}

.day-heads { border-bottom: 1px solid var(--line); }

.day-heads button, .all-day .lane {
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.day-heads strong { display: block; font-size: 18px; font-weight: 600; }
.day-heads span, .gutter { color: var(--muted); font-size: 12px; }
.day-heads .is-today strong { color: var(--today); }

.all-day { border-bottom: 1px solid var(--line); min-height: 36px; align-items: stretch; }
.all-day .gutter { padding: 8px; }

.time-scroll {
  overflow: auto;
  min-height: 0;
  position: relative;
}

.hours, .day-col { position: relative; height: calc(var(--hour) * 24); }
.hours { border-right: 1px solid var(--line); }
.day-col { border-left: 1px solid var(--line); }
.day-col.is-today { background: rgba(196, 85, 42, 0.04); }

.hour-label, .hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--hour);
}

.hour-label {
  transform: translateY(-8px);
  text-align: right;
  padding-right: 8px;
  color: var(--muted);
  font-size: 11px;
}

.hour-line { border-top: 1px solid var(--line); }

.block {
  position: absolute;
  padding: 4px 6px;
  z-index: 1;
}

.block strong, .block div {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--today);
  z-index: 2;
  pointer-events: none;
}

.detail {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 280px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 18px 16px;
  box-shadow: 0 16px 40px rgba(28, 25, 21, 0.12);
  z-index: 4;
  overflow: auto;
}

.detail header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.detail h3 { margin: 0 0 8px; font-size: 22px; letter-spacing: -0.03em; }
.detail button { border: 0; background: transparent; cursor: pointer; font-size: 20px; }
.detail dl { margin: 16px 0 0; }
.detail dt { color: var(--muted); font-size: 12px; margin-top: 12px; }
.detail dd { margin: 2px 0 0; }
