* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  overflow: hidden;
  height: 100vh;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
#sidebar {
  width: 340px;
  min-width: 340px;
  background: #16213e;
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: margin-left 0.3s ease;
  border-right: 1px solid #1a3a5c;
}

#sidebar.collapsed {
  margin-left: -340px;
}

.sidebar-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid #1a3a5c;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #DAA520;
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 0.8rem;
  color: #8899aa;
  margin-top: 4px;
}

/* Share button */
.share-btn {
  padding: 5px 12px;
  background: #0f1b35;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  color: #667788;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.share-btn:hover {
  border-color: #DAA520;
  color: #DAA520;
}

.share-btn.copied {
  background: #1a3a5c;
  border-color: #DAA520;
  color: #DAA520;
}

/* Search */
.search-box {
  padding: 12px 20px;
  position: relative;
}

#search {
  width: 100%;
  padding: 10px 14px;
  background: #0f1b35;
  border: 1px solid #1a3a5c;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

#search:focus {
  border-color: #DAA520;
}

#search::placeholder {
  color: #556677;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 20px;
  right: 20px;
  background: #0f1b35;
  border: 1px solid #1a3a5c;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.search-results.active {
  display: block;
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #1a2a40;
  transition: background 0.15s;
}

.search-result-item:hover,
.search-result-item.search-active {
  background: #1a3050;
}

.search-result-item.search-active {
  border-left: 2px solid #DAA520;
  padding-left: 12px;
}

.search-result-item .result-name {
  font-size: 0.85rem;
  color: #e0e0e0;
}

.search-result-item .result-meta {
  font-size: 0.72rem;
  color: #667788;
  margin-top: 2px;
}

/* Filters */
.filter-section {
  padding: 12px 20px;
  border-bottom: 1px solid #1a3a5c;
}

.filter-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #667788;
  margin-bottom: 8px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 3px 0;
}

.filter-item input[type="checkbox"] {
  accent-color: #DAA520;
  cursor: pointer;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-aar { background: #DAA520; }
.dot-nsb { background: #2E86AB; }
.dot-state { background: #6B8F71; }
.dot-blm { background: #C17817; }
.dot-usfs { background: #2D6A4F; }

#state-filter {
  width: 100%;
  padding: 8px 10px;
  background: #0f1b35;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

#state-filter:focus {
  border-color: #DAA520;
}

/* Discover button */
.discover-section {
  padding: 8px 20px 8px;
}

.discover-btn {
  width: 100%;
  padding: 10px 14px;
  background: linear-gradient(135deg, #1a3050, #1a3a5c);
  border: 1px solid #2a4a6c;
  border-radius: 8px;
  color: #DAA520;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.discover-btn:hover {
  background: linear-gradient(135deg, #1e3a5c, #244a6c);
  border-color: #DAA520;
}

.discover-btn:active {
  transform: scale(0.98);
}

/* List controls (favorites + length filter) */
.list-controls {
  display: flex;
  gap: 6px;
  padding: 6px 20px 8px;
  border-bottom: 1px solid #1a3a5c;
}

.ctrl-btn {
  padding: 5px 10px;
  background: #0f1b35;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  color: #556677;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.ctrl-btn:hover {
  border-color: #2a4a6c;
  color: #8899aa;
}

.ctrl-btn.active {
  background: #1a3a5c;
  border-color: #DAA520;
  color: #DAA520;
}

.ctrl-btn.has-favs {
  color: #DAA520;
}

.ctrl-select {
  flex: 1;
  padding: 5px 8px;
  background: #0f1b35;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  color: #8899aa;
  font-size: 0.75rem;
  cursor: pointer;
  outline: none;
}

.ctrl-select:focus {
  border-color: #DAA520;
}

/* Byway list */
.byway-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.byway-list-item {
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.byway-list-item:hover {
  background: #1a3050;
}

.byway-list-item.active {
  background: #1a3a5c;
  border-left: 3px solid #DAA520;
  padding-left: 17px;
}

.byway-list-item.active .item-name {
  color: #DAA520;
}

.byway-list-item .dot {
  margin-top: 4px;
}

.byway-list-item .item-info {
  flex: 1;
  min-width: 0;
}

.byway-list-item .item-name {
  font-size: 0.82rem;
  color: #d0d8e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.byway-list-item .item-meta {
  font-size: 0.7rem;
  color: #556677;
  margin-top: 2px;
}

/* Bookmark button in list */
.bookmark-btn {
  background: none;
  border: none;
  color: #334455;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.bookmark-btn:hover {
  color: #DAA520;
  transform: scale(1.2);
}

.bookmark-btn.bookmarked {
  color: #DAA520;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid #1a3a5c;
  font-size: 0.72rem;
  color: #556677;
}

.sidebar-footer a {
  color: #6699bb;
  text-decoration: none;
}

.sidebar-footer a:hover {
  text-decoration: underline;
}

.shortcuts-hint {
  margin-top: 4px;
  color: #3a4a5a;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
}

/* Map */
#map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

.sidebar-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  background: #16213e;
  border: 1px solid #1a3a5c;
  color: #DAA520;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.sidebar-toggle:hover {
  background: #1a3050;
}

/* Loading */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(22, 33, 62, 0.95);
  padding: 16px 28px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #c0c8d0;
  z-index: 20;
  pointer-events: none;
}

.loading.hidden {
  display: none;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #334;
  border-top-color: #DAA520;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Popups */
.maplibregl-popup-content {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border-radius: 10px !important;
  padding: 16px 20px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
  border: 1px solid #1a3a5c !important;
  max-width: 320px !important;
}

.maplibregl-popup-tip {
  border-top-color: #16213e !important;
}

.maplibregl-popup-close-button {
  color: #667788 !important;
  font-size: 1.2rem !important;
  right: 8px !important;
  top: 6px !important;
}

.maplibregl-popup-close-button:hover {
  color: #DAA520 !important;
  background: none !important;
}

.popup-name {
  font-size: 1rem;
  font-weight: 700;
  color: #DAA520;
  margin-bottom: 6px;
  padding-right: 16px;
}

.popup-designation {
  font-size: 0.78rem;
  color: #8899aa;
  margin-bottom: 4px;
}

.popup-state {
  font-size: 0.78rem;
  color: #6B8F71;
  margin-bottom: 4px;
}

.popup-miles {
  font-size: 0.78rem;
  color: #8899aa;
}

.popup-links {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.popup-gmaps {
  display: inline-block;
  padding: 6px 14px;
  background: #1a3a5c;
  color: #DAA520 !important;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.15s;
}

.popup-gmaps:hover {
  background: #244a6c;
}

.popup-wiki {
  display: inline-block;
  padding: 6px 14px;
  background: #1a3a5c;
  color: #8899aa !important;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: all 0.15s;
}

.popup-wiki:hover {
  background: #244a6c;
  color: #c0c8d0 !important;
}

/* Popup bookmark button */
.popup-bookmark {
  display: inline-block;
  padding: 6px 12px;
  background: #0f1b35;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  color: #556677;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.popup-bookmark:hover {
  border-color: #DAA520;
  color: #DAA520;
}

.popup-bookmark.active {
  background: #1a3a5c;
  border-color: #DAA520;
  color: #DAA520;
}

/* Tooltip */
.byway-tooltip {
  pointer-events: none;
  position: absolute;
  background: rgba(22, 33, 62, 0.92);
  color: #e0e0e0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 15;
  border: 1px solid #1a3a5c;
  display: none;
}

/* Mobile */
@media (max-width: 768px) {
  #sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    width: 300px;
    min-width: 300px;
  }

  #sidebar.collapsed {
    margin-left: -300px;
  }
}
