* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: system-ui, sans-serif; font-size: 14px; color: #1d2433; }
body { display: flex; }

#sidebar { width: 340px; flex: none; display: flex; flex-direction: column; background: #f7f8fb; border-right: 1px solid #d9dde6; overflow-y: auto; }
#sidebar header, #sidebar section, #sidebar footer { padding: 12px 14px; border-bottom: 1px solid #e3e6ee; }
#sidebar footer { margin-top: auto; border-bottom: 0; display: flex; gap: 8px; }
h1 { margin: 0 0 8px; font-size: 20px; }
h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: #5b6478; }
h3 { margin: 0 0 8px; }
#map { flex: 1; min-width: 0; }

.row { display: flex; gap: 6px; }
.row.end { justify-content: flex-end; margin-top: 12px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 6px 8px; border: 1px solid #c4cad8; border-radius: 6px; background: #fff; color: inherit; }
button, .fileBtn { padding: 6px 10px; border: 1px solid #c4cad8; border-radius: 6px; background: #fff; cursor: pointer; white-space: nowrap; }
button:hover, .fileBtn:hover { background: #eef1f8; }
button.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
button.primary:hover { background: #1d4fd0; }
button.danger { color: #b42318; margin-right: auto; }
.hint { margin: 8px 0 0; color: #7a8296; font-size: 12px; }

#results { list-style: none; margin: 8px 0 0; padding: 0; }
#results li { padding: 6px 8px; border: 1px solid #e3e6ee; border-radius: 6px; margin-bottom: 4px; background: #fff; cursor: pointer; font-size: 13px; }
#results li:hover { background: #eef1f8; }

#stopList { margin: 0; padding: 0; list-style: none; counter-reset: stop; }
#stopList li { counter-increment: stop; display: flex; gap: 8px; align-items: flex-start; padding: 8px; margin-bottom: 6px; background: #fff; border: 1px solid #e3e6ee; border-radius: 8px; cursor: pointer; }
#stopList li:hover { border-color: #2563eb; }
#stopList li::before { content: counter(stop); flex: none; width: 22px; height: 22px; border-radius: 50%; background: #2563eb; color: #fff; text-align: center; line-height: 22px; font-size: 12px; font-weight: 600; }
.stopInfo { flex: 1; min-width: 0; }
.stopInfo b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stopInfo small { color: #6b7388; }
.moveBtns { display: flex; flex-direction: column; gap: 2px; }
.moveBtns button { padding: 0 6px; line-height: 16px; font-size: 11px; }

dialog { border: 0; border-radius: 12px; padding: 18px; width: min(440px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog label { display: block; margin-bottom: 10px; font-size: 12px; color: #5b6478; }
dialog label input, dialog label textarea { margin-top: 3px; color: #1d2433; font-size: 14px; }
.coords { font-size: 12px; color: #7a8296; }

.pin { width: 26px; height: 26px; border-radius: 50%; background: #2563eb; border: 2px solid #fff; color: #fff; text-align: center; line-height: 22px; font-weight: 700; font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

@media (max-width: 700px) {
  body { flex-direction: column-reverse; }
  #sidebar { width: 100%; height: 45%; border-right: 0; border-top: 1px solid #d9dde6; }
  #map { height: 55%; flex: none; }
}

/* View mode hides every editing control; the /edit/ page sets <body class="edit"> */
body:not(.edit) .editOnly { display: none !important; }
body.edit .moveBtns { display: flex; }
body:not(.edit) .moveBtns { display: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
a.fileBtn { color: inherit; text-decoration: none; margin-left: auto; }
dialog fieldset:disabled input, dialog fieldset:disabled textarea { background: #f3f4f8; }
