:root {
  /* Colors */
  --bg-dark: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.75);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --video-color: #06b6d4; /* Cyan */
  --video-bg: rgba(6, 182, 212, 0.1);
  --control-color: #8b5cf6; /* Purple */
  --control-bg: rgba(139, 92, 246, 0.1);
  
  --accent: #3b82f6;
  
  /* Layout */
  --panel-width: 400px;
  --border-radius: 16px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-main);
  background-color: var(--bg-dark);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Glassmorphic UI Panel */
.ui-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  width: var(--panel-width);
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transition: transform 250ms ease-out;
}

.ui-panel.desktop-collapsed {
  transform: translateX(calc(-100% - 24px));
}

/* Reopen tab — aligns with the panel header so it sits where the close button was */
.panel-reopen-btn {
  display: none;
  position: fixed;
  left: 0;
  top: 47px;
  z-index: 1001;
  width: 28px;
  height: 44px;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-left: none;
  border-radius: 0 10px 10px 0;
  color: var(--text-main);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
  transition: var(--transition);
}

.panel-reopen-btn.visible {
  display: flex;
}

.panel-reopen-btn:hover,
.panel-reopen-btn:focus-visible {
  color: white;
  background: rgba(59, 130, 246, 0.35);
  border-color: var(--accent);
  outline: none;
}

header {
  padding: 24px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-title {
  min-width: 0; /* allow flex child to shrink */
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Desktop action bar — Share, Export, Import icons below the header */
.desktop-action-bar {
  display: flex;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.15);
}

.desktop-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 4px 8px;
  background: none;
  border: none;
  border-right: 1px solid var(--panel-border);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: var(--transition);
}

.desktop-action-btn:last-child {
  border-right: none;
}

.desktop-action-btn:hover,
.desktop-action-btn:focus-visible {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.desktop-locate-btn.locating {
  color: var(--accent);
}

.desktop-locate-btn.locating svg {
  animation: spin 1s linear infinite;
  transform-origin: center;
}

.desktop-locate-btn.locate-success {
  color: #34d399;
}

.desktop-locate-btn.locate-error {
  color: #f87171;
}

/* Desktop panel collapse button */
.panel-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.panel-collapse-btn:hover,
.panel-collapse-btn:focus-visible {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.scrollable-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Custom Scrollbar */
.scrollable-content::-webkit-scrollbar {
  width: 6px;
}
.scrollable-content::-webkit-scrollbar-track {
  background: transparent;
}
.scrollable-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-section h2::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--video-color);
  box-shadow: 0 0 10px var(--video-color);
}

.control-section h2::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--control-color);
  box-shadow: 0 0 10px var(--control-color);
}

/* ── Collapsible sections ────────────────────────────────────────────────── */

.section-toggle {
  background: none;
  border: none;
  padding: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  font-family: inherit;
  gap: 8px;
}

.section-toggle:hover {
  color: #e2e8f0;
}

.section-toggle .chevron {
  flex-shrink: 0;
  transition: transform 0.25s ease;
  transform: rotate(-90deg);
}

.controls-section:not(.collapsed) .section-toggle .chevron {
  transform: rotate(0deg);
}

.section-body {
  max-height: var(--section-body-height, 0px);
  overflow: visible;
  opacity: 1;
  transition: max-height 0.26s ease, opacity 0.18s ease;
}

.controls-section h2 {
  transition: margin-bottom 0.26s ease;
}

.controls-section.is-animating .section-body {
  overflow: hidden;
}

.controls-section.collapsed .section-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

.controls-section.collapsed h2 {
  margin-bottom: 0;
}

/* ─────────────────────────────────────────────────────────────────────────── */

.input-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
}

select, input[type="range"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: white;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  appearance: none;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

select:hover, select:focus {
  border-color: rgba(255, 255, 255, 0.3);
  background-color: rgba(0, 0, 0, 0.5);
}

select option {
  background: #1e293b;
  color: white;
}

/* Slider */
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label-info-group {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.info-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 50%;
  transition: color 0.15s ease;
  line-height: 0;
}

.info-btn:hover,
.info-btn:focus-visible {
  color: var(--text-main);
  outline: none;
}

.info-btn[aria-expanded="true"] {
  color: var(--accent);
}

.info-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: -12px;
  width: 280px;
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  z-index: 2000;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
}

.info-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 20px;
  border: 6px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.15);
}

.info-tooltip.visible {
  display: block;
}

.tooltip-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: white;
}

.info-tooltip p {
  margin-bottom: 8px;
  color: #cbd5e1;
}

.info-tooltip ul {
  margin: 8px 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #cbd5e1;
}

.info-tooltip li strong {
  color: white;
}

.tooltip-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--text-muted) !important;
  margin-bottom: 0 !important;
}

.value-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  padding: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Environment preset buttons */
.env-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.env-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.env-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text-main);
}

.env-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.env-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Toggle */
.toggle-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.toggle {
  position: relative;
}

.toggle-checkbox {
  display: none;
}

.toggle-label {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  padding: 4px;
  cursor: pointer;
  position: relative;
  width: 140px;
}

.toggle-label span {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  z-index: 2;
  transition: var(--transition);
  padding: 4px 0;
}

.toggle-label .metric {
  color: white;
}

.toggle-label .imperial {
  color: var(--text-muted);
}

.toggle-checkbox:checked + .toggle-label .metric {
  color: var(--text-muted);
}

.toggle-checkbox:checked + .toggle-label .imperial {
  color: white;
}

.toggle-label::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  transition: var(--transition);
  z-index: 1;
}

.toggle-checkbox:checked + .toggle-label::after {
  transform: translateX(100%);
}

/* Results Section */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.terrain-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.terrain-status {
  font-size: 13px;
  flex: 1;
}

.terrain-status[data-state="idle"]      { color: var(--text-muted); }
.terrain-status[data-state="computing"] { color: #fbbf24; }
.terrain-status[data-state="done"]      { color: #34d399; }
.terrain-status[data-state="error"]     { color: #f87171; }

.result-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  position: relative;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 12px 0 0 12px;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  align-self: stretch;
  position: relative;
}

.info-tooltip--below {
  bottom: auto;
  top: calc(100% + 8px);
  left: auto;
  right: 0;
}

.info-tooltip--below::after {
  top: auto;
  bottom: 100%;
  left: auto;
  right: 8px;
  border-top-color: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

.video-result::before {
  background: var(--video-color);
  box-shadow: 0 0 15px var(--video-color);
}

.control-result::before {
  background: var(--control-color);
  box-shadow: 0 0 15px var(--control-color);
}

.result-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  align-self: flex-start;
}

.result-value {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.video-result .result-value {
  color: var(--video-color);
  text-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.control-result .result-value {
  color: var(--control-color);
  text-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.limiting-factor {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  transition: opacity 0.3s ease;
}

.limiting-factor .highlight {
  font-weight: 600;
  color: white;
}

footer {
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--panel-border);
}

.footer-icon-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.footer-icon-btn {
  min-width: 96px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.footer-icon-btn:hover,
.footer-icon-btn:focus-visible {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  outline: none;
}

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
}

/* ── Button system ────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
  flex-shrink: 0;
}

.terrain-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: #2563eb;
  border-color: #2563eb;
  outline: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}
.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  outline: none;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
}
.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  outline: none;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}
.btn-danger:hover,
.btn-danger:focus-visible {
  background: rgba(239, 68, 68, 0.25);
  border-color: #f87171;
  outline: none;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* ── Profiles section ─────────────────────────────────────────────────────── */

.profile-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.profile-buttons .btn {
  flex: 1;
  font-size: 12px;
  padding: 7px 8px;
}

/* ── Recent locations ─────────────────────────────────────────────────────── */

.recent-locations-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.location-item {
  display: flex;
  align-items: stretch;
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  transition: var(--transition);
}

.location-item:hover,
.location-item:focus-within {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

.location-pin-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-pin-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 6px 0 0 6px;
}

.location-delete-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  background: none;
  border: none;
  border-left: 1px solid var(--panel-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.location-delete-btn:hover,
.location-delete-btn:focus-visible {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
  outline: none;
}

.locations-empty {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Export / Import ──────────────────────────────────────────────────────── */

.data-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius);
  padding: 24px;
  width: min(400px, calc(100vw - 48px));
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 16px;
}

.modal-body {
  margin-bottom: 20px;
}

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

.modal-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.modal-optional {
  font-weight: 400;
  color: var(--text-muted);
}

.modal-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: white;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  box-sizing: border-box;
}

.modal-input:hover,
.modal-input:focus {
  border-color: rgba(255, 255, 255, 0.3);
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-error {
  display: block;
  font-size: 12px;
  color: #f87171;
  margin-top: 6px;
  min-height: 16px;
}

.modal-message {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.5;
}

.modal-message strong {
  color: var(--text-main);
}

.settings-modal-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.settings-row > div:first-child {
  min-width: 0;
  flex: 1 1 170px;
}

.settings-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.settings-help {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.settings-contact-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  transition: var(--transition);
}

.settings-contact-link span {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.settings-contact-link strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  color: var(--accent);
}

.settings-contact-link:hover,
.settings-contact-link:focus-visible {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.1);
  outline: none;
}

/* Share button — desktop panel header */
.share-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.share-btn:hover,
.share-btn:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  outline: none;
}

/* Toast notification */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 9999;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 20px;
  border-radius: 30px;
  color: white;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

/* Custom hardware inline forms */
.custom-form {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.2s ease, opacity 0.2s ease;
}

.custom-form.visible {
  max-height: 360px;
  opacity: 1;
  padding-top: 4px;
}

.custom-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: white;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.custom-input:hover,
.custom-input:focus {
  border-color: rgba(255, 255, 255, 0.3);
  background-color: rgba(0, 0, 0, 0.5);
}

.custom-input.invalid {
  border-color: #f87171;
}

.field-error {
  font-size: 11px;
  color: #f87171;
  display: none;
}

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

/* Map Hint Chip */
.map-hint {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px 24px;
  border-radius: 30px;
  color: white;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  animation: pulse 2s infinite;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.map-hint.hidden {
  opacity: 0;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255, 0.1); }
  70% { box-shadow: 0 0 0 15px rgba(255,255,255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255, 0); }
}

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

/* Dark theme overrides for Leaflet */
.leaflet-container {
  background-color: #0f172a;
}
.leaflet-layer,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-control-attribution {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

/* Panel structure */
.panel-header {
  display: none; /* shown only on mobile via media query */
}

.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* allows flex child to shrink for scrollable-content to work */
}

/* Responsive */
@media (max-width: 768px) {
  .ui-panel {
    top: auto;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 60vh;
    border-radius: 24px 24px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transition: height 250ms ease-out;
  }

  .ui-panel.collapsed {
    height: 148px;
  }

  .panel-body {
    transition: opacity 200ms ease-out;
  }

  .ui-panel.collapsed .panel-body {
    opacity: 0;
    pointer-events: none;
  }
  
  .map-hint {
    top: 20px;
  }

  /* Panel header: mobile reveal — stacked vertically (toggle above, action bar below) */
  .panel-header {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
  }

  /* Full-width tap + drag target */
  .panel-toggle-btn {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 20px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
    font-family: inherit;
    touch-action: none;
  }

  .panel-toggle-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 24px 24px 0 0;
  }

  /* Visual drag handle pill */
  .handle-pill {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    flex-shrink: 0;
  }

  .panel-peek-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
  }

  /* Peek results row */
  .peek-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    justify-content: center;
  }

  .peek-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .peek-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
  }

  .peek-value {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .video-peek  { color: var(--video-color); }
  .control-peek { color: var(--control-color); }

  .peek-divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
  }

  /* Mobile action bar — sits below the peek row, phone-app tab-bar style */
  .mobile-action-bar {
    display: flex;
    border-top: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
  }

  .mobile-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 4px 6px;
    background: none;
    border: none;
    border-right: 1px solid var(--panel-border);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: var(--transition);
  }

  .mobile-action-btn:last-child {
    border-right: none;
  }

  .mobile-action-btn:hover,
  .mobile-action-btn:focus-visible {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
    outline: none;
  }

  .desktop-action-bar {
    display: none;
  }

  /* Locate button state classes (added/removed by locateUser()) */
  .mobile-locate-btn.locating {
    color: var(--accent);
  }

  .mobile-locate-btn.locating svg {
    animation: spin 1s linear infinite;
    transform-origin: center;
  }

  .mobile-locate-btn.locate-success {
    color: #34d399;
  }

  .mobile-locate-btn.locate-error {
    color: #f87171;
  }

  /* Footer export/import buttons are redundant on mobile — action bar covers them */
  .data-actions {
    display: none;
  }

  /* Desktop-only controls — hidden on mobile */
  .panel-collapse-btn,
  .panel-reopen-btn {
    display: none !important;
  }

  /* Hide redundant title when panel is expanded on mobile */
  .panel-body header {
    display: none;
  }
}

/* ── About page — document layout ──────────────────────────────────────────── */

.about-page {
  overflow-y: auto;
  height: auto;
  min-height: 100vh;
}

.about-header {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 24px;
  border-bottom: 1px solid var(--panel-border);
}

.about-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-top: 16px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.about-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 6px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--text-main);
}

.about-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
}

.about-content section {
  margin-bottom: 40px;
}

.about-content h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-main);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.about-content p {
  font-size: 15px;
  line-height: 1.7;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.about-content p strong {
  color: var(--text-main);
}

.about-content ul,
.about-content ol {
  margin: 12px 0 16px 24px;
  color: #cbd5e1;
}

.about-content li {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 8px;
}

.about-content ol.numbered-steps li {
  margin-bottom: 12px;
}

.about-content code {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  color: #93c5fd;
}

.about-content pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  overflow-x: auto;
}

.about-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
}

.about-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(59, 130, 246, 0.3);
  transition: border-color 0.15s ease;
}

.about-content a:hover {
  border-bottom-color: var(--accent);
}

.about-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px;
  border-top: 1px solid var(--panel-border);
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.about-footer a {
  color: var(--text-muted);
}

/* About link in main app footer */
.about-link-row {
  text-align: center;
  margin: 8px 0;
}

.about-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.15s ease;
}

.about-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── First-visit intro modal content ────────────────────────────────────────── */

.intro-lead {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--text-main);
}

.intro-steps {
  margin: 0 0 16px 20px;
  padding: 0;
}

.intro-steps li {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 8px;
  color: #cbd5e1;
}

.intro-steps li strong {
  color: var(--text-main);
}

.intro-footer {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}

.intro-footer a {
  color: var(--accent);
  text-decoration: none;
}

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