:root {
  --bg: #070b0f;
  --panel: #0b1015;
  --panel-soft: #151a20;
  --panel-raised: #20262d;
  --input-bg: #232b33;
  --input-border: #4a535d;
  --text: #f5f7fa;
  --muted: #a3abb5;
  --line: #2b323a;
  --accent: #d71920;
  --accent-strong: #ff2b34;
  --accent-soft: rgba(215, 25, 32, 0.16);
  --danger: #ff4b55;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

/* Critical Leaflet layout rules in case the CDN stylesheet is blocked. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
  background: #000;
  outline-offset: 1px;
  touch-action: pan-x pan-y;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
}

.leaflet-container img.leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-safari .leaflet-tile {
  image-rendering: -webkit-optimize-contrast;
}

.leaflet-map-pane,
.leaflet-control-container {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-map-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-pane > svg {
  pointer-events: none;
}

.leaflet-pane > svg path,
.leaflet-interactive {
  pointer-events: auto;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 10px;
}

.leaflet-bottom {
  bottom: 10px;
}

.leaflet-left {
  left: 10px;
}

.leaflet-right {
  right: 10px;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
  float: left;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
  float: right;
}

.leaflet-control-zoom {
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-raised);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  color: var(--text);
  font-size: 19px;
  font-weight: 500;
  line-height: 28px;
  text-align: center;
  text-decoration: none;
}

.leaflet-control-zoom a + a {
  border-top: 1px solid var(--line);
}

.leaflet-control-attribution {
  padding: 3px 7px;
  background: rgba(11, 16, 21, 0.78);
  color: var(--muted);
  font-size: 11px;
}

.leaflet-control-attribution a {
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

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

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  gap: 9px;
  padding: 12px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 600;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.compact-brand p {
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-link {
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.user-bar span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.user-bar strong {
  display: block;
  margin-top: 3px;
  font-size: 0.95rem;
  font-weight: 500;
}

.user-bar a {
  color: var(--danger);
  font-weight: 500;
  text-decoration: none;
}

.tool-panel,
.route-panel,
.actions,
.quick-actions {
  display: grid;
  gap: 7px;
}

.tool-panel,
.quick-actions,
.compact-actions {
  grid-template-columns: 1fr 1fr;
}

.bottom-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: auto;
}

.share-actions {
  grid-template-columns: 1fr 1fr;
}

.share-actions .ghost-button {
  grid-column: 1 / -1;
}

.collection-link {
  grid-column: 1 / -1;
  text-decoration: none;
}

.tool-button,
.primary-button,
.ghost-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 400;
}

.tool-button span:first-child {
  font-size: 1rem;
}

.tool-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
  background: #2b323a;
  transform: translateY(-1px);
}

.tool-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.tool-button.is-saved {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

button:disabled {
  color: #a6aca9;
  cursor: not-allowed;
  opacity: 0.72;
}

.route-panel {
  padding-top: 0;
}

.compact-panel {
  gap: 7px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 7px;
}

label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 0.84rem;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
}

select {
  width: 100%;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
}

textarea {
  width: 100%;
  min-height: 72px;
  padding: 8px;
  resize: vertical;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.35;
  outline: none;
}

.color-input {
  height: 30px;
  min-height: 30px;
  padding: 2px;
  background: var(--input-bg);
  cursor: pointer;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.2);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.2);
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.2);
}

.stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.stats div {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
}

.stats strong {
  display: block;
  margin-top: 0;
  font-size: 0.78rem;
  font-weight: 500;
}

.poi-summary {
  display: grid;
  gap: 5px;
}

.poi-summary > button {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.poi-summary > button:disabled {
  cursor: not-allowed;
}

.poi-summary > button span {
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.poi-summary > button strong {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
}

.poi-list {
  display: grid;
  max-height: 128px;
  gap: 4px;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.poi-list-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 30px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.poi-list-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.poi-list-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--poi-color, var(--accent));
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
}

.poi-list-item strong,
.poi-list-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poi-list-item strong {
  font-size: 0.78rem;
  font-weight: 500;
}

.poi-list-item small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.66rem;
}

.notes-button {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.notes-button:hover,
.notes-button.has-notes {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.notes-button span {
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.notes-button strong {
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
}

.route-notes-input {
  min-height: 150px;
}

.status {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 1200;
  width: fit-content;
  max-width: min(560px, calc(100vw - 32px));
  min-height: 0;
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(11, 16, 21, 0.96);
  color: var(--text);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  text-align: center;
  transition: opacity 180ms ease, transform 180ms ease;
  transform: translate(-50%, 8px);
  pointer-events: none;
}

.status.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.status.is-error {
  border-left-color: var(--danger);
  background: rgba(36, 12, 16, 0.96);
  color: #ffd7da;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
  display: none;
}

.poi-modal {
  display: grid;
  width: min(360px, 100%);
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 16, 21, 0.98);
  box-shadow: var(--shadow);
}

.poi-modal header,
.poi-modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.poi-modal header {
  margin-bottom: 4px;
}

.poi-modal header span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.poi-modal h2 {
  margin: 2px 0 0;
  font-size: 1rem;
  font-weight: 500;
}

.modal-close {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.poi-modal footer {
  margin-top: 6px;
}

.poi-modal footer button {
  flex: 1;
}

.actions {
  margin-top: 0;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 400;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.ghost-button {
  background: var(--panel-raised);
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 400;
}

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

.routes-panel {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  gap: 6px;
  padding-top: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title h2 {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 500;
  text-transform: uppercase;
}

.panel-title span {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
}

.route-search {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.78rem;
}

.route-list {
  display: grid;
  align-content: start;
  min-height: 0;
  gap: 5px;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.route-list::-webkit-scrollbar {
  width: 8px;
}

.route-list::-webkit-scrollbar-track {
  background: transparent;
}

.route-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line);
}

.route-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 30px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.route-item:hover,
.route-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.route-swatch {
  width: 9px;
  height: 20px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.route-info {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.route-info strong {
  min-width: 0;
}

.route-info strong,
.route-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-info strong {
  font-size: 0.82rem;
  font-weight: 500;
}

.route-shared-icon {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  line-height: 1;
  vertical-align: 1px;
}

.route-info small {
  flex: 0 0 auto;
  margin-top: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.empty-list {
  padding: 9px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.map-wrap,
#map {
  min-height: 100vh;
}

.map-wrap {
  position: relative;
}

#map {
  width: 100%;
}

.map-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 700;
  display: grid;
  gap: 7px;
}

.map-tool-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(11, 16, 21, 0.92);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(31, 37, 34, 0.14);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}

.map-tool-button:hover:not(:disabled),
.map-tool-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.map-tool-button:disabled {
  color: #a6aca9;
  cursor: not-allowed;
  opacity: 0.72;
}

.point-marker {
  display: inline-grid;
  min-width: 50px;
  height: 24px;
  place-items: center;
  padding: 0 8px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1;
}

.poi-marker {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--poi-color, var(--accent));
  color: #fff;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.36);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
}

.leaflet-popup {
  margin-bottom: 14px;
}

.leaflet-popup-content-wrapper {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(11, 16, 21, 0.98);
  color: var(--text);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.46);
}

.leaflet-popup-tip {
  display: none;
}

.leaflet-popup-content {
  width: auto !important;
  min-width: 210px;
  margin: 0;
  font-size: 0.8rem;
}

.leaflet-container a.leaflet-popup-close-button {
  top: 8px;
  right: 8px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(32, 38, 45, 0.9);
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
}

.leaflet-container a.leaflet-popup-close-button:hover {
  background: var(--panel-raised);
  color: var(--text);
}

.poi-popup-card {
  min-width: 210px;
  padding: 12px 34px 12px 12px;
}

.poi-popup-header {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.poi-popup-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: var(--poi-color, var(--accent));
  color: #fff;
  font-size: 0.78rem;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
}

.poi-popup-card small {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1;
  text-transform: capitalize;
}

.poi-popup-card strong {
  display: block;
  margin-top: 2px;
  padding-right: 3px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.2;
}

.poi-popup-card p {
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: #d7dde5;
  font-size: 0.78rem;
  line-height: 1.35;
}

.route-map-label {
  display: inline-block;
  max-width: 130px;
  padding: 3px 8px;
  overflow: hidden;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: rgba(11, 16, 21, 0.9);
  box-shadow: 0 4px 12px rgba(31, 37, 34, 0.16);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}


#map.leaflet-container {
  cursor: grab;
}

#map.leaflet-container.is-drawing {
  cursor: crosshair;
}

.public-view .leaflet-container {
  cursor: grab;
}

.public-view {
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background: #000;
}

.public-map-shell,
#publicMap {
  min-height: 100vh;
  min-height: 100svh;
}

.public-map-shell {
  position: relative;
  overflow: hidden;
  background: #000;
}

#publicMap {
  width: 100%;
}

.public-route-card {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 700;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  width: min(360px, calc(100vw - 28px));
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 16, 21, 0.94);
  box-shadow: var(--shadow);
}

.public-brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.public-route-card span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.public-route-card h1 {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-route-meta {
  display: grid;
  flex: 0 0 auto;
  gap: 6px;
  justify-items: end;
}

.public-route-meta strong {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
}

.public-route-meta .primary-button {
  min-height: 28px;
  padding: 0 12px;
}

.public-route-footer {
  display: contents;
}

.public-poi-panel {
  position: absolute;
  top: 118px;
  left: 14px;
  z-index: 700;
  display: grid;
  width: min(360px, calc(100vw - 28px));
  max-height: min(360px, calc(100vh - 152px));
  gap: 8px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 16, 21, 0.94);
  box-shadow: var(--shadow);
}

.public-poi-panel[hidden] {
  display: none;
}

.public-poi-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.public-poi-title span {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.public-poi-title strong {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
}

.public-poi-list {
  display: grid;
  gap: 5px;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.public-poi-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.public-poi-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.public-poi-item strong,
.public-poi-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-poi-item strong {
  font-size: 0.8rem;
  font-weight: 500;
}

.public-poi-item small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.66rem;
}

.public-notes-panel {
  position: absolute;
  top: 118px;
  right: 14px;
  z-index: 700;
  width: min(360px, calc(100vw - 28px));
  max-height: min(260px, calc(100vh - 152px));
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 16, 21, 0.94);
  box-shadow: var(--shadow);
}

.public-notes-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.public-notes-panel p {
  margin: 7px 0 0;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.public-empty {
  display: grid;
  min-height: 100vh;
  place-content: center;
  padding: 24px;
  background: var(--bg);
  text-align: center;
}

.public-empty h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 500;
}

.public-empty p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
}

.collection-page {
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
}

.collection-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
}

.collection-sidebar {
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 9px;
  height: 100vh;
  height: 100svh;
  min-height: 0;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: rgba(11, 16, 21, 0.98);
  box-shadow: var(--shadow);
}

.collection-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.collection-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.15;
}

.collection-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.collection-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.collection-count strong {
  display: grid;
  min-width: 24px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 500;
}

.collection-list {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.collection-route-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.collection-route-item:hover,
.collection-route-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.collection-route-item strong,
.collection-route-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-route-item strong {
  font-size: 0.84rem;
  font-weight: 500;
}

.collection-route-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
}

.collection-detail {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.collection-detail[hidden] {
  display: none;
}

.collection-detail h2 {
  margin: 0;
  overflow: hidden;
  font-size: 0.96rem;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-detail p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.collection-notes {
  max-height: 92px;
  padding: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text) !important;
  white-space: pre-wrap;
}

.collection-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.collection-actions a {
  text-decoration: none;
}

.collection-map-wrap,
#collectionMap {
  min-height: 100vh;
  min-height: 100svh;
}

.collection-map-wrap {
  position: relative;
  min-width: 0;
}

#collectionMap {
  width: 100%;
}

.collection-routes-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 720;
  display: none;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 16, 21, 0.94);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  background: #05070a;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(5, 7, 10, 0.96) 0%, rgba(5, 7, 10, 0.82) 42%, rgba(5, 7, 10, 0.62) 100%),
    linear-gradient(135deg, rgba(215, 25, 32, 0.18), transparent 38%),
    url("https://tile.openstreetmap.org/7/62/48.png");
  background-size: auto, auto, 256px 256px;
}

.login-panel {
  width: min(100%, 390px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 16, 21, 0.97);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-logo {
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  object-fit: contain;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 500;
  line-height: 1.1;
}

.login-brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form .primary-button {
  margin-top: 10px;
}

.login-submit {
  min-height: 34px;
}

.login-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 75, 85, 0.34);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  background: rgba(36, 12, 16, 0.96);
  color: #ffd7da;
  font-size: 0.84rem;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 1fr);
  }

  .sidebar {
    gap: 14px;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand h1 {
    font-size: 1.22rem;
  }

  .compact-brand p {
    max-width: 180px;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
    margin-top: 0;
  }

  .map-wrap,
  #map {
    min-height: 520px;
  }

  .public-route-card {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: 8px;
    left: 8px;
    width: auto;
    border-right: 0;
    border-left: 0;
    border-radius: 8px;
    padding: 9px;
  }

  .public-brand-logo {
    width: 38px;
    height: 38px;
  }

  .public-route-card h1 {
    font-size: 0.9rem;
  }

  .public-poi-panel {
    position: static;
    width: 100%;
    max-height: 112px;
    padding: 9px;
    box-shadow: none;
  }

  .public-poi-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(168px, 1fr);
    overflow-x: auto;
    overflow-y: hidden;
    padding-right: 0;
    padding-bottom: 2px;
  }

  .public-notes-panel {
    position: static;
    width: 100%;
    max-height: 88px;
    padding: 9px;
    box-shadow: none;
  }

  .public-route-footer {
    position: absolute;
    right: 10px;
    bottom: calc(26px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    z-index: 700;
    display: grid;
    gap: 8px;
  }

  .public-route-footer .public-poi-panel,
  .public-route-footer .public-notes-panel {
    border-radius: 8px;
    background: rgba(11, 16, 21, 0.94);
  }

  .public-map-shell,
  #publicMap {
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
  }

  .collection-shell {
    position: relative;
    display: block;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .collection-map-wrap,
  #collectionMap {
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
  }

  .collection-routes-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
  }

  .collection-sidebar {
    position: absolute;
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    height: auto;
    max-height: none;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(11, 16, 21, 0.96);
  }

  .collection-header,
  .collection-sidebar .route-search,
  .collection-count,
  .collection-list {
    display: none;
  }

  .collection-detail {
    gap: 6px;
  }

  .collection-detail h2 {
    font-size: 0.9rem;
  }

  .collection-notes {
    max-height: 72px;
  }

  body.is-collection-list-open .collection-sidebar {
    top: auto;
    max-height: min(58vh, 440px);
  }

  body.is-collection-list-open .collection-header,
  body.is-collection-list-open .collection-sidebar .route-search,
  body.is-collection-list-open .collection-count,
  body.is-collection-list-open .collection-list {
    display: flex;
  }

  body.is-collection-list-open .collection-list {
    display: grid;
    max-height: 30vh;
  }

  body.is-collection-list-open .collection-routes-toggle {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
}

@media (max-height: 760px) {
  .sidebar {
    gap: 7px;
    padding: 10px;
  }

  .routes-panel {
    gap: 5px;
  }

  .route-list {
    gap: 4px;
  }

  .route-item {
    min-height: 27px;
    padding: 3px 6px;
  }

  .route-swatch {
    width: 8px;
    height: 17px;
  }

  .route-info strong {
    font-size: 0.78rem;
  }

  .route-info small {
    font-size: 0.66rem;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .brand h1 {
    font-size: 0.92rem;
  }
}
