/* ─── Reset ──────────────────────────────────────────────────────── */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
  color: #222;
  font-size: 14px;
}

/* ─── Utility ────────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ─── Login Screen ───────────────────────────────────────────────── */

#login-screen {
  position: fixed;
  inset: 0;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-card input {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 7px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.login-card input:focus {
  border-color: #45B7D1;
}

.login-card button {
  background: #222;
  color: white;
  border: none;
  border-radius: 7px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.login-card button:hover {
  background: #444;
}

#login-error {
  color: #e74c3c;
  font-size: 13px;
  text-align: center;
  margin-top: -4px;
}

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

#app {
  display: flex;
  height: 100vh;
  position: relative;
}

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

#sidebar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1100;
  width: 280px;
  height: auto;
  max-height: calc(100vh - 24px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

#sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

#new-trip-btn {
  background: #222;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

#new-trip-btn:hover {
  background: #444;
}

#logout-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #888;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

#logout-btn:hover {
  background: #f5f5f5;
}

/* ─── All Photos Button ──────────────────────────────────────────── */

#all-photos-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#all-photos-btn {
  width: 100%;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

#all-photos-btn:hover {
  background: #eee;
}

#total-count {
  background: #e5e7eb;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}

/* ─── Trip List ──────────────────────────────────────────────────── */

#trip-list {
  overflow-y: visible;
  flex: none;
}

/* ─── Trip Item ──────────────────────────────────────────────────── */

.trip-item {
  display: flex;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
}

.trip-item.selected .trip-body {
  background: #f8f9fa;
}

.trip-color-bar {
  width: 4px;
  flex-shrink: 0;
}

.trip-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.trip-body {
  padding: 10px 12px 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.trip-body:hover {
  background: #f8f9fa;
}

.trip-header-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.trip-color-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.trip-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.trip-count {
  background: #f0f0f0;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  color: #555;
}

.trip-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.trip-download-btn {
  color: #aaa;
  font-size: 13px;
}

.trip-download-btn:hover {
  color: #1a73e8;
  background: #e8f0fe;
}

.trip-edit-btn {
  color: #888;
}

.trip-edit-btn:hover {
  color: #333;
  background: #eee;
}

.trip-delete-btn {
  color: #ccc;
  font-size: 13px;
}

.trip-delete-btn:hover {
  color: #e74c3c;
  background: #fde8e8;
}

.trip-dates {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* ─── Upload Section ─────────────────────────────────────────────── */

.trip-upload-section {
  background: #f8f9fa;
  border-top: 1px solid #f0f0f0;
  padding: 8px 12px;
}

.upload-btn {
  width: 100%;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.upload-btn:hover {
  background: #f0f0f0;
}

.progress-wrap {
  margin-top: 7px;
  display: none;
}

.progress-track {
  background: #e5e7eb;
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
}

.progress-fill {
  background: #45B7D1;
  height: 100%;
  width: 0%;
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

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

#map {
  flex: 1;
  background-color: #080818;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='200'%3E%3Ccircle cx='23' cy='17' r='1.3' fill='white' opacity='0.95'/%3E%3Ccircle cx='187' cy='83' r='1.4' fill='white' opacity='0.90'/%3E%3Ccircle cx='251' cy='141' r='1.2' fill='white' opacity='0.88'/%3E%3Ccircle cx='92' cy='156' r='1.5' fill='white' opacity='0.92'/%3E%3Ccircle cx='143' cy='38' r='1.1' fill='white' opacity='0.85'/%3E%3Ccircle cx='38' cy='185' r='1.2' fill='white' opacity='0.87'/%3E%3Ccircle cx='67' cy='31' r='0.9' fill='white' opacity='0.70'/%3E%3Ccircle cx='134' cy='75' r='0.8' fill='white' opacity='0.65'/%3E%3Ccircle cx='201' cy='22' r='0.85' fill='white' opacity='0.72'/%3E%3Ccircle cx='278' cy='48' r='0.9' fill='white' opacity='0.68'/%3E%3Ccircle cx='45' cy='112' r='0.75' fill='white' opacity='0.60'/%3E%3Ccircle cx='159' cy='118' r='0.8' fill='white' opacity='0.63'/%3E%3Ccircle cx='218' cy='167' r='0.9' fill='white' opacity='0.71'/%3E%3Ccircle cx='108' cy='193' r='0.75' fill='white' opacity='0.58'/%3E%3Ccircle cx='289' cy='176' r='0.85' fill='white' opacity='0.66'/%3E%3Ccircle cx='12' cy='64' r='0.8' fill='white' opacity='0.62'/%3E%3Ccircle cx='175' cy='145' r='0.7' fill='white' opacity='0.55'/%3E%3Ccircle cx='56' cy='178' r='0.9' fill='white' opacity='0.69'/%3E%3Ccircle cx='233' cy='95' r='0.75' fill='white' opacity='0.61'/%3E%3Ccircle cx='118' cy='45' r='0.8' fill='white' opacity='0.67'/%3E%3Ccircle cx='267' cy='128' r='0.85' fill='white' opacity='0.64'/%3E%3Ccircle cx='152' cy='192' r='0.8' fill='white' opacity='0.60'/%3E%3Ccircle cx='34' cy='52' r='0.45' fill='white' opacity='0.50'/%3E%3Ccircle cx='78' cy='7' r='0.4' fill='white' opacity='0.45'/%3E%3Ccircle cx='145' cy='26' r='0.5' fill='white' opacity='0.52'/%3E%3Ccircle cx='212' cy='58' r='0.4' fill='white' opacity='0.42'/%3E%3Ccircle cx='256' cy='14' r='0.45' fill='white' opacity='0.48'/%3E%3Ccircle cx='19' cy='138' r='0.5' fill='white' opacity='0.44'/%3E%3Ccircle cx='88' cy='89' r='0.4' fill='white' opacity='0.40'/%3E%3Ccircle cx='167' cy='67' r='0.45' fill='white' opacity='0.46'/%3E%3Ccircle cx='198' cy='112' r='0.4' fill='white' opacity='0.38'/%3E%3Ccircle cx='241' cy='78' r='0.5' fill='white' opacity='0.50'/%3E%3Ccircle cx='73' cy='145' r='0.4' fill='white' opacity='0.43'/%3E%3Ccircle cx='127' cy='162' r='0.45' fill='white' opacity='0.47'/%3E%3Ccircle cx='183' cy='188' r='0.4' fill='white' opacity='0.39'/%3E%3Ccircle cx='295' cy='103' r='0.5' fill='white' opacity='0.51'/%3E%3Ccircle cx='31' cy='188' r='0.4' fill='white' opacity='0.41'/%3E%3Ccircle cx='267' cy='58' r='0.4' fill='white' opacity='0.38'/%3E%3Ccircle cx='103' cy='125' r='0.5' fill='white' opacity='0.49'/%3E%3Ccircle cx='224' cy='185' r='0.4' fill='white' opacity='0.42'/%3E%3Ccircle cx='8' cy='93' r='0.45' fill='white' opacity='0.40'/%3E%3Ccircle cx='175' cy='28' r='0.4' fill='white' opacity='0.43'/%3E%3Ccircle cx='289' cy='38' r='0.5' fill='white' opacity='0.46'/%3E%3Ccircle cx='47' cy='72' r='0.4' fill='white' opacity='0.38'/%3E%3Ccircle cx='119' cy='5' r='0.45' fill='white' opacity='0.44'/%3E%3Ccircle cx='235' cy='152' r='0.4' fill='white' opacity='0.40'/%3E%3Ccircle cx='62' cy='198' r='0.5' fill='white' opacity='0.47'/%3E%3Ccircle cx='192' cy='48' r='0.4' fill='white' opacity='0.41'/%3E%3Ccircle cx='138' cy='135' r='0.45' fill='white' opacity='0.43'/%3E%3Ccircle cx='273' cy='195' r='0.4' fill='white' opacity='0.37'/%3E%3Ccircle cx='14' cy='168' r='0.5' fill='white' opacity='0.45'/%3E%3Ccircle cx='208' cy='138' r='0.4' fill='white' opacity='0.39'/%3E%3Ccircle cx='83' cy='57' r='0.45' fill='white' opacity='0.42'/%3E%3Ccircle cx='157' cy='175' r='0.4' fill='white' opacity='0.40'/%3E%3Ccircle cx='247' cy='108' r='0.5' fill='white' opacity='0.48'/%3E%3Ccircle cx='97' cy='172' r='0.45' fill='white' opacity='0.43'/%3E%3Ccircle cx='176' cy='108' r='0.4' fill='white' opacity='0.38'/%3E%3Ccircle cx='282' cy='68' r='0.5' fill='white' opacity='0.46'/%3E%3Ccircle cx='52' cy='152' r='0.4' fill='white' opacity='0.40'/%3E%3Ccircle cx='165' cy='54' r='0.45' fill='white' opacity='0.44'/%3E%3C/svg%3E");
  background-size: 300px 200px;
}

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

.leaflet-ctrl-mapcontrols {
  position: relative;
}

.leaflet-ctrl-mapcontrols .leaflet-bar a:not(.leaflet-ctrl-icon) {
  font: bold 18px 'Lucida Console', Monaco, monospace;
  text-indent: 1px;
}

.leaflet-ctrl-icon {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.leaflet-ctrl-icon.locating {
  color: #1a73e8 !important;
  animation: locate-pulse 1s ease-in-out infinite;
}

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

.leaflet-ctrl-style-panel {
  position: absolute;
  top: 0;
  right: calc(100% + 6px);
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  padding: 4px;
  min-width: 100px;
  z-index: 1000;
}

.leaflet-style-opt {
  display: block;
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  color: #444;
  white-space: nowrap;
  font-family: inherit;
}

.leaflet-style-opt:hover {
  background: #f4f4f4;
}

.leaflet-style-opt.active {
  color: #1a73e8;
  font-weight: 600;
}

.leaflet-style-opt.active::before {
  content: '✓  ';
}

/* ─── Photo Markers ──────────────────────────────────────────────── */

/* Override Leaflet's default divIcon styles */
.leaflet-marker-icon.photo-marker-wrapper {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  overflow: visible !important;
}

.photo-marker {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.25s ease, filter 0.25s ease;
  pointer-events: auto !important;
}

.photo-marker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none !important;
}

.photo-marker:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.photo-marker.faded {
  opacity: 0.2;
  filter: grayscale(80%);
}

.photo-marker.guess {
  box-shadow: 0 0 0 2px #ff3b30, 0 2px 8px rgba(0, 0, 0, 0.35);
}

.guess-ring {
  position: absolute;
  width: 62px;
  height: 62px;
  border: 2px dashed #ff3b30;
  border-radius: 50%;
  top: -7px;
  left: -7px;
  pointer-events: none;
  animation: guess-pulse 1.8s ease-in-out infinite;
}

@keyframes guess-pulse {
  0%, 100% { opacity: 0.9; }
  50%       { opacity: 0.25; }
}

/* ─── Guess photos sidebar section ───────────────────────────────── */

.guess-photos-section {
  border-top: 1px solid #ffe4e4;
  background: #fff8f8;
  padding: 8px 12px 10px;
}

.guess-photos-header {
  font-size: 11px;
  color: #ff3b30;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 7px;
}

.guess-photo-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.guess-photo-item:hover {
  background: #ffdede;
}

.guess-thumb {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #ff3b30;
}

.guess-time {
  font-size: 11px;
  color: #777;
  line-height: 1.3;
}

.trip-count-guess {
  background: #ffe4e4;
  color: #ff3b30;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.guess-confirm-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  flex-shrink: 0;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid #ffb3b3;
  background: #fff0f0;
  transition: background 0.1s, border-color 0.1s;
}

.guess-confirm-label:hover {
  background: #ffdede;
  border-color: #ff3b30;
}

.guess-confirm-cb {
  width: 13px;
  height: 13px;
  margin: 0;
  cursor: pointer;
  accent-color: #ff3b30;
}

.guess-confirm-text {
  font-size: 10px;
  font-weight: 600;
  color: #ff3b30;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  user-select: none;
}

/* ─── Timeline Panel ─────────────────────────────────────────────── */

#timeline-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#timeline-back-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

#timeline-back-btn:hover {
  background: #f0f0f0;
}

#timeline-recalc-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}

#timeline-recalc-btn:hover {
  background: #f0f0f0;
}

#timeline-recalc-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

#timeline-trip-name {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#timeline-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

#sidebar.sidebar-timeline-open {
  overflow: hidden;
}

/* Photo rows */
.tl-photo-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #f5f5f5;
  cursor: default;
  min-height: 0;
  flex-shrink: 0;
}

.tl-photo-row.tl-photo-guess {
  background: #fff8f8;
}

.tl-thumb {
  flex: none;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  object-fit: cover;
  border-radius: 5px;
  cursor: pointer;
  display: block;
  transition: opacity 0.15s;
}

.tl-thumb:hover {
  opacity: 0.8;
}

.tl-photo-info {
  flex: 1;
  min-width: 0;
}

.tl-date {
  display: block;
  font-size: 11px;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-coords {
  display: block;
  font-size: 10px;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-photo-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.tl-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 4px;
  font-size: 13px;
  color: #888;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}

.tl-icon-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.tl-delete-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Segment rows */
.tl-segment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 22px;
  background: #fafafa;
  border-bottom: 1px solid #f5f5f5;
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
  cursor: pointer;
}

.tl-segment-row.tl-segment-highlighted {
  background: #eff6ff;
  border-left-color: #3b82f6;
}

.tl-seg-line {
  width: 2px;
  height: 22px;
  background: #d1d5db;
  border-radius: 1px;
  flex-shrink: 0;
}

.tl-mode-select {
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 3px 6px;
  background: white;
  cursor: pointer;
  color: #444;
  -webkit-appearance: none;
  appearance: none;
}

.tl-mode-select:disabled {
  opacity: 0.5;
}

.tl-distance {
  font-size: 11px;
  color: #bbb;
  white-space: nowrap;
  margin-left: auto;
}

.tl-seg-spinner {
  font-size: 13px;
  color: #aaa;
  animation: tl-spin 1s linear infinite;
}

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

/* Guess header in timeline */
.tl-guess-header {
  padding: 8px 12px 6px;
  font-size: 11px;
  color: #ff3b30;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #fff8f8;
  border-top: 2px solid #ffe4e4;
  border-bottom: 1px solid #ffe4e4;
}

.tl-empty {
  padding: 24px 16px;
  color: #aaa;
  font-size: 13px;
  text-align: center;
}

/* Trip timeline button */
.trip-timeline-btn {
  font-size: 15px;
  letter-spacing: -1px;
}

/* ─── Trip Modal ─────────────────────────────────────────────────── */

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

.modal-content {
  background: white;
  border-radius: 12px;
  width: 500px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: #555;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.label-row {
  flex-direction: row !important;
  align-items: center;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #333 !important;
  gap: 9px !important;
  cursor: pointer;
}

.modal-body input[type="text"],
.modal-body input[type="date"] {
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 7px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.modal-body input[type="text"]:focus,
.modal-body input[type="date"]:focus {
  border-color: #45B7D1;
}

.modal-body input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #45B7D1;
  flex-shrink: 0;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ─── Color Picker ───────────────────────────────────────────────── */

#color-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.selected {
  border-color: #222;
  box-shadow: 0 0 0 2px white inset;
}

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

.btn-primary {
  background: #222;
  color: white;
  border: none;
  border-radius: 7px;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #444;
}

.btn-secondary {
  background: none;
  border: 1px solid #ddd;
  border-radius: 7px;
  padding: 9px 22px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: #f5f5f5;
}

/* ─── Lightbox ───────────────────────────────────────────────────── */

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
}

#lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: white;
  font-size: 34px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
  z-index: 2;
}

#lightbox-close:hover {
  opacity: 1;
}

#lightbox-thumbs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  max-width: 92vw;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

#lightbox-thumbs::-webkit-scrollbar {
  height: 4px;
}

#lightbox-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

#lightbox-thumbs img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.5;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: opacity 0.15s, border-color 0.15s;
}

#lightbox-thumbs img:hover {
  opacity: 0.85;
}

#lightbox-thumbs img.active {
  opacity: 1;
  border-color: white;
}

#lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
}

#lightbox-prev,
#lightbox-next {
  background: none;
  border: none;
  color: white;
  font-size: 56px;
  cursor: pointer;
  padding: 0 12px;
  opacity: 0.75;
  line-height: 1;
  transition: opacity 0.15s;
  user-select: none;
  flex-shrink: 0;
}

#lightbox-prev:hover,
#lightbox-next:hover {
  opacity: 1;
}

#lightbox-img {
  max-width: 80vw;
  max-height: 65vh;
  border-radius: 4px;
  display: block;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  transition: opacity 0.15s;
}

#lightbox-img.loading {
  opacity: 0.15;
}

#lightbox-spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#lightbox-spinner.visible {
  opacity: 1;
}

#lightbox-spinner::after {
  content: '';
  display: block;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: lb-spin 0.7s linear infinite;
}

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

#lightbox-info {
  color: rgba(255, 255, 255, 0.85);
  margin-top: 14px;
  font-size: 13px;
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
}

#lightbox-number {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
}

#lightbox-trip {
  font-size: 15px;
  font-weight: 600;
  margin-top: 12px;
  text-align: center;
  letter-spacing: 0.2px;
}

/* ─── Mobile ─────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  /* Use dynamic viewport height so content fits under iOS Safari chrome */
  body {
    height: 100dvh;
  }

  #app {
    height: 100dvh;
    flex-direction: column;
    overflow: hidden;
  }

  #sidebar {
    position: relative;
    top: auto;
    left: auto;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    height: auto;
    max-height: none;
    flex-shrink: 0;
    overflow: visible;
    border-bottom: 1px solid #e5e7eb;
  }

  /* Public map: title + All Photos collapsed into one compact bar */
  #sidebar-top {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
  }

  #sidebar-top #sidebar-header {
    flex: 1;
    min-width: 0;
    padding: 0 12px;
    border-bottom: none;
    display: flex;
    align-items: center;
  }

  #sidebar-top #sidebar-header h2 {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #sidebar-top #all-photos-wrap {
    border-bottom: none;
    border-left: 1px solid #e5e7eb;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }

  #sidebar-top #all-photos-btn {
    padding: 4px 9px;
    font-size: 11px;
    border-radius: 12px;
    background: #f0f0f0;
    border-color: transparent;
    white-space: nowrap;
  }

  /* Public map: scrollable trip list */
  #trip-list {
    max-height: 130px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide upload/guess on public map mobile */
  .trip-upload-section,
  .guess-photos-section {
    display: none;
  }

  #map {
    flex: 1;
    min-height: 0;
  }

  /* ── Admin mobile: 50/50 split ─────────────────────────────── */

  body.admin-page #sidebar {
    height: 50dvh;
    overflow: hidden;
    flex-shrink: 0;
  }

  body.admin-page #sidebar-header {
    padding: 8px 12px;
    flex-shrink: 0;
  }

  body.admin-page #sidebar-header h2 {
    font-size: 13px;
  }

  body.admin-page #new-trip-btn,
  body.admin-page #logout-btn {
    padding: 4px 9px;
    font-size: 11px;
  }

  body.admin-page #all-photos-wrap {
    padding: 5px 10px;
    flex-shrink: 0;
  }

  body.admin-page #all-photos-btn {
    -webkit-appearance: none;
    padding: 6px 10px;
  }

  body.admin-page #trip-list {
    flex: 1;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.admin-page .trip-upload-section {
    display: block;
  }

  body.admin-page #map {
    flex: 1;
    min-height: 0;
  }

  /* Mobile: timeline takes full height, map hides */
  body.admin-page.timeline-open #sidebar {
    height: 100dvh;
  }

  body.admin-page.timeline-open #map {
    display: none;
  }
}
