:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: #182b3d;
  background: #eaf3fa;
  --surface: #fff;
  --border: #c4d7e8;
  --muted: #465e74;
  --accent: #17588c;
  --danger: #942e2a;
}

* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 5vw, 2.75rem); line-height: 1.12; }
h2 { font-size: 1.2rem; line-height: 1.3; }
a { color: var(--accent); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2478ad; outline-offset: 3px; }

.shell { width: min(100% - 2rem, 54rem); margin: 0 auto; padding: 3rem 0; }
.narrow { max-width: 34rem; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.back { margin-bottom: 1rem; }
h1 + .back { margin: 1rem 0 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.actions form { margin: 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .5rem .85rem;
  border: 1px solid transparent;
  border-radius: .6rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 650;
}
.button:hover { background: #12446d; }
.button.secondary, .button.danger { background: var(--surface); border-color: var(--border); color: var(--accent); }
.button.danger { color: var(--danger); }
.button.secondary:hover { background: #edf6fd; }
.button.danger:hover { background: #fff2f1; }

.route-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.card { padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: .85rem; }
.public-card { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .8rem; color: inherit; text-decoration: none; }
.public-card:hover { border-color: #779fbe; background: #f6fbff; }
.public-card:hover h2 { color: var(--accent); }
.public-card .comment { flex-basis: 100%; }
.points { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.comment { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.card h2 { overflow-wrap: anywhere; }
.card-copy .comment { margin-top: .25rem; }
.empty { padding: 1rem 0; color: var(--muted); }

.form-panel { display: grid; gap: .5rem; margin-top: 1.25rem; }
.form-panel > label { font-weight: 650; }
.form-panel input, .form-panel textarea {
  width: 100%;
  padding: .55rem .65rem;
  margin-bottom: .6rem;
  border: 1px solid #839db3;
  border-radius: .5rem;
  color: inherit;
  background: var(--surface);
}
.form-panel textarea { resize: vertical; }
.form-panel .button { justify-self: start; }
.muted { color: var(--muted); font-weight: 400; }
.error { border-radius: .5rem; padding: .7rem .8rem; margin-bottom: .75rem; background: #fff0ef; color: var(--danger); }

.admin-card { display: flex; align-items: center; gap: .85rem; scroll-margin-block: 1rem; }
.card-copy { flex: 1 1 auto; min-width: 0; }
.card-actions { margin-left: auto; }
.order-control { display: grid; flex-shrink: 0; border: 1px solid var(--border); border-radius: .5rem; }
.order-control button, .drag-handle {
  display: grid;
  place-items: center;
  width: 2.75rem;
  min-height: 2rem;
  border: 0;
  border-radius: .4rem;
  background: transparent;
  color: var(--accent);
}
.order-control button:hover:not(:disabled), .drag-handle:hover { background: #e6f2fb; }
.order-control button:disabled { color: #9aafc1; cursor: default; }
.drag-handle { display: none; font-size: 1.35rem; touch-action: none; user-select: none; cursor: grab; }
.can-drag .drag-handle { display: grid; }
.drag-ghost { opacity: .5; }

.map-page { position: relative; height: 100vh; height: 100dvh; }
.map-frame { display: block; width: 100%; height: 100%; border: 0; }
.map-controls {
  position: absolute;
  top: max(.75rem, env(safe-area-inset-top));
  left: max(.75rem, env(safe-area-inset-left));
  right: max(.75rem, env(safe-area-inset-right));
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  pointer-events: none;
}
.map-controls a { pointer-events: auto; box-shadow: 0 2px 6px #182b3d26; }

@media (max-width: 37rem) {
  .shell { padding: 1.75rem 0; }
  .admin-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .5rem .8rem; }
  .order-control { grid-row: span 2; }
  .admin-card .card-actions { grid-column: 2; margin-left: 0; }
  .admin-card .card-copy:first-child { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-card { transition: none !important; }
}
