:root {
  --accent: #b5491f;
  --background: #f6f5f2;
  --border: #d6d3cc;
  --error: #b42318;
  --surface: #ffffff;
  --text: #1f1d1a;
  --text-muted: #6b665e;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #e8794a;
    --background: #171614;
    --border: #3a3732;
    --error: #f97066;
    --surface: #211f1c;
    --text: #ecebe7;
    --text-muted: #a29d94;
  }
}

* {
  box-sizing: border-box;
}

body {
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  margin: 0;
}

a {
  color: var(--accent);
}

.header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.brand {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.main {
  margin: 0 auto;
  max-width: 80rem;
  padding: 1.5rem 1rem;
}

.login {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 3rem auto;
  max-width: 22rem;
  padding: 1.5rem;
}

.login h1 {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
}

input:not([type="checkbox"]),
select,
textarea {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text);
  font: inherit;
  padding: 0.5rem 0.625rem;
}

.button {
  background: var(--accent);
  border: 0;
  border-radius: 0.375rem;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
}

.link-button {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.error {
  color: var(--error);
  font-size: 0.875rem;
}

.error ul {
  margin: 0;
  padding-left: 1.25rem;
}

.validation-summary-valid {
  display: none;
}

.nav {
  display: flex;
  gap: 1rem;
  margin-right: auto;
}

.nav a {
  text-decoration: none;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
}

.filter {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
  max-width: 32rem;
}

.filter input {
  flex: 1;
}

.filter .button {
  margin-top: 0;
}

.table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-collapse: collapse;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  width: 100%;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.table th {
  color: var(--text-muted);
  font-weight: 500;
}

.table .number {
  text-align: right;
}

.table .url {
  word-break: break-all;
}

.edit {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.edit + .edit {
  margin-top: 2rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.checks {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.checks label {
  align-items: center;
  display: flex;
  gap: 0.375rem;
}

.fields {
  align-items: start;
  display: grid;
  gap: 0.5rem 1rem;
  grid-template-columns: 9rem minmax(0, 1fr);
}

.fields label {
  padding-top: 0.5rem;
}

.fields select,
.fields input,
.fields textarea {
  width: 100%;
}

.ranges {
  border-collapse: collapse;
}

.ranges th,
.ranges td {
  padding: 0.25rem 1rem 0.25rem 0;
  text-align: left;
}

.ranges th {
  font-size: 0.875rem;
  font-weight: 500;
}

.short,
.fields .short {
  width: 7rem;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.field-validation-valid {
  display: none;
}

@media (max-width: 40rem) {
  .fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .fields label {
    padding-top: 0;
  }
}

.title-row {
  align-items: baseline;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.title-row .button {
  margin-top: 0;
  text-decoration: none;
}

.panel .table {
  margin-bottom: 0.75rem;
}

.panel .filter {
  margin-bottom: 0;
}

.danger {
  background: var(--error);
}

.pictures {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.picture {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
  padding-bottom: 0.5rem;
}

.picture img {
  aspect-ratio: 3 / 2;
  display: block;
  object-fit: cover;
  width: 100%;
}

.picture-info,
.picture-actions {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0 0.75rem;
}

.picture-info {
  font-size: 0.875rem;
  font-weight: 600;
}

.picture-actions {
  font-size: 0.875rem;
}

.link-button:disabled {
  color: var(--text-muted);
  cursor: default;
}

.picture-large {
  border-radius: 0.5rem;
  display: block;
  height: auto;
  margin-bottom: 1rem;
  max-width: 100%;
}

.section-title {
  margin: 1.5rem 0 0;
}

.title-row .nav {
  margin-right: 0;
}

.links {
  border-collapse: collapse;
  width: 100%;
}

.links th,
.links td {
  padding: 0.25rem 0.5rem 0.25rem 0;
  text-align: left;
  vertical-align: top;
}

.links th {
  font-size: 0.875rem;
  font-weight: 500;
}

.links td:first-child {
  width: 5.5rem;
}

.links td:nth-child(2) {
  width: 30%;
}

.links input {
  width: 100%;
}

.job-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.job-buttons .button {
  margin-top: 0;
}

.button:disabled {
  cursor: default;
  opacity: 0.5;
}

.route-map {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  height: 70vh;
  min-height: 24rem;
  overflow: hidden;
}

.map-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.875rem;
  gap: 0.5rem 1.25rem;
  margin-top: 0.75rem;
}

.map-legend span {
  align-items: center;
  display: inline-flex;
  gap: 0.375rem;
}

.swatch {
  border-radius: 2px;
  display: inline-block;
  height: 4px;
  width: 1.25rem;
}

.swatch-waypoint {
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: 50%;
  height: 0.7rem;
  width: 0.7rem;
}

.swatch-waypoint-selected {
  background: #f97316;
  border-color: #7c2d12;
}

.swatch-waypoint-dropped {
  background: #b42318;
  border-color: #7a1a12;
}

.swatch-network {
  background: #2b5770;
}

.swatch-via-ferrata {
  background: #d6792c;
}

.swatch-route {
  height: 5px;
}

.swatch-drawn {
  background: repeating-linear-gradient(90deg, #2b5770 0 10px, transparent 10px 15px);
}

.swatch-preview {
  background: #16a34a;
}

.map-layout {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 20rem;
}

.editor {
  max-height: 80vh;
  overflow-y: auto;
}

.editor h2 {
  margin-top: 1rem;
}

.editor h2:first-child {
  margin-top: 0;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  font-size: 0.875rem;
  gap: 0.75rem;
  justify-content: space-between;
}

.preview-stats {
  display: grid;
  font-size: 0.875rem;
  gap: 0.25rem;
  margin: 0;
}

.preview-stats div {
  display: flex;
  justify-content: space-between;
}

.preview-stats dd {
  font-weight: 600;
  margin: 0;
}

.waypoint-list {
  font-size: 0.875rem;
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.waypoint-item {
  align-items: center;
  border-radius: 0.25rem;
  display: flex;
  gap: 0.5rem;
  padding: 0.125rem 0.375rem;
}

.waypoint-item.selected {
  background: var(--background);
  outline: 1px solid var(--accent);
}

.waypoint-item.dropped .waypoint-label {
  color: var(--error);
}

.waypoint-label {
  color: var(--text);
  flex: 1;
  text-align: left;
}

.waypoint-marker {
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: 50%;
  color: #111827;
  cursor: grab;
  font: 600 0.6875rem/1 system-ui, sans-serif;
  height: 1.375rem;
  padding: 0;
  width: 1.375rem;
}

.waypoint-marker.selected {
  background: #f97316;
  border-color: #7c2d12;
  color: #ffffff;
  z-index: 1;
}

.waypoint-marker.dropped {
  background: #b42318;
  border-color: #7a1a12;
  color: #ffffff;
}

@media (max-width: 60rem) {
  .map-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.editor-actions .button {
  margin-top: 0;
}
