/* Layout: the sea chart fills the screen; one panel carries everything else –
   a bottom sheet on the phone, a fixed column on iPad and Mac. */
:root {
  --ink: #0e2a3d;          /* chart ink, deep navy */
  --ink-2: #4a6170;        /* secondary text */
  --paper: #fbfcfc;        /* panel ground */
  --paper-2: #eef3f5;      /* inset ground, bluish like shallow water */
  --line: #d5dfe4;
  --track: #b3127f;        /* chart magenta: routes and notes on paper charts */
  --track-soft: #f4dcec;
  --sea: #1c7c9c;
  --k-marina: #17456b;
  --k-anker: #1c9a8a;
  --k-goeta: #5a8f29;
  --k-steg: #d9822b;
  --k-see: #b3127f;
  --k-tag: #8a99a3;
  --shadow: 0 6px 28px rgba(14, 42, 61, .22);
  --display: "DIN Condensed", "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --panel-w: 400px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8f0f4; --ink-2: #9fb3bf; --paper: #10202c; --paper-2: #182d3b; --line: #2a4252;
    --track: #ff6cc4; --track-soft: #4a1f3c; --sea: #5cc0de;
    --k-marina: #7fb6e6; --k-anker: #4fd0bd; --k-goeta: #9ccc5e; --k-steg: #f0a556; --k-see: #ff6cc4; --k-tag: #7d8f9a;
    --shadow: 0 6px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.45 var(--body); color: var(--ink); background: var(--paper); overflow: hidden; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; background: #cfe3ec; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: brightness(.78) saturate(.85); }
}

/* ---------- panel ---------- */
#panel {
  position: fixed; z-index: 1000; background: var(--paper); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  left: 0; right: 0; bottom: 0; height: 92dvh; border-radius: 18px 18px 0 0;
  transform: translateY(calc(92dvh - 50dvh)); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  touch-action: none;
}
#panel[data-snap="peek"] { transform: translateY(calc(92dvh - 132px - env(safe-area-inset-bottom, 0px))); }
#panel[data-snap="half"] { transform: translateY(calc(92dvh - 50dvh)); }
#panel[data-snap="full"] { transform: translateY(0); }
#panel.dragging { transition: none; }
#grip { border: 0; background: none; width: 100%; padding: 14px 0 12px; cursor: grab; flex: none; touch-action: none; }
#grip span { display: block; width: 46px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
#content { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: 2px max(18px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); }
#panel[data-snap="peek"] #content { overflow: hidden; }

@media (min-width: 760px) {
  #panel { top: 12px; bottom: 12px; left: 12px; right: auto; width: var(--panel-w); height: auto; border-radius: 16px; transform: none !important; touch-action: auto; }
  #grip { display: none; }
  #content { padding-top: 20px; }
  .leaflet-left { left: calc(var(--panel-w) + 14px); }
}

/* ---------- type ---------- */
h1, h2, .num, .eyebrow, .tab { font-family: var(--display); }
h1 { font-size: 34px; line-height: 1; margin: 0; letter-spacing: .01em; text-transform: uppercase; }
h2 { font-size: 21px; line-height: 1.1; margin: 26px 0 10px; text-transform: uppercase; letter-spacing: .03em; }
.eyebrow { font-size: 15px; letter-spacing: .09em; text-transform: uppercase; color: var(--track); margin: 0 0 4px; }
.sub { color: var(--ink-2); margin: 6px 0 0; }
.arrow { color: var(--track); padding: 0 .15em; }
small, .small { font-size: 12.5px; color: var(--ink-2); }

/* ---------- pieces ---------- */
.nav { display: flex; justify-content: space-between; align-items: center; margin: 0 0 12px; }
.back { border: 0; background: none; padding: 6px 0; color: var(--sea); font-weight: 600; cursor: pointer; }
.steps { display: flex; gap: 8px; }
.steps button { width: 40px; height: 36px; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; font-size: 20px; line-height: 1; cursor: pointer; }
.steps button:disabled { opacity: .3; cursor: default; }
.tabs { display: flex; gap: 4px; margin: 16px 0 4px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 8px 12px 7px; font-size: 18px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--track); }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 16px; }
.fact { background: var(--paper); padding: 10px 12px 9px; min-width: 0; }
.fact .num { font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.fact .num span { font-size: 17px; color: var(--ink-2); margin-left: 3px; }
.fact .lbl { font-size: 11.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.fact.link { border: 0; text-align: left; cursor: pointer; position: relative; font: inherit; color: inherit; }
.fact.link .num { color: var(--track); }
.fact.link .pin { position: absolute; top: 8px; right: 10px; color: var(--track); font-size: 17px; }
.fact .lbl i { font-style: normal; text-transform: none; letter-spacing: 0; display: block; }

.ends { margin: 16px 0 0; padding: 0; list-style: none; position: relative; }
.ends li { position: relative; padding: 0 0 14px 24px; }
.ends li::before { content: ""; position: absolute; left: 4px; top: 5px; width: 9px; height: 9px; border-radius: 50%; border: 2.5px solid var(--track); background: var(--paper); z-index: 1; }
.ends li:first-child::after { content: ""; position: absolute; left: 10px; top: 14px; bottom: -6px; border-left: 2px dashed var(--track); opacity: .5; }
.ends li:last-child { padding-bottom: 0; }
.ends li:last-child::before { background: var(--track); }
.ends b { display: block; }
.ends button { display: block; border: 0; background: none; padding: 0; font-weight: 700; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.coord { font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 12.5px; padding: 3px 9px; border-radius: 99px; background: var(--paper-2); color: var(--ink); white-space: nowrap; }
.chip.hot { background: var(--track-soft); color: var(--track); font-weight: 600; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--c, var(--ink-2)); vertical-align: 0; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { border-bottom: 1px solid var(--line); }
.rows button { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: baseline; width: 100%; text-align: left; border: 0; background: none; padding: 10px 0; cursor: pointer; }
.rows .d { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rows .n { min-width: 0; }
.rows .n small { display: block; }
.rows .v { font-family: var(--display); font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows .v span { font-size: 13px; color: var(--ink-2); margin-left: 2px; }

.card { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 12px 14px; margin-top: 8px; cursor: pointer; }
.card .v { font-family: var(--display); font-size: 26px; float: right; font-variant-numeric: tabular-nums; }
.card .v span { font-size: 15px; color: var(--ink-2); margin-left: 3px; }
.card b { display: block; }

.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 4px 0 12px; }
.bar i { background: var(--c); min-width: 3px; }
.legend { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 14px; font-variant-numeric: tabular-nums; }
.legend .r { text-align: right; }
.legend .p { text-align: right; color: var(--ink-2); }

.records { margin: 0; display: grid; grid-template-columns: 1fr; gap: 12px; }
.records dt { font-size: 11.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.records dd { margin: 2px 0 0; }
.records dd b { font-family: var(--display); font-size: 22px; font-weight: 400; margin-right: 6px; }

.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.thumbs button { position: relative; border: 0; padding: 0; background: var(--paper-2); aspect-ratio: 1; border-radius: 4px; overflow: hidden; cursor: pointer; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .vid::after { content: "▶"; position: absolute; right: 5px; bottom: 3px; color: #fff; font-size: 13px; text-shadow: 0 0 4px #000; }
.locked { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; color: var(--ink-2); }
.locked a { color: var(--sea); font-weight: 600; }

:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }

/* ---------- map marks ---------- */
.stop-label { background: none; border: 0; box-shadow: none; font: 600 11.5px var(--body); color: #0e2a3d; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; padding: 0; }
.stop-label::before { display: none; }

.preview-pop .leaflet-popup-content-wrapper { padding: 0; border-radius: 10px; overflow: hidden; }
.preview-pop .leaflet-popup-content { margin: 0; width: 132px !important; }
.map-preview { display: block; position: relative; border: 0; padding: 0; background: #0e2a3d; cursor: pointer; width: 132px; }
.map-preview img { display: block; width: 132px; height: 132px; object-fit: cover; }
.map-preview span { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 8px 5px; font: 600 11.5px var(--body); color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); }
.speed-label { font: 13px var(--body); color: #0e2a3d; border: 0; box-shadow: 0 2px 10px rgba(14, 42, 61, .3); padding: 5px 9px; border-radius: 8px; white-space: nowrap; }

/* ---------- lightbox ---------- */
#lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(4, 12, 18, .96); display: grid; place-items: center; }
#lb-img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
#lightbox button { position: absolute; border: 0; background: rgba(255, 255, 255, .14); color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 26px; line-height: 1; cursor: pointer; }
#lb-close { top: calc(12px + env(safe-area-inset-top, 0px)); right: 14px; }
#lb-prev { left: 10px; top: 50%; margin-top: -22px; }
#lb-next { right: 10px; top: 50%; margin-top: -22px; }
#lb-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 18px calc(14px + env(safe-area-inset-bottom, 0px)); color: #fff; font-size: 13.5px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
@media (prefers-reduced-motion: reduce) { #panel { transition: none; } }
