:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #f1f4f2;
  background: #000;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #000;
}

main {
  width: min(960px, calc(100% - 32px));
  margin: 32px auto;
}

main.narrow {
  width: min(440px, calc(100% - 32px));
  margin-top: 6vh;
}

#login-view {
  color: #f1f4f2;
}

#login-view > h1,
#login-view > p {
  text-align: center;
}

#app-view {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: 28px max(16px, calc((100% - 960px) / 2));
  background: #000;
  color: #f1f4f2;
}

#login-view[hidden],
#app-view[hidden] {
  display: none;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
}

.app-header,
.section-heading,
.actions,
.companion-item,
.distance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header {
  margin-bottom: 4px;
  justify-content: flex-start;
}

.app-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-group,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.club-logo {
  display: block;
  width: 76px;
  height: 76px;
  object-fit: contain;
}

.login-logo {
  width: 96px;
  height: 96px;
  margin-bottom: 12px;
}

.home-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid #777;
  border-radius: 6px;
  background: #252525;
  color: #f1f4f2;
  font-weight: 600;
  text-decoration: none;
}

.home-link:hover {
  background: #363636;
}

.home-link:focus-visible {
  outline: 3px solid #d0d0d0;
  outline-offset: 2px;
}

.login-home-link {
  margin-top: 16px;
}

.app-home-link {
  margin: 0;
}

.brand-copy {
  flex: 1;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-header p,
.muted {
  color: #c4c4c4;
}

.panel {
  margin: 16px 0;
  padding: 22px;
  border: 1px solid #4a4a4a;
  border-radius: 10px;
  background: #202020;
  box-shadow: 0 3px 12px #0006;
}

form,
label {
  display: grid;
  gap: 8px;
}

form {
  gap: 16px;
}

label {
  font-weight: 600;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #777;
  border-radius: 6px;
  background: #151515;
  color: #f1f4f2;
}

input::placeholder,
textarea::placeholder {
  color: #c4c4c4;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid #d0d0d0;
  outline-offset: 2px;
}

button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #aaa;
  border-radius: 6px;
  background: #4b4b4b;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button:not(.secondary):not(.danger) {
  border-color: #aaa;
}

button:hover:not(:disabled) {
  background: #5c5c5c;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary {
  border: 1px solid #777;
  background: #252525;
  color: #f1f4f2;
}

button.secondary:hover:not(:disabled) {
  background: #363636;
}

button.danger {
  border: 1px solid #888;
  background: #303030;
  color: #fff;
}

button.danger:hover:not(:disabled) {
  background: #414141;
}

button.small {
  padding: 6px 9px;
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.event-categories {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  border-bottom: 1px solid #393939;
}

.modality-tabs {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.modality-tab {
  min-width: 0;
  padding-right: 4px;
  padding-left: 4px;
  border-radius: 6px 6px 0 0;
}

.modality-tab[aria-selected="true"] {
  border-color: #c4c4c4;
  border-bottom-width: 3px;
  background: #3b3b3b;
  font-weight: 700;
}

fieldset {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #666;
  border-radius: 8px;
  background: #1b1b1b;
}

legend {
  padding: 0 6px;
  font-weight: 700;
}

.distance-row {
  align-items: end;
  padding-bottom: 12px;
  border-bottom: 1px solid #393939;
}

.distance-row:last-child {
  border-bottom: 0;
}

.distance-row label:first-child {
  flex: 2;
}

.distance-row label:nth-child(2) {
  flex: 1;
}

.event-list,
.companion-list {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.event-item {
  display: grid;
  width: 100%;
  min-height: 64px;
  gap: 5px;
  padding: 14px;
  border: 1px solid #777;
  border-radius: 6px;
  background: #202020;
  color: #f1f4f2;
  text-align: left;
}

.event-item:hover:not(:disabled) {
  border-color: #aaa;
  background: #303030;
  color: #fff;
}

.event-item span {
  font-weight: 400;
}

.event-link {
  overflow-wrap: anywhere;
}

.companion-item {
  display: flex;
  min-width: 0;
  padding: 10px 0;
}

.companion-item > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.companion-item .actions {
  flex-shrink: 0;
}

.companion-list li,
#detail-distances li {
  padding: 10px 8px;
  border-bottom: 1px solid #393939;
}

.companion-list li:last-child,
#detail-distances li:last-child {
  border-bottom: 0;
}

.section-heading > * {
  min-width: 0;
}

#detail-summary {
  overflow-wrap: anywhere;
}

.companion-form {
  margin: 22px 0;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #555;
  background: #1b1b1b;
}

.actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.actions button {
  min-width: 104px;
}

.message {
  padding: 10px 12px;
  border-radius: 6px;
}

.message.error {
  border: 1px solid #82443e;
  background: #451d1b;
  color: #ffd0cb;
}

.message.success {
  border: 1px solid #3e8150;
  background: #15351f;
  color: #c1f0cb;
}

@media (max-width: 640px) {
  body {
    min-width: 0;
  }

  main {
    margin-top: 16px;
  }

  .app-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header {
    align-items: flex-start;
  }

  .brand-group {
    min-width: 0;
    width: 100%;
  }

  .app-actions-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  #app-view {
    padding: 20px 16px;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .event-categories {
    align-items: stretch;
    flex-direction: column;
    border-bottom: 0;
  }

  .distance-row,
  .companion-item {
    align-items: stretch;
    flex-direction: column;
  }

  .companion-item .actions {
    flex-shrink: 1;
  }

  .distance-row button {
    align-self: flex-start;
  }

  .actions button {
    flex: 1 1 auto;
  }

  .panel {
    padding: 16px;
  }

  fieldset {
    min-width: 0;
    padding: 12px;
  }
}
