:root {
  --bg: #0b1118;
  --panel: rgba(13, 20, 29, 0.94);
  --line: #223041;
  --text: #e8eef4;
  --muted: #8a99aa;
  --accent: #4da3ff;
  --gold: #ffd166;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
a { color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }

.top { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 60px; display: flex; gap: 10px;
  align-items: flex-start; z-index: 3; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  font-weight: 700; white-space: nowrap; }
.logo { color: var(--accent); }
.live { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 13px;
  font-weight: 700; white-space: nowrap; color: var(--text); letter-spacing: 0.02em; }
.live b { font-variant-numeric: tabular-nums; }
.live i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff5454; margin-right: 4px;
  vertical-align: 1px; box-shadow: 0 0 0 0 rgba(255, 84, 84, 0.7); animation: livepulse 1.6s infinite; }
@keyframes livepulse { 70% { box-shadow: 0 0 0 7px rgba(255, 84, 84, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 84, 84, 0); } }
@media (prefers-reduced-motion: reduce) { .live i { animation: none; } }
.ai-cta { background: var(--accent); color: #04121d; border-radius: 12px; padding: 9px 13px; font-weight: 800; font-size: 14px;
  text-decoration: none; white-space: nowrap; }
.ai-cta:hover { filter: brightness(1.1); }
.searchwrap { position: relative; flex: 1; max-width: 420px; }
#search { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); outline: none; font-size: 16px; }
#search:focus { border-color: var(--accent); }
.results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; max-height: 50vh; overflow: auto; }
.results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.results li:hover, .results li.active { background: #16222f; }
.results .muted { margin-left: auto; font-size: 12px; }

.banner { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 56px); left: 12px; max-width: calc(100% - 380px);
  background: rgba(255, 209, 102, 0.14); border: 1px solid rgba(255, 209, 102, 0.45); color: var(--gold);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; z-index: 2; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }

.legend { position: fixed; left: 12px; bottom: 40px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px; font-size: 12px; z-index: 2; display: grid; grid-template-columns: auto auto; gap: 3px 12px; }
.legend button { background: none; border: 0; padding: 0; display: flex; align-items: center; gap: 6px; color: var(--text); text-align: left; }
.legend button.off { opacity: 0.35; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.count { position: fixed; right: 12px; bottom: 40px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 10px; font-size: 12px; color: var(--muted); z-index: 2; }

.card { position: fixed; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 56px); width: 340px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; z-index: 4;
  backdrop-filter: blur(8px); }
.card-head { display: flex; gap: 10px; align-items: center; padding-right: 26px; }
.card-head .dot { width: 14px; height: 14px; }
.card h2 { margin: 0; font-size: 19px; line-height: 1.2; word-break: break-word; }
.close { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 24px; color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.card-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.btn { flex: 1; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: #04111f; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.on { background: transparent; color: var(--accent); }
.muted { color: var(--muted); }
/* Server-rendered summary on /ship/<mmsi>; the map script swaps it for the card. */
.ssr { position: fixed; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 56px); width: 340px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; z-index: 3; }
.ssr h1 { margin: 0 0 6px; font-size: 19px; }
.ssr p { margin: 0 0 8px; font-size: 14px; line-height: 1.4; }
body.embed .ssr { display: none; }
.small { font-size: 12px; }

.foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  font-size: 11px; color: var(--muted); background: linear-gradient(transparent, rgba(11, 17, 24, 0.9)); z-index: 1;
  display: flex; gap: 8px; flex-wrap: wrap; }
.foot .sep { opacity: 0.5; }

.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-bottom-right { bottom: 70px; }

@media (max-width: 640px) {
  .top { right: 12px; flex-direction: column; }
  .brand, .live { display: none; }
  .ai-cta { align-self: flex-end; padding: 6px 11px; font-size: 13px; border-radius: 999px; }
  .searchwrap { max-width: none; width: 100%; }
  .banner { top: calc(max(12px, env(safe-area-inset-top)) + 50px); left: 12px; right: 12px; max-width: none; font-size: 12px;
    white-space: normal; text-align: center; border-radius: 12px; }
  /* Bottom up: footer (two lines), legend, map attribution, ship count. */
  .legend { bottom: calc(72px + env(safe-area-inset-bottom)); grid-template-columns: repeat(4, auto); font-size: 11px; left: 8px; right: 8px; }
  .maplibregl-ctrl-bottom-right { bottom: calc(128px + env(safe-area-inset-bottom)); }
  .count { bottom: calc(176px + env(safe-area-inset-bottom)); right: 8px; }
  .card { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 60vh; overflow: auto; }
  .ssr { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 60vh; overflow: auto; z-index: 5; }
  .maplibregl-ctrl-top-right { display: none; }
}

.install { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 6;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 40px 12px 14px; font-size: 14px; }
.install .close { top: 4px; }

.welcome { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); width: min(460px, calc(100% - 24px)); z-index: 7;
  background: rgba(13, 20, 30, 0.96); border: 1px solid var(--accent); border-radius: 16px; padding: 16px 18px 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.welcome h2 { margin: 6px 0 6px; font-size: 20px; line-height: 1.25; }
.welcome p { margin: 6px 0; font-size: 14px; }
.welcome .close { top: 8px; right: 8px; }
.welcome-kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--muted); }
.welcome-kicker i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ff5454; margin-right: 5px; vertical-align: 1px; }
.welcome-q { font-size: 16px !important; font-weight: 700; color: var(--accent); min-height: 2.6em; transition: opacity 0.3s; }
.welcome-actions { display: flex; gap: 8px; margin: 10px 0 6px; }
.welcome-actions .btn { flex: 1; text-align: center; text-decoration: none; }
.ask-ai { display: block; margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; }
.ask-ai:hover { text-decoration: underline; }
@media (max-width: 640px) { .welcome { bottom: calc(12px + env(safe-area-inset-bottom)); } }

/* Inside the iPhone app the native screens provide search, card and footer. */
body.embed .top, body.embed .card, body.embed .foot, body.embed .count, body.embed .banner, body.embed .install, body.embed .welcome { display: none !important; }
body.embed .legend { bottom: 12px; }
.noscript { position: relative; z-index: 9; max-width: 640px; margin: 80px auto; padding: 16px; }
