.event-filter {
  position: relative;
  display: flex;
}

.event-filter-trigger {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--control-line);
  border-radius: var(--pill-radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.event-filter-trigger:hover {
  border-color: var(--muted);
}

.event-filter.has-active-filters .event-filter-trigger {
  color: var(--text);
}

.event-filter.is-open .event-filter-trigger {
  border-color: var(--accent);
  color: var(--accent);
}

.event-filter-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.event-filter-dropdown {
  position: absolute;
  inset-block-start: calc(100% + 10px);
  inset-inline-end: 0;
  z-index: 22;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--container-radius);
  background: var(--panel);
  box-shadow: var(--dialog-shadow);
}

.event-filter-dropdown[hidden] {
  display: none;
}

.event-filter-title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
}

.event-filter-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 8px;
}

.event-filter-options.is-compact {
  column-gap: 4px;
}

.event-filter-options.has-two-columns,
.event-filter-options.is-measuring {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.event-filter-options.has-two-columns:not(.is-measuring) .event-filter-option.is-full-width {
  grid-column: 1 / -1;
}

.event-filter-options.is-measuring {
  overflow: clip;
}

/* Measure each option's unwrapped intrinsic width before choosing the column count. */
.event-filter-options.is-measuring .event-filter-option {
  width: max-content;
  grid-template-columns: 20px max-content max-content;
  white-space: nowrap;
}

.event-filter-option {
  display: grid;
  min-width: 0;
  min-height: 44px;
  grid-template-columns: 20px auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.event-filter-options.is-compact .event-filter-option {
  gap: 4px;
  padding-inline: 4px;
}

.event-filter-option:hover {
  background: var(--control-hover);
}

.event-filter-option input {
  width: 20px;
  height: 20px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--control-line);
  border-radius: 50%;
  background-color: var(--panel);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 14px 14px;
  cursor: pointer;
}

.event-filter-option input:checked {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='m4.5 9 3 3 6-7' fill='none' stroke='%23111' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.event-filter-option input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.event-filter-emoji {
  font-size: 1.125rem;
  line-height: 1;
}

.event-filter-option-label {
  min-width: 0;
  justify-self: start;
  overflow-wrap: anywhere;
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.25;
}

.event-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

@media (max-width: 700px) {
  .event-filter-dropdown {
    position: fixed;
    inset-block-start: 69px;
    inset-inline: 16px;
    width: auto;
    max-height: calc(100vh - 85px);
    max-height: calc(100dvh - 85px);
  }
}

/* Active event-type filters are indicated independently of date restrictions. */
.event-filter.has-active-filters .event-filter-trigger::after {
  position: absolute;
  inset-block-start: 5px;
  inset-inline-end: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  content: '';
}
.feed-pill-header .event-filter-trigger {
  position: relative;
}
