/* ── Filter bar ── */

.filter-bar {
  background: var(--color-white, #fff);
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}

.filter-bar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 3.5rem 12px var(--component-padding, 16px);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  text-align: left;
}

.filter-bar__header:hover {
  background: #f9fafb;
}

.filter-bar__header-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar__active-summary {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-bar__chip {
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 9999px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 500;
}

.filter-bar__arrow {
  font-size: 0.7rem;
  color: #9ca3af;
  flex-shrink: 0;
  margin-left: 8px;
}

.filter-bar__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 var(--component-padding, 16px) 12px;
  overflow-y: auto;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  max-height: 60vh;
  opacity: 1;
}

.filter-bar__body[aria-hidden="true"] {
  max-height: 0;
  opacity: 0;
  padding-bottom: 0;
  pointer-events: none;
}

.filter-bar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.filter-bar__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 2.5rem;
  flex-shrink: 0;
}

.filter-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Search hits, marked up by PGroonga's pgroonga_highlight_html. */
.keyword {
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
}

.filter-search__input {
  padding: 4px 14px;
  border-radius: 9999px;
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 0.8rem;
  min-width: 14rem;
  max-width: 100%;
}

.filter-search__input:focus {
  outline: none;
  border-color: #5a67d8;
}

.filter-btn {
  padding: 4px 14px;
  border-radius: 9999px;
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  cursor: pointer;
}

.filter-btn:hover {
  border-color: #5a67d8;
  color: #5a67d8;
}

.filter-btn--active {
  background: #5a67d8;
  border-color: #5a67d8;
  color: #fff;
}

.filter-btn--active:hover {
  background: #434fba;
  border-color: #434fba;
  color: #fff;
}

/* ── Collapsible filter section (open/close only) ── */

.filter-section {
  border-top: 1px solid #f3f4f6;
  padding-top: 6px;
}

.filter-section__label {
  display: flex;
  align-items: center;
  padding: 2px 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  list-style: none;
}

.filter-section__label::-webkit-details-marker {
  display: none;
}

.filter-section__label::before {
  content: "▶";
  display: inline-block;
  font-size: 0.65em;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.filter-section[open] > .filter-section__label::before {
  transform: rotate(90deg);
}

.filter-section .filter-bar__row {
  margin-top: 6px;
}

/* ── Participant filter chips ── */

.filter-btn--participant {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: 6px;
}

.participant-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  background: #e0e7ff;
}

.participant-avatar--initial {
  background: #c7d2fe;
  color: #3730a3;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.filter-btn--participant.filter-btn--active .participant-avatar--initial {
  background: #eef2ff;
  color: #4338ca;
}

/* ── Selected participant banner ── */

.participant-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 48rem;
  margin: 16px auto 0;
  padding: 10px 16px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #3730a3;
}

.participant-banner .participant-avatar {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.participant-banner__text {
  flex: 1;
  line-height: 1.5;
}

.participant-banner__tags {
  color: #4f46e5;
}

.participant-banner__count {
  font-weight: 600;
  white-space: nowrap;
}

.participant-banner__clear {
  flex-shrink: 0;
  padding: 4px 14px;
  border-radius: 9999px;
  border: 1.5px solid #a5b4fc;
  background: #fff;
  color: #4338ca;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.participant-banner__clear:hover {
  background: #4338ca;
  border-color: #4338ca;
  color: #fff;
}

/* ── Timeline content ── */

.cd-timeline__content {
  /* Card body text sizing (em -> keeps mobile/desktop breakpoint ratio) */
  --card-body-font-size: 1.5em; /* event body, body link, comment body */
  --card-time-font-size: 1.1em; /* comment timestamp: smaller than body */
}

.cd-timeline__content a {
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Enlarge the event body paragraph and its inline link only.
   Scoped to direct children so tag badges (a.event-tag-badge) stay unchanged. */
.cd-timeline__content > p[data-inline-edit-target="content"],
.cd-timeline__content > a {
  font-size: var(--card-body-font-size);
}

.event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.event-tag-badge {
  background-color: hsl(220, 90%, 93%);
  color: hsl(220, 90%, 36%);
  border-radius: 9999px;
  padding: 0.2em 0.65em;
  font-size: 0.75em;
  font-family: var(--font-secondary, sans-serif);
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.event-tag-badge:hover {
  background-color: hsl(220, 90%, 85%);
  color: hsl(220, 90%, 28%);
}

.admin-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.admin-visible-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-visible-toggle form {
  display: inline;
  margin: 0;
  padding: 0;
}

.admin-edit-event-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
  line-height: 0;
}

.admin-update-event-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.admin-update-event-textarea {
  width: 100%;
}

/* ── Event creation modal ── */

.event-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.event-modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 2rem;
  width: 90%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.event-modal-title {
  font-size: 1.25rem;
  font-weight: bold;
  margin-bottom: 1.25rem;
}

.event-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  color: #666;
}

.event-modal-close:hover {
  color: #111;
}

.event-modal-overlay[hidden] {
  display: none !important;
}

/* ── Event form ── */

.event-form-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-form-fields label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: #374151;
}

.event-form-input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}

.event-form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.event-form-errors {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.event-form-error-message {
  color: #dc2626;
  font-size: 0.875rem;
  margin: 0.2rem 0;
}

.event-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.event-form-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.event-form-btn--submit {
  background: #3b82f6;
  color: #fff;
}

.event-form-btn--submit:hover {
  background: #2563eb;
}

.event-form-btn--cancel {
  background: #e5e7eb;
  color: #374151;
}

.event-form-btn--cancel:hover {
  background: #d1d5db;
}

/* ── Flash messages ── */

#flash-messages {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  width: fit-content;
  max-width: 90%;
  pointer-events: none;
}

.flash-notice,
.flash-alert {
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  font-size: 0.95rem;
  animation: flash-fade 4s ease-in-out forwards;
}

.flash-notice {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.flash-alert {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

@keyframes flash-fade {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
