@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
  --navy-950: #0A1526;
  --navy-900: #11203A;
  --navy-800: #1B2D4D;
  --navy-700: #27354F;
  --blue-700: #245C97;
  --blue-600: #2C6CB0;
  --blue-500: #3B82C4;
  --blue-400: #409BCA;
  --steel-300: #7BA8CE;
  --steel-200: #A9C8E4;
  --steel-100: #DCE8F4;
  --steel-50:  #F0F5FA;

  --ink-900: #11161F;
  --ink-700: #2B3340;
  --ink-600: #4A5563;
  --ink-500: #69737F;
  --ink-400: #8A95A5;
  --ink-300: #AEB7C4;
  --line-200: #E6EAF0;
  --line-100: #EFF2F6;
  --paper:    #FBFCFD;
  --white:    #FFFFFF;

  --bg:        #FBFCFD;
  --bg-subtle: #F4F7FA;
  --surface:   #FFFFFF;
  --surface-2: #F7F9FC;
  --elevated:  #FFFFFF;
  --border:    #E6EAF0;
  --border-strong: #D3DAE4;

  --fg:        #11161F;
  --fg-2:      #4A5563;
  --fg-3:      #8A95A5;
  --fg-on-accent: #FFFFFF;

  --primary:        #2C6CB0;
  --primary-hover:  #245C97;
  --primary-press:  #1F4F84;
  --primary-soft:   #EAF1F8;
  --accent:         #409BCA;
  --ring:           rgba(44,108,176,0.35);

  --success: #1F8A5B;
  --warning: #B5791F;
  --danger:  #C0413B;
  --success-soft: #E7F3EC;
  --warning-soft: #F8F0E0;
  --danger-soft:  #F8E9E8;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 28px;
  --r-full: 999px;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --s-12: 48px; --s-16: 64px; --s-20: 80px;

  --shadow-xs: 0 1px 2px rgba(16,33,58,0.06);
  --shadow-sm: 0 1px 3px rgba(16,33,58,0.08), 0 1px 2px rgba(16,33,58,0.04);
  --shadow-md: 0 4px 16px rgba(16,33,58,0.08), 0 2px 4px rgba(16,33,58,0.04);
  --shadow-lg: 0 12px 36px rgba(16,33,58,0.12), 0 4px 10px rgba(16,33,58,0.06);

  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', 'JetBrains Mono', monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;
}

[data-theme="dark"] {
  --bg:        #0A1526;
  --bg-subtle: #0E1B30;
  --surface:   #121F36;
  --surface-2: #16243E;
  --elevated:  #1A2A45;
  --border:    #243349;
  --border-strong: #324460;

  --fg:        #E8EEF6;
  --fg-2:      #A7B4C6;
  --fg-3:      #6E7E96;
  --fg-on-accent: #06101F;

  --primary:        #4F9BD6;
  --primary-hover:  #6BAEE0;
  --primary-press:  #3B82C4;
  --primary-soft:   #152B45;
  --accent:         #5FB0DC;
  --ring:           rgba(95,176,220,0.40);

  --success: #4DBE8A; --warning: #E0B056; --danger: #E27772;
  --success-soft: #122C22; --warning-soft: #2E2616; --danger-soft: #2E1A19;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.30);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.40), 0 1px 2px rgba(0,0,0,0.30);
  --shadow-md: 0 4px 18px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.30);
  --shadow-lg: 0 14px 40px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.40);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}
::selection { background: var(--steel-200); }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid var(--bg); }

/* ---- App shell ---- */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px max(16px, 4vw);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
}

.header-logo { display: inline-flex; align-items: center; text-decoration: none; }
.header-logo img {
  height: 26px;
  display: block;
  transition: opacity var(--dur) var(--ease);
}
.header-logo:hover img { opacity: 0.8; }

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease);
}
.theme-toggle:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 max(16px, 4vw);
}
.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-3);
  transition: color var(--dur) var(--ease);
}
.tab-btn:hover { color: var(--fg-2); }
.tab-btn.active {
  font-weight: 600;
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-btn.active:hover { color: var(--primary); }

.tab-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--fg-3);
  border-radius: var(--r-full);
  padding: 3px 8px;
  line-height: 1;
}

/* ---- Views ---- */
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; flex-direction: column; }

/* ---- Chat view ---- */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.chat-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
}

/* Hero / empty state */
.chat-inner.empty {
  padding: 0 24px;
  min-height: 100%;
  justify-content: center;
}
.hero { text-align: left; padding-bottom: 40px; }
.hero-eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(30px, 4.4vw, 44px);
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--fg);
}
.hero p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-2);
  max-width: 520px;
  margin-top: 16px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

/* Quick action chips */
.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 9px 15px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg-2);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}
.quick-action:hover {
  background: var(--primary-soft);
  border-color: var(--steel-200);
  color: var(--primary-press);
}
.quick-action i { color: var(--primary); }

/* Messages */
.msg-user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}
.msg-user-bubble {
  background: var(--primary);
  color: var(--fg-on-accent);
  padding: 11px 16px;
  border-radius: 16px 16px 5px 16px;
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 78%;
  word-wrap: break-word;
}

.msg-ai {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.msg-ai-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: var(--primary-soft);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  overflow: hidden;
}
.msg-ai-avatar img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.msg-ai-body {
  max-width: 82%;
}
.msg-ai-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--fg);
  word-wrap: break-word;
}
/* Shared Markdown content styling — used by both the main chat (.msg-ai-text)
   and the map side panel (.vm-msg-text) via the .md-content class. */
.md-content p { margin: 0 0 4px; }
.md-content br + br { display: none; }
.md-content h3, .md-content h4 { margin: 12px 0 4px; font-size: 14.5px; font-weight: 600; }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.md-content ul, .md-content ol { margin: 4px 0; padding-left: 20px; }
.md-content li { margin: 2px 0; }
.md-content code { font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.md-content a { color: var(--primary); text-decoration: underline; }
.md-content em { font-style: italic; }
.md-table-wrap {
  overflow-x: auto; margin: 8px 0; -webkit-overflow-scrolling: touch;
}
.md-table {
  width: 100%; border-collapse: collapse; font-size: 13px; min-width: 360px;
}
.md-table th, .md-table td {
  text-align: left; padding: 6px 10px; border: 1px solid var(--border); white-space: nowrap;
}
.md-table th {
  font-weight: 600; background: var(--surface-2); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.md-table tr:nth-child(even) { background: var(--surface-2); }

/* Country flags — real images (flagcdn) with a text-badge fallback.
   Shared by the chat surfaces and the vessel map; adapts to light/dark. */
.flag {
  display: inline-block; width: 18px; height: 13px;
  vertical-align: -2px; border-radius: 2px; object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.flag-badge {
  display: inline-block; padding: 0 4px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 0.72em; font-weight: 700;
  letter-spacing: 0.3px; vertical-align: 1px;
  background: rgba(127, 127, 127, 0.18); color: inherit;
}

/* Vessel table */
.vessel-table {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.vessel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
}
.vessel-row:first-child { border-top: none; }
.vessel-row:nth-child(even) { background: var(--surface-2); }
.vessel-row:nth-child(odd) { background: var(--surface); }
.vessel-info { flex: 1; min-width: 0; }
.vessel-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
}
.vessel-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  margin-top: 2px;
}
.vessel-time {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}
.vessel-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  border-radius: var(--r-full);
  padding: 4px 9px;
  letter-spacing: 0.02em;
}
.vessel-status.arrived, .vessel-status.berthed {
  background: var(--success-soft); color: var(--success);
}
.vessel-status.delayed {
  background: var(--warning-soft); color: var(--warning);
}
.vessel-status.underway, .vessel-status.anchorage {
  background: var(--primary-soft); color: var(--primary);
}

/* Token cost */
.token-cost { margin-top: 10px; }
.token-cost-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.token-cost-details {
  display: none;
  gap: 18px;
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}
.token-cost-details.open { display: flex; }
.token-cost-details .label { color: var(--fg-3); }
.token-cost-details .cost { color: var(--primary); }

/* Was-this-helpful feedback row under an AI answer */
.msg-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--fg-3);
  font-size: 12px;
}
.msg-feedback-label { letter-spacing: 0.01em; }
.msg-feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border, rgba(128,128,128,0.25));
  border-radius: 6px;
  cursor: pointer;
  padding: 4px;
  color: var(--fg-3);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.msg-feedback-btn:hover { color: var(--primary); border-color: var(--primary); }
.msg-feedback-btn.chosen { color: var(--primary); border-color: var(--primary); }
.msg-feedback-thanks { display: none; color: var(--fg-3); }
.msg-feedback-error { display: none; color: var(--fg-3); }
.msg-feedback.failed .msg-feedback-error { display: inline; }
/* Once voted, keep the selected thumb visible and disable further voting. */
.msg-feedback.done .msg-feedback-label,
.msg-feedback.done .msg-feedback-btn:not(.chosen) { display: none; }
.msg-feedback.done .msg-feedback-btn.chosen {
  cursor: default;
  opacity: 1;
}
.msg-feedback.done .msg-feedback-thanks { display: inline; }

/* Thinking dots */
.thinking {
  display: flex;
  gap: 5px;
  padding: 6px 2px;
}
.thinking span {
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--steel-300);
  animation: cp-pulse 1.2s infinite ease-in-out;
}
.thinking span:nth-child(2) { animation-delay: 0.18s; }
.thinking span:nth-child(3) { animation-delay: 0.36s; }

/* ---- Composer ---- */
.composer-area {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.composer-area.no-border { border-top: none; }
/* Blank state (no messages yet): tighten the gap between the quota banner and
   the composer input. Only applies before the first message. */
.composer-area.no-border .composer-inner { padding-top: 0; }
.composer-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 24px 18px;
}
.composer-quick {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.composer-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.composer-box.focused {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
.composer-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--fg);
}
.composer-input::placeholder { color: var(--fg-3); }
.composer-send {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease);
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--fg-3);
}
.composer-send.ready {
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}
.composer-send:disabled { cursor: default; }

.composer-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.composer-disclaimer {
  font-size: 11.5px;
  color: var(--fg-3);
  text-align: center;
}
/* Powered-by badge — rests at the tab layer, right-aligned; matches the
   landing header pill (same height as the menu button). */
.powered-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  align-self: center;
  margin-left: auto;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.powered-label {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
  line-height: 1;
}
.powered-header-badge img {
  height: 12px;
  display: block;
  opacity: 0.85;
}

/* ---- Coming Soon views ---- */
.coming-soon {
  height: 100%;
  overflow-y: auto;
  display: flex;
}
.coming-soon-inner {
  max-width: 860px;
  margin: auto;
  padding: clamp(32px, 5vh, 60px) 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.coming-soon-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--fg-3);
  border-radius: var(--r-full);
  padding: 3px 8px;
  line-height: 1;
}
.coming-soon h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(26px, 3.6vw, 36px);
  letter-spacing: -0.025em;
  color: var(--fg);
  margin: 10px 0 0;
}
.coming-soon p {
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--fg-2);
  max-width: 480px;
  margin-top: 14px;
}

/* Beat dots + MCP workflow diagram moved to the landing page (landing.css). */

/* ===================== VESSEL MAP ===================== */

/* Map view — uses flex display when active */
#view-map.active { display: flex; }

/* Mapbox control overrides */
.mapboxgl-ctrl-attrib { font-size: 9px !important; opacity: 0.5; }
.mapboxgl-ctrl-attrib a { color: #8B95A5 !important; }
.mapboxgl-ctrl-group {
  background: rgba(255,255,255,0.92) !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  border-radius: 8px !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
}
.mapboxgl-ctrl-group button {
  width: 34px !important; height: 34px !important;
  border-color: rgba(0,0,0,0.06) !important;
}
.mapboxgl-ctrl-group button + button { border-top: 1px solid rgba(0,0,0,0.06) !important; }
.mapboxgl-ctrl-group button:hover { background: rgba(0,0,0,0.04) !important; }
[data-theme="dark"] .mapboxgl-ctrl-group {
  background: rgba(18,31,54,0.92) !important;
  border-color: #243349 !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}
[data-theme="dark"] .mapboxgl-ctrl-group button { border-color: #243349 !important; }
[data-theme="dark"] .mapboxgl-ctrl-group button + button { border-top-color: #243349 !important; }
[data-theme="dark"] .mapboxgl-ctrl-group button:hover { background: rgba(36,51,73,0.8) !important; }
[data-theme="dark"] .mapboxgl-ctrl-group button .mapboxgl-ctrl-icon {
  filter: invert(0.75) sepia(0.1) hue-rotate(180deg) brightness(1.2);
}
[data-theme="dark"] .mapboxgl-ctrl-attrib a { color: #5A6E88 !important; }

/* Sidebar divider */
.vm-divider {
  width: 6px; cursor: col-resize; flex-shrink: 0;
  position: relative; z-index: 3;
  background: transparent;
  transition: background 0.15s ease;
}
.vm-divider:hover, .vm-divider.active { background: var(--primary); }
.vm-divider-grip {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 4px; height: 32px; border-radius: 2px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}
.vm-divider:hover .vm-divider-grip, .vm-divider.active .vm-divider-grip {
  background: rgba(255,255,255,0.5);
}

/* Empty-state overlay */
.vm-empty-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(251,252,253,0.28);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  transition: opacity 1.2s cubic-bezier(0.16,1,0.3,1);
}
[data-theme="dark"] .vm-empty-overlay { background: rgba(10,21,38,0.28); }

.vm-radar {
  position: relative; width: 52px; height: 52px;
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.vm-ping {
  position: absolute; inset: 0; border-radius: 999px;
  border: 1.5px solid rgba(44,108,176,0.2);
  animation: empty-ping 2.4s ease-out infinite;
}
.vm-ping-delayed { animation-delay: 0.6s; }
.vm-radar-center {
  width: 52px; height: 52px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
}
.vm-overlay-text {
  text-align: center; max-width: 300px;
  transition: opacity 0.8s ease 0.1s, transform 0.8s ease 0.1s;
}
.vm-overlay-title {
  font-family: var(--font-sans); font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.4;
}
.vm-overlay-sub {
  font-family: var(--font-sans); font-size: 12.5px;
  line-height: 1.5; margin-top: 6px;
}
.vm-overlay-hint {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  transition: opacity 0.6s ease 0.05s;
}

@keyframes empty-ping {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Toolbar */
.vm-toolbar {
  position: absolute; top: 14px; left: 14px; display: flex; gap: 4px; z-index: 2;
}
.vm-toolbar-btn {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid rgba(0,0,0,0.08); border-radius: 8px;
  padding: 7px 11px; cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s ease;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em;
}
.vm-toolbar-btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

/* Legend */
.vm-legend {
  position: absolute; bottom: 14px; left: 14px;
  border: 1px solid rgba(0,0,0,0.08); border-radius: 10px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  z-index: 2; overflow: hidden;
  animation: popup-in 0.25s cubic-bezier(0.16,1,0.3,1) both;
}
.vm-legend-header {
  display: flex; align-items: center; gap: 7px; width: 100%;
  background: none; border: none; cursor: pointer;
  padding: 9px 14px 0;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; text-align: left;
}
.vm-legend-chevron {
  font-size: 11px; transition: transform 0.2s ease; line-height: 1;
}
.vm-legend-chevron.collapsed { transform: rotate(180deg); }
.vm-legend-body { padding: 7px 14px 10px; }
.vm-legend-body.collapsed { display: none; }
.vm-legend-item {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 10.5px;
  margin-bottom: 4px;
}
.vm-legend-item:last-of-type { margin-bottom: 0; }
.vm-legend-count {
  font-family: var(--font-mono); font-size: 10px;
  margin-top: 7px; padding-top: 7px;
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex; flex-direction: column; gap: 2px;
}
.vm-legend-updated { font-size: 9px; opacity: 0.75; letter-spacing: 0.02em; }

/* Popup */
.vm-popup {
  position: absolute; z-index: 10; width: 276px;
  border: 1px solid; border-radius: 12px;
  padding: 14px 16px;
  animation: popup-in 0.22s cubic-bezier(0.16,1,0.3,1) both;
  font-family: var(--font-sans); pointer-events: auto;
}
.vm-popup-hover { animation-duration: 0.12s; }
.vm-popup-hint {
  margin-top: 10px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8;
}
.vm-popup-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.vm-popup-name {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vm-popup-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
}
.vm-popup-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 999px;
  margin-right: 5px;
}
.vm-popup-close {
  width: 24px; height: 24px; border-radius: 6px; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; flex-shrink: 0;
}
.vm-popup-row {
  display: flex; gap: 20px; margin-top: 12px;
  font-family: var(--font-mono); font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.vm-popup-label {
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 2px;
}
.vm-popup-expanded {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 14px;
  font-family: var(--font-mono); font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.vm-popup-expand {
  background: none; border: none; color: #4F9BD6; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px;
  padding: 10px 0 0; display: flex; align-items: center; gap: 4px;
}

@keyframes popup-in {
  from { opacity: 0; transform: translateY(6px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* Sidebar */
.vm-sidebar {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg); border-left: 1px solid var(--border);
}
.vm-sidebar-header {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.vm-sidebar-header-icon {
  width: 28px; height: 28px; border-radius: 999px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
}
.vm-sidebar-header span {
  font-size: 14px; font-weight: 600; color: var(--fg); letter-spacing: -0.01em;
}
.vm-prompts {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: nowrap; gap: 5px; flex-shrink: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  /* fade the right edge → signals there are more chips to scroll to (removed at
     the end via the .at-end class). Applied to the scroll viewport, so the fade
     stays at the visible right edge regardless of scroll position. */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
}
.vm-prompts.at-end { -webkit-mask-image: none; mask-image: none; }
.vm-prompts::-webkit-scrollbar { display: none; }
.vm-prompt {
  display: inline-flex; align-items: center; gap: 5px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px;
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 500; color: var(--fg-2);
  cursor: pointer; transition: all 200ms ease; white-space: nowrap;
}
.vm-prompt:hover {
  background: var(--primary-soft); border-color: var(--steel-200); color: var(--primary);
}
.vm-prompt:disabled { cursor: default; opacity: 0.6; }
.vm-chat-messages { flex: 1; overflow-y: auto; padding: 14px 12px; min-height: 0; display: flex; flex-direction: column; }
.vm-chat-messages:has(.vm-sidebar-empty) { justify-content: center; }
.vm-sidebar-empty { text-align: center; padding: 16px 12px; }
.vm-sidebar-empty-icon {
  width: 36px; height: 36px; border-radius: 999px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px; overflow: hidden;
}

/* Chat messages in sidebar */
.vm-msg-user { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.vm-msg-user-bubble {
  background: var(--primary); color: var(--fg-on-accent); padding: 9px 14px;
  border-radius: 14px 14px 4px 14px; font-size: 13.5px; line-height: 1.5; max-width: 88%;
}
.vm-msg-ai { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 16px; }
.vm-msg-avatar {
  width: 26px; height: 26px; border-radius: 999px; background: var(--primary-soft);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  margin-top: 1px; overflow: hidden;
}
.vm-msg-avatar img { width: 15px; height: 15px; object-fit: contain; }
.vm-msg-body { max-width: 85%; min-width: 0; }
.vm-msg-text { font-size: 13.5px; line-height: 1.55; color: var(--fg); }

/* Usage toggle in sidebar */
.vm-usage { margin-top: 8px; }
.vm-usage-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 2px 0;
  color: var(--fg-3); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
}
.vm-usage-details {
  display: none; gap: 14px; margin-top: 5px;
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}
.vm-usage-details.open { display: flex; }

/* Composer in sidebar */
.vm-composer { padding: 10px 12px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.vm-composer-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 6px 6px 6px 14px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.vm-composer-box.focused { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.vm-composer-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: var(--font-sans); font-size: 13.5px; color: var(--fg); min-width: 0;
}
.vm-composer-input::placeholder { color: var(--fg-3); }
.vm-composer-send {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  cursor: default; background: var(--surface-2); color: var(--fg-3);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--dur) var(--ease); flex-shrink: 0;
}
.vm-composer-send.ready { background: var(--primary); color: #fff; cursor: pointer; }
.vm-source-label {
  font-size: 9.5px; color: var(--fg-3); text-align: center; margin-top: 10px;
  font-family: var(--font-mono); letter-spacing: 0.04em;
}

/* Mobile bottom sheet */
.vm-mobile-chat-toggle {
  position: absolute; bottom: 16px; right: 16px; z-index: 4;
  width: 50px; height: 50px; border-radius: 999px;
  background: var(--primary); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25); color: #fff;
  animation: popup-in 0.25s cubic-bezier(0.16,1,0.3,1);
}
/* Unread badge on the button's top-right edge (app-icon style) + a subtle pulse
   on the button — the pre-loaded fleet summary is waiting in the collapsed chat. */
.vm-mobile-chat-badge {
  position: absolute; top: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 999px;
  background: var(--danger, #e0554e); border: 2px solid #fff;
}
.vm-mobile-chat-toggle.has-unseen {
  animation: popup-in 0.25s cubic-bezier(0.16,1,0.3,1), vm-chat-pulse 2.2s ease-out 0.8s infinite;
}
@keyframes vm-chat-pulse {
  0%   { box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 0 rgba(44,108,176,0.45); }
  70%  { box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 14px rgba(44,108,176,0); }
  100% { box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 0 rgba(44,108,176,0); }
}
@media (prefers-reduced-motion: reduce) {
  .vm-mobile-chat-toggle.has-unseen { animation: popup-in 0.25s cubic-bezier(0.16,1,0.3,1); }
}
.vm-mobile-sheet {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 5;
  height: 0; min-height: 0; max-height: 0; overflow: hidden;
  transition: height 0.35s cubic-bezier(0.16,1,0.3,1), min-height 0.35s cubic-bezier(0.16,1,0.3,1), max-height 0.35s cubic-bezier(0.16,1,0.3,1);
  border-radius: 0;
  box-shadow: none;
  background: var(--bg);
}
.vm-mobile-sheet.open {
  height: 60%; min-height: 300px; max-height: 75%;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
/* Dragged to full — covers the map. */
.vm-mobile-sheet.open.full { height: 94%; min-height: 94%; max-height: 94%; }
/* No transition while the finger is dragging so the sheet tracks 1:1. */
.vm-mobile-sheet.dragging { transition: none; }
.vm-sheet-handle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 8px 0 6px; background: var(--bg); flex-shrink: 0;
  width: 100%; border: none; font: inherit; color: inherit;   /* it's a <button> */
  cursor: grab; touch-action: none;   /* drag to resize without scrolling */
}
.vm-sheet-handle:active { cursor: grabbing; }
.vm-sheet-pill {
  width: 40px; height: 5px; border-radius: 999px; border: none;
  background: var(--border-strong);
}
.vm-sheet-chevron { color: var(--fg-3); }
/* Gentle "pull up" hint while at half (a few bounces on open, then rests). */
.vm-mobile-sheet.open:not(.full) .vm-sheet-chevron { animation: vm-sheet-hint 1.3s ease-in-out 3; }
@keyframes vm-sheet-hint {
  0%, 100% { transform: translateY(1px); opacity: 0.55; }
  50%      { transform: translateY(-3px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .vm-sheet-chevron { animation: none !important; } }

/* ---- Animations ---- */
@keyframes cp-pulse {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}
@keyframes cp-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes cp-hero-up {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-44px); }
}
.cp-enter { animation: cp-rise var(--dur-slow) var(--ease-out) both; }
.cp-hero-exit { animation: cp-hero-up 720ms var(--ease-out) both; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .mcp-heading { font-size: clamp(24px, 5vw, 32px) !important; }
  .mcp-desc { font-size: 15px !important; }
}
@media (max-width: 768px) {
  .tab-label-text { display: none; }
  .header-meta { display: none; }
  /* Composer chips (mid-conversation) scroll in a single row; the negative
     margin lets them bleed to the screen edge to hint scrollability. The
     blank-state hero chips keep their default wrapping (not a scroll row). */
  .composer-quick {
    flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none;
    margin-left: -24px; margin-right: -24px; padding: 0 24px;
  }
  .composer-quick::-webkit-scrollbar { display: none; }
  .composer-quick .quick-action { flex-shrink: 0; }
  /* Compact, stacked powered pill (matches the landing's mobile treatment). */
  .powered-header-badge {
    flex-direction: column; gap: 1px; align-items: center;
    height: auto; padding: 4px 9px; justify-content: center; box-sizing: border-box;
  }
  .powered-header-badge img { height: 10px; }
  .powered-label { font-size: 7.5px; }
  .mapboxgl-ctrl-group { margin: 8px !important; }
  .mapboxgl-ctrl-group button { width: 30px !important; height: 30px !important; }

  .chat-inner { padding: 20px 16px 16px; }
  .chat-inner.empty { padding: 0 16px; }
  .composer-inner { padding: 12px 16px 14px; }
  .view .quota-inner { padding: 0 16px; }  /* match input's mobile inset; .view beats the later-declared base rule */
  .msg-ai-body { max-width: 90%; }
  .msg-user-bubble { max-width: 88%; }
  .hero h1 { font-size: clamp(26px, 7vw, 36px); }
  .md-table td { white-space: normal; min-width: 80px; }
  .vm-timeline { padding: 10px 12px; gap: 8px; }
  .vm-timeline-presets { gap: 2px; }
  .vm-timeline-preset { padding: 3px 8px; font-size: 10px; }
  .vm-timeline-time { font-size: 11px; min-width: 40px; }
  /* Static "24h" chip is redundant on mobile and steals track width — hide it. */
  .vm-timeline-preset-label, .vm-timeline-divider { display: none; }
}

/* ===================== TRAIL TIMELINE ===================== */
.vm-timeline {
  position: absolute; bottom: 14px; left: 14px; right: 14px; z-index: 8;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-radius: 12px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: slide-up 0.3s cubic-bezier(0.16,1,0.3,1) both;
  pointer-events: auto;
}
.vm-timeline-play {
  width: 32px; height: 32px; border-radius: 999px; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.15s ease;
}
.vm-timeline-play:hover { transform: scale(1.08); }
.vm-timeline-play:active { transform: scale(0.96); }

.vm-timeline-track-wrap {
  flex: 1; min-width: 0; position: relative; height: 32px;
  display: flex; flex-direction: column; justify-content: center;
}
.vm-timeline-track {
  width: 100%; height: 4px; border-radius: 999px;
  position: relative; cursor: pointer;
}
.vm-timeline-segments {
  position: absolute; inset: 0; border-radius: 999px; overflow: hidden;
  pointer-events: none;
}
.vm-timeline-progress {
  position: absolute; top: 0; left: 0; height: 100%; border-radius: 999px;
  pointer-events: none;
}
.vm-timeline-handle {
  position: absolute; top: 50%; width: 14px; height: 14px;
  border-radius: 999px; transform: translate(-50%, -50%);
  cursor: grab; transition: box-shadow 0.15s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.vm-timeline-handle:active { cursor: grabbing; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

.vm-timeline-ticks {
  position: relative; left: 0; right: 0; height: 16px; margin-top: 4px;
  pointer-events: none;
}
.vm-timeline-tick {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transform: translateX(-50%);
}
.vm-timeline-tick-line {
  width: 1px; height: 6px;
}
.vm-timeline-tick-label {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.04em;
  white-space: nowrap;
}

.vm-timeline-time {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums; min-width: 44px; text-align: center;
  flex-shrink: 0;
}
.vm-timeline-presets {
  display: flex; gap: 3px; flex-shrink: 0;
}
.vm-timeline-preset {
  padding: 4px 10px; border-radius: 6px; border: none;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all 0.15s ease;
}
.vm-timeline-divider {
  width: 1px; height: 20px; flex-shrink: 0;
}
.vm-timeline-close {
  width: 28px; height: 28px; border-radius: 8px; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; line-height: 1; flex-shrink: 0;
  transition: all 0.15s ease;
}

/* Trail card (compact vessel info during trail mode) */
.vm-trail-card {
  position: absolute; top: 14px; left: 14px; z-index: 8;
  width: 240px; border-radius: 10px; border: 1px solid;
  padding: 12px 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: popup-in 0.25s cubic-bezier(0.16,1,0.3,1) both;
  font-family: var(--font-sans);
}
.vm-trail-card-name {
  font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vm-trail-card-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 3px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
}
.vm-trail-card-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px;
  margin-top: 8px; font-family: var(--font-mono); font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.vm-trail-card-label {
  font-size: 8px; letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 1px;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Trail start/end endpoint markers */
.vm-trail-endpoint {
  width: 10px; height: 10px; border-radius: 50%; position: relative;
}
.vm-trail-endpoint::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 1.5px solid; opacity: 0;
  animation: trail-pulse 2s ease-in-out infinite;
}
.vm-trail-start { background: #4DBE8A; }
.vm-trail-start::after { border-color: #4DBE8A; }
.vm-trail-end { background: #E27772; }
.vm-trail-end::after { border-color: #E27772; }
.vm-trail-glow {
  width: 0; height: 0; background: transparent;
}
.vm-trail-glow::after {
  content: ''; position: absolute; inset: -18px; border-radius: 50%;
  border: 2px solid #409BCA; opacity: 0;
  animation: trail-pulse 1.8s ease-in-out infinite;
}
.vm-trail-glow::before {
  content: ''; position: absolute; inset: -12px; border-radius: 50%;
  border: 1.5px solid #409BCA; opacity: 0;
  animation: trail-pulse 1.8s ease-in-out 0.4s infinite;
}
.vm-trail-glow.moving::after, .vm-trail-glow.moving::before { border-color: #4DBE8A; }
.vm-trail-glow.still::after, .vm-trail-glow.still::before { border-color: #E27772; }
.vm-trail-glow.gap::after, .vm-trail-glow.gap::before { border-color: #9AA7B8; }

@keyframes trail-pulse {
  0% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 0.6; }
  100% { opacity: 0; transform: scale(1.6); }
}

/* "View movement" button in popup */
.vm-popup-trail-btn {
  display: flex; align-items: center; gap: 5px; width: 100%;
  margin-top: 8px; padding: 7px 0 0; border: none; border-top: 1px solid;
  background: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  color: var(--primary); transition: opacity 0.15s ease;
}
.vm-popup-trail-btn:hover { opacity: 0.8; }

/* ===================== Access gate (gate.js) ===================== */

/* ---- Account menu ---- */
.am-wrap { position: relative; }
.am-trigger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; min-width: 40px; padding: 0; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg-2);
  transition: all var(--dur) var(--ease);
}
.am-trigger:hover, .am-trigger[aria-expanded="true"] { background: var(--surface-2); }
.am-trigger[aria-expanded="true"] { border-color: var(--border-strong); }
.am-trigger.signed-in { padding: 0 10px 0 4px; border-radius: 999px; }
.am-avatar {
  width: 26px; height: 26px; border-radius: 999px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}
.am-avatar.lg { width: 34px; height: 34px; }
.am-name { font-family: var(--font-sans); font-size: 13.5px; font-weight: 600; color: var(--fg); }
.am-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 252px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); padding: 10px;
  animation: slide-up 0.16s var(--ease-out) both;
}
.am-panel[hidden] { display: none; }
.am-divider { border-top: 1px solid var(--border); margin: 8px 0; }
.am-eyebrow {
  font-family: var(--font-sans); font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--fg-3); padding: 2px 6px 8px;
}
.am-account { display: flex; align-items: center; gap: 10px; padding: 4px 6px 8px; }
.am-btn {
  width: 100%; padding: 11px; border-radius: var(--r-md); border: none; cursor: pointer;
  background: var(--primary); color: #fff;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  transition: background var(--dur) var(--ease);
}
.am-btn:hover { background: var(--primary-hover); }
.am-btn.ghost { margin-top: 8px; background: var(--surface); color: var(--fg); border: 1px solid var(--border-strong); }
.am-btn.ghost:hover { background: var(--surface-2); }
.am-nav { display: flex; flex-direction: column; }
.am-navlink {
  display: block; padding: 9px 8px; border-radius: var(--r-md); text-decoration: none;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; color: var(--fg);
  transition: background var(--dur) var(--ease);
}
.am-navlink:hover { background: var(--surface-2); }
.am-theme-segment {
  display: flex; gap: 4px; padding: 4px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border); margin: 0 2px;
}
.am-theme-segment button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--fg-3);
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  transition: all var(--dur) var(--ease);
}
.am-theme-segment button.active {
  border-color: var(--border); background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow-xs);
}
.am-theme-segment button.active i { color: var(--primary); }

/* ---- Modal scaffold ---- */
@keyframes gate-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes gate-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes gate-spin { to { transform: rotate(360deg); } }
@keyframes gate-tick-pop { 0% { transform: scale(0.4); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes gate-tick-draw { 0% { stroke-dashoffset: 30; } 35% { stroke-dashoffset: 0; } 70% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 30; } }
.gate-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: color-mix(in srgb, var(--navy-950) 52%, transparent);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: gate-fade-in 0.2s ease both; font-family: var(--font-sans);
}
.gate-overlay.mobile { align-items: flex-end; padding: 0; }
.gate-modal {
  width: 100%; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: slide-up 0.3s var(--ease-out) both;
}
.gate-overlay.mobile .gate-modal { border-radius: 18px 18px 0 0; animation-name: gate-sheet-up; }
/* Mobile bottom sheet: keep the header pinned while the long form scrolls, and
   clear the home indicator so the submit button stays tappable. */
.gate-overlay.mobile .gate-header {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
}
.gate-overlay.mobile .gate-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.gate-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 13px; }
.gate-header-text { flex: 1; min-width: 0; }
.gate-title { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg); }
.gate-subtitle { margin-top: 4px; font-size: 13px; line-height: 1.5; color: var(--fg-2); }
.gate-close {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--fg-3);
}
.gate-body { padding: 18px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.gate-two { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.gate-two.single { grid-template-columns: 1fr; }
.gate-field { display: block; }
.gate-label {
  display: block; margin-bottom: 6px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500; letter-spacing: 0.01em; color: var(--fg-2);
}
.gate-label .req { color: var(--fg-3); }
.gate-field input, .gate-field textarea, .gate-field select {
  width: 100%; box-sizing: border-box; font-family: var(--font-sans); font-size: 14px;
  color: var(--fg); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 10px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.gate-field input.mono { font-family: var(--font-mono); }
.gate-field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.gate-field input:focus, .gate-field textarea:focus, .gate-field select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.gate-field input.invalid { border-color: var(--danger); }
.gate-field input.invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.gate-select { position: relative; display: block; }
.gate-select select { padding-right: 34px; appearance: none; -webkit-appearance: none; cursor: pointer; }
.gate-select select.placeholder { color: var(--fg-3); }
.gate-select i, .gate-select svg {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none; display: flex; color: var(--fg-3);
}
.gate-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.gate-error {
  display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--danger);
}
.gate-error[hidden] { display: none; }
.gate-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 18px; border-radius: var(--r-md); border: none; cursor: pointer;
  background: var(--primary); color: #fff;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  transition: background .15s, opacity .15s;
}
.gate-btn:hover:not(:disabled) { background: var(--primary-hover); }
.gate-btn:disabled { background: var(--border-strong); opacity: 0.7; cursor: not-allowed; }
.gate-btn.inline { width: auto; padding: 12px 20px; }
.gate-btn.ghost { background: var(--surface); color: var(--fg); border: 1px solid var(--border-strong); }
.gate-btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.gate-consent {
  font-family: var(--font-sans); font-size: 12px; color: var(--fg-3);
  text-align: center; line-height: 1.5;
}
.gate-consent a { color: var(--fg-2); text-decoration: underline; text-underline-offset: 2px; }
.gate-consent a:hover { color: var(--primary); }
.gate-confirm { padding: 32px 24px 28px; text-align: center; }
.gate-tick {
  width: 52px; height: 52px; border-radius: 999px; margin: 0 auto;
  background: var(--success-soft); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  animation: gate-tick-pop 0.7s var(--ease-out) both;
}
.gate-tick svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: gate-tick-draw 2.4s var(--ease-out) 0.35s infinite; }
@media (prefers-reduced-motion: reduce) {
  .gate-tick svg path { animation: none !important; stroke-dashoffset: 0 !important; }
}
.gate-confirm-title { margin-top: 16px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg); text-wrap: balance; }
.cp-nowrap { white-space: nowrap; }
.gate-confirm-sub { margin-top: 8px; font-size: 13.5px; line-height: 1.6; color: var(--fg-2); }
.gate-confirm-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }

/* ---- Locked Vessel Map ---- */
@keyframes vm-lane-move { from { left: -4%; } to { left: 104%; } }
@keyframes vm-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.vm-locked {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.vm-locked-chart { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.7; filter: grayscale(0.2); }
[data-theme="dark"] .vm-locked-chart { opacity: 0.5; }
.vm-locked-vessels { position: absolute; inset: 0; }
.vm-locked-lane { position: absolute; left: 0; animation: vm-lane-move linear infinite; }
.vm-locked-bob { animation: vm-bob ease-in-out infinite; }
.vm-locked-bob svg { display: block; filter: drop-shadow(0 0 7px color-mix(in srgb, var(--primary) 55%, transparent)); }
.vm-locked-scrim {
  position: absolute; inset: 0;
  background: radial-gradient(120% 92% at 50% 46%, rgba(251,252,253,0.4) 0%, rgba(251,252,253,0.92) 78%);
}
[data-theme="dark"] .vm-locked-scrim {
  background: radial-gradient(120% 92% at 50% 46%, rgba(10,21,38,0.34) 0%, rgba(10,21,38,0.84) 78%);
}
.vm-locked-cta { position: relative; max-width: 460px; text-align: center; padding: 0 24px; animation: slide-up 0.4s var(--ease-out) both; }
.vm-locked-eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-3);
}
.vm-locked-cta h2 {
  margin: 10px 0 0; font-family: var(--font-sans); font-weight: 600;
  font-size: 30px; letter-spacing: -0.025em; color: var(--fg); text-wrap: balance;
}
.vm-locked-cta p {
  margin: 12px auto 0; max-width: 400px; font-family: var(--font-sans); font-size: 15px;
  line-height: 1.6; color: var(--fg-2); text-wrap: balance;
}
.vm-locked-cta .gate-btn { margin-top: 26px; }
@media (max-width: 767px) { .vm-locked-cta h2 { font-size: 24px; } }

/* ---- MCP tab gate additions ---- */
.mcp-eyebrow {
  display: inline-block;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--fg-3); margin-bottom: 0;
}
.mcp-gate-cta { margin: 26px 0 0; }

/* ---- Daily quota banner ---- */
/* Full-width band above the composer divider; the inner block centres the
   banner so it lines up exactly with the composer input. (Centring on the
   flex item itself would shrink-wrap it — auto margins on a flex child.) */
.quota-inner { max-width: 760px; margin: 0 auto; padding: 0 24px; }
/* Message text stays dark for readability; only the icon (and border/bg)
   carries the state colour — consistent across all three states. */
.quota-banner {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 10px; padding: 10px 14px; border-radius: var(--r-md);
  font-family: var(--font-sans); font-size: 13.5px; line-height: 1.4; text-align: left;
  color: var(--fg);
}
.quota-banner svg { flex-shrink: 0; }
.quota-reset {
  margin-left: auto; flex-shrink: 0; padding: 0; background: none; border: none;
  cursor: pointer; font-family: var(--font-mono); font-size: 11.5px;
  text-decoration: underline; color: var(--fg-3);
}
.quota-reset:hover { color: var(--fg-2); }
.quota-banner[hidden] { display: none; }
.quota-banner.neutral {
  background: var(--surface-2); border: 1px solid var(--border);
}
.quota-banner.neutral svg { color: var(--fg-3); }
.quota-banner.warn {
  background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
}
.quota-banner.warn svg { color: var(--warning); }
.quota-banner.danger {
  background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.quota-banner.danger svg { color: var(--danger); }

/* ============================================================
   Premium gate (unlocked map: trail + map-chat) + simulated clip
   ============================================================ */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sim-scrub { from { transform: scaleX(0); } to { transform: scaleX(1); } }
/* Query bubble slides/fades in, holds, then the reply follows — one 7s loop. */
@keyframes mc-query {
  0%, 8% { opacity: 0; transform: translateY(-4px); }
  16%, 88% { opacity: 1; transform: translateY(0); }
  96%, 100% { opacity: 0; transform: translateY(-4px); }
}
@keyframes mc-reply {
  0%, 46% { opacity: 0; transform: translateY(-4px); }
  56%, 88% { opacity: 1; transform: translateY(0); }
  96%, 100% { opacity: 0; transform: translateY(-4px); }
}

.ds-eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--primary);
}

/* Research-preview cue on the vessel card's "View movement" button (free tier) */
.vm-popup-trail-btn.premium { color: #378ADD; }

/* Free-tier map-chat "Find out more →" */
.vm-preview-more {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 8px;
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; color: var(--primary);
}
.vm-preview-more:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---- Gate modal shell ---- */
.pg { position: relative; }
/* Video and body share the same horizontal inset so the borders read even. */
.pg-video { padding: 12px 24px 0; }
/* Reuses .gate-close (same look as the sign-in / request modals) and only adds
   the floating position + a shadow so it reads over the dark clip. */
.pg-close {
  position: absolute; top: 16px; right: 16px; z-index: 3; box-shadow: var(--shadow-md);
}
.pg-close:hover { background: var(--surface-2); color: var(--fg-2); }
.pg-body { padding: 16px 24px 20px; }
.pg-title { margin-top: 8px; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg); }
.pg-value { margin-top: 6px; font-size: 14px; line-height: 1.5; color: var(--fg-2); text-wrap: pretty; }
.pg-points { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.pg-point { display: flex; align-items: flex-start; gap: 9px; }
.pg-point svg { flex-shrink: 0; margin-top: 1px; color: var(--primary); }
.pg-point span { font-size: 13.5px; line-height: 1.45; color: var(--fg); text-wrap: pretty; }
.pg-cta { margin-top: 18px; }
.pg-try {
  margin-top: 8px; background: var(--surface); color: var(--fg); border: 1px solid var(--border-strong);
}
.pg-try:hover:not(:disabled) { background: var(--surface-2); }
@media (max-width: 767px) {
  .pg-video { padding: 12px 18px 0; }
  .pg-body { padding: 16px 18px 22px; }
}

/* ---- Simulated proof clip ---- */
/* Cap the hero so the modal fits without scrolling on normal viewports; the SVG
   crops (preserveAspectRatio slice) rather than distorting when height is capped. */
.pg-sim {
  /* Cap the clip so the video + copy fit the modal without a scrollbar: reserve
     ~400px for the body (eyebrow/title/value/points/CTAs) out of the viewport. */
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  max-height: clamp(130px, calc(92dvh - 400px), 380px);
  border-radius: var(--r-lg); overflow: hidden;
  background: linear-gradient(160deg, #0A1526 0%, #14263F 100%); border: 1px solid rgba(123,168,206,0.28);
}
.pg-sim-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Real recording: one 16:9 clip fills the slot at any size. */
.pg-video-real { background: #0A1526; }
/* contain (not cover) so a non-16:9 recording keeps its full frame — the video
   card's dark background shows as a thin letterbox rather than cropping the
   scrubber/card at the edges. A true 16:9 clip fills with no bars. */
.pg-video-el { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
/* Inline clip uses our custom controls — suppress iOS Safari's native
   start-playback button / control panel so it doesn't double up + steal taps.
   The fullscreen (.big) video keeps native `controls` for mobile playback. */
.pg-sim:not(.big) .pg-video-el::-webkit-media-controls-start-playback-button,
.pg-sim:not(.big) .pg-video-el::-webkit-media-controls-overlay-play-button,
.pg-sim:not(.big) .pg-video-el::-webkit-media-controls-panel,
.pg-sim:not(.big) .pg-video-el::-webkit-media-controls { display: none !important; -webkit-appearance: none; }
/* Real-video full-screen button — the only overlay control (the clip shows the
   app's own play/timeline). Corner-placed, above the tap-to-play cover. */
.pg-video-expand {
  position: absolute; bottom: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: #fff;
  border: 1px solid rgba(255,255,255,0.25); background: rgba(10,21,38,0.55);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.pg-video-cover {
  position: absolute; inset: 0; z-index: 1; border: none; cursor: pointer;
  background: rgba(10,21,38,0.35); display: flex; align-items: center; justify-content: center;
}
/* the class's display:flex beats the UA [hidden] rule, so hide it explicitly */
.pg-video-cover[hidden] { display: none; }
.pg-video-cover-btn {
  width: 52px; height: 52px; border-radius: 999px; background: rgba(64,155,202,0.92); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.pg-sim.paused .pg-sim-scrub,
.pg-sim.paused .pg-sim-q,
.pg-sim.paused .pg-sim-a { animation-play-state: paused; }
.pg-sim-bubbles {
  position: absolute; top: 10px; left: 10px; right: 52px;
  display: flex; flex-direction: column; gap: 5px; pointer-events: none;
}
.pg-sim-q {
  align-self: flex-end; font-family: var(--font-sans); font-size: 9.5px; font-weight: 600; color: #fff;
  background: rgba(55,138,221,0.92); border-radius: 10px 10px 3px 10px; padding: 4px 9px;
  opacity: 0; animation: mc-query 7s linear infinite;
}
.pg-sim-a {
  align-self: flex-start; font-family: var(--font-sans); font-size: 9.5px; font-weight: 500; color: #E8F2FB;
  background: rgba(10,21,38,0.6); border: 1px solid rgba(64,155,202,0.4);
  border-radius: 10px 10px 10px 3px; padding: 4px 9px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; animation: mc-reply 7s linear infinite;
}
.pg-sim-badge {
  position: absolute; bottom: 30px; left: 12px;
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #7BA8CE;
  background: rgba(10,21,38,0.5); border-radius: 999px; padding: 3px 8px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.pg-sim-controls {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px 10px;
  display: flex; align-items: center; gap: 10px;
}
.pg-sim-play {
  width: 26px; height: 26px; border-radius: 999px; border: none; cursor: pointer; flex-shrink: 0;
  background: rgba(64,155,202,0.9); color: #fff; display: flex; align-items: center; justify-content: center;
}
.pg-sim-track { flex: 1; height: 3px; border-radius: 999px; background: rgba(123,168,206,0.25); overflow: hidden; }
.pg-sim-scrub {
  height: 100%; background: #409BCA; border-radius: 999px; transform-origin: left;
  animation: sim-scrub 7s linear infinite;
}
.pg-sim-expand {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; cursor: pointer; color: #AFC6DD;
  border: 1px solid rgba(123,168,206,0.3); background: rgba(10,21,38,0.5);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
/* Fullscreen expand */
.pg-sim-fs {
  position: fixed; inset: 0; z-index: 120; background: rgba(6,13,24,0.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 5vw; animation: fade-in 0.2s ease both;
}
.pg-sim-fs-inner { width: min(1200px, 92vw); position: relative; }
/* Fullscreen: size to the viewport (overriding the modal's short max-height cap),
   so it's tall on desktop and fills the width when a phone is rotated to landscape. */
.pg-sim.big { border-radius: 14px; aspect-ratio: 16 / 9; max-height: 86vh; }
.pg-sim.big .pg-sim-badge { bottom: 12px; }
.pg-sim-fs-close {
  position: absolute; top: -14px; right: -14px; width: 34px; height: 34px; border-radius: 999px;
  border: none; cursor: pointer; background: var(--surface); box-shadow: var(--shadow-md); color: var(--fg-2);
  display: flex; align-items: center; justify-content: center;
}
@media (prefers-reduced-motion: reduce) {
  .pg-sim-scrub, .pg-sim-q, .pg-sim-a { animation: none !important; }
  .pg-sim-svg animate, .pg-sim-svg animateMotion { display: none; }
}
