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

:root {
  --bg:           #111110;
  --surface:      #1c1c1a;
  --surface-2:    #242422;
  --border:       #2e2e2c;
  --text:         #e8e8e5;
  --text-muted:   #888884;
  --accent:       #4ade80;   /* green — nature/outdoors feel */
  --accent-hover: #22c55e;
  --danger:       #ef4444;
  --danger-hover: #dc2626;
  --sidebar-w:    160px;
  --radius:       8px;
  /* Mobile variables */
  --mobile-header-h: 50px;
  --mobile-tab-bar-h: 44px;
  --mobile-drawer-max-h: 70vh;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────── */

#app {
  display: flex;
  min-height: 100vh;
}

#app-logo {
  position: fixed;
  bottom: 36px;
  left: 0;
  width: var(--sidebar-w);
  height: auto;
  opacity: 0.6;
  pointer-events: none;
  z-index: 9999;
  padding: 0 14px;
}

#about-btn {
  position: fixed;
  bottom: 14px;
  left: 0;
  width: var(--sidebar-w);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: center;
  cursor: pointer;
  z-index: 9999;
  padding: 4px 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}

#about-btn:hover {
  opacity: 1;
}

/* ── About modal ─────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

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

#about-modal .modal-box {
  padding: 32px 28px 28px;
  max-width: 440px!important;
  width: calc(100% - 40px);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-logo {
  width: 120px;
  height: auto;
  opacity: 0.9;
  align-self: center;
  margin-bottom: 4px;
}

.modal-box p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-box p strong {
  color: var(--text);
}

.modal-box a {
  color: var(--accent);
  text-decoration: none;
}

.modal-box a:hover {
  text-decoration: underline;
}

.modal-disclaimer {
  font-size: 0.75rem !important;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  opacity: 0.7;
}

/* ── Sidebar ─────────────────────────────────── */

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-header button {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-header button:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

#trips-list {
  list-style: none;
  padding: 8px 6px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trip-item {
  display: flex;
  align-items: center;
  border-radius: 6px;
  overflow: hidden;
}

.trip-item-name {
  flex: 1;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 6px;
  transition: background 0.1s, color 0.1s;
}

.trip-item-name:hover {
  background: var(--surface-2);
  color: var(--text);
}

.trip-item.active .trip-item-name {
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 500;
}

/* ── Main ───────────────────────────────────── */

#main {

    /* overflow: hidden; */
    /* height: 100vh; */

  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  text-align: center;
}

#empty-state strong {
  color: var(--accent);
}

/* ── Trip view ──────────────────────────────── */

#trip-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px;
  gap: 16px;
}

#trip-view.hidden { display: none; }
#empty-state.hidden { display: none; }
.hidden { display: none !important; }

#trip-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 16px 8px; 
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

#trip-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 260px;
  flex-shrink: 0;
}

#trip-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-group {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.header-group button {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border);
  font-size: 0.78rem;
  padding: 4px 10px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.header-group button:hover {
  background: var(--border);
  color: var(--text);
}

.header-group a {
  font-size: 0.78rem;
  padding: 4px 10px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.header-group a:hover {
  text-decoration: underline;
}

.header-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Tabs ───────────────────────────────────── */

#trip-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  padding: 0 8px;
}

.tab-btn {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.tab-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.tab-btn.active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--accent);
  font-weight: 600;
}

/* ── Tab panels ─────────────────────────────── */

.tab-panel {
  display: flex;
  flex-direction: column;
}

/* ── Cards ──────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#info-card {
  position: relative;
  isolation: isolate;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#map-open-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}

#map-open-link:hover {
  text-decoration: underline;
}

/* ── Map ────────────────────────────────────── */

#map-panel {
  flex-direction: column;
}

#weather-url-row,
#marker-name-row,
#route-drawing-row,
#route-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

#weather-url-row input,
#marker-name-row input,
#route-name-row input {
  flex: 1;
  min-width: 0;
}

#waypoint-count {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.url-row-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

#map-container {
  height: 96vh;
  position: relative;
}

#satellite-ring {
  position: absolute;
  z-index: 501;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 2px 12px rgba(0,0,0,0.5);
  width: 288px;
  height: 288px;
  margin-left: -144px;
  margin-top: -144px;
  display: none;
  top: 0;
  left: 0;
}

#satellite-lens-btn {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  padding: 5px 10px;
  font-size: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.15s;
}

#satellite-lens-btn:hover,
#satellite-lens-btn.active {
  background: var(--surface-2);
  opacity: 1;
}

#satellite-lens-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

#map-top-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 6px;
}

#satellite-lens-wrap {
  position: static;
  transform: none;
  z-index: unset;
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  opacity: 0.9;
  transition: opacity 0.15s;
}

#satellite-lens-wrap:hover {
  opacity: 1;
}

.satellite-lens-icon {
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}

#satellite-lens-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  border: none;
  padding: 0;
}

#satellite-lens-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #000;
  cursor: pointer;
  transition: transform 0.1s;
}

#satellite-lens-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #000;
  cursor: pointer;
}

#satellite-lens-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#satellite-lens-toggle {
  display: none;
  padding: 4px 12px;
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

#satellite-lens-toggle.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

#map-container.lens-active #leaflet-map {
  cursor: none;
}

#leaflet-map {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--surface-2);
}

.leaflet-publicAccess-pane {
  opacity: 0.45;
}

.leaflet-publicAccess-pane .leaflet-tile {
  filter: contrast(0.5);
}

.leaflet-container {
  background: var(--surface-2);
}

/* map interaction mode buttons */
#add-marker-btn.mode-active,
#add-night-stay-btn.mode-active,
#draw-route-btn.mode-active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

#public-access-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  padding: 4px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
#public-access-btn:hover { opacity: 1; }

#public-access-btn.layer-active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
  opacity: 1;
}

.leaflet-container.cursor-crosshair {
  cursor: crosshair !important;
}

/* custom marker pin */
.map-marker-pin {
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  background: #ef4444;
  border: 2px solid #000;
  transform: rotate(-45deg);
  margin-left: -9px;
  margin-top: -9px;
}

.night-stay-pin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #818cf8;
  border: 2px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* dark Leaflet popups */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
  background: var(--surface);
}

.leaflet-popup-content {
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 8px 12px;
}

.leaflet-popup-content b {
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

.popup-delete-btn {
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 4px;
  cursor: pointer;
}

.popup-delete-btn:hover {
  background: var(--danger);
  color: #fff;
}

#notes-panel,
#gear-panel {
  position: absolute;
  top: 50%;
  bottom: 45px;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow: hidden;
}

/* ── Map overlay panel (top-right accordion) ── */

#map-overlay-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1001;
  width: 265px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.overlay-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  pointer-events: all;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}

.overlay-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 12px;
  background: var(--surface-2);
  border: none;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.overlay-section-toggle:hover {
  background: var(--border);
  color: var(--text);
}

.toggle-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  display: inline-block;
}

.overlay-section.collapsed .toggle-chevron {
  transform: rotate(-90deg);
}

.overlay-section-body {
  display: flex;
  flex-direction: column;
  max-height: 400px;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.overlay-section.collapsed .overlay-section-body {
  max-height: 0;
}

.overlay-section .checklist {
  max-height: 200px;
  overflow-y: auto;
}

/* ── Route Drawing Overlay Section ───────────────────────── */
#route-drawing-section,
#marker-section,
#night-stay-section {
  position: absolute;
  top: 80px;
  left: 10px;
  width: 320px;
  z-index: 500;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.overlay-section-header-fixed {
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.route-drawing-icon,
.marker-icon,
.night-stay-icon {
  font-size: 1.1rem;
}

.route-waypoint-count {
  margin-left: auto;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
}

.overlay-section-body-fixed {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overlay-section-body-fixed label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: -4px;
}

.overlay-section-body-fixed input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.overlay-section-body-fixed input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.action-hint,
.route-drawing-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 4px;
  border-left: 3px solid var(--accent);
}

.action-buttons,
.route-drawing-actions {
  display: flex;
  gap: 8px;
}

.action-buttons button,
.route-drawing-actions button {
  flex: 1;
}

#route-drawing-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#route-name-input-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

#route-name-input-section label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

#route-name-input-section input {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

#route-name-input-section input:focus {
  outline: none;
  border-color: var(--accent);
}

.route-name-actions {
  display: flex;
  gap: 8px;
}

.route-name-actions button {
  flex: 1;
}

/* ── Trip Specs ─────────────────────────────────────────── */
.trip-specs-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trip-specs-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.specs-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.specs-total strong {
  color: var(--text);
}

.header-summary {
  display: none;
  font-size: 0.78rem;
  margin-left: auto;
  margin-right: 6px;
  opacity: 0.9;
}
.collapsed .header-summary {
  display: flex;
  align-items: center;
  gap: 4px;
}

.specs-total-elev {
  display: flex;
  gap: 6px;
}

.specs-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.route-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.specs-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.specs-dist {
  white-space: nowrap;
  flex-shrink: 0;
}

.specs-gain {
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--accent);
}

.specs-loss {
  white-space: nowrap;
  flex-shrink: 0;
  color: #f87171;
}

.specs-unknown {
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.weather-empty {
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.weather-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.73rem;
}
.weather-row:last-child { border-bottom: none; }

.weather-day  { color: var(--text); }
.weather-icon { font-size: 0.85rem; }
.weather-temp { min-width: 3.8rem; text-align: right; white-space: nowrap; }
.temp-hi      { color: var(--text); font-weight: 600; }
.temp-lo      { color: var(--text-muted); }
.weather-rain { font-weight: 600; min-width: 2.8rem; text-align: right; }
.weather-prob { color: var(--text-muted); min-width: 2.2rem; text-align: right; }
.weather-unit { font-size: 0.65rem; font-weight: 400; opacity: 0.7; margin-left: 1px; }

.rain-none     .weather-rain { color: var(--text-muted); }
.rain-light    .weather-rain { color: #60a5fa; }
.rain-moderate .weather-rain { color: #38bdf8; }
.rain-heavy    .weather-rain { color: #f87171; }

.food-nights-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.food-profile-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.food-profile-bar select {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.72rem;
  padding: 3px 4px;
  outline: none;
  font-family: inherit;
}

.food-profile-bar button {
  font-size: 0.72rem;
  padding: 3px 7px;
  white-space: nowrap;
}

.food-nights-bar #food-nights-count,
.food-nights-bar #food-people-count {
  font-weight: 700;
  color: var(--accent);
}

.people-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Notes ──────────────────────────────────── */

#notes-input {
  flex: 1;
  min-height: 240px;
  resize: vertical;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 12px 14px;
  outline: none;
}

#notes-input::placeholder {
  color: var(--text-muted);
}

/* ── Checklists ─────────────────────────────── */

.checklist {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  transition: background 0.1s;
}

.checklist-item:hover {
  background: var(--surface-2);
}

.checklist-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  cursor: pointer;
}

.item-text {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
  transition: color 0.1s;
}

.checklist-item.done .item-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.delete-item-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity 0.1s, color 0.1s;
  flex-shrink: 0;
}

.checklist-item:hover .delete-item-btn {
  opacity: 1;
}

.delete-item-btn:hover {
  color: var(--danger);
}

.add-item-row {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.add-item-input {
  flex: 1;
  min-width: 0;
}

/* ── Buttons ────────────────────────────────── */

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.82rem;
  transition: background 0.15s, border-color 0.15s;
}

button:hover {
  background: var(--border);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-highlight,
.header-group button.btn-highlight {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #000 !important;
  font-weight: 600;
}

.btn-highlight:hover,
.header-group button.btn-highlight:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}

/* ── Inputs ─────────────────────────────────── */

input[type="text"],
input[type="url"],
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus {
  border-color: var(--accent);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

/* ── Modals ─────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 340px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-box h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-box p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.modal-box input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Category accordion ─────────────────────── */

.categories-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.cat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  user-select: none;
  transition: background 0.1s;
}

.cat-header:not(.cat-header--editing):hover {
  background: var(--surface-2);
  cursor: pointer;
}

/* Chevron arrow */
.cat-chevron {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.cat-chevron::before {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translateY(2px);
  transition: transform 0.18s;
}

.cat-chevron.open::before {
  transform: rotate(45deg) translateY(-2px);
}

.cat-emoji {
  font-size: 1.1rem;
  flex-shrink: 0;
  cursor: pointer;
  line-height: 1;
}

.cat-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text);
  cursor: pointer;
}

.cat-act-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 5px 6px;
  border-radius: 5px;
  flex-shrink: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.1s, background 0.1s;
}

.cat-act-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cat-del-btn:hover {
  color: var(--danger);
}

/* Category body */
.cat-body {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.cat-body.open {
  display: flex;
}

.cat-items-list {
  overflow: visible;
}

/* Editing state */
.cat-header--editing {
  background: var(--surface-2);
  gap: 8px;
  flex-wrap: nowrap;
}

.cat-emoji-inp {
  width: 46px !important;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.cat-name-inp {
  flex: 1;
  min-width: 0;
}

.cat-save-btn {
  flex-shrink: 0;
}

/* Add category row */
.add-category-row {
  padding: 8px 10px;
  flex-shrink: 0;
}

.add-category-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 7px;
  border-radius: 8px;
}

.add-category-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.categories-empty-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
}

/* Profile editor – categories container */
#profile-categories-container {
  flex: 1;
  min-height: 100px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#profile-categories-container .cat-section {
  border-radius: 8px;
}

#profile-categories-container .cat-header {
  padding: 8px 10px;
}

#profile-categories-container .categories-empty-hint {
  padding: 16px;
}

.profile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.profile-bar select {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 4px 8px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.profile-bar select:focus {
  border-color: var(--accent);
}

.profile-bar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Profiles modal ─────────────────────────── */

.modal-box--wide {
  min-width: 560px;
  max-width: 740px;
  width: 90vw;
}

.profiles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profiles-header button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px 6px;
  line-height: 1;
}

.profiles-header button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.profiles-layout {
  display: flex;
  gap: 16px;
  min-height: 300px;
}

.profiles-list-col {
  width: 170px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--border);
  padding-right: 16px;
}

#profiles-list-ul {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-list-item {
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-list-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.profile-list-item.active {
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 500;
}

.profiles-editor-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#profile-edit-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
}

.profile-name-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.profile-name-row input {
  flex: 1;
  min-width: 0;
}

#profile-items-list {
  flex: 1;
  min-height: 140px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
}

.profile-edit-footer {
  display: flex;
  justify-content: flex-end;
}

#profile-edit-hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ── Mobile utility classes ──────────────────── */

.mobile-only {
  display: none !important;
}

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVE STYLES
   ══════════════════════════════════════════════ */

@media (max-width: 768px) {
  
  /* ── Show mobile elements ─────────────────────── */
  .mobile-only {
    display: block !important;
  }

  /* ── Mobile hamburger menu ────────────────────── */
  #mobile-menu-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 10001;
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }

  #mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: all 0.3s;
  }

  #mobile-menu-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  #mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
  }

  #mobile-menu-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* ── Mobile backdrop ──────────────────────────── */
  #mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: block !important;
  }

  #mobile-backdrop.hidden {
    display: none !important;
  }

  /* ── Sidebar as mobile drawer ─────────────────── */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.5);
  }

  #sidebar.mobile-open {
    transform: translateX(0);
  }

  /* ── Hide logo and legal button on mobile ──────── */
  #app-logo,
  #about-btn {
    display: none;
  }

  /* ── Main layout adjustments ──────────────────── */
  #app {
    flex-direction: column;
  }

  #main {
    width: 100%;
    height: 100vh;
  }

  #trip-view {
    padding: 0;
    gap: 0;
    height: 100vh;
  }

  /* ── Info card full screen ────────────────────── */
  #info-card {
    height: 100vh;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

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

  #map-container {
    height: 100% !important;
  }

  /* ── Hide desktop overlay panel ───────────────── */
  #map-overlay-panel {
    display: none !important;
  }

  /* ── But show action panels on mobile ──────────── */
  #marker-section,
  #night-stay-section,
  #route-drawing-section {
    top: 60px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: 400px;
    margin: 0 auto;
  }

  /* ── Mobile trip header ───────────────────────── */
  #trip-header {
    position: relative;
    padding: 8px 12px;
    flex-shrink: 0;
    height: auto;
    min-height: var(--mobile-header-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
  }

  #trip-tabs {
    padding: 0;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  #trip-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    font-size: 0.88rem;
    padding: 6px 14px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Hide desktop header actions */
  #trip-header-actions {
    display: none !important;
  }

  /* ── Mobile actions menu button ───────────────── */
  #mobile-actions-btn {
    position: fixed;
    top: 10px;
    right: 64px;
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-bottom: 4px;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }

  #mobile-actions-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
  }

  /* ── Mobile action menu ───────────────────────── */
  #mobile-action-menu {
    position: fixed;
    top: var(--mobile-header-h);
    right: 0;
    width: 240px;
    max-width: 80vw;
    background: var(--surface);
    border: 1px solid var(--border);
    border-right: none;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    box-shadow: -2px 2px 12px rgba(0,0,0,0.5);
    z-index: 10002;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex !important;
    flex-direction: column;
    padding: 8px 0;
    max-height: calc(100vh - var(--mobile-header-h) - 20px);
    overflow-y: auto;
  }

  #mobile-action-menu.open {
    transform: translateX(0);
  }

  .mobile-action-group {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
  }

  .mobile-action-group button {
    background: transparent;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 12px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-action-group button:active {
    background: var(--surface-2);
  }

  .mobile-action-group button.btn-danger {
    color: var(--danger);
  }

  .mobile-action-group button.btn-danger:active {
    background: rgba(239, 68, 68, 0.1);
  }

  .mobile-action-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 12px;
  }

  /* ── Mobile overlay drawer (bottom) ───────────── */
  #mobile-overlay-drawer {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 1002;
    background: var(--surface);
    border: 1px solid var(--border);
    max-height: var(--mobile-drawer-max-h);
    transform: translateY(calc(100% - var(--mobile-tab-bar-h) - 16px));
    transition: transform 0.3s ease;
    display: flex !important;
    flex-direction: column;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
  }

  #mobile-overlay-drawer.open {
    transform: translateY(0);
  }

  #mobile-drawer-tabs {
    display: flex;
    gap: 4px;
    padding: 4px 12px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-drawer-tab {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
  }

  .mobile-drawer-tab.active {
    background: var(--surface-2);
    color: var(--accent);
    border-color: var(--accent);
  }

  .mobile-drawer-logo {
    padding: 4px 8px;
    flex: 0 0 auto;
    min-width: 60px;
  }

  .mobile-drawer-logo img {
    width: 44px;
    height: auto;
    display: block;
    opacity: 0.7;
    transition: opacity 0.15s;
  }

  .mobile-drawer-logo:hover img,
  .mobile-drawer-logo.active img {
    opacity: 1;
  }

  #mobile-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
  }

  /* Style the cloned overlay sections in mobile drawer */
  #mobile-drawer-content .overlay-section {
    margin-bottom: 12px;
    box-shadow: none;
  }

  #mobile-drawer-content .overlay-section:last-child {
    margin-bottom: 0;
  }

  /* Disable accordion toggle in mobile drawer */
  #mobile-drawer-content .toggle-chevron {
    display: none;
  }

  #mobile-drawer-content .overlay-section-toggle {
    pointer-events: none;
    cursor: default;
  }

  /* ── Notes and Gear panels ────────────────────── */
  #notes-panel,
  #gear-panel {
    top: 0;
    bottom: var(--mobile-header-h);
    border-top: none;
  }

  /* ── Map controls adjustments ─────────────────── */
  #map-top-bar {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  #satellite-lens-wrap {
    padding: 6px 12px;
    width: auto;
  }

  #satellite-lens-slider {
    display: none;
  }

  #satellite-lens-toggle {
    display: block;
  }

  /* Fixed center lens on mobile */
  #satellite-ring.mobile-fixed {
    left: 50% !important;
    top: 50% !important;
    pointer-events: none;
  }

  #public-access-btn {
    display: none !important;
  }

  /* Style the mobile public access action button */
  #mobile-public-access {
    position: relative;
  }

  #mobile-public-access::before {
    content: '○';
    margin-right: 8px;
    font-size: 1.1rem;
    opacity: 0.6;
  }

  body:has(#public-access-btn.layer-active) #mobile-public-access::before {
    content: '●';
    color: #3b82f6;
    opacity: 1;
  }

  /* ── Modals mobile adjustments ────────────────── */
  .modal-box {
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .modal-box--wide {
    min-width: 0;
    width: calc(100vw - 32px);
  }

  .profiles-layout {
    flex-direction: column;
    gap: 12px;
  }

  .profiles-list-col {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
  }

  /* ── Touch target improvements ────────────────── */
  button,
  .trip-item-name,
  .tab-btn,
  .overlay-section-toggle {
    min-height: 44px;
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
  }

  /* Remove tap highlight on all interactive elements */
  a, button, input, textarea, select {
    -webkit-tap-highlight-color: transparent;
  }

  /* ── Adjust input rows for mobile ─────────────── */
  #weather-url-row,
  #marker-name-row,
  #night-stay-name-row,
  #route-drawing-row,
  #route-name-row {
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px;
  }

  #weather-url-row input,
  #marker-name-row input,
  #night-stay-name-row input,
  #route-name-row input {
    width: 100%;
    flex: none;
  }

  #weather-url-row button,
  #marker-name-row button,
  #night-stay-name-row button,
  #route-name-row button,
  #route-drawing-row button {
    flex: 1;
    min-width: 80px;
  }

  /* ── Prevent body scroll when drawer/sidebar open ─ */
  body.mobile-scroll-lock {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}

/* ── Landscape mobile adjustments ───────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  #mobile-overlay-drawer {
    max-height: 60vh;
  }

  #mobile-drawer-content {
    max-height: calc(60vh - var(--mobile-tab-bar-h) - 30px);
  }
}

/* ── Small mobile screens ─────────────────────────── */
@media (max-width: 480px) {
  :root {
    font-size: 15px;
  }

  #sidebar {
    width: 260px;
  }

  #mobile-drawer-tabs {
    padding: 4px 8px 8px;
    gap: 3px;
  }

  .mobile-drawer-tab {
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  #satellite-lens-slider {
    width: 60px;
  }
}
