#agenda-open {
  min-height: 40px;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--brand-hover);
  font-size: 14px;
  font-weight: 650;
  position: relative;
  white-space: nowrap;
  padding: 8px 12px;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

#agenda-open.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-hover);
}

#agenda-open:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-hover);
}

#agenda-open:active {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #fff;
  transform: translateY(1px);
}

#agenda-open:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand);
}

#agenda[hidden] { display: none; }

.agenda-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 20px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.agenda-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.agenda-nav button,
.agenda-modes button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 12px;
  font-weight: 600;
}

.agenda-nav button:hover,
.agenda-modes button:hover {
  border-color: var(--brand);
  color: var(--brand-hover);
}

.agenda-nav strong {
  margin-left: 4px;
  font-size: 16px;
}

.agenda-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.agenda-modes,
.agenda-kinds {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.agenda-modes {
  margin-left: auto;
  align-self: end;
}

.agenda-modes button.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-hover);
}

.agenda-filters {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
}

.agenda-filters > label {
  margin: 0;
  display: grid;
  gap: 6px;
  flex: 0 1 220px;
  min-width: 180px;
  font-size: 13px;
  color: var(--muted);
}

.agenda-filters .picker,
.agenda-filters .picker-face {
  width: 100%;
  min-width: 160px;
  min-height: 40px;
}

.agenda-filters .check-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  align-self: end;
  gap: 8px;
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 6px 12px;
}

.agenda-filters .check-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
}

.agenda-board {
  padding: 12px;
  min-height: 420px;
  overflow: auto;
}

.agenda-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.agenda-month-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.agenda-day-cell {
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  cursor: pointer;
}

.agenda-day-cell.is-muted { opacity: .45; }
.agenda-day-cell.is-today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.agenda-day-cell strong { font-size: 13px; }
.agenda-day-cell .agenda-chip {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.agenda-chip-block { background: #ffe8dc; color: #9a3412; }
.agenda-chip-meeting { background: #e0efff; color: #1e40af; }
.agenda-chip-due { background: #efe7ff; color: #5b21b6; }
.agenda-chip-free { background: #dcfce7; color: #166534; }

.agenda-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  flex: 1 0 100%;
}

.agenda-legend[hidden] { display: none; }

.agenda-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
}

.agenda-dots {
  display: inline-flex;
  gap: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.agenda-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.agenda-week,
.agenda-day-grid {
  display: grid;
  gap: 0;
}

.agenda-week {
  grid-template-columns: 56px repeat(5, minmax(0, 1fr));
  min-width: 760px;
}

.agenda-day-grid {
  grid-template-columns: 56px minmax(0, 1fr);
}

.agenda-hours {
  align-self: start;
}

.agenda-time-label {
  height: 48px;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  padding-right: 8px;
  transform: translateY(-6px);
}

.agenda-col-head {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 4px 12px;
  color: var(--muted);
}

.agenda-col-head.is-today { color: var(--brand-hover); }

.agenda-col {
  position: relative;
  border-left: 1px solid var(--border);
  align-self: start;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 47px,
      var(--border) 47px,
      var(--border) 48px
    );
}

.agenda-now {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  height: 2px;
  background: var(--brand);
  pointer-events: none;
  transform: translateY(-50%);
}

.agenda-now::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  transform: translateY(-50%);
}

.agenda-event.can-move {
  padding: 0;
  cursor: grab;
  touch-action: none;
}

.agenda-event.is-dragging {
  z-index: 4;
  cursor: grabbing;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.18);
  pointer-events: none;
}

.agenda-event.is-conflict {
  box-shadow: inset 0 0 0 2px #b91c1c;
}

.agenda-event-hit {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 6px 8px 12px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  text-align: left;
  cursor: inherit;
}

.agenda-resize {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
  cursor: ns-resize;
}

.agenda-resize::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 28px;
  height: 3px;
  border-radius: 99px;
  background: currentColor;
  opacity: .5;
  transform: translateX(-50%);
}

.agenda-event,
.agenda-free {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  border: 0;
  text-align: left;
  cursor: pointer;
  z-index: 1;
}

.agenda-event strong,
.agenda-free strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-event span:not(.agenda-dots),
.agenda-free span {
  display: block;
  font-size: 11px;
  font-weight: 500;
  opacity: .85;
}

.agenda-event.is-block { background: #ffe8dc; color: #9a3412; }
.agenda-event.is-meeting { background: #dbeafe; color: #1e3a8a; }
.agenda-event.is-due {
  background: #ede9fe;
  color: #5b21b6;
  height: 28px !important;
}

.agenda-event.agenda-user-tone-0,
.agenda-chip.agenda-user-tone-0 { background: #dbeafe; color: #1e3a8a; }
.agenda-event.agenda-user-tone-1,
.agenda-chip.agenda-user-tone-1 { background: #d1fae5; color: #065f46; }
.agenda-event.agenda-user-tone-2,
.agenda-chip.agenda-user-tone-2 { background: #ede9fe; color: #5b21b6; }
.agenda-event.agenda-user-tone-3,
.agenda-chip.agenda-user-tone-3 { background: #ffedd5; color: #9a3412; }
.agenda-event.agenda-user-tone-4,
.agenda-chip.agenda-user-tone-4 { background: #dcfce7; color: #14532d; }
.agenda-event.agenda-user-tone-5,
.agenda-chip.agenda-user-tone-5 { background: #fce7f3; color: #9d174d; }
.agenda-event.agenda-user-tone-6,
.agenda-chip.agenda-user-tone-6 { background: #e0e7ff; color: #3730a3; }
.agenda-event.agenda-user-tone-7,
.agenda-chip.agenda-user-tone-7 { background: #fef9c3; color: #854d0e; }
.agenda-event.agenda-user-tone-8,
.agenda-chip.agenda-user-tone-8 { background: #cffafe; color: #155e75; }
.agenda-event.agenda-user-tone-9,
.agenda-chip.agenda-user-tone-9 { background: #ffe4e6; color: #9f1239; }
.agenda-event.agenda-user-tone-10,
.agenda-chip.agenda-user-tone-10 { background: #ccfbf1; color: #115e59; }
.agenda-event.agenda-user-tone-11,
.agenda-chip.agenda-user-tone-11 { background: #fef3c7; color: #92400e; }
.agenda-event.agenda-user-tone-12,
.agenda-chip.agenda-user-tone-12 { background: #e0f2fe; color: #075985; }
.agenda-event.agenda-user-tone-13,
.agenda-chip.agenda-user-tone-13 { background: #fae8ff; color: #86198f; }
.agenda-event.agenda-user-tone-14,
.agenda-chip.agenda-user-tone-14 { background: #ecfccb; color: #3f6212; }
.agenda-event.agenda-user-tone-15,
.agenda-chip.agenda-user-tone-15 { background: #e2e8f0; color: #334155; }

.agenda-dot.agenda-user-tone-0 { background: #1e3a8a; }
.agenda-dot.agenda-user-tone-1 { background: #065f46; }
.agenda-dot.agenda-user-tone-2 { background: #5b21b6; }
.agenda-dot.agenda-user-tone-3 { background: #9a3412; }
.agenda-dot.agenda-user-tone-4 { background: #14532d; }
.agenda-dot.agenda-user-tone-5 { background: #9d174d; }
.agenda-dot.agenda-user-tone-6 { background: #3730a3; }
.agenda-dot.agenda-user-tone-7 { background: #854d0e; }
.agenda-dot.agenda-user-tone-8 { background: #155e75; }
.agenda-dot.agenda-user-tone-9 { background: #9f1239; }
.agenda-dot.agenda-user-tone-10 { background: #115e59; }
.agenda-dot.agenda-user-tone-11 { background: #92400e; }
.agenda-dot.agenda-user-tone-12 { background: #075985; }
.agenda-dot.agenda-user-tone-13 { background: #86198f; }
.agenda-dot.agenda-user-tone-14 { background: #3f6212; }
.agenda-dot.agenda-user-tone-15 { background: #334155; }
.agenda-free {
  background: rgba(22, 163, 74, .14);
  color: #166534;
  border: 1px dashed #22c55e;
  z-index: 2;
}

.agenda-empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

#block-dialog {
  width: min(440px, 94vw);
  padding: 20px;
}

#block-delete[hidden],
#agenda-new-block[hidden] { display: none !important; }

@media (max-width: 720px) {
  .agenda-toolbar { grid-template-columns: 1fr; }
  .agenda-actions { justify-self: start; }
  #agenda-open { padding: 8px; font-size: 12px; min-height: 44px; }
  #agenda-open .agenda-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .agenda-month { grid-template-columns: repeat(7, minmax(36px, 1fr)); }
  .agenda-day-cell { min-height: 72px; padding: 4px; }
  .agenda-day-cell .agenda-chip { font-size: 10px; padding: 2px 4px; }
}
