:root {
  --night: #06121F;
  --panel: rgba(9, 25, 42, .92);
  --rule: #1E3A57;
  --ink: #DCE8F3;
  --dim: #8AA3BB;
  --vhf: #00F0FF;
  --mf: #FFC21A;
  --hf: #FF3DF5;
  --ntx: #3DFF7A;
  --hull: #E0483E;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--vhf); outline-offset: 2px; }

.leaflet-container { background: #020E2E; font: inherit; }
.leaflet-base-pane { filter: grayscale(1) sepia(1) hue-rotate(188deg) saturate(3.2) brightness(.62) contrast(1.1); }
.leaflet-labels-pane { pointer-events: none; }
.leaflet-control-attribution { background: rgba(6,18,31,.7) !important; color: var(--dim) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--ink) !important; }
.leaflet-bar a { background: rgba(9,25,42,.92) !important; color: var(--ink) !important; border-color: var(--rule) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #0C2135; color: var(--ink); border: 1px solid var(--rule); box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 13.5px; min-width: 220px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--dim); }

.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.chart { position: relative; flex: 1 1 auto; min-height: 0; }
#map { position: absolute; inset: 0; background: #020E2E; }
.boot-error { position: absolute; z-index: 900; left: 10px; right: 10px; bottom: 10px;
  background: #3A1016; border: 1px solid #FF6B6B; border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }

/* info list (bottom) */
.info { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; padding: 0 2px 6px; margin-bottom: 6px; border-bottom: 1px solid var(--rule); }
.cell { display: flex; flex-direction: column; min-width: 0; }
.cell.wide { grid-column: 1 / -1; margin-top: 4px; }
.cell .k { font-size: 11px; color: var(--dim); }
.cell .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .v small { font-size: 11.5px; font-weight: 400; color: var(--dim); margin-left: 6px; }
.ntx { position: relative; overflow: hidden; padding-top: 3px; min-height: 28px; font-size: 13px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%); }
.ntx-track { display: inline-flex; gap: 6px; white-space: nowrap; will-change: transform; }
.ntx.run .ntx-track { animation: ticker var(--dur, 20s) linear infinite; }
.ntx.run:active .ntx-track, .ntx.run:hover .ntx-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(var(--shift)); } }
.ntx-item { flex: none; display: inline-flex; gap: 6px; align-items: center; padding: 2px 9px 2px 2px; border-radius: 8px; background: rgba(61,255,122,.08); }
.ntx-item b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; background: rgba(61,255,122,.22); color: var(--ntx); font-size: 14px; text-shadow: 0 0 6px rgba(61,255,122,.8); }
.ntx-item small { color: var(--dim); }
.ntx .none { color: var(--dim); }
.ntx .more { position: absolute; right: 0; top: 5px; color: var(--ntx); font-size: 14px; pointer-events: none; }

/* bottom panel */
.dock { flex: none; background: #0A1D31; border-top: 1px solid var(--rule); padding: 8px 10px calc(var(--safe-b) + 6px); box-shadow: 0 -6px 18px rgba(0,0,0,.35); }
.counts .cap { font-size: 11px; color: var(--dim); }
.layers { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 0 6px; }
.chip { flex: 0 0 auto; text-shadow: 0 0 8px currentColor; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 20px;
  border: 1px solid var(--rule); background: transparent; color: var(--dim); font-size: 13px; cursor: pointer; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.chip b { font-variant-numeric: tabular-nums; color: var(--ink); }
.chip.vhf { color: var(--vhf); } .chip.mf { color: var(--mf); } .chip.hf { color: var(--hf); } .chip.ntx { color: var(--ntx); }
.chip[aria-pressed="false"] { opacity: .4; }
.pos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.coord { display: flex; align-items: center; gap: 3px; background: #061424; border: 1px solid var(--rule); border-radius: 10px; padding: 3px 4px 3px 8px; min-width: 0; }
.coord:focus-within { border-color: var(--vhf); }
.coord .lbl { font-size: 11px; color: var(--dim); margin-right: 2px; }
.coord input { min-width: 0; height: 38px; background: transparent; border: 0; font-size: 18px; font-variant-numeric: tabular-nums; text-align: center; padding: 0; }
.coord input:focus { outline: none; background: rgba(56,211,230,.08); border-radius: 6px; }
.coord .deg { width: 2.4em; } .coord .min { width: 3.2em; }
.coord .u { color: var(--dim); font-size: 16px; }
.hemi { margin-left: auto; flex: none; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--vhf); background: rgba(56,211,230,.12); color: var(--vhf); font-weight: 800; font-size: 16px; cursor: pointer; }
.acts { grid-column: 1 / -1; display: grid; grid-template-columns: 46px 1fr; gap: 6px; }
.acts .icon, .acts .go { height: 44px; border-radius: 10px; border: 1px solid var(--rule); background: #0F2A44; cursor: pointer; }
.acts .icon svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; }
.acts .go { background: var(--vhf); border-color: var(--vhf); color: #04202A; font-weight: 700; font-size: 15px; }
.msg { margin: 6px 2px 0; font-size: 12px; color: var(--dim); }
.msg.err { color: #FF8A8A; }
.copy { margin: 2px 2px 0; font-size: 10px; color: var(--dim); opacity: .75; }

/* ship */
.ship-ic { pointer-events: auto; }
.ship { width: 64px; height: 64px; position: relative; filter: drop-shadow(0 3px 6px rgba(0,0,0,.55)); cursor: grab; }
.ship svg { width: 64px; height: 64px; overflow: visible; }
.ship .boat { transform-origin: 32px 44px; animation: rock 3.2s ease-in-out infinite; }
.ship .puff { animation: puff 2.4s ease-out infinite; opacity: 0; }
.ship .puff.p2 { animation-delay: .8s; } .ship .puff.p3 { animation-delay: 1.6s; }
.ship .wave { animation: wave 1.6s linear infinite; }
.ship .wave.w2 { animation-delay: -.8s; }
@keyframes rock { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-2.5px) rotate(3deg); } }
@keyframes puff { 0% { opacity: .9; transform: translate(0,0) scale(.5); } 100% { opacity: 0; transform: translate(9px,-16px) scale(1.4); } }
@keyframes wave { 0% { transform: translateX(-6px); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateX(6px); opacity: 0; } }
.ship-ic.moved .ship { animation: hop .5s ease-out; }
@keyframes hop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* station markers */
.st-ic { width: 20px; height: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5px; padding: 2.5px;
  border-radius: 6px; background: #020A1C; border: 2px solid #FFFFFF; box-shadow: 0 0 0 2px rgba(255,255,255,.15), 0 0 12px 3px var(--glow, rgba(0,240,255,.7)); }
.st-ic i { border-radius: 2px; }
.st-ic i.v { background: var(--vhf); box-shadow: 0 0 5px var(--vhf); } .st-ic i.f { background: var(--mf); box-shadow: 0 0 5px var(--mf); } .st-ic i.h { background: var(--hf); box-shadow: 0 0 5px var(--hf); }
.st-ic i.o { background: transparent; }
.ntx-ic { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #021A0C;
  border: 2px solid var(--ntx); color: var(--ntx); font-weight: 800; font-size: 13px; text-shadow: 0 0 6px var(--ntx); box-shadow: 0 0 12px 3px rgba(61,255,122,.6); }

/* popup */
.pop h4 { margin: 0; font-size: 16px; }
.pop .sub { color: var(--dim); font-size: 12px; margin: 2px 0 8px; }
.pop .mmsi { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px; background: #061424;
  border-radius: 10px; margin-bottom: 8px; }
.pop .mmsi span { color: var(--dim); font-size: 12px; }
.pop .mmsi b { font-size: 18px; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.pop table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pop td { padding: 5px 4px; border-top: 1px solid var(--rule); vertical-align: top; }
.pop td:first-child { font-weight: 700; width: 44px; }
.pop td.vhf { color: var(--vhf); } .pop td.mf { color: var(--mf); } .pop td.hf { color: var(--hf); }
.pop .ok { color: #7CE38B; font-size: 11.5px; } .pop .no { color: var(--dim); font-size: 11.5px; }
.pop .foot { margin-top: 8px; font-size: 11px; color: var(--dim); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 1fr 390px; }
  .chart { grid-column: 1; }
  .dock { grid-column: 2; border-top: 0; border-left: 1px solid var(--rule); overflow-y: auto; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { .ship .boat, .ship .puff, .ship .wave { animation: none; } .ship .puff { opacity: 0; } }
