/* OutHere Map Viewer — Styles */

/* ---------------------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------------------- */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: #f4f0e8;
  color: #3d3529;
  overflow: hidden;         /* map is full-screen */
}

/* ---------------------------------------------------------------------------
   Full-screen map
   --------------------------------------------------------------------------- */

#map {
  position: absolute;
  inset: 0;
}

/* ---------------------------------------------------------------------------
   Map control buttons — unified parchment system
   Applies to: MapLibre native controls + custom planBtn/layersBtn
   --------------------------------------------------------------------------- */

/* Control group card: parchment border + shadow to match planning toolbar buttons */
.maplibregl-ctrl-group {
  border-radius: 8px !important;
  border: 1px solid #D5CBBA !important;
  box-shadow: 0 2px 8px rgba(30,26,20,0.18) !important;
  overflow: hidden !important;
}

/* All control buttons: 40×40, parchment fill */
.maplibregl-ctrl-group button {
  width: 40px !important;
  height: 40px !important;
  background-color: #F2EDE3 !important;
  color: #1E1A14 !important;
  transition: background-color 0.15s !important;
}

.maplibregl-ctrl-group button:hover {
  background-color: #EDE7DA !important;
}

/* Separator between stacked buttons (zoom +/-) */
.maplibregl-ctrl-group button:not(:last-child) {
  border-bottom: 1px solid #D5CBBA !important;
}

/* planBtn / layersBtn icon alignment */
#planBtn,
#layersBtn {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Active = panel open: subtle tinted background, icon takes accent color */
#planBtn.active  { background-color: #EDE7DA !important; color: #B8431A !important; }
#layersBtn.active { background-color: #EDE7DA !important; color: #4A7C8A !important; }

/* ---------------------------------------------------------------------------
   Layer control panel
   --------------------------------------------------------------------------- */

.layer-panel {
  position: absolute;
  top: 12px;
  left: 54px;
  width: 260px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: #f4f0e8;
  border: 1px solid #c9c3b5;
  border-radius: 3px;
  z-index: 2;
  padding: 12px 0;
  display: none;            /* toggled via JS */
}

.layer-panel.open {
  display: block;
}

.layer-panel h3 {
  font-size: 0.7rem;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a7e6b;
  padding: 4px 16px 8px;
  font-family: Georgia, 'Times New Roman', serif;
}

/* Individual layer toggle row */
.layer-toggle {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.layer-toggle:hover {
  background: #ede8de;
}

.layer-toggle input[type="checkbox"] {
  accent-color: #8a7e6b;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.layer-toggle .layer-name {
  font-size: 0.9rem;
  font-weight: normal;
  flex: 1;
  font-family: Georgia, 'Times New Roman', serif;
  color: #3d3529;
}

/* Legend dots/swatches within each toggle row */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 16px 10px 42px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: #8a7e6b;
  font-family: Georgia, 'Times New Roman', serif;
}

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

/* Divider between sections */
.layer-divider {
  height: 1px;
  background: #c9c3b5;
  margin: 6px 16px;
}

/* ---------------------------------------------------------------------------
   Layer style customization controls
   --------------------------------------------------------------------------- */

.style-expand-btn {
  background: none;
  border: none;
  color: #8a7e6b;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: auto;
  flex-shrink: 0;
  transition: color 0.15s;
  line-height: 1;
}

.style-expand-btn:hover {
  color: #3d3529;
}

.style-controls {
  padding: 8px 16px 12px 42px;
  border-top: 1px solid #c9c3b5;
}

.style-sub-header {
  font-size: 0.7rem;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a7e6b;
  margin: 8px 0 4px;
  font-family: Georgia, 'Times New Roman', serif;
}

.style-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  overflow: hidden;
}

.style-row-label {
  font-size: 0.75rem;
  color: #8a7e6b;
  width: 50px;
  flex-shrink: 0;
  font-family: Georgia, 'Times New Roman', serif;
}

.style-row input[type="color"] {
  width: 32px;
  height: 24px;
  border: 1px solid #c9c3b5;
  border-radius: 3px;
  padding: 1px;
  cursor: pointer;
  background: none;
}

.style-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: #8a7e6b;
  height: 4px;
}

.style-row .style-value {
  font-size: 0.75rem;
  color: #8a7e6b;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
  font-family: Georgia, 'Times New Roman', serif;
}

.dash-selector {
  display: flex;
  gap: 2px;
  background: #e8e2d6;
  border-radius: 3px;
  padding: 2px;
}

.dash-btn {
  background: transparent;
  border: none;
  padding: 3px 10px;
  border-radius: 2px;
  font-size: 0.75rem;
  color: #8a7e6b;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  font-family: inherit;
}

.dash-btn.active {
  background: #f4f0e8;
  color: #3d3529;
}

.dash-btn:hover:not(.active) {
  color: #3d3529;
}

.style-data-driven-note {
  font-size: 0.65rem;
  color: #8a7e6b;
  font-style: italic;
  margin-top: -2px;
  margin-bottom: 4px;
  font-family: Georgia, 'Times New Roman', serif;
}

.style-reset-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 4px 8px;
  background: none;
  border: 1px solid #c9c3b5;
  border-radius: 3px;
  font-size: 0.75rem;
  color: #8a7e6b;
  cursor: pointer;
  transition: background 0.1s;
  font-family: Georgia, 'Times New Roman', serif;
}

.style-reset-btn:hover {
  background: #ede8de;
}

/* ---------------------------------------------------------------------------
   MapLibre control overrides
   --------------------------------------------------------------------------- */

.maplibregl-ctrl-top-left,
.maplibregl-ctrl-top-right {
  top: 12px;
}

/* maplibregl-ctrl-group base styles are defined in the unified section above */

/* Scale bar */
.maplibregl-ctrl-scale {
  background: rgba(255, 255, 255, 0.85) !important;
  border-color: #6b7280 !important;
  font-size: 11px !important;
  border-radius: 3px !important;
  padding: 1px 6px !important;
}

/* Geolocate button pulse */
.maplibregl-ctrl-geolocate {
  border-radius: 8px !important;
}

/* ---------------------------------------------------------------------------
   Loading overlay
   --------------------------------------------------------------------------- */

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248, 244, 240, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #c9c3b5;
  border-top-color: #3d3529;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 16px;
  font-size: 0.9rem;
  color: #8a7e6b;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
}

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

/* ---------------------------------------------------------------------------
   Error banner
   --------------------------------------------------------------------------- */

.error-banner {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 5;
  max-width: 90%;
  text-align: center;
  display: none;
}

.error-banner.visible {
  display: block;
}

/* ---------------------------------------------------------------------------
   Planning toolbar — floating left-side map tools
   --------------------------------------------------------------------------- */

.planning-toolbar {
  position: fixed;
  top: 12px; /* fallback; overridden by JS to align with planBtn */
  left: 62px; /* 10px gap from right edge of 40px MapLibre control group */
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Panel open: toolbar immediately visible (no hover required) */
.planning-toolbar.visible {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.tool-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: #F2EDE3;
  border: 1px solid #D5CBBA;
  border-radius: 8px;
  color: #1E1A14;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(30,26,20,0.18);
  transition: background 0.15s, box-shadow 0.15s;
  padding: 0;
}

.tool-btn:hover {
  background: #EDE7DA;
}

.tool-btn.active {
  background: #B8431A;
  border-color: transparent;
  color: #F2EDE3;
  box-shadow: 0 2px 8px rgba(184,67,26,0.35);
}

#deleteWaypointBtn.active {
  background: #8B1A1A;
  color: #F2EDE3;
  box-shadow: 0 2px 8px rgba(139,26,26,0.35);
  border-color: transparent;
}

/* Point type selector — vertical stack, visible only during route drawing */
.point-type-selector {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  background: transparent;
  transition: opacity 0.18s ease, max-height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.point-type-selector.visible {
  max-height: 240px;
  opacity: 1;
  pointer-events: auto;
}

.point-type-btn {
  background: #F2EDE3;
  border: 1px solid #D5CBBA;
  border-radius: 8px;
  color: #6B5E4C;
  padding: 0 10px;
  height: 40px;
  width: 40px;
  box-sizing: border-box;
  font-size: 10px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1.2;
}

.point-type-btn:hover {
  background: #EDE7DA;
  color: #1E1A14;
}

.point-type-btn.active                             { background: #B8431A; border-color: transparent; color: #F2EDE3; box-shadow: 0 2px 8px rgba(184,67,26,0.35); }
.point-type-btn.active[data-point-type="route"]   { background: #7D9168; box-shadow: 0 2px 8px rgba(125,145,104,0.35); }
.point-type-btn.active[data-point-type="camp"]    { background: #D4A853; box-shadow: 0 2px 8px rgba(212,168,83,0.35); }
.point-type-btn.active[data-point-type="dayhike"] { background: #4A7C8A; box-shadow: 0 2px 8px rgba(74,124,138,0.35); }
.point-type-btn.active[data-point-type="rest"]    { background: #C09A6B; box-shadow: 0 2px 8px rgba(192,154,107,0.35); }

.point-type-btn kbd {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: #A89880;
  margin-right: 4px;
}

.point-type-btn.active kbd {
  color: inherit;
  opacity: 0.7;
}

/* ---------------------------------------------------------------------------
   Drawing hint overlay
   --------------------------------------------------------------------------- */

.drawing-hint {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,26,20,0.85);
  color: #F2EDE3;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.drawing-hint.visible {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   Route drawing instructions (parchment floating overlay at bottom)
   --------------------------------------------------------------------------- */

.route-instructions {
  position: fixed;
  bottom: 50px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: center;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.route-instructions.visible {
  opacity: 1;
  pointer-events: auto;
}

body.panel-open .route-instructions {
  right: calc(520px + 20px);
}

.route-instructions-inner {
  background: #F2EDE3;
  border: 1px solid #D5CBBA;
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(30,26,20,0.18);
  max-width: 100%;
}

.route-instructions-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #6B5E4C;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.route-instructions-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  line-height: 1.7;
  color: #6B5E4C;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.route-instructions-steps li {
  padding-left: 10px;
  position: relative;
}

.route-instructions-steps li::before {
  content: "\2022";
  position: absolute;
  left: 0;
  color: #A89880;
}

.route-instructions-steps strong {
  color: #B8431A;
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Trip planning panel — right-side modal
   --------------------------------------------------------------------------- */

.trip-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  height: 100vh;
  background: #F2EDE3;
  background-image: repeating-linear-gradient(0deg, transparent 28px, rgba(180,168,148,0.06) 29px);
  box-shadow: -8px 0 40px rgba(30,26,20,0.22);
  z-index: 4;
  display: flex;
  flex-direction: column;
  transform: translateX(520px);
  transition: transform 0.25s ease;
  overflow: hidden;
  font-family: 'DM Sans', sans-serif;
  color: #1E1A14;
}

.trip-panel.open {
  transform: translateX(0);
}

/* ---------------------------------------------------------------------------
   Modal header
   --------------------------------------------------------------------------- */

.modal-header {
  flex-shrink: 0;
  padding: 24px 28px 0;
}

.modal-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.nps-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #4A7C8A;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.modal-close-btn {
  background: #E8E1D4;
  border: none;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #6B5E4C;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.modal-close-btn:hover {
  background: #D5CBBA;
  color: #1E1A14;
}

.trip-title-input {
  display: block;
  width: 100%;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 28px;
  font-weight: 800;
  color: #1E1A14;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  margin-bottom: 12px;
}

.trip-title-input:focus {
  border-bottom: 1.5px solid #C09A6B;
}

.trip-title-input::placeholder {
  color: #A89880;
  font-style: italic;
  font-weight: 400;
}

.trip-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #EDE6D9;
  border-radius: 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  color: #4A3E30;
}

/* ---------------------------------------------------------------------------
   Tab bar
   --------------------------------------------------------------------------- */

.sidebar-tabs {
  flex-shrink: 0;
  display: flex;
  padding: 0 28px;
  border-bottom: 2px solid #D5CBBA;
  gap: 4px;
}

.sidebar-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #8A7B68;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: color 0.15s, border-color 0.15s;
}

.sidebar-tab:hover {
  color: #1E1A14;
}

.sidebar-tab.active {
  font-weight: 600;
  color: #B8431A;
  border-bottom-color: #B8431A;
}

/* Tab panels */
.sidebar-tab-panel {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-tab-panel--hidden {
  display: none;
}

/* ---------------------------------------------------------------------------
   Readme tab panel
   --------------------------------------------------------------------------- */

#readmePanel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#readmePanel.sidebar-tab-panel--hidden {
  display: none;
}

/* Toolbar row: Preview button + print */
.readme-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid #D5CBBA;
  gap: 8px;
}

/* Preview toggle button — 3D rotateX flip */
.readme-preview-btn {
  position: relative;
  overflow: hidden;
  width: 80px;
  height: 28px;
  border: none;
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s ease;
}

.readme-preview-btn[data-mode="edit"]    { background: #B8431A; }
.readme-preview-btn[data-mode="preview"] { background: #4A7C8A; }
.readme-preview-btn[data-mode="edit"]:hover    { background: #4A7C8A; }
.readme-preview-btn[data-mode="preview"]:hover { background: #B8431A; }

.btn-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #F2EDE3;
  white-space: nowrap;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-face--front {
  transform: translateY(0);
}

.btn-face--back {
  transform: translateY(100%); /* edit mode default: parks below */
}

/* Preview mode: back parks above so it slides DOWN into view on hover */
.readme-preview-btn[data-mode="preview"] .btn-face--back {
  transform: translateY(-100%);
}

/* Edit → Preview: slides UP */
.readme-preview-btn[data-mode="edit"]:hover .btn-face--front { transform: translateY(-100%); }
.readme-preview-btn[data-mode="edit"]:hover .btn-face--back  { transform: translateY(0); }

/* Preview → Edit: slides DOWN */
.readme-preview-btn[data-mode="preview"]:hover .btn-face--front { transform: translateY(100%); }
.readme-preview-btn[data-mode="preview"]:hover .btn-face--back  { transform: translateY(0); }

/* After click: shiver to confirm, suppress hover flip until mouseout */
@keyframes btn-shiver {
  0%   { transform: rotate(0deg); }
  15%  { transform: rotate(-1.5deg); }
  32%  { transform: rotate(1.5deg); }
  50%  { transform: rotate(-1deg); }
  66%  { transform: rotate(1deg); }
  82%  { transform: rotate(-0.4deg); }
  92%  { transform: rotate(0.4deg); }
  100% { transform: rotate(0deg); }
}

.readme-preview-btn.clicked {
  animation: btn-shiver 0.4s ease;
}

/* While .clicked: freeze all face transitions and background so nothing moves until mouseout */
.readme-preview-btn.clicked .btn-face {
  transition: none;
}

.readme-preview-btn[data-mode="edit"].clicked:hover    { background: #B8431A; }
.readme-preview-btn[data-mode="preview"].clicked:hover { background: #4A7C8A; }

/* Suppress hover flip — higher specificity wins over hover rules */
.readme-preview-btn[data-mode="edit"].clicked:hover .btn-face--front    { transform: translateY(0); }
.readme-preview-btn[data-mode="edit"].clicked:hover .btn-face--back     { transform: translateY(100%); }
.readme-preview-btn[data-mode="preview"].clicked:hover .btn-face--front { transform: translateY(0); }
.readme-preview-btn[data-mode="preview"].clicked:hover .btn-face--back  { transform: translateY(-100%); }

.readme-print-btn {
  background: none;
  border: 1px solid #D5CBBA;
  border-radius: 4px;
  padding: 4px 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #8A7B68;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.readme-print-btn:hover {
  color: #1E1A14;
  border-color: #8A7B68;
}

/* TOC */
.readme-toc {
  flex-shrink: 0;
  border-bottom: 1px solid #D5CBBA;
  background: #EDE7DA;
  padding: 5px 0;
}

.toc-link {
  display: block;
  padding: 3px 28px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #8A7B68;
  text-decoration: none;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.toc-link:hover {
  background: #E2D9CA;
  color: #1E1A14;
}

/* Edit area */
#readmeEditArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Template picker */
.readme-template-picker {
  flex-shrink: 0;
  padding: 14px 28px 12px;
  border-bottom: 1px solid #D5CBBA;
  background: #EDE7DA;
}

.template-prompt {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #6B5E4C;
  margin: 0 0 10px;
}

.template-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.template-opt-btn {
  background: #F2EDE3;
  border: 1px solid #D5CBBA;
  border-radius: 4px;
  padding: 8px 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #1E1A14;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s, border-color 0.1s;
  display: block;
  line-height: 1.3;
}

.template-opt-btn:hover {
  background: #EDE7DA;
  border-color: #C9BFB0;
}

.template-opt-blank {
  color: #8A7B68;
}

/* Markdown textarea */
.readme-editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  border: none;
  border-top: 1px solid #D5CBBA;
  padding: 20px 28px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #2E2820;
  background: #F2EDE3;
  box-sizing: border-box;
  overflow-y: auto;
}

.readme-editor:focus {
  outline: none;
}

/* Read/preview area */
#readmeReadArea {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 20px 28px;
}

/* ---------------------------------------------------------------------------
   Rendered markdown
   --------------------------------------------------------------------------- */

.readme-rendered {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 14px;
  line-height: 1.75;
  color: #2E2820;
}

.readme-rendered h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: #1E1A14;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #D5CBBA;
}

.readme-rendered h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  color: #1E1A14;
  margin: 18px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid #D5CBBA;
}

.readme-rendered h1:first-child,
.readme-rendered h2:first-child {
  margin-top: 0;
}

.readme-rendered h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  color: #1E1A14;
  margin: 14px 0 6px;
}

.readme-rendered h4 {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #6B5E4C;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 10px 0 4px;
}

.readme-rendered p {
  margin: 0 0 10px;
}

.readme-rendered ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.readme-rendered li {
  margin: 4px 0;
}

.readme-rendered .readme-checklist {
  list-style: none;
  padding-left: 2px;
}

.readme-check-label {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  cursor: default;
  line-height: 1.5;
}

.readme-check-label input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: #B8431A;
  width: 14px;
  height: 14px;
}

.readme-rendered strong {
  font-weight: 700;
}

.readme-rendered em {
  font-style: italic;
}

.readme-rendered a {
  color: #4A7C8A;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.readme-rendered a:hover {
  color: #1E1A14;
}

.readme-empty-msg {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 14px;
  font-style: italic;
  color: #8A7B68;
  text-align: center;
  padding: 32px 0;
}

/* ---------------------------------------------------------------------------
   Timeline tab — unassigned pool (tray)
   --------------------------------------------------------------------------- */

.unassigned-pool {
  padding: 12px 18px 14px;
  border-bottom: 1px solid #C9BFB0;
  background: #E2D9CA;
}

.pool-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6B5E4C;
  margin-bottom: 8px;
}

.pool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.pool-empty {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: #A89880;
  padding: 2px 0;
  font-style: italic;
}

/* Waypoint pills */
.feature-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px 5px 7px;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: grab;
  transition: opacity 0.1s;
}

/* Type tints for pills */
.feature-chip[data-type="camp"] {
  background: #FDF7E8;
  border: 1px solid #E0C870;
  color: #D4A853;
}
.feature-chip[data-type="route"],
.feature-chip[data-type="dayhike_spur"] {
  background: #EFF4EB;
  border: 1px solid #A8C098;
  color: #7D9168;
}
.feature-chip[data-type="dayhike"] {
  background: #EAF3F5;
  border: 1px solid #90B8C4;
  color: #4A7C8A;
}
.feature-chip[data-type="rest"],
.feature-chip[data-type="meal"] {
  background: #F8F2EA;
  border: 1px solid #C8A870;
  color: #C09A6B;
}
.feature-chip[data-type="waypoint"] {
  background: #EBF2F6;
  border: 1px solid #88B0C8;
  color: #5A8FA8;
}

.feature-chip:hover {
  opacity: 0.85;
}

.chip-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* ---------------------------------------------------------------------------
   Day sections
   --------------------------------------------------------------------------- */

.day-section {
  margin-bottom: 14px;
  overflow: hidden;
}

.day-divider {
  display: block;
  width: 100%;
  height: 1px;
  background: #C9BFB0;
  margin: 0 0 14px;
}

.day-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px 6px;
  cursor: pointer;
  background: none;
  border: none;
}

.day-header:hover {
  background: rgba(0,0,0,0.02);
}

.day-header:focus-visible {
  outline: 1px solid #C9BFB0;
  outline-offset: -2px;
}

.day-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6B5E4C;
  white-space: nowrap;
}

.day-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: #A89880;
  white-space: nowrap;
}

.day-rule {
  flex: 1;
  height: 1px;
  background: #C9BFB0;
  min-width: 0;
}

.day-stats-inline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: #A89880;
  white-space: nowrap;
}

.day-section.day-active .day-label {
  color: #1E1A14;
}

.day-feature-list {
  background: transparent;
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Drop zone */
.day-drop-zone {
  padding: 18px 16px;
  text-align: center;
  border: 1.5px dashed #C0B098;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.day-drop-zone-icon {
  opacity: 0.35;
}

.day-drop-zone-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #A89880;
}

.day-feature-list.drag-over .day-drop-zone {
  border-color: #8A7B68;
  background: rgba(0,0,0,0.03);
}

/* Add Day row */
.add-day-row {
  padding: 4px 18px 24px;
}

.add-day-btn {
  width: 100%;
  padding: 8px 0;
  background: none;
  border: 1px dashed #C9BFB0;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #8A7B68;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.add-day-btn:hover {
  border-color: #8A7B68;
  color: #1E1A14;
}

/* ---------------------------------------------------------------------------
   Timeline cards (assigned features)
   --------------------------------------------------------------------------- */

.feature-tile {
  border-radius: 7px;
  padding: 9px 11px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(30,26,20,0.07);
  transition: box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

/* Type tints for cards */
.feature-tile[data-type="camp"] {
  background: #FDF7E8;
  color: #D4A853;
}
.feature-tile[data-type="route"],
.feature-tile[data-type="dayhike_spur"] {
  background: #EFF4EB;
  color: #7D9168;
}
.feature-tile[data-type="dayhike"] {
  background: #EAF3F5;
  color: #4A7C8A;
}
.feature-tile[data-type="rest"],
.feature-tile[data-type="meal"] {
  background: #F8F2EA;
  color: #C09A6B;
}
.feature-tile[data-type="waypoint"] {
  background: #EBF2F6;
  color: #5A8FA8;
}

/* Tile header row */
.tile-header-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 2px;
}

.tile-type-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.tile-title {
  flex: 1;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tile-edit-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px 5px;
  font-size: 14px;
  color: inherit;
  opacity: 0.35;
  cursor: pointer;
  border-radius: 3px;
  transition: opacity 0.15s, color 0.15s;
  line-height: 1;
}

.feature-tile:hover .tile-edit-btn,
.feature-tile.editing .tile-edit-btn {
  opacity: 1;
}

.tile-stat {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: inherit;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

.tile-description {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 11px;
  font-style: italic;
  line-height: 14px;
  color: #3A3020;
  margin: 3px 0 0;
  opacity: 0.8;
}

.tile-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: inherit;
  opacity: 0.7;
  margin: 3px 0 0;
}

.tile-drag-handle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 4px 2px 4px 4px;
  color: inherit;
  opacity: 0.25;
  cursor: grab;
  line-height: 1;
}

.tile-drag-handle:hover {
  opacity: 0.5;
}

/* Card editing state */
.feature-tile.editing {
  box-shadow: 0 0 0 2px #C09A6B, 0 3px 12px rgba(192,154,107,0.18);
}

.tile-title-input {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1.5px solid currentColor;
  padding: 0 0 1px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: inherit;
  outline: none;
  min-width: 0;
}

.tile-field {
  margin-top: 7px;
}

.tile-field-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: inherit;
  opacity: 0.7;
  display: block;
  margin-bottom: 2px;
}

.tile-field select,
.tile-date-sel {
  width: 100%;
  padding: 3px 6px;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: inherit;
  cursor: pointer;
}

.tile-checkbox-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: inherit;
  cursor: pointer;
}

.tile-checkbox-row input[type="checkbox"] {
  accent-color: currentColor;
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.tile-notes-field {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 7px 9px;
  background: #FFF8EE;
  border: 1px solid #E0C080;
  border-radius: 5px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 11px;
  font-style: italic;
  color: #5A4020;
  line-height: 1.6;
  resize: vertical;
  min-height: 56px;
  box-sizing: border-box;
}

.tile-notes-field:focus {
  outline: none;
  border-color: #C09A6B;
}

.tile-edit-actions {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  align-items: center;
}

.tile-cancel-btn {
  padding: 4px 10px;
  background: #EDE6D9;
  border: none;
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #6B5E4C;
  cursor: pointer;
  transition: background 0.1s;
}

.tile-cancel-btn:hover {
  background: #D5CBBA;
}

.tile-save-btn {
  padding: 4px 10px;
  background: currentColor;
  border: none;
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #F2EDE3;
  cursor: pointer;
  transition: opacity 0.1s;
}

.tile-save-btn:hover {
  opacity: 0.85;
}

.tile-delete-btn {
  margin-left: auto;
  padding: 4px 8px;
  background: none;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #B8431A;
  cursor: pointer;
  transition: background 0.1s;
}

.tile-delete-btn:hover {
  background: rgba(184,67,26,0.08);
}

/* ---------------------------------------------------------------------------
   Trip actions section
   --------------------------------------------------------------------------- */

.trip-panel-divider {
  flex-shrink: 0;
  height: 1px;
  background: #D5CBBA;
  margin: 0;
}

.trip-actions-section {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 28px 24px;
}

.trip-action-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #D5CBBA;
  border-radius: 4px;
  background: #EDE6D9;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #1E1A14;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s;
}

.trip-action-btn:hover {
  background: #D5CBBA;
}

.upload-label {
  cursor: pointer;
}

.trip-action-danger {
  color: #B8431A;
  border-color: #D09070;
}

.trip-action-danger:hover {
  background: rgba(184,67,26,0.06);
}

/* ---------------------------------------------------------------------------
   Drawing preview chip (live feedback during route drawing)
   --------------------------------------------------------------------------- */

.drawing-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px 5px 9px;
  background: #FDF7E8;
  border: 1px solid #E0C870;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #D4A853;
  cursor: default;
}

.drawing-preview-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #B8431A;
  flex-shrink: 0;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ---------------------------------------------------------------------------
   Drag-and-drop
   --------------------------------------------------------------------------- */

.feature-chip.dragging,
.feature-tile.dragging {
  opacity: 0.4;
}

.unassigned-pool.drag-over {
  background: #D5CBBA;
}

.day-feature-list.drag-over {
  background: rgba(0,0,0,0.02);
}

.drag-drop-indicator {
  height: 2px;
  background: #C09A6B;
  border-radius: 1px;
  pointer-events: none;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   Print styles
   --------------------------------------------------------------------------- */

@media print {
  .planning-toolbar,
  .drawing-hint,
  #map,
  .sidebar-tabs,
  .readme-toolbar,
  .readme-toc,
  #readmeEditArea,
  .trip-panel-divider,
  .trip-actions-section,
  .route-instructions,
  .modal-header,
  .layer-panel,
  .loading-overlay,
  .error-banner {
    display: none !important;
  }

  body, html {
    overflow: visible !important;
  }

  .trip-panel {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
  }

  #readmePanel,
  #readmeReadArea {
    display: block !important;
    overflow: visible !important;
  }

  .sidebar-tab-panel--hidden {
    display: block !important;
  }

  .readme-rendered {
    font-size: 11pt;
    line-height: 1.65;
    max-width: 700px;
    color: #000;
  }

  .readme-rendered h1,
  .readme-rendered h2 {
    page-break-after: avoid;
  }
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .layer-panel {
    width: calc(100vw - 70px);
    left: 54px;
    right: auto;
  }

  .trip-panel {
    width: 100vw;
    transform: translateX(100vw);
  }

  .trip-panel.open {
    transform: translateX(0);
  }

  /* On mobile the panel overlays; don't push map */
  body.panel-open #map {
    right: 0;
  }
}
  font-size: 0.75rem;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 2px;
  line-height: 1;
  white-space: nowrap;
  font-family: inherit;
}

.tile-duration-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}

.tile-delete-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.15);
}

/* Inline duration number input (replaces duration button on click) */
.tile-duration-input {
  width: 52px;
  padding: 2px 4px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  font-size: 0.75rem;
  font-family: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.4);
  text-align: center;
}

.tile-duration-input:focus {
  outline: none;
}
