:root {
  color-scheme: light dark;
}

*[hidden] {
  display: none !important;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  margin: 2rem auto;
  max-width: 1100px;
  padding: 0 1.5rem 4rem;
  background: #f8fafc;
  color: #0f172a;
}

.page-footer {
  margin-top: 2rem;
  text-align: right;
  font-size: 0.95rem;
  color: #475569;
}

h1 {
  margin-bottom: 1.5rem;
  font-size: clamp(1.5rem, 2.5vw + 1rem, 2.75rem);
  text-align: center;
}

form,
.list-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

form {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
}

fieldset {
  border: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

legend {
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.form-note {
  margin: 0 0 0.25rem;
  color: #dc2626;
  font-weight: 700;
  animation: form-note-blink 1.5s ease-in-out infinite;
}

@keyframes form-note-blink {
  0% { opacity: 1; }
  50% { opacity: 0.35; }
  100% { opacity: 1; }
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

input,
textarea,
select {
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #cbd5f5;
  background: #f8fbff;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button {
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

button.primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

button.secondary {
  background: white;
  color: #1e293b;
  border: 1px solid #cbd5f5;
}

button.danger {
  background: #ef4444;
  color: white;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
  box-shadow: none;
}

.actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* smaller cohesive buttons in actions */
.actions button {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 8px;
  box-shadow: none;
}
.actions button:hover {
  transform: none;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.form-actions .primary {
  flex: 1;
  padding: 0.55rem 1.25rem;
}

.form-actions .secondary {
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
}

.participant-summary {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.35rem;
  display: block;
}

.participant-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.participant-tag {
  background: #e2e8f0;
  color: #1e293b;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.2;
}

.participant-more {
  background: #cbd5f5;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.2;
  font-weight: 600;
}

.participant-empty {
  font-size: 0.85rem;
  color: #94a3b8;
}

.participants-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.participant-line {
  font-size: 0.9rem;
  color: #1e293b;
  white-space: nowrap;
}

.blocked-access {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1f2937;
  color: white;
  text-align: center;
  padding: 2rem;
  gap: 1rem;
}

.blocked-access h1 {
  font-size: 2rem;
  margin: 0;
}

.blocked-access p {
  font-size: 1.1rem;
  margin: 0;
  color: #cbd5f5;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.list-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list-nav span {
  font-weight: 600;
  min-width: 8rem;
  text-align: center;
}

@media (max-width: 768px) {
  .list-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .list-nav {
    justify-content: center;
  }
}

#list-section th.list-hidden,
#list-section td.list-hidden,
#mylist-section th.mylist-hidden,
#mylist-section td.mylist-hidden {
  display: none;
}

.page-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.page-title {
  align-self: center;
  font-weight: 700;
  font-size: 1.65rem;
  letter-spacing: 0.02em;
  color: #111827;
  text-align: center;
}

.page-title span {
  display: block;
}

.user-selector {
  align-self: flex-end;
  position: relative;
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.user-selector-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.15rem;
  background: transparent;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  text-align: right;
  justify-content: flex-end;
}

.user-selector-trigger:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 0.3rem;
}

.user-selector.single .user-selector-trigger {
  cursor: default;
}

.user-selector.single .user-selector-arrow {
  display: none;
}

.user-selector-arrow {
  width: 0;
  height: 0;
  border-left: 0.3rem solid transparent;
  border-right: 0.3rem solid transparent;
  border-top: 0.45rem solid #1f2937;
  transition: transform 0.2s ease;
}

.user-selector.open .user-selector-arrow {
  transform: rotate(180deg);
}

.user-selector-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 18rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  padding: 0.35rem 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 50;
}

.user-selector-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.55rem 1rem;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  color: #1f2937;
  text-align: left;
  cursor: pointer;
}

.user-selector-option[aria-selected="true"] {
  font-weight: 700;
  background: #e0e7ff;
}

.user-selector-option:hover,
.user-selector-option:focus-visible {
  background: #eef2ff;
  outline: none;
}

.view-toggle {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0 1rem;
}

.view-toggle-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.meta-author {
  font-size: 0.85rem;
  color: #2563eb;
  font-weight: 600;
}

.view-toggle button {
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid #cbd5f5;
  background: white;
  color: #1e293b;
  font-weight: 600;
}

.view-toggle button.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.view-toggle button.benefit-toggle,
.view-toggle button.benefit-toggle.active {
  color: #dc2626;
  font-weight: 700;
}

.benefit-dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  max-width: 960px;
  width: min(90vw, 960px);
  background: transparent;
}

.benefit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.benefit-dialog__content {
  background: white;
  border-radius: 18px;
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.35);
  border: 1px solid #e2e8f0;
  line-height: 1.65;
  color: #0f172a;
  min-height: min(85vh, 600px);
}

.benefit-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.benefit-dialog__header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #111827;
}

.benefit-dialog__header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.benefit-dialog__body p {
  margin: 0;
}

.benefit-dialog__edit {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.2rem;
  color: #dc2626;
}

.benefit-dialog__edit:hover {
  color: #b91c1c;
  transform: none;
}

.benefit-content-display {
  white-space: pre-line;
  line-height: 1.7;
  font-size: 1rem;
  color: #0f172a;
}

.benefit-editor-toolbar {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.benefit-toolbar-button {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.benefit-toolbar-button:hover {
  background: #e2e8f0;
  transform: none;
}

.benefit-edit-textarea {
  width: 100%;
  min-height: 220px;
  border-radius: 12px;
  border: 1px solid #dbeafe;
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.6;
  background: #f8fbff;
}

.benefit-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.benefit-empty {
  color: #94a3b8;
  font-style: italic;
}

.benefit-alert {
  color: #dc2626;
  font-weight: 700;
}

.benefit-text-red {
  color: #dc2626;
  font-weight: 600;
}

.benefit-text-blue {
  color: #2563eb;
  font-weight: 600;
}

.benefit-text-green {
  color: #15803d;
  font-weight: 600;
}

.benefit-dialog__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  color: #475569;
}

.benefit-dialog__close:hover {
  color: #1f2937;
  transform: none;
}

.toggle-button-group {
  display: inline-flex;
  border: 1px solid #cbd5f5;
  border-radius: 999px;
  overflow: hidden;
}

.toggle-button-group .toggle-button {
  border: none;
  border-radius: 0;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
  background: white;
  color: #1e293b;
}

.toggle-button-group .toggle-button.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
}

.datetime-input {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
}

.datetime-input input[type="date"],
.datetime-input select {
  flex: 1 1 120px;
  min-width: 110px;
  border: 1px solid #cbd5f5;
  background: white;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

input.locked-input,
input.locked-input:read-only {
  background: #e2e8f02b;
  color: #64748b;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .datetime-input {
    flex-wrap: wrap;
  }

  .datetime-input input[type="date"],
  .datetime-input select {
    flex: 1 1 120px;
    min-width: 100px;
  }
}

#edit-dialog {
  width: min(95vw, 760px);
  max-width: 760px;
}

#edit-dialog form {
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  font-size: 0.95rem;
}

.title-cell-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.title-cell-content .badge {
  align-self: flex-start;
}

.title-primary {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.title-description {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#list-section table,
#mylist-section table {
  table-layout: auto;
}

#list-section table thead th:first-child,
#list-section table tbody td:first-child,
#mylist-section table thead th:first-child,
#mylist-section table tbody td:first-child {
  width: 33%;
  max-width: 33%;
}

#list-section table thead th:nth-child(2),
#list-section table tbody td:nth-child(2),
#mylist-section table thead th:nth-child(2),
#mylist-section table tbody td:nth-child(2) {
  width: auto;
  max-width: none;
}

#list-section table thead th:nth-child(4),
#list-section table tbody td:nth-child(4),
#mylist-section table thead th:nth-child(4),
#mylist-section table tbody td:nth-child(4) {
  width: auto;
  max-width: none;
}

#list-section table thead th:nth-child(6),
#list-section table tbody td:nth-child(6),
#mylist-section table thead th:nth-child(6),
#mylist-section table tbody td:nth-child(6) {
  width: auto;
  max-width: none;
}

/* Hide location column (3rd col) from list */
table thead th:nth-child(3),
table tbody td:nth-child(3) {
  display: none;
}

th,
td {
  padding: 0.9rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

thead th {
  text-align: left;
  background: #f1f5f9;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #475569;
}

tr.closed {
  background: #f8fafc;
  color: #475569;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #1d4ed8;
  color: white;
}

.badge.closed {
  background: #94a3b8;
}

.message {
  margin-top: 1rem;
  font-weight: 600;
  color: #2563eb;
}

.error {
  color: #dc2626;
}
#calendar-section {
  display: grid;
  gap: 1.25rem;
}

.list-header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-weekdays span {
  text-align: center;
}

.calendar-weekdays span:first-child {
  color: #ef4444;
  font-weight: 700;
}

.calendar-weekdays span:last-child {
  color: #2563eb;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.75rem;
}

.calendar-cell {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-start;
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fbff;
  min-height: 110px;
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
  position: relative;
}

.calendar-add-button {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  font-size: 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.calendar-add-button:hover {
  background: rgba(37, 99, 235, 0.22);
  transform: scale(1.05);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.22);
}

.calendar-add-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.28);
}

.calendar-cell:hover {
  border-color: #2563eb;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}

.calendar-cell.other-month {
  opacity: 0.45;
}

.calendar-cell.active {
  border: 2px solid #2563eb;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
  background: #f0f5ff;
}

.calendar-day-number {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
}

.calendar-event-tag {
  display: inline-flex;
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-more {
  font-size: 0.75rem;
  color: #475569;
}

.calendar-details {
  border-top: 1px solid #e2e8f0;
  padding-top: 1.25rem;
  display: grid;
  gap: 1rem;
}

.calendar-details h3 {
  margin: 0;
  font-size: 1.1rem;
}

.calendar-join-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid #dbeafe;
  background: white;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.calendar-join-info {
  display: grid;
  gap: 0.35rem;
  flex: 1 1 0;
  min-width: 0;
}

.calendar-join-info h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.calendar-join-meta {
  font-size: 0.85rem;
  color: #475569;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.calendar-empty {
  font-size: 0.95rem;
  color: #64748b;
}

.calendar-join-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
  flex: 0 0 auto;
}

.calendar-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #2563eb;
  color: white;
}

.calendar-status.closed {
  background: #94a3b8;
  color: white;
}

@media (max-width: 640px) {
  .page-title {
    width: 100%;
    font-size: 1.35rem;
  }

  .user-selector {
    width: 100%;
  }

  .user-selector-trigger {
    justify-content: flex-end;
    width: 100%;
  }

  .user-selector-menu {
    min-width: 100%;
  }
}

@media (max-width: 780px) {
  body {
    margin: 1.5rem auto;
    padding: 0 1rem 2rem;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
  }

  td {
    border: none;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    padding-left: 50%;
  }

  td::before {
    content: attr(data-label);
    position: absolute;
    left: 1rem;
    width: calc(50% - 1rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #475569;
  }

  td:last-child {
    border-bottom: none;
  }
}
