    :root {
      --accent: #38bdf8;
      --accent-soft: rgba(56, 189, 248, 0.14);
      --accent-strong: #0ea5e9;
      --accent-warm: #f97316;
      --text-main: #e5e7eb;
      --text-muted: #9ca3af;
      --danger: #f97373;
      --success: #4ade80;
      /* Typography Scale */
      --font-primary: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

      --text-display: 2rem;      /* 32px - page titles */
      --text-heading: 1.375rem;  /* 22px - section headings */
      --text-subhead: 1rem;      /* 16px - card titles */
      --text-body: 0.875rem;     /* 14px - body text */
      --text-caption: 0.75rem;   /* 12px - labels, meta */
      --text-micro: 0.6875rem;   /* 11px - small labels */
      --text-nano: 0.625rem;     /* 10px - badges, tiny */

      --weight-regular: 400;
      --weight-medium: 500;
      --weight-semibold: 600;
      --weight-bold: 700;

      --leading-tight: 1.1;
      --leading-snug: 1.25;
      --leading-normal: 1.5;
      --leading-relaxed: 1.6;

      --tracking-tight: -0.02em;
      --tracking-normal: 0;
      --tracking-wide: 0.08em;
      --tracking-wider: 0.12em;
      --tracking-widest: 0.16em;

      /* Surface hierarchy (true neutral dark, Linear/Raycast-inspired) */
      --surface-0: #08090a;
      --surface-1: rgba(17, 18, 20, 0.97);
      --surface-2: rgba(25, 26, 29, 0.95);
      --surface-3: rgba(38, 40, 44, 0.7);
      --surface-4: rgba(38, 40, 44, 0.97);

      /* Border hierarchy (white-opacity, not slate-based) */
      --border-subtle: rgba(255, 255, 255, 0.06);
      --border-default: rgba(255, 255, 255, 0.10);
      --border-strong: rgba(255, 255, 255, 0.18);
      --border-accent: rgba(56, 189, 248, 0.3);

      /* Text hierarchy */
      --text-primary: #f7f8f8;
      --text-secondary: #e5e7eb;
      --text-tertiary: #9ca3af;
      --text-quaternary: #6b7280;
      --text-accent: #38bdf8;

      /* Status colors */
      --status-success: #4ade80;
      --status-success-bg: rgba(74, 222, 128, 0.12);
      --status-success-border: rgba(74, 222, 128, 0.3);
      --status-danger: #f97373;
      --status-danger-bg: rgba(249, 115, 115, 0.12);
      --status-danger-border: rgba(249, 115, 115, 0.3);
      --status-warning: #fbbf24;
      --status-warning-bg: rgba(251, 191, 36, 0.12);
      --status-warning-border: rgba(251, 191, 36, 0.3);
      --status-info: #38bdf8;
      --status-info-bg: rgba(56, 189, 248, 0.12);
      --status-info-border: rgba(56, 189, 248, 0.3);

      /* Spacing Scale (8px base) */
      --space-0: 0;
      --space-1: 0.25rem;   /* 4px */
      --space-2: 0.5rem;    /* 8px */
      --space-3: 0.75rem;   /* 12px */
      --space-4: 1rem;      /* 16px */
      --space-5: 1.25rem;   /* 20px */
      --space-6: 1.5rem;    /* 24px */
      --space-8: 2rem;      /* 32px */
      --space-10: 2.5rem;   /* 40px */
      --space-12: 3rem;     /* 48px */
      --space-16: 4rem;     /* 64px */
      --space-20: 5rem;     /* 80px */

      /* Border Radius Scale */
      --radius-sm: 4px;
      --radius-md: 6px;
      --radius-lg: 8px;
      --radius-xl: 12px;
      --radius-2xl: 16px;
      --radius-pill: 9999px;

      /* Elevation / Shadow System (multi-layer inset, Raycast-inspired) */
      --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
      --shadow-md: 0 0 0 1px var(--border-subtle), 0 4px 12px rgba(0, 0, 0, 0.3);
      --shadow-lg: 0 0 0 1px var(--border-subtle), 0 8px 24px rgba(0, 0, 0, 0.35);
      --shadow-xl: 0 0 0 1px var(--border-subtle), 0 24px 50px rgba(0, 0, 0, 0.5);
      --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
      --shadow-glow-strong: 0 0 30px rgba(56, 189, 248, 0.3);
      --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.2);
      --shadow-panel: 0 0 0 1px var(--border-subtle), 0 16px 40px rgba(0, 0, 0, 0.45);
      --shadow-card: 0 0 0 1px var(--border-subtle), 0 2px 8px rgba(0, 0, 0, 0.2);
      --shadow-button-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);
      --shadow-popup: 0 0 0 1px var(--border-subtle), 0 8px 24px rgba(0, 0, 0, 0.35);

      /* Transition Tokens */
      --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
      --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
      --duration-fast: 120ms;
      --duration-normal: 200ms;
      --duration-slow: 300ms;
      --transition-colors: color var(--duration-normal) var(--ease-out), background-color var(--duration-normal) var(--ease-out), border-color var(--duration-normal) var(--ease-out);
      --transition-all: all var(--duration-normal) var(--ease-out);
      --transition-transform: transform var(--duration-fast) var(--ease-out);

      /* Dock */
      --dock-width: 56px;
      --dock-icon-size: 40px;
      --dock-active-indicator: 3px;

      /* Panels */
      --panel-width: 320px;
      --survey-panel-width: 420px;
      --panel-max-height: 80vh;

      /* Toast */
      --toast-width: 340px;
      --toast-max-visible: 4;
      --toast-gap: 8px;
      --toast-offset: 24px;

      /* Context menu */
      --menu-width: 200px;
      --menu-item-height: 40px;

      /* FAB */
      --fab-size: 52px;
      --fab-offset: 24px;

      /* Input states */
      --input-bg: var(--surface-3);
      --input-bg-focus: var(--surface-2);
      --input-ring: 0 0 0 2px var(--accent-soft);

      /* Scrollbar */
      --scrollbar-width: 4px;
      --scrollbar-width-hover: 6px;
      --scrollbar-thumb: var(--border-default);
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      height: 100%;
      margin: 0;
      font-family: var(--font-primary);
      background: var(--surface-0);
      color: var(--text-main);
    }

    body {
      display: flex;
      background-image: radial-gradient(circle at top, #111214 0, var(--surface-0) 45%, #000 100%);
      background-attachment: fixed;
    }

    /* Custom scrollbar */
    ::-webkit-scrollbar {
      width: var(--scrollbar-width);
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: var(--scrollbar-thumb);
      border-radius: var(--radius-pill);
    }

    ::-webkit-scrollbar-thumb:hover {
      background: var(--border-strong);
    }

    h1, h2, h3, h4, h5, h6 {
      letter-spacing: -0.3px;
    }

    #app {
      width: 100%;
      height: 100vh;
      overflow: hidden;
      position: relative;
      padding-left: var(--dock-width);
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* ============================================
       DOCK NAVIGATION
       ============================================ */

    #dock {
      position: fixed;
      top: 0;
      left: 0;
      width: var(--dock-width);
      height: 100vh;
      background: var(--surface-0);
      border-right: 1px solid var(--border-subtle);
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 12px 0;
      z-index: 100;
      gap: 4px;
    }

    .dock-icon {
      width: var(--dock-icon-size);
      height: var(--dock-icon-size);
      border-radius: var(--radius-xl);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: var(--text-tertiary);
      position: relative;
      transition: background var(--duration-normal) var(--ease-out),
                  color var(--duration-normal) var(--ease-out),
                  transform var(--duration-fast) var(--ease-out);
    }

    .dock-icon:hover {
      background: var(--surface-3);
      color: var(--text-primary);
      transform: scale(1.05);
    }

    .dock-icon.active {
      background: var(--accent-soft);
      color: var(--accent);
    }

    .dock-icon.active::before {
      content: '';
      position: absolute;
      left: -8px;
      top: 50%;
      transform: translateY(-50%);
      width: var(--dock-active-indicator);
      height: 20px;
      background: var(--accent);
      border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    }

    .dock-icon svg {
      width: 22px;
      height: 22px;
    }

    .dock-spacer {
      flex: 1;
    }

    .dock-bottom {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      padding-top: 8px;
      border-top: 1px solid var(--border-subtle);
      width: 100%;
    }

    #dock-zoom-badge {
      font-size: var(--text-nano);
      color: var(--text-quaternary);
      font-family: var(--font-mono);
    }

    /* ============================================
       FLOATING PANELS
       ============================================ */

    .floating-panel {
      position: fixed;
      top: 0;
      left: var(--dock-width);
      width: var(--panel-width);
      max-height: 100vh;
      background: var(--surface-1);
      border-right: 1px solid var(--border-subtle);
      box-shadow: var(--shadow-panel);
      z-index: 90;
      display: none;
      flex-direction: column;
      overflow: hidden;
      opacity: 0;
      transform: translateX(-12px);
      transition: opacity 250ms var(--ease-out),
                  transform 250ms var(--ease-out);
    }

    .floating-panel.open {
      display: flex;
      opacity: 1;
      transform: translateX(0);
    }

    .floating-panel.closing {
      opacity: 0;
      transform: translateX(-12px);
      transition-duration: 180ms;
    }

    .panel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border-subtle);
      flex-shrink: 0;
    }

    .panel-title {
      font-size: var(--text-subhead);
      font-weight: var(--weight-semibold);
      color: var(--text-primary);
      letter-spacing: -0.3px;
    }

    button.panel-close {
      width: 28px;
      height: 28px;
      min-width: 28px;
      min-height: 28px;
      border-radius: var(--radius-md);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: var(--text-quaternary);
      background: none;
      border: none;
      padding: 0;
      margin: 0;
      box-shadow: none;
      font-size: 16px;
      filter: none;
    }

    button.panel-close:hover {
      background: var(--surface-3);
      color: var(--text-secondary);
      filter: none;
    }

    .panel-body {
      flex: 1;
      overflow-y: auto;
      padding: 16px 20px;
    }

    /* Shared component styles */

    .section-card {
      border-radius: var(--radius-xl);
      background: var(--surface-2);
      border: 1px solid var(--border-subtle);
      padding: 12px;
      box-shadow: var(--shadow-card);
      margin-bottom: 12px;
    }

    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
    }

    .section-title {
      font-size: var(--text-caption);
      text-transform: uppercase;
      letter-spacing: var(--tracking-wider);
      color: var(--text-tertiary);
    }

    .badge {
      font-size: 10px;
      padding: 2px 7px;
      border-radius: 999px;
      background: var(--surface-3);
      border: 1px solid var(--border-subtle);
      color: var(--text-secondary);
      white-space: nowrap;
    }

    .field-label {
      display: block;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.16em;
      color: var(--text-tertiary);
      margin-bottom: 3px;
    }

    .field-row {
      display: flex;
      gap: 6px;
      align-items: center;
      margin-bottom: 6px;
      flex-wrap: wrap;
    }

    select {
      font-family: inherit;
    }

    #layer-select,
    #basemap-select {
      width: 100%;
      padding: 10px 14px;
      border-radius: var(--radius-lg);
      border: none;
      border-bottom: 1px solid var(--border-subtle);
      background: var(--input-bg);
      color: var(--text-main);
      font-size: var(--text-body);
      outline: none;
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-position: right 14px center;
      background-size: 12px;
      background-repeat: no-repeat;
      transition: border-color var(--duration-normal) var(--ease-out),
                  box-shadow var(--duration-normal) var(--ease-out),
                  background-color var(--duration-normal) var(--ease-out);
    }

    #layer-select:focus,
    #basemap-select:focus {
      border: 1px solid var(--accent);
      box-shadow: var(--input-ring);
      background-color: var(--input-bg-focus);
    }

    #layer-select option,
    #basemap-select option {
      background-color: #1a1b1e;
      color: var(--text-primary);
      padding: 8px;
    }

    #layer-select option:checked,
    #basemap-select option:checked {
      background-color: var(--accent);
      color: white;
    }

    .hint {
      font-size: 11px;
      color: var(--text-tertiary);
      margin-top: 4px;
      line-height: 1.4;
    }

    .hint strong {
      color: var(--text-secondary);
      font-weight: 500;
    }

    .layer-meta {
      font-size: 11px;
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 4px 10px;
      margin-top: 5px;
      color: var(--text-tertiary);
    }

    .layer-meta span {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .layer-meta-label {
      text-transform: uppercase;
      letter-spacing: 0.12em;
      font-size: 10px;
      color: var(--text-quaternary);
    }

    .chip {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 2px 7px;
      border-radius: 999px;
      font-size: 10px;
      background: var(--surface-3);
      border: 1px solid var(--border-subtle);
      color: var(--text-secondary);
    }

    .chip-dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: var(--accent);
    }

    /* Layer list for multiple layers */
    .active-layer-item {
      background: var(--surface-3);
      padding: 8px;
      border-radius: var(--radius-md);
      margin-bottom: 6px;
      border: 1px solid var(--border-subtle);
    }

    .active-layer-item .layer-name {
      font-size: 11px;
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .active-layer-item input[type="checkbox"] {
      cursor: pointer;
      width: 22px;
      height: 22px;
      flex-shrink: 0;
    }

    .active-layer-item input[type="range"] {
      width: 100%;
      margin-top: 4px;
    }

    .active-layer-item .layer-color {
      width: 12px;
      height: 12px;
      border-radius: 2px;
      display: inline-block;
      border: 1px solid var(--border-default);
    }

    .active-layer-item .remove-btn {
      cursor: pointer;
      color: var(--status-danger);
      font-size: 18px;
      line-height: 1;
      min-width: 44px;
      min-height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: -8px -4px -8px 0;
      position: relative;
      z-index: 2;
      flex-shrink: 0;
    }

    /* Feature info popup on map */
    .feature-popup {
      background: var(--surface-1);
      border-radius: var(--radius-xl);
      padding: 16px;
      max-width: 300px;
      max-height: 280px;
      overflow-y: auto;
    }

    .feature-popup table {
      width: 100%;
      border-collapse: collapse;
      font-size: var(--text-caption);
    }

    .feature-popup th,
    .feature-popup td {
      padding: 4px 6px;
      border-bottom: 1px solid var(--border-subtle);
      vertical-align: top;
    }

    .feature-popup th {
      width: 36%;
      text-align: left;
      font-size: var(--text-nano);
      text-transform: uppercase;
      letter-spacing: var(--tracking-wide);
      color: var(--text-quaternary);
      font-weight: var(--weight-medium);
    }

    .feature-popup td {
      color: var(--text-secondary);
    }

    .feature-popup tr:nth-child(odd) {
      background: var(--surface-2);
    }

    .feature-popup-wrapper .maplibregl-popup-content {
      background: transparent;
      padding: 0;
      border-radius: var(--radius-xl);
      box-shadow: none;
    }

    .feature-popup-wrapper .maplibregl-popup-tip {
      border-top-color: var(--surface-1);
    }

    .feature-popup-wrapper .maplibregl-popup-close-button {
      color: var(--text-quaternary);
      font-size: 18px;
      padding: 4px 8px;
      right: 4px;
      top: 4px;
    }

    .feature-popup-wrapper .maplibregl-popup-close-button:hover {
      background: var(--surface-3);
      border-radius: var(--radius-sm);
    }

    /* Button styles */
    button,
    .btn {
      background: var(--accent);
      color: white;
      border: none;
      padding: 10px 18px;
      min-height: 40px;
      border-radius: var(--radius-lg);
      cursor: pointer;
      font-size: var(--text-body);
      font-weight: var(--weight-medium);
      margin: 2px 0;
      width: 100%;
      transition: var(--transition-all);
      box-shadow: var(--shadow-button-inset);
      letter-spacing: 0;
      text-transform: none;
    }

    button:hover,
    .btn:hover {
      filter: brightness(1.1);
    }

    button:active,
    .btn:active {
      transform: scale(0.98);
      transition: transform 50ms var(--ease-out);
    }

    button.secondary {
      background: transparent;
      border: 1px solid var(--border-default);
      color: var(--text-secondary);
      box-shadow: none;
    }

    button.secondary:hover {
      background: var(--surface-3);
    }

    button.danger {
      background: var(--status-danger-bg);
      color: var(--status-danger);
      border: 1px solid var(--status-danger-border);
      box-shadow: none;
    }

    button.danger:hover {
      background: rgba(249, 115, 115, 0.2);
    }

    button.success {
      background: var(--status-success);
      color: #000;
      box-shadow: var(--shadow-button-inset);
    }

    button:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      transform: none;
    }

    .status-pill {
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 10px;
      border: 1px solid var(--border-subtle);
      background: var(--surface-3);
      color: var(--text-tertiary);
      white-space: nowrap;
    }

    .status-pill span {
      color: var(--accent-strong);
    }

    .status-indicator {
      display: inline-block;
      width: 7px;
      height: 7px;
      border-radius: 50%;
      margin-right: 4px;
    }

    .status-indicator.connected {
      background: #22c55e;
      box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
    }

    .status-indicator.disconnected {
      background: #ef4444;
      box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
    }

    /* MAP AREA */

    #map-container {
      position: relative;
      overflow: hidden;
      height: 100%;
    }

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

    /* MapLibre controls tweak */

    .maplibregl-ctrl-group button {
      background: var(--surface-2);
      border-color: var(--border-subtle);
    }

    .maplibregl-ctrl-group button:hover {
      background: var(--surface-3);
    }

    .maplibregl-ctrl-attrib {
      background: var(--surface-1) !important;
      color: var(--text-quaternary) !important;
      font-size: var(--text-nano);
    }

    /* Geolocate Control - Bottom Center */
    #geolocate-container {
      position: absolute;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 10;
    }

    #geolocate-container .maplibregl-ctrl-geolocate {
      width: 56px;
      height: 56px;
      border-radius: 50%;
      background: var(--surface-1);
      border: 2px solid var(--border-default);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: var(--transition-all);
    }

    #geolocate-container .maplibregl-ctrl-geolocate:hover {
      background: rgba(31, 41, 55, 0.95);
      border-color: var(--accent);
      transform: scale(1.05);
    }

    #geolocate-container .maplibregl-ctrl-geolocate .maplibregl-ctrl-icon {
      width: 28px;
      height: 28px;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v4M12 18v4M2 12h4M18 12h4'/%3E%3C/svg%3E");
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
    }

    #geolocate-container .maplibregl-ctrl-geolocate:hover .maplibregl-ctrl-icon {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v4M12 18v4M2 12h4M18 12h4'/%3E%3C/svg%3E");
    }

    #geolocate-container .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2322d3ee' stroke='%2322d3ee' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v4M12 18v4M2 12h4M18 12h4'/%3E%3C/svg%3E");
    }

    #geolocate-container .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active {
      border-color: var(--accent);
      box-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
    }

    /* Location Confirmation Panel */
    #location-confirm-panel {
      position: absolute;
      bottom: 100px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 20;
      background: var(--surface-1);
      border: 1px solid var(--border-subtle);
      border-radius: var(--radius-2xl);
      padding: 20px;
      min-width: 280px;
      max-width: 340px;
      box-shadow: var(--shadow-panel);
      animation: card-entrance var(--duration-slow) var(--ease-out);
    }

    .confirm-panel-header {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 16px;
      padding-bottom: 12px;
      border-bottom: 1px solid var(--border-subtle);
    }

    .confirm-panel-header .confirm-icon {
      font-size: 24px;
    }

    .confirm-panel-header h3 {
      margin: 0;
      font-size: var(--text-subhead);
      font-weight: var(--weight-semibold);
      color: var(--text-main);
    }

    .confirm-panel-body {
      margin-bottom: 16px;
    }

    .confirm-coords {
      background: var(--surface-3);
      border-radius: var(--radius-md);
      padding: 12px;
      margin-bottom: 12px;
    }

    .coord-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 4px 0;
      font-size: 13px;
    }

    .coord-label {
      color: var(--text-tertiary);
      font-weight: var(--weight-medium);
    }

    .coord-row span:last-child {
      color: var(--accent);
      font-family: var(--font-mono);
      font-weight: 600;
    }

    .coord-row.accuracy span:last-child {
      color: #22c55e;
    }

    .confirm-hint {
      font-size: var(--text-micro);
      color: var(--text-tertiary);
      text-align: center;
      margin: 0;
      font-style: italic;
    }

    .confirm-panel-actions {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .confirm-btn {
      width: 100%;
      padding: 12px 16px;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      border: none;
      transition: var(--transition-all);
    }

    .confirm-btn.success {
      background: linear-gradient(135deg, #0ea5e9, #0284c7);
      color: white;
    }

    .confirm-btn.success:hover {
      background: linear-gradient(135deg, #38bdf8, #0ea5e9);
      transform: translateY(-1px);
    }

    .confirm-btn.secondary {
      background: var(--surface-3);
      color: var(--text-primary);
    }

    .confirm-btn.secondary:hover {
      background: var(--surface-4);
    }

    .confirm-btn.danger {
      background: rgba(127, 29, 29, 0.6);
      color: var(--color-danger-text, #fca5a5);
    }

    .confirm-btn.danger:hover {
      background: rgba(153, 27, 27, 0.8);
    }

    /* Mobile adjustments for confirmation panel */
    @media (max-width: 480px) {
      #location-confirm-panel {
        bottom: 80px;
        left: 10px;
        right: 10px;
        transform: none;
        max-width: none;
      }
    }

    .form-group {
      margin-bottom: 18px;
    }

    .form-group label {
      display: block;
      font-size: var(--text-caption);
      font-weight: var(--weight-medium);
      letter-spacing: 0;
      text-transform: none;
      color: var(--text-tertiary);
      margin-bottom: 6px;
    }

    .form-group input[type="text"],
    .form-group input[type="email"] {
      width: 100%;
      padding: 12px 14px;
      min-height: 40px;
      border: none;
      border-bottom: 1px solid var(--border-subtle);
      border-radius: var(--radius-lg);
      background: var(--input-bg);
      color: var(--text-primary);
      font-size: 15px;
      font-family: var(--font-primary);
      outline: none;
      transition: border-color var(--duration-normal) var(--ease-out),
                  box-shadow var(--duration-normal) var(--ease-out),
                  background-color var(--duration-normal) var(--ease-out);
    }

    .form-group input[type="text"]:focus,
    .form-group input[type="email"]:focus {
      border: 1px solid var(--accent);
      box-shadow: var(--input-ring);
      background: var(--input-bg-focus);
    }

    .form-group input[type="text"]:not(:placeholder-shown),
    .form-group input[type="email"]:not(:placeholder-shown) {
      border: 1px solid var(--border-subtle);
    }

    .form-group input::placeholder {
      color: var(--text-quaternary);
      opacity: 0.7;
    }

    /* Upload Progress Bar */
    .upload-progress-container {
      background: var(--surface-1);
      border: 1px solid rgba(56, 189, 248, 0.3);
      border-radius: 10px;
      padding: 16px;
      margin-bottom: 16px;
    }

    .upload-progress-label {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      font-size: 12px;
      color: var(--text-main);
    }

    #upload-progress-text {
      color: var(--accent);
      font-weight: 500;
    }

    #upload-progress-percent {
      color: var(--accent-strong);
      font-weight: 700;
      font-size: 14px;
    }

    .upload-progress-bar {
      height: 8px;
      background: rgba(31, 41, 55, 0.8);
      border-radius: 4px;
      overflow: hidden;
    }

    .upload-progress-fill {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, var(--accent), var(--accent-strong));
      border-radius: 4px;
      transition: width 0.3s ease;
    }

    /* Very small screens (320px-400px) - optimized for narrow devices */
    @media (max-width: 400px) {
      /* Camera section adjustments */
      .camera-section {
        padding: 14px;
      }

      .camera-section h3 {
        font-size: 11px;
      }

      .camera-buttons button {
        font-size: 11px;
        padding: 10px 8px;
      }

      .captured-images {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 6px;
      }

      /* Section cards on very small screens */
      .section-card {
        padding: 8px;
      }

      .section-title {
        font-size: 11px;
      }

      .section-header .badge {
        font-size: 9px;
      }

      /* Prevent horizontal scroll */
      html, body {
        overflow-x: hidden;
      }
    }

    /* ============================================
       SURVEY SLIDE-OUT PANEL
       ============================================ */

.survey-panel-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.1);
  z-index: 1999;
}

.survey-panel-backdrop.active {
  display: block;
}

.survey-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: var(--survey-panel-width);
  /* 100vh on mobile Safari/Chrome includes the area under the dynamic URL bar,
     hiding ~50-90px at the bottom of the footer (and the Hide Survey button).
     dvh tracks the actually-visible viewport. vh kept as fallback. */
  height: 100vh;
  height: 100dvh;
  background: var(--surface-1);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-panel);
  z-index: 2000;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
}

.survey-panel.active {
  display: flex;
  transform: translateX(0);
}

.survey-panel-header {
  flex-shrink: 0;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.survey-panel-title {
  font-size: var(--text-heading);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.survey-panel-coords {
  margin-top: 8px;
  font-size: var(--text-caption);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.survey-panel-accuracy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-nano);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.accuracy-good { background: var(--status-success-bg); color: var(--status-success); border: 1px solid var(--status-success-border); }
.accuracy-fair { background: var(--status-warning-bg); color: var(--status-warning); border: 1px solid var(--status-warning-border); }
.accuracy-poor { background: var(--status-danger-bg); color: var(--status-danger); border: 1px solid var(--status-danger-border); }

.accuracy-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.survey-segmented {
  display: flex;
  background: var(--surface-3);
  border-radius: var(--radius-lg);
  padding: 3px;
  margin: 12px 24px 0;
  flex-shrink: 0;
}

.survey-segmented > button.survey-segment {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  min-height: auto;
  margin: 0;
  width: auto;
  box-shadow: none;
  filter: none;
  transition: background var(--duration-normal) var(--ease-out), color var(--duration-normal) var(--ease-out);
}

.survey-segmented > button.survey-segment:hover { color: var(--text-secondary); filter: none; background: none; }

.survey-segmented > button.survey-segment.active {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.survey-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.form-section {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 16px;
}

.form-section h3 {
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin: 0 0 16px 0;
  letter-spacing: -0.2px;
}

.name-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Interest level segmented slider */
.interest-slider { position: relative; padding: 8px 0; }

.interest-track {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  height: 40px;
}

.interest-track::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 12px;
  right: 12px;
  height: 3px;
  background: var(--border-default);
  border-radius: var(--radius-pill);
  transform: translateY(-50%);
}

.interest-stop {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  z-index: 1;
  background: var(--surface-3);
  border: 2px solid var(--border-default);
  color: var(--text-quaternary);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  transition: all var(--duration-normal) var(--ease-out);
}

.interest-stop:hover { border-color: var(--accent); color: var(--text-secondary); transform: scale(1.1); }

.interest-stop.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 12px var(--accent-soft);
}

.interest-stop.below-selected {
  background: var(--accent-soft);
  border-color: rgba(56, 189, 248, 0.4);
}

.interest-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: var(--text-nano);
  color: var(--text-quaternary);
}

.survey-panel-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-1);
}

.survey-submit-btn {
  width: 100%;
  padding: 12px;
  min-height: 44px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  box-shadow: var(--shadow-button-inset);
  transition: var(--transition-all);
  margin: 0;
}

.survey-submit-btn:hover { filter: brightness(1.1); }
.survey-submit-btn:active { transform: scale(0.98); }

.survey-secondary-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
}

.survey-secondary-actions button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  cursor: pointer;
  padding: 6px 8px;
  width: auto;
  min-height: auto;
  margin: 0;
  box-shadow: none;
  filter: none;
}

.survey-secondary-actions button:hover { color: var(--text-primary); filter: none; }
.survey-secondary-actions button.danger-text { color: var(--status-danger); }

    /* Camera & Image Upload Section */
    .camera-section {
      background: var(--surface-3);
      border: 1px solid var(--border-subtle);
      border-left: 2px solid rgba(74, 222, 128, 0.4);
      border-radius: var(--radius-lg);
      padding: 20px 20px 20px 22px;
      margin-bottom: 16px;
      box-shadow: var(--shadow-sm);
    }

    .camera-section h3 {
      margin: 0 0 16px 0;
      padding-bottom: 0;
      font-size: var(--text-caption);
      font-weight: var(--weight-semibold);
      color: var(--text-tertiary);
      text-transform: uppercase;
      letter-spacing: var(--tracking-wider);
      border-bottom: none;
    }

    .camera-controls {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 12px;
    }

    .camera-controls button {
      flex: 1;
      min-width: 120px;
      min-height: 44px;
      margin: 0;
    }

    #camera-preview {
      width: 100%;
      max-width: 100%;
      border-radius: 8px;
      background: #000;
      display: none;
      margin-bottom: 12px;
    }

    #camera-canvas {
      display: none;
    }

    .captured-images {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
      gap: 8px;
      margin-top: 12px;
    }

    .captured-image-item {
      position: relative;
      aspect-ratio: 1;
      border-radius: var(--radius-md);
      overflow: hidden;
      border: 1px solid var(--border-subtle);
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .captured-image-item img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .captured-image-item .remove-image {
      position: absolute;
      top: 4px;
      right: 4px;
      background: rgba(239, 68, 68, 0.95);
      color: white;
      border: none;
      border-radius: 50%;
      width: 24px;
      height: 24px;
      font-size: 16px;
      line-height: 1;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .captured-image-item .remove-image:hover {
      background: rgba(220, 38, 38, 1);
    }

    /* Image Carousel */
    .image-carousel {
      background: var(--surface-3);
      border: 1px solid var(--border-subtle);
      border-left: 2px solid rgba(251, 191, 36, 0.4);
      border-radius: var(--radius-lg);
      padding: 20px 20px 20px 22px;
      margin-bottom: 16px;
      box-shadow: var(--shadow-sm);
    }

    .image-carousel h3 {
      margin: 0 0 16px 0;
      padding-bottom: 0;
      font-size: var(--text-caption);
      font-weight: var(--weight-semibold);
      color: var(--text-tertiary);
      text-transform: uppercase;
      letter-spacing: var(--tracking-wider);
      border-bottom: none;
    }

    .carousel-container {
      position: relative;
      width: 100%;
      aspect-ratio: 16 / 9;
      background: #000;
      border-radius: 8px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .carousel-container img {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
    }

    .carousel-nav {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      background: var(--surface-2);
      border: 1px solid var(--border-default);
      color: var(--text-main);
      border-radius: 50%;
      width: 44px;
      height: 44px;
      font-size: 20px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .carousel-nav:hover {
      background: rgba(31, 41, 55, 0.95);
      color: var(--accent);
    }

    .carousel-nav.prev {
      left: 8px;
    }

    .carousel-nav.next {
      right: 8px;
    }

    .carousel-counter {
      position: absolute;
      bottom: 8px;
      left: 50%;
      transform: translateX(-50%);
      background: var(--surface-1);
      border: 1px solid var(--border-default);
      padding: 4px 12px;
      border-radius: 12px;
      font-size: 12px;
      color: var(--text-main);
    }

    .image-type-badge {
      position: absolute;
      top: 8px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(34, 211, 238, 0.95);
      border: 1px solid rgba(6, 182, 212, 0.8);
      padding: 6px 16px;
      border-radius: 16px;
      font-size: 13px;
      font-weight: 600;
      color: var(--surface-0);
      z-index: 10;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .carousel-empty {
      color: var(--text-muted);
      text-align: center;
      padding: 32px;
      font-size: 13px;
    }

    .hidden {
      display: none !important;
    }

    /* Responsive / mobile behaviour */

    @media (max-width: 900px) {
      html,
      body {
        /* dvh tracks the actually-visible viewport (excludes the URL bar);
           overflow:hidden stops the page from scrolling when the URL bar
           shrinks the visible area below content height. Without these,
           the FAB at the bottom of the map gets pushed off-screen until
           the user scrolls. */
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
      }

      body {
        background-attachment: scroll;
      }

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

      /* Ensure inputs scroll into view when focused */
      .form-group input[type="text"],
      .form-group input[type="email"] {
        /* Slightly larger font to prevent iOS zoom */
        font-size: 16px;
      }
    }
/* ============================================
   AUTH SCREEN
   ============================================ */

#auth-screen {
  position: fixed;
  inset: 0;
  background: var(--surface-0);
  background-image: radial-gradient(circle at top, #111214 0, var(--surface-0) 45%, #000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

.auth-container {
  width: 100%;
  max-width: 380px;
  padding: 0 20px;
}

.auth-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: 32px;
  box-shadow: var(--shadow-xl);
}

.auth-title {
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
  text-align: center;
  margin: 0 0 24px 0;
  letter-spacing: -0.5px;
}

.auth-segmented {
  display: flex;
  background: var(--surface-3);
  border-radius: var(--radius-lg);
  padding: 3px;
  margin-bottom: 24px;
}

.auth-segmented > button.auth-segment {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  min-height: auto;
  margin: 0;
  width: auto;
  box-shadow: none;
  filter: none;
  transition: background var(--duration-normal) var(--ease-out), color var(--duration-normal) var(--ease-out);
}

.auth-segmented > button.auth-segment:hover { color: var(--text-secondary); filter: none; background: none; }

.auth-segmented > button.auth-segment.active {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  min-height: 40px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-primary);
  outline: none;
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out),
              background-color var(--duration-normal) var(--ease-out);
}

.auth-form input:focus {
  border: 1px solid var(--accent);
  box-shadow: var(--input-ring);
  background: var(--input-bg-focus);
}

.auth-form input::placeholder {
  color: var(--text-quaternary);
  opacity: 0.7;
}

.auth-error {
  font-size: var(--text-caption);
  color: var(--status-danger);
  min-height: 18px;
}
    .survey-visibility {
      display: flex; align-items: center; gap: 10px; padding: 8px 0;
      border-top: 1px solid var(--border-default); margin-top: 8px;
    }
    .visibility-toggle {
      position: relative; width: 36px; height: 20px;
      background: rgba(255,255,255,0.1); border-radius: 10px;
      cursor: pointer; transition: background 0.2s;
    }
    .visibility-toggle.on { background: var(--accent); }
    .visibility-toggle::after {
      content: ''; position: absolute; top: 2px; left: 2px;
      width: 16px; height: 16px; background: #fff; border-radius: 50%;
      transition: transform 0.2s;
    }
    .visibility-toggle.on::after { transform: translateX(16px); }
    .visibility-label { font-size: 0.8rem; color: var(--text-muted); }
    .share-btn {
      background: none; border: 1px solid var(--border-default); color: var(--text-muted);
      border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 0.75rem;
      margin-left: auto; transition: color 0.15s, border-color 0.15s;
    }
    .share-btn:hover { color: var(--accent); border-color: var(--accent); }
    .share-url {
      font-size: 0.75rem; color: var(--accent); word-break: break-all;
      padding: 6px 8px; background: rgba(255,255,255,0.04); border-radius: 6px;
      margin-top: 6px; display: flex; align-items: center; gap: 8px;
    }
    .share-url button {
      background: none; border: 1px solid var(--border-default); color: var(--danger);
      border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 0.7rem;
      white-space: nowrap;
    }

    /* ========================================
       FOCUS STATES — Accessibility
       ======================================== */

    /* Universal focus-visible ring */
    :focus-visible {
      outline: 2px solid #38bdf8;
      outline-offset: 2px;
    }

    /* Remove default outline for mouse users */
    :focus:not(:focus-visible) {
      outline: none;
    }

    /* Custom focus for inputs */
    .form-group input:focus-visible,
    .form-group select:focus-visible,
    .form-group textarea:focus-visible {
      outline: none;
      border-color: #38bdf8;
      box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2), 0 0 0 1px rgba(56, 189, 248, 0.5);
    }

    /* Custom focus for buttons */
    button:focus-visible,
    .btn:focus-visible,
    .confirm-btn:focus-visible,
    .interest-stop:focus-visible {
      outline: 2px solid #38bdf8;
      outline-offset: 2px;
      box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15);
    }

    /* Focus for cards and interactive containers */
    .section-card:focus-visible,
    .active-layer-item:focus-visible {
      outline: 2px solid #38bdf8;
      outline-offset: -2px;
    }

    /* Focus for select dropdowns */
    #layer-select:focus-visible,
    #basemap-select:focus-visible {
      outline: none;
      border-color: #38bdf8;
      box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2), 0 0 0 1px rgba(56, 189, 248, 0.5);
    }

    /* Skip-to-content link (accessibility) */
    .skip-link {
      position: absolute;
      top: -100%;
      left: 50%;
      transform: translateX(-50%);
      background: #38bdf8;
      color: var(--surface-0);
      padding: 8px 16px;
      border-radius: 0 0 8px 8px;
      font-size: 14px;
      font-weight: 600;
      z-index: 9999;
      transition: top 0.2s;
    }

    .skip-link:focus {
      top: 0;
    }

    /* ========================================
       COMPONENT STATES — Hover, Active, Disabled
       ======================================== */

    /* Card hover states */
    .section-card {
      transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .section-card:hover {
      border-color: var(--border-default);
      box-shadow: 0 16px 35px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
    }

    /* Layer item hover */
    .active-layer-item {
      transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .active-layer-item:hover {
      border-color: var(--border-default);
      background: var(--surface-2);
    }

    /* Button active (pressed) states */
    button:active:not(:disabled),
    .btn:active:not(:disabled) {
      transform: scale(0.98);
      transition: transform 60ms ease;
    }

    .confirm-btn:active:not(:disabled) {
      transform: scale(0.98);
    }

    .interest-stop:active:not(:disabled) {
      transform: scale(0.97);
    }

    /* Disabled state improvements */
    button:disabled,
    .btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
      pointer-events: none;
    }

    /* Interactive element cursor */
    .captured-image-item {
      transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .captured-image-item:hover {
      border-color: #38bdf8;
      transform: scale(1.03);
    }

    /* Carousel nav button states */
    .carousel-nav {
      transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .carousel-nav:active {
      transform: translateY(-50%) scale(0.92);
    }

    /* Badge/pill hover */
    .badge:hover,
    .chip:hover {
      border-color: var(--border-default);
    }

    /* Status pill interactive */
    .status-pill {
      transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Form input states */
    .form-group input[type="text"],
    .form-group input[type="email"] {
      transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .form-group input[type="text"]:hover:not(:focus),
    .form-group input[type="email"]:hover:not(:focus) {
      border-color: var(--border-strong);
    }

    /* Error state for form inputs */
    .form-group input.error {
      border-color: rgba(249, 115, 115, 0.6);
      box-shadow: 0 0 0 3px rgba(249, 115, 115, 0.15);
    }

    .form-group input.error:focus {
      border-color: #f97373;
      box-shadow: 0 0 0 3px rgba(249, 115, 115, 0.2), 0 0 0 1px rgba(249, 115, 115, 0.5);
    }

    /* Success state for form inputs */
    .form-group input.success {
      border-color: rgba(74, 222, 128, 0.6);
      box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
    }

    /* Loading state for buttons */
    button.loading {
      position: relative;
      color: transparent;
      pointer-events: none;
    }

    button.loading::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 18px;
      height: 18px;
      margin: -9px 0 0 -9px;
      border: 2px solid rgba(255, 255, 255, 0.3);
      border-top-color: white;
      border-radius: 50%;
      animation: button-spin 0.6s linear infinite;
    }

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

    /* ========================================
       RESPONSIVE BREAKPOINTS — Professional Scale
       ======================================== */

    /* Tablet: 601px - 900px */
    @media (min-width: 601px) and (max-width: 900px) {
      .captured-images {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
      }
    }

    /* Desktop Large: 1201px+ */
    @media (min-width: 1201px) {
      .captured-images {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      }
    }

    /* Touch target enforcement for mobile */
    @media (max-width: 600px) {
      button,
      .btn,
      .confirm-btn,
      .carousel-nav {
        min-height: 44px;
        min-width: 44px;
      }
    }

    /* Reduced motion preference */
    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }

    /* High contrast mode support */
    @media (prefers-contrast: high) {
      :root {
        --border-default: rgba(148, 163, 184, 0.6);
        --text-main: #ffffff;
        --text-muted: #d1d5db;
      }

      .section-card,
      .form-section,
      .camera-section,
      .image-carousel {
        border-width: 2px;
      }

      button,
      .btn {
        border: 1px solid rgba(255, 255, 255, 0.3);
      }
    }

    /* ========================================
       GLOBAL POLISH
       ======================================== */

    /* Custom scrollbar for panels and forms */
    .panel-body::-webkit-scrollbar,
    .survey-panel-body::-webkit-scrollbar,
    .feature-popup::-webkit-scrollbar {
      width: 6px;
    }

    .panel-body::-webkit-scrollbar-track,
    .survey-panel-body::-webkit-scrollbar-track,
    .feature-popup::-webkit-scrollbar-track {
      background: transparent;
    }

    .panel-body::-webkit-scrollbar-thumb,
    .survey-panel-body::-webkit-scrollbar-thumb,
    .feature-popup::-webkit-scrollbar-thumb {
      background: var(--border-default);
      border-radius: 3px;
    }

    .panel-body::-webkit-scrollbar-thumb:hover,
    .survey-panel-body::-webkit-scrollbar-thumb:hover,
    .feature-popup::-webkit-scrollbar-thumb:hover {
      background: var(--border-strong);
    }

    /* Firefox scrollbar */
    .panel-body,
    .survey-panel-body,
    .feature-popup {
      scrollbar-width: thin;
      scrollbar-color: var(--border-default) transparent;
    }

    /* Text selection */
    ::selection {
      background: rgba(56, 189, 248, 0.3);
      color: #f7f8f8;
    }

    /* Smooth scroll behavior */
    html {
      scroll-behavior: smooth;
    }

    @media (prefers-reduced-motion: reduce) {
      html {
        scroll-behavior: auto;
      }
    }
    /* Camera flash effect */
    .camera-flash {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: white;
      z-index: 9998;
      opacity: 0;
      pointer-events: none;
    }

    .camera-flash.flash {
      animation: flash-effect 0.3s ease-out;
    }

    @keyframes flash-effect {
      0% { opacity: 0.6; }
      100% { opacity: 0; }
    }

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.camera-tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.camera-tab-content.active {
  display: flex;
}

.camera-mode-buttons {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
}

.camera-mode-btn {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary, #94a3b8);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.camera-mode-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary, #e2e8f0);
}

.camera-mode-btn.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
}

.camera-mode-content {
  display: none;
}

.camera-mode-content.active {
  display: block;
}

/* ============================================
   FLOATING ACTION BUTTON
   ============================================ */

.fab {
  position: absolute;
  bottom: var(--fab-offset);
  right: var(--fab-offset);
  width: var(--fab-size);
  height: var(--fab-size);
  min-width: var(--fab-size);
  min-height: var(--fab-size);
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg), 0 0 20px var(--accent-soft);
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(56, 189, 248, 0.4);
  filter: none;
}

.fab:active {
  transform: scale(0.95);
}

.fab.hidden {
  display: none;
}

.fab:disabled {
  pointer-events: none;
  opacity: 0.7;
}

/* ============================================
   TOAST NOTIFICATION SYSTEM
   ============================================ */

#toast-container {
  position: fixed;
  bottom: var(--toast-offset);
  right: var(--toast-offset);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--toast-gap);
  pointer-events: none;
}

.toast {
  width: var(--toast-width);
  background: var(--surface-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  transition: transform var(--duration-slow) var(--ease-out),
              opacity var(--duration-normal) var(--ease-out);
}

.toast-accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  margin-top: 1px;
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  line-height: var(--leading-snug);
}

.toast-detail {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: var(--leading-normal);
}

.toast-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-quaternary);
  cursor: pointer;
  font-size: 18px;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  margin: 0;
  box-shadow: none;
}

.toast-dismiss:hover {
  color: var(--text-secondary);
  background: var(--surface-3);
  filter: none;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
}

.toast-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--border-default);
  transform-origin: right;
  animation: toast-progress-shrink linear forwards;
}

@keyframes toast-progress-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.toast-enter {
  opacity: 0;
  transform: translateX(24px);
}

.toast-exit {
  animation: toast-fade-out var(--duration-normal) var(--ease-out) forwards;
}

@keyframes toast-fade-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ============================================
   CONTEXT MENU
   ============================================ */

.context-menu {
  position: fixed;
  width: var(--menu-width);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-panel);
  z-index: 3000;
  padding: 4px;
  display: none;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 150ms var(--ease-out),
              transform 150ms var(--ease-out);
}

.context-menu.open {
  display: block;
  opacity: 1;
  transform: scale(1);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--menu-item-height);
  padding: 0 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: var(--text-body);
  color: var(--text-secondary);
  transition: background var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.context-menu-item:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.context-menu-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.context-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-quaternary);
}

.context-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 8px;
}

/* ============================================
   HOVER PREVIEW CARDS
   ============================================ */

.hover-preview {
  position: absolute;
  width: 240px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px;
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms var(--ease-out),
              transform 150ms var(--ease-out);
}

.hover-preview.visible {
  opacity: 1;
  transform: translateY(0);
}

.hover-preview-name {
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hover-preview-address {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hover-preview-interest {
  display: flex;
  gap: 4px;
}

.hover-preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-default);
}

.hover-preview-dot.filled {
  background: var(--accent);
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

@keyframes card-entrance {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-body .section-card {
  animation: card-entrance var(--duration-slow) var(--ease-out) backwards;
}

.panel-body .section-card:nth-child(1) { animation-delay: 0ms; }
.panel-body .section-card:nth-child(2) { animation-delay: 50ms; }
.panel-body .section-card:nth-child(3) { animation-delay: 100ms; }
.panel-body .section-card:nth-child(4) { animation-delay: 150ms; }

@keyframes zoom-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

#dock-zoom-badge.pulse {
  animation: zoom-pulse var(--duration-slow) var(--ease-out);
}

@keyframes gps-glow {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 20px var(--accent-soft); }
  50% { box-shadow: var(--shadow-lg), 0 0 30px rgba(56, 189, 248, 0.5); }
}

.fab.acquiring {
  animation: gps-glow 1.5s ease-in-out infinite;
}

/* ============================================
   FULLSCREEN LIGHTBOX
   ============================================ */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

.lightbox.open {
  opacity: 1;
}

.lightbox-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform: scale(0.95);
  transition: transform 200ms var(--ease-out);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox.open .lightbox-content img {
  transform: scale(1);
}

.lightbox-content #lightbox-pano {
  width: 100% !important;
  height: 100% !important;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  top: calc(16px + env(safe-area-inset-top, 0px));
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 24px;
  cursor: pointer;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 150ms var(--ease-out);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  filter: none;
}

.lightbox-counter {
  position: absolute;
  top: 20px;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  z-index: 10001;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox-badge {
  position: absolute;
  top: 20px;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 16px;
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  color: var(--accent);
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  z-index: 10001;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 28px;
  cursor: pointer;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 150ms var(--ease-out);
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.2);
  filter: none;
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.lightbox-gyro-btn {
  position: absolute;
  bottom: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 200ms var(--ease-out), color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}

.lightbox-gyro-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  filter: none;
}

.lightbox-gyro-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 20px var(--accent-soft);
}

/* Hide nav arrows on mobile — use swipe */
@media (max-width: 768px) {
  .lightbox-nav {
    display: none;
  }

  .lightbox-gyro-btn {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  /* Dock → bottom horizontal bar */
  #dock {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 52px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0 8px;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
  }

  .dock-icon {
    width: 44px;
    height: 44px;
  }

  .dock-icon.active::before {
    left: 50%;
    top: auto;
    bottom: -4px;
    transform: translateX(-50%);
    width: 20px;
    height: var(--dock-active-indicator);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }

  .dock-spacer {
    display: none;
  }

  .dock-bottom {
    flex-direction: row;
    padding-top: 0;
    border-top: none;
    gap: 12px;
    width: auto;
  }

  #dock-zoom-badge {
    display: none;
  }

  /* App layout — remove dock left padding, add bottom padding */
  #app {
    padding-left: 0;
    padding-bottom: 52px;
  }

  /* Floating panels → full-width bottom sheets */
  .floating-panel {
    top: auto;
    bottom: 52px;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 60vh;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    transform: translateY(12px);
  }

  .floating-panel.open {
    transform: translateY(0);
  }

  .floating-panel.closing {
    transform: translateY(12px);
  }

  /* Survey panel → full-width */
  .survey-panel {
    width: 100%;
    max-width: 100%;
  }

  .survey-panel-header {
    padding: 16px 20px;
  }

  .survey-panel-body {
    padding: 16px 20px;
  }

  .survey-panel-footer {
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .survey-segmented {
    margin: 12px 20px 0;
  }

  /* Form sections tighter */
  .form-section {
    padding: 20px 16px;
  }

  .name-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Interest slider smaller */
  .interest-stop {
    width: 28px;
    height: 28px;
    font-size: var(--text-nano);
  }

  /* Toast narrower on mobile */
  #toast-container {
    left: var(--toast-offset);
    right: var(--toast-offset);
    bottom: calc(52px + var(--toast-offset));
  }

  .toast {
    width: 100%;
  }

  /* FAB repositioned above dock */
  .fab {
    bottom: calc(52px + var(--fab-offset));
    right: var(--fab-offset);
  }

  /* Context menu max width */
  .context-menu {
    max-width: calc(100vw - 32px);
  }

  /* Location confirm panel */
  #location-confirm-panel {
    bottom: calc(52px + 16px);
    left: 16px;
    right: 16px;
    transform: none;
    max-width: none;
  }

  /* Auth card tighter padding on small screens */
  .auth-card {
    padding: 24px 20px;
  }

  /* Map container fills the (dynamic) viewport minus the bottom dock */
  #map-container {
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
  }

  /* Lift the FAB and geolocate button above an open dock panel.
     Without this, the bottom-sheet panel covers them and the user has to
     close the panel just to start a survey or find their location. */
  #fab,
  #geolocate-container {
    transition: bottom 200ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  body.has-floating-panel #fab,
  body.has-floating-panel #geolocate-container {
    bottom: calc(60vh + 68px);
  }
}

/* Extra small phones */
@media (max-width: 380px) {
  .survey-panel-title {
    font-size: var(--text-subhead);
  }

  .form-section {
    padding: 16px 12px;
  }

  .interest-stop {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
}
