body {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 40px);
}

.site-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.brand {
  flex: 1 1 auto;
  min-width: max-content;
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 72px;
  width: auto;
}

.actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-left: auto;
}

.actions button {
  margin: 0;
}

.site-header.is-wrapped {
  justify-content: center;
}

.site-header.is-wrapped .brand {
  flex-basis: 100%;
  text-align: center;
}

.site-header.is-wrapped .brand-logo {
  margin-inline: auto;
}

.site-header.is-wrapped .actions {
  flex-basis: 100%;
  justify-content: center;
  margin-left: 0;
}

.actions[hidden] {
  display: none;
}

dialog {
  box-sizing: border-box;
  max-width: 420px;
  position: relative;
  width: calc(100vw - 2rem);
}

dialog input {
  box-sizing: border-box;
  width: 100%;
}

#auth-dialog #login-form,
#auth-dialog #register-form,
#auth-dialog #email-verification-form,
#auth-dialog #password-reset-form,
#auth-dialog #password-reset-confirm-form {
  margin-bottom: 0;
}

#auth-dialog .auth-static-message {
  color: var(--text-main);
  line-height: 1.45;
  margin: 0 0 0.75rem;
}

#auth-dialog .auth-static-message:last-child {
  margin-bottom: 0;
}

#auth-dialog .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0;
}

#auth-dialog .form-actions button {
  margin: 0;
}

#auth-dialog #auth-message {
  color: var(--danger) !important;
  display: block;
  font-size: 0.875rem;
  line-height: 1.35;
  margin: 0.5rem 0 0;
}

#auth-dialog #auth-message.success-message {
  color: var(--text-muted) !important;
}

.form-actions {
  margin-top: 1rem;
}

.dialog-close {
  background: transparent;
  border-radius: 50%;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  margin: 0;
  padding: 0;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 2rem;
}

.dialog-close svg {
  height: 1rem;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
  width: 1rem;
}

.dialog-close:hover {
  background: var(--surface-control);
  color: var(--text-main);
}

.danger-button {
  background: var(--danger);
  color: var(--danger-text);
}

.danger-button:hover {
  background: var(--danger-hover);
}

.content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.empty-state {
  margin: auto;
  text-align: center;
  white-space: pre-line;
}

.empty-state[hidden] {
  display: none;
}

.load-more {
  margin: 2rem auto 0;
}

.create-page[hidden],
.edit-page[hidden],
.profile-page[hidden],
.about-page[hidden],
.event-page[hidden],
.events[hidden] {
  display: none;
}

.create-page > h1,
.create-page > p,
.edit-page > h1,
.profile-page > h1,
.about-page > h1,
.event-page > h1 {
  text-align: center;
}

.about-page {
  margin: 0 auto;
  max-width: 760px;
  width: 100%;
}

.about-page h2 {
  margin-top: 0;
}

.create-page small,
.edit-page small,
.profile-page .form-message,
dialog .form-message {
  color: var(--text-muted);
  display: block;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.create-page form > label,
.edit-page form > label,
.profile-page section > label,
#profile-account-form > label,
#profile-password-form > label {
  display: block;
  margin-top: 1rem;
}

.create-page form > label:first-child,
.edit-page form > label:first-child,
.profile-page section > label:first-child,
#profile-account-form > label:first-child,
#profile-password-form > label:first-child {
  margin-top: 0;
}

.create-page form,
.edit-page form,
#profile-account-form,
#profile-password-form {
  max-width: 420px;
}

.create-page input,
.create-page textarea,
.edit-page input,
.edit-page textarea,
#profile-account-form input,
#profile-password-form input {
  box-sizing: border-box;
  margin-bottom: 0;
  width: 100%;
}

.create-page textarea,
.edit-page textarea {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.difficulty-field {
  border: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 1rem 0 0;
  min-width: 0;
  padding: 0;
}

.difficulty-field legend {
  align-items: center;
  display: inline-flex;
  grid-column: 1 / -1;
  margin-bottom: 0.5rem;
  padding: 0;
}

.difficulty-help-button {
  align-items: center;
  border-radius: 50%;
  box-sizing: border-box;
  color: var(--text-muted);
  display: flex;
  height: 1.75rem;
  justify-content: center;
  margin: 0;
  min-height: 0;
  min-width: 0;
  padding: 0;
  text-decoration: none;
  width: 1.75rem;
}

.difficulty-help-button:hover,
.difficulty-help-button:focus,
.difficulty-help-button:active {
  color: var(--link);
  text-decoration: none;
}

.difficulty-help-button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.difficulty-help-button svg {
  display: block;
  fill: currentColor;
  height: 1.25rem;
  width: 1.25rem;
}

.difficulty-descriptions {
  margin: 0;
}

.difficulty-descriptions dt {
  font-weight: 700;
}

.difficulty-descriptions dd {
  color: var(--text-muted);
  margin: 0.25rem 0 0.75rem;
}

.difficulty-descriptions dd:last-child {
  margin-bottom: 0;
}

.event-difficulty-value {
  align-items: center;
  display: inline-flex;
  gap: 0.25rem;
  justify-self: end;
}

.event-difficulty-value .difficulty-help-button {
  height: 1rem;
  width: 1rem;
}

.event-difficulty-value .difficulty-help-button svg {
  height: 1rem;
  width: 1rem;
}

.difficulty-field label {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0 0.75rem;
}

.difficulty-field input {
  flex: 0 0 auto;
  margin: 0;
  width: auto;
}

.route-preview-image {
  aspect-ratio: 16 / 9;
  background: var(--surface-control);
  display: block;
  margin-top: 0.75rem;
  object-fit: cover;
  width: 100%;
}

.route-preview-image[hidden] {
  display: none;
}

.start-location-map {
  --event-map-stats-font-size: 0.7rem;
  aspect-ratio: 16 / 9;
  background: var(--surface-control);
  margin-top: 0.75rem;
  min-height: 220px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.start-location-map.is-loading,
.start-location-map.is-error {
  display: grid;
  place-items: center;
  text-align: center;
}

.start-location-map.is-error {
  color: var(--danger);
}

.start-location-place {
  margin-bottom: 1rem;
}

.start-location-place:empty {
  display: none;
}

.start-location-map .ol-zoom {
  bottom: auto;
  left: auto;
  margin: 0;
  right: 0.5rem;
  top: 0.5rem;
}

.required-mark {
  color: var(--danger);
  font-weight: 700;
}

.create-page .form-message,
.edit-page .form-message,
.profile-page .form-message,
dialog .form-message {
  color: var(--danger);
}

.profile-page .form-message.success-message,
dialog .form-message.success-message {
  color: var(--text-muted);
}

.invalid-field {
  border-color: var(--danger);
  outline: 1px solid var(--danger);
}

.cancel-field {
  color: var(--danger);
  display: block;
  font-weight: 600;
  margin-bottom: 0;
}

.cancel-field input {
  margin-right: 0.5rem;
  width: auto;
}

.edit-actions {
  display: flex;
  gap: 1rem;
  margin: 1rem 0 0;
}

.profile-page section {
  margin-bottom: 2rem;
}

.profile-page input {
  box-sizing: border-box;
  margin-bottom: 0;
  width: 100%;
}

.profile-page section:first-of-type input {
  max-width: 420px;
}

.profile-field-hint {
  color: var(--text-muted);
  display: block;
  margin-top: 0.25rem;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.profile-actions button {
  margin: 0;
}

.create-page form > button,
#logout-button,
#profile-password-form > button {
  margin-bottom: 0;
  margin-top: 1rem;
}

.profile-actions #logout-button {
  margin: 0;
}

.edit-actions button {
  margin-bottom: 0;
}

.profile-events-table {
  overflow-x: auto;
}

.profile-events-table table {
  table-layout: fixed;
  width: 800px;
}

.profile-events-table th,
.profile-events-table td {
  vertical-align: middle;
}

.profile-events-table th:nth-child(1),
.profile-events-table td:nth-child(1) {
  width: 130px;
}

.profile-events-table th:nth-child(3),
.profile-events-table td:nth-child(3) {
  width: 130px;
}

.profile-events-table td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-page {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.event-page > h1 {
  margin: 0;
}

.event-cancelled-message {
  color: var(--danger);
  margin: -1rem 0 0;
  text-align: center;
}

.event-cancelled-message[hidden] {
  display: none;
}

.event-columns {
  display: grid;
  align-items: stretch;
  gap: 2rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.event-columns > * {
  min-width: 0;
}

.event-page h2 {
  margin: 0 0 1rem;
}

.event-columns p,
.event-page dl {
  margin: 0;
}

.event-page #event-contacts {
  display: inline-block;
  margin-bottom: 2rem;
}

.event-page dl {
  display: grid;
  grid-template-columns: 1fr auto;
}

.event-page dt {
  color: var(--text-muted);
}

.event-page dd {
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

#event-description {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.event-participants-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}

.event-participants-header h2,
.event-participants-header button {
  margin: 0;
}

.event-participants-message {
  color: var(--text-muted);
  margin: 0;
}

.event-participants-message.error-message {
  color: var(--danger);
}

.event-participants-list {
  column-count: 2;
  column-gap: 2rem;
  margin: 0;
  padding-left: 1.25rem;
}

.event-participants-list li {
  break-inside: avoid;
  margin-bottom: 0.25rem;
}

.map-placeholder,
.route-placeholder {
  background: var(--surface-control);
  display: grid;
  place-items: center;
}

.map-placeholder {
  min-height: 100%;
}

.route-placeholder {
  aspect-ratio: 16 / 9;
}

.event-map-shell {
  background: transparent;
  position: relative;
  --event-map-control-size: 24px;
  --event-map-control-height: 24px;
  --event-map-control-padding-x: 0.65em;
  --event-map-icon-box: 19px;
  --event-map-icon-size: 15px;
  --event-map-stats-font-size: 0.7rem;
}

.event-map .event-map-tabs {
  align-items: stretch;
  display: flex;
  left: 50%;
  padding: 1px;
  top: 0.5em;
  transform: translateX(-50%);
}

.event-map .event-map-tabs button {
  box-sizing: border-box;
  font: inherit;
  font-size: var(--event-map-stats-font-size);
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 0 1px;
  min-height: var(--event-map-control-height);
  min-width: var(--event-map-control-size);
  padding: 0 var(--event-map-control-padding-x);
  white-space: nowrap;
  width: 80px;
}

.event-map .event-map-tabs button:first-child {
  border-radius: 2px 0 0 2px;
  margin-left: 0;
}

.event-map .event-map-tabs button:last-child {
  border-radius: 0 2px 2px 0;
}

.event-map .event-map-tabs button.active {
  color: var(--ol-foreground-color);
  font-weight: 700;
}

.event-map .event-map-tabs button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.event-map {
  aspect-ratio: 16 / 9;
  min-height: 280px;
  position: relative;
  width: 100%;
}

.event-map-message {
  color: var(--danger);
  display: block;
  margin: 0;
  margin-top: 0.25rem;
}

.event-map-message:empty {
  display: none;
}

.event-map-contribution {
  align-items: center;
  bottom: 0.15rem;
  color: var(--ol-subtle-foreground-color);
  display: inline-flex;
  font-size: calc(var(--event-map-stats-font-size) * 0.75);
  gap: 0.35em;
  justify-content: center;
  left: 50%;
  line-height: 1.2;
  padding: 0.3em 0.6em;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
  z-index: 1;
}

.event-map-contribution a {
  color: inherit;
  text-decoration: underline;
}

.event-map-route-overlay {
  bottom: 1.25rem;
  background-color: var(--ol-subtle-background-color);
  border-radius: 4px;
  display: flex;
  font-size: var(--event-map-stats-font-size);
  left: 50%;
  padding: 1px;
  transform: translateX(-50%);
}

.event-map-route-overlay[hidden] {
  display: none;
}

.event-map-route-chip {
  align-items: center;
  background-color: var(--ol-background-color);
  border: 0;
  border-radius: 2px;
  box-sizing: border-box;
  color: var(--ol-subtle-foreground-color);
  display: inline-flex;
  gap: 0.35em;
  justify-content: center;
  line-height: 1.2;
  margin: 0 0 0 1px;
  min-height: var(--event-map-control-height);
  min-width: var(--event-map-control-size);
  padding: 0 var(--event-map-control-padding-x);
  text-align: center;
  text-decoration: none;
  user-select: none;
}

.event-map-route-chip:first-child {
  margin-left: 0;
}

.event-map-route-chip:focus-visible,
.event-map-route-chip:hover {
  color: var(--ol-foreground-color);
  outline: 1px solid var(--ol-subtle-foreground-color);
  text-decoration: none;
}

.event-map-route-stats {
  border-radius: 2px 0 0 2px;
  cursor: default;
  pointer-events: none;
  text-transform: uppercase;
}

.event-map-route-stats strong {
  color: var(--ol-foreground-color);
  font-weight: 600;
  text-transform: none;
}

.event-map-route-action {
  height: var(--event-map-control-size);
  min-height: var(--event-map-control-size);
  min-width: var(--event-map-control-size);
  padding: 0;
  width: var(--event-map-control-size);
}

.event-map-route-edit {
  border-radius: 0;
}

.event-map-route-download {
  border-radius: 0 2px 2px 0;
}

.event-map-route-icon {
  display: inline-flex;
  font-size: var(--event-map-icon-size);
  height: var(--event-map-icon-box);
  line-height: 1;
  width: var(--event-map-icon-box);
}

.event-map-shell .ol-zoom {
  bottom: auto;
  left: auto;
  margin: 0;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.event-map-fullscreen-control {
  left: auto;
  right: 0.5rem;
  top: 0.5rem;
}

.event-map-fullscreen-button {
  align-items: center;
  display: inline-flex;
  height: var(--event-map-control-size);
  justify-content: center;
  min-height: var(--event-map-control-size);
  min-width: var(--event-map-control-size);
  padding: 0;
  width: var(--event-map-control-size);
}

.event-map-fullscreen-button svg {
  height: 1em;
  width: 1em;
}

.event-map-fullscreen-button.is-active {
  background: var(--text-muted);
  color: var(--surface-control);
}

.event-map:fullscreen {
  aspect-ratio: auto;
  height: 100%;
  width: 100%;
}

.ol-touch .event-map-shell {
  --event-map-control-size: 33px;
  --event-map-control-height: 33px;
  --event-map-icon-box: 26px;
  --event-map-icon-size: 21px;
  --event-map-stats-font-size: 0.85rem;
}

.ol-touch .event-map-shell .event-map-route-chip:not(.event-map-route-stats) {
  font-size: 1.5em;
}

@media (hover: none), (pointer: coarse) {
  .event-map-shell {
    --event-map-control-size: 33px;
    --event-map-control-height: 33px;
    --event-map-icon-box: 26px;
    --event-map-icon-size: 21px;
    --event-map-stats-font-size: 0.85rem;
  }

  .event-map-shell .event-map-route-chip:not(.event-map-route-stats) {
    font-size: 1.5em;
  }
}

.events {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
}

.events article {
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
}

.events article:hover {
  border-color: var(--link);
}

.stale-event {
  opacity: 0.4;
}

.events article > a {
  color: inherit;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  position: relative;
  text-decoration: none;
}

.events article > a:hover {
  text-decoration: none;
}

.events article > a:focus {
  outline: none;
}

.events article > a:focus-visible {
  outline: none;
}

.events article > a:focus-visible::before {
  border: 2px solid var(--focus);
  border-radius: 3px;
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.event-card-media {
  display: block;
  position: relative;
}

.event-card-badges {
  align-items: flex-end;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  left: 0;
  position: absolute;
}

.event-card-badge {
  font-size: 1rem;
  line-height: 1.25;
  padding: 0.2rem 1rem;
  text-align: center;
}

.event-card-badge-cancelled {
  background: var(--danger-subtle);
  color: var(--danger);
}

.event-card-badge-participating {
  background: var(--success-subtle);
  color: var(--success);
}

.preview {
  aspect-ratio: 16 / 9;
  background: var(--preview-background);
  display: block;
  object-fit: cover;
  width: 100%;
}

.event-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px 8px;
}

.events h2 {
  display: -webkit-box;
  font-size: 1rem;
  margin: 0 0 1rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.event-card-place {
  color: var(--text-muted);
  display: -webkit-box;
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 0.35rem 0 1rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.events h2 + .event-card-place {
  margin-top: -0.65rem;
}

.events dl {
  display: grid;
  grid-template-columns: 1fr auto;
  margin: auto 0 0;
}

.events dt {
  color: var(--text-muted);
}

.events dd {
  margin: 0;
  text-align: right;
}

.site-footer {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  text-align: left;
}

.site-footer .footer-copy {
  flex: 1 1 auto;
  margin: 0;
  min-width: max-content;
}

.site-footer nav {
  flex: 0 0 auto;
  margin-left: auto;
}

.site-footer.is-wrapped {
  justify-content: center;
  text-align: center;
}

.site-footer.is-wrapped .footer-copy,
.site-footer.is-wrapped nav {
  flex-basis: 100%;
  margin-left: 0;
}

.site-footer nav,
.site-footer a {
  word-spacing: normal;
}

@media (max-width: 700px) {
  .event-columns {
    grid-template-columns: 1fr;
  }

  .event-participants-list {
    column-count: 1;
  }
}
