:root {
  --sea-950: #062c33;
  --sea-900: #0b3c43;
  --sea-800: #12535a;
  --sea-700: #176b70;
  --sea-accent: #0e8f7c;
  --sea-accent-soft: #d8f2eb;
  --surface: #f5f8f7;
  --surface-raised: #ffffff;
  --ink: #102a2d;
  --muted: #5d7374;
  --border: #d5e1df;
  --map-panel: rgb(255 255 255 / 0.96);
  --shadow: 0 16px 46px rgb(7 47 51 / 0.14);
  --radius: 14px;
  --header-height: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #092f35;
    --surface-raised: #104249;
    --ink: #e4f1ef;
    --muted: #aec5c2;
    --border: #276066;
    --map-panel: rgb(9 47 53 / 0.97);
    --sea-accent-soft: #124c46;
    --shadow: 0 16px 46px rgb(0 0 0 / 0.26);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-width: 320px;
  overflow: hidden;
  color: var(--ink);
  background: var(--surface);
  font-family: Arial, Helvetica, sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--sea-accent); outline-offset: 2px; }

.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 1000;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  color: #fff;
  background: var(--sea-950);
}
.skip-link:focus { top: 0.75rem; }

.sea-header {
  position: relative;
  z-index: 700;
  height: var(--header-height);
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  background: var(--surface-raised);
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  gap: 1rem;
}
.sea-brand { display: inline-flex; align-items: center; gap: 0.6rem; color: inherit; text-decoration: none; font-size: 0.96rem; font-weight: 800; letter-spacing: 0.08em; white-space: nowrap; }
.sea-brand img { width: 30px; height: 30px; }
.sea-brand b { color: var(--sea-accent); font-weight: 800; }
.sea-nav { display: flex; align-items: center; justify-content: center; gap: 0.15rem; height: 100%; }
.sea-nav a { display: inline-flex; align-items: center; height: 100%; padding: 0 0.75rem; border-bottom: 2px solid transparent; color: var(--muted); font-size: 0.88rem; font-weight: 700; text-decoration: none; }
.sea-nav a:hover, .sea-nav a.active { border-bottom-color: var(--sea-accent); color: var(--ink); }
.refresh-button { justify-self: end; min-width: 5.5rem; padding: 0.55rem 0.85rem; border: 1px solid var(--sea-accent); border-radius: 999px; color: #fff; background: var(--sea-accent); font-size: 0.82rem; font-weight: 800; white-space: nowrap; transition: transform 160ms ease, background 160ms ease; }
.refresh-button:hover { background: #087261; }
.refresh-button:active { transform: translateY(1px) scale(0.98); }

.sea-workspace { min-height: calc(100dvh - var(--header-height)); display: grid; grid-template-columns: minmax(0, 1fr) 390px; }
.map-stage { position: relative; min-height: calc(100dvh - var(--header-height)); overflow: hidden; background: var(--sea-800); }
#map { position: absolute; inset: 0; z-index: 250; }
.map-scrim { pointer-events: none; position: absolute; inset: 0; z-index: 200; background: linear-gradient(180deg, rgb(6 44 51 / 0.7) 0%, transparent 22%, transparent 74%, rgb(6 44 51 / 0.48) 100%); }
.map-heading { position: absolute; z-index: 300; top: 1.35rem; left: 1.5rem; max-width: 320px; color: #fff; pointer-events: none; text-shadow: 0 2px 14px rgb(6 44 51 / 0.88); }
.map-kicker, .panel-kicker { margin: 0 0 0.35rem; color: var(--sea-accent); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.map-heading .map-kicker { color: #8ee6d5; }
.map-heading h1 { margin: 0; font-size: clamp(1.65rem, 2.25vw, 2.35rem); line-height: 1.02; letter-spacing: -0.045em; }
.map-controls { position: absolute; z-index: 300; top: 6.25rem; left: 1.5rem; padding: 0.35rem; border: 1px solid rgb(255 255 255 / 0.2); border-radius: var(--radius); background: rgb(6 44 51 / 0.82); backdrop-filter: blur(12px); display: flex; align-items: center; gap: 0.2rem; }
.layer-label { padding: 0 0.5rem; color: rgb(255 255 255 / 0.68); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.layer-button { border: 0; border-radius: 9px; padding: 0.45rem 0.6rem; color: #d9ece9; background: transparent; font-size: 0.78rem; font-weight: 700; transition: background 160ms ease, color 160ms ease, transform 160ms ease; }
.layer-button:hover { background: rgb(255 255 255 / 0.1); }
.layer-button.active { color: var(--sea-950); background: #fff; }
.layer-button:active { transform: scale(0.98); }
.map-status { position: absolute; z-index: 300; bottom: 1.3rem; right: 1.4rem; max-width: 260px; padding: 0.55rem 0.7rem; border: 1px solid rgb(255 255 255 / 0.18); border-radius: 10px; color: #eef9f7; background: rgb(6 44 51 / 0.84); font-size: 0.75rem; font-weight: 600; }
.map-legend { position: absolute; z-index: 300; bottom: 1.25rem; left: 1.25rem; padding: 0.55rem 0.75rem; border: 1px solid rgb(255 255 255 / 0.18); border-radius: 10px; color: #e8f6f3; background: rgb(6 44 51 / 0.84); font-size: 0.72rem; display: flex; gap: 0.8rem; }
.map-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.legend-mark { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.speed-still { background: #94a3b8; }.speed-slow { background: #f1b94c; }.speed-fast { background: #0e8f7c; }

.sea-panel { position: relative; z-index: 500; height: calc(100dvh - var(--header-height)); overflow-y: auto; padding: 1.35rem; border-left: 1px solid var(--border); background: var(--map-panel); box-shadow: var(--shadow); }
.panel-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.panel-topline h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.035em; }
.panel-close { display: none; border: 0; border-radius: 8px; padding: 0.4rem 0.55rem; color: var(--muted); background: transparent; font-size: 0.77rem; font-weight: 700; }
.panel-close:hover { background: var(--sea-accent-soft); color: var(--ink); }
.vessel-search { display: grid; gap: 0.35rem; margin-top: 1.2rem; color: var(--muted); font-size: 0.77rem; font-weight: 700; }
.vessel-search input { width: 100%; padding: 0.72rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; outline: none; color: var(--ink); background: var(--surface-raised); }
.vessel-search input::placeholder { color: var(--muted); opacity: 0.75; }
.vessel-search input:focus { border-color: var(--sea-accent); }
.search-results { min-height: 0; max-height: 158px; overflow-y: auto; }
.search-result { width: 100%; padding: 0.66rem 0; border: 0; border-bottom: 1px solid var(--border); color: var(--ink); background: transparent; text-align: left; }
.search-result:hover { color: var(--sea-accent); }.search-result strong, .search-result span { display: block; }.search-result strong { font-size: 0.84rem; }.search-result span { margin-top: 0.15rem; color: var(--muted); font-size: 0.72rem; }
.overview-grid { margin: 1.1rem 0 1.2rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.metric { min-height: 76px; padding: 0.65rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); display: flex; flex-direction: column; justify-content: space-between; }
.metric span { color: var(--muted); font-size: 0.69rem; font-weight: 700; }.metric strong { color: var(--ink); font-size: 1.32rem; letter-spacing: -0.045em; }
.weather-risk { margin: -0.45rem 0 1rem; padding: 0.7rem 0.8rem; border-left: 3px solid var(--sea-accent); background: var(--sea-accent-soft); }
.weather-risk span, .weather-risk strong, .weather-risk small { display: block; }
.weather-risk span { color: var(--muted); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.weather-risk strong { margin-top: 0.2rem; color: var(--ink); font-size: 0.82rem; }
.weather-risk small { margin-top: 0.18rem; color: var(--muted); font-size: 0.68rem; }
.panel-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.panel-tab { min-width: 0; padding: 0.56rem 0.15rem; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: 0.72rem; font-weight: 800; }
.panel-tab:hover { color: var(--ink); }.panel-tab.active { color: var(--sea-accent); border-bottom-color: var(--sea-accent); }
.panel-view { display: none; padding-top: 1.1rem; }.panel-view.active { display: block; }
.empty-state { padding: 1rem 0.15rem; color: var(--muted); }.empty-state strong { display: block; color: var(--ink); font-size: 0.93rem; }.empty-state p, .trend-intro p { margin: 0.4rem 0 0; font-size: 0.82rem; line-height: 1.55; }
.vessel-detail { display: grid; gap: 1rem; }.hidden { display: none !important; }
.watch-button { margin-top: 0.6rem; padding: 0.42rem 0.6rem; border: 1px solid var(--sea-accent); border-radius: 8px; color: var(--sea-accent); background: transparent; font-size: 0.72rem; font-weight: 800; }
.watch-button:hover { color: #fff; background: var(--sea-accent); }
.vessel-identity { padding-bottom: 0.85rem; border-bottom: 1px solid var(--border); }.vessel-identity h3 { margin: 0; font-size: 1.3rem; letter-spacing: -0.035em; }.vessel-identity p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.77rem; }
.detail-section h4 { margin: 0 0 0.55rem; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.11em; }.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }.detail-grid div { padding: 0.58rem; border-radius: 10px; background: var(--sea-accent-soft); }.detail-grid span { display: block; color: var(--muted); font-size: 0.66rem; font-weight: 700; }.detail-grid strong { display: block; margin-top: 0.18rem; color: var(--ink); font-size: 0.82rem; overflow-wrap: anywhere; }
.movement-card, .board-item { padding: 0.8rem 0; border-bottom: 1px solid var(--border); }.movement-card:first-child, .board-item:first-child { padding-top: 0; }.movement-card strong, .board-item strong { display: block; font-size: 0.86rem; }.movement-card span, .board-item span { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.75rem; line-height: 1.4; }.board-item { width: 100%; border-left: 0; border-right: 0; border-top: 0; color: var(--ink); background: transparent; text-align: left; }.board-item:hover strong { color: var(--sea-accent); }
.board-summary, .trend-intro { padding: 0.8rem; border-radius: var(--radius); background: var(--sea-accent-soft); }.board-summary strong, .trend-intro strong { display: block; color: var(--ink); font-size: 0.9rem; }.board-summary span { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.72rem; }
.trend-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.55rem; margin: 1rem 0; }.trend-metric { padding: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }.trend-metric span { display: block; color: var(--muted); font-size: 0.69rem; font-weight: 700; }.trend-metric strong { display: block; margin-top: 0.25rem; font-size: 1.4rem; letter-spacing: -0.05em; }.type-row { display: flex; align-items: center; justify-content: space-between; padding: 0.68rem 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }.type-row span { color: var(--muted); }
.source-note { margin: 1.2rem 0 0; color: var(--muted); font-size: 0.68rem; line-height: 1.5; }
.source-note a { color: var(--sea-accent); }

.vessel-marker { width: 15px; height: 15px; border: 2px solid rgb(255 255 255 / 0.92); background: var(--marker-color, #0e8f7c); box-shadow: 0 2px 7px rgb(0 0 0 / 0.28); transform: rotate(45deg); }.vessel-marker.is-selected { outline: 3px solid rgb(255 255 255 / 0.75); outline-offset: 3px; }.leaflet-container { font-family: Arial, Helvetica, sans-serif; background: var(--sea-800); }.leaflet-popup-content-wrapper { border-radius: 12px; color: var(--ink); background: var(--surface-raised); }.leaflet-popup-tip { background: var(--surface-raised); }.leaflet-popup-content { margin: 0.75rem 0.85rem; }.map-popup strong, .map-popup span { display: block; }.map-popup strong { font-size: 0.86rem; }.map-popup span { margin-top: 0.2rem; color: var(--muted); font-size: 0.73rem; }
.vessel-marker { width: 0; height: 0; border: 0; border-right: 5px solid transparent; border-bottom: 12px solid var(--marker-color, #0e8f7c); border-left: 5px solid transparent; background: transparent; box-shadow: none; filter: none; transform-origin: 50% 58%; }
.vessel-marker.is-selected { outline: 0; filter: drop-shadow(0 0 3px #fff) drop-shadow(0 2px 4px rgb(0 0 0 / 0.54)); }
.noscript-notice { padding: 1rem; color: var(--ink); background: var(--surface); }

.sea-info { background: var(--sea-800); border-top: 1px solid rgb(255 255 255 / 0.08); }
.sea-info-inner { max-width: 860px; margin: 0 auto; padding: 3rem 1.5rem 3.5rem; color: rgb(234 248 245 / 0.92); }
.sea-info-inner h2 { margin: 0 0 0.9rem; color: #fff; font-size: clamp(1.4rem, 2.2vw, 1.9rem); letter-spacing: -0.03em; }
.sea-info-inner h3 { margin: 2.1rem 0 1rem; color: #fff; font-size: 1.1rem; letter-spacing: -0.02em; }
.sea-info-inner p { margin: 0 0 0.9rem; font-size: 0.95rem; line-height: 1.65; color: rgb(234 248 245 / 0.78); }
.sea-faq { display: grid; gap: 1.15rem; margin: 0; }
.sea-faq > div { padding-bottom: 1.15rem; border-bottom: 1px solid rgb(255 255 255 / 0.08); }
.sea-faq > div:last-child { border-bottom: 0; padding-bottom: 0; }
.sea-faq dt { margin: 0 0 0.35rem; color: #fff; font-size: 0.92rem; font-weight: 700; }
.sea-faq dd { margin: 0; color: rgb(234 248 245 / 0.75); font-size: 0.86rem; line-height: 1.6; }
.sea-attribution { margin: 2.1rem 0 0; padding-top: 1.3rem; border-top: 1px solid rgb(255 255 255 / 0.08); color: rgb(234 248 245 / 0.6); font-size: 0.72rem; line-height: 1.6; }
.sea-attribution a { color: var(--sea-accent); }

@media (max-width: 980px) {
  .sea-header { grid-template-columns: auto 1fr auto; }.sea-nav { justify-content: flex-start; overflow-x: auto; }.sea-nav a { padding: 0 0.5rem; }
  .sea-workspace { grid-template-columns: minmax(0, 1fr) 340px; }
  .map-heading, .map-controls { left: 1rem; }.map-heading { top: 1rem; }.map-controls { top: 5.75rem; }
}
@media (max-width: 767px) {
  body { overflow: auto; }.sea-header { position: sticky; top: 0; height: 58px; padding: 0 0.75rem; grid-template-columns: auto 1fr auto; gap: 0.45rem; }.sea-brand span { font-size: 0.78rem; }.sea-brand img { width: 26px; height: 26px; }.sea-nav { gap: 0; }.sea-nav a { padding: 0 0.38rem; font-size: 0.7rem; }.refresh-button { min-width: 0; padding: 0.45rem 0.6rem; font-size: 0.72rem; }
  .sea-workspace { display: block; min-height: 0; }.map-stage { height: 60dvh; min-height: 440px; }.map-heading { top: 1rem; left: 1rem; max-width: 250px; }.map-heading h1 { font-size: 1.65rem; }.map-controls { top: 5rem; left: 0.75rem; right: 0.75rem; justify-content: space-between; }.layer-label { display: none; }.layer-button { flex: 1; }.map-legend { left: 0.75rem; bottom: 0.75rem; gap: 0.45rem; font-size: 0.67rem; }.map-status { right: 0.75rem; bottom: 0.75rem; max-width: 150px; font-size: 0.67rem; }
  .sea-panel { height: auto; min-height: 40dvh; padding: 1rem; border-top: 1px solid var(--border); border-left: 0; }.panel-close { display: none; }.overview-grid { margin-bottom: 0.85rem; }.metric { min-height: 68px; }.panel-tab { font-size: 0.67rem; }.source-note { padding-bottom: 0.5rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; } }
