:root {
  --ink: #12263a;
  --ink-2: #4a5d70;
  --ink-3: #7d8c9a;
  --paper: #f7f4ee;
  --card: #ffffff;
  --line: #e2ddd2;
  --accent: #2e7d4f;      /* buffalo green */
  --accent-soft: #e3f0e7;
  --sea: #1d5c8c;
  --route: #1f7a4a;
  --photo: #f08a24;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); }

#app { display: grid; grid-template-columns: 380px 1fr; height: 100vh; }

/* ---------------- journal ---------------- */
#journal { overflow-y: auto; border-right: 1px solid var(--line); background: var(--paper); }
.j-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 2; }
.brand { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
#voyage-select { margin-top: 8px; width: 100%; padding: 6px; border-radius: 6px; border: 1px solid var(--line); }
h1 { font-size: 21px; margin: 6px 0 2px; line-height: 1.2; }
.sub { color: var(--ink-2); font-size: 13px; }
.crew { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.stats { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.stats b { display: block; font-size: 16px; color: var(--ink); }

#j-body { padding: 12px 14px 40px; }
.section-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin: 14px 6px 8px; }

.note { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; font-size: 13px; line-height: 1.45; }
.note h4 { margin: 0 0 4px; font-size: 13px; }
.note .who { color: var(--ink-3); font-weight: 400; }
.note a { color: var(--sea); font-size: 12px; }

.day { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.day.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 12px; cursor: pointer; }
.day-head:hover { background: #fbfaf7; }
.day-head h3 { margin: 0; font-size: 15px; }
.day-head .date { color: var(--ink-3); font-size: 12px; font-weight: 400; margin-left: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 12px; }
.chip { font-size: 12.5px; background: #eef1f3; color: var(--ink-2); border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.chip b { color: var(--ink); font-weight: 700; }

.moment { display: flex; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.moment:hover { background: #fbfaf7; }
.moment.active { background: var(--accent-soft); }
.moment img { width: 76px; height: 76px; object-fit: cover; border-radius: 6px; flex: none; }
.moment .m-icon { width: 76px; height: 76px; border-radius: 6px; flex: none; display: grid; place-items: center; background: #f1eee7; font-size: 26px; }
.moment h4 { margin: 0 0 2px; font-size: 14px; }
.moment .m-time { font-size: 12px; color: var(--ink-2); }
.moment p { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--ink-2); white-space: pre-line; }
.sources { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; margin-top: 18px; font-size: 13px; line-height: 1.5; color: var(--ink-2); scroll-margin-top: 150px; }
.sources summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--ink-2); }
.sources summary::-webkit-details-marker { display: none; }
.sources summary::after { content: "+"; font-size: 18px; font-weight: 400; color: var(--ink-3); }
.sources[open] summary::after { content: "−"; }
.sources summary:hover { color: var(--ink); }
.sources h4 { margin: 10px 0 4px; font-size: 13px; color: var(--ink); }
.sources ul { margin: 0; padding-left: 18px; }
.sources li { margin-bottom: 5px; }
.sources b { color: var(--ink); }
.sources a { color: var(--sea); }

/* ---------------- map + dashboard ---------------- */
#stage { display: grid; grid-template-rows: 1fr auto; min-height: 0; min-width: 0; }
#map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe7ea; }
/* Muted, cartographic basemap so the route and weather carry the color */
.basemap { filter: saturate(.45) brightness(1.06) contrast(.92); }
/* Soft vignette, a common cartographic finishing touch */
#map-wrap::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 450; box-shadow: inset 0 0 90px rgba(18, 38, 58, .18); }

#legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12px; color: var(--ink); }
#legend span { display: inline-flex; align-items: center; gap: 6px; }
#legend i { display: inline-block; font-style: normal; }
.lg-speed i { width: 64px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, rgb(251,182,26), rgb(232,89,12), rgb(194,37,92), rgb(95,61,196)); box-shadow: 0 0 0 1.5px #fff; }
.lg-speed small { font-size: 12px; }
.lg-speed small:first-child { font-weight: 600; }
.lg-ahead { width: 22px; height: 0; border-top: 2px dashed rgba(18, 38, 58, .55); }
.lg-photo { width: 10px; height: 10px; border-radius: 50%; background: var(--photo); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.lg-badge { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 11px; display: inline-grid !important; place-items: center; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.lg-high { background: rgb(21, 101, 192); } .lg-low { background: rgb(198, 40, 40); }
.lg-wind i { width: 64px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgb(205,210,228), rgb(150,185,225), rgb(90,165,205), rgb(70,175,140), rgb(165,200,80), rgb(240,205,70), rgb(240,145,60)); }
.lg-wind small { font-size: 12px; }
.lg-wind small:first-child { font-weight: 600; }
.lg-isobar { width: 22px; height: 0; border-top: 1.8px solid rgba(18, 38, 58, .75); }

#dash { background: var(--card); border-top: 1px solid var(--line); padding: 10px 16px 10px; }
#player { display: flex; align-items: center; gap: 14px; }
#play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--route); color: #fff; font-size: 15px; cursor: pointer; flex: none; }
#play:hover { filter: brightness(1.1); }
.when { display: flex; flex-direction: column; min-width: 190px; font-size: 14px; font-variant-numeric: tabular-nums; }
.when span { font-size: 12px; color: var(--route); font-weight: 600; }
.scrub { flex: 1; min-width: 0; }
.slider { position: relative; height: 28px; }
#scrub { position: absolute; inset: 0; width: 100%; margin: 0; accent-color: var(--route); background: transparent; }
#ticks { position: absolute; left: 8px; right: 8px; top: 0; bottom: 0; pointer-events: none; }
#ticks span { position: absolute; top: 0; width: 1px; height: 6px; background: var(--ink-3); }
#ticks span.m { top: -1px; width: 7px; height: 7px; border-radius: 50%; background: var(--photo); transform: translateX(-3px); border: 1px solid #fff; }
.speed { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--ink-2); }
.speed > span { font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
#speed { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 13px; background: #fff; color: var(--ink); }
#speed-hint { font-size: 11px; color: var(--ink-3); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.tiles > div { background: #f3f5f6; border-radius: 8px; padding: 7px 10px; min-width: 0; }
.tiles label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.tiles b { font-size: 16px; font-variant-numeric: tabular-nums; display: block; }
.dash-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px 20px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.layers { display: flex; gap: 14px; font-size: 12px; }
.layers input { vertical-align: -2px; accent-color: var(--route); }

/* map markers */
.boat-icon { width: 30px; height: 30px; }
.boat-rot { width: 30px; height: 30px; transition: transform .15s linear; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.photo-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--photo); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.35); cursor: pointer; transition: transform .15s; }
.photo-dot.note { background: #fff; border-color: var(--route); }
.photo-dot:hover, .photo-dot.active { transform: scale(1.5); }
.photo-dot.pop { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(2); } 100% { transform: scale(1); } }
.leaflet-tooltip.place-label { background: rgba(255,255,255,.92); border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.25); font-size: 12px; font-weight: 700; color: var(--ink); padding: 2px 7px; }
.leaflet-tooltip.place-label::before { display: none; }
.graticule-label { font: 600 11px -apple-system, sans-serif; color: rgba(18, 38, 58, .75); white-space: nowrap; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.leaflet-pane.leaflet-wx-pane { pointer-events: none; }
.leaflet-tooltip.dot-tip { padding: 3px; border-radius: 6px; }
.dot-tip img { display: block; width: 120px; height: 90px; object-fit: cover; border-radius: 4px; }
.dot-tip div { font-size: 11px; font-weight: 600; padding: 3px 2px 0; max-width: 120px; white-space: normal; }

.leaflet-popup-content { margin: 10px 12px; width: 260px !important; font-size: 13px; line-height: 1.4; }
.pop img { width: 100%; max-height: 170px; object-fit: cover; border-radius: 6px; cursor: zoom-in; display: block; }
.pop h4 { margin: 8px 0 2px; font-size: 15px; }
.pop .m-time { font-size: 12px; color: var(--ink-2); }
.pop p { margin: 6px 0 0; white-space: pre-line; }
.pop a { color: var(--sea); font-size: 12px; }

#lightbox { position: fixed; inset: 0; z-index: 5000; background: rgba(8, 16, 26, .9); display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
#lightbox[hidden] { display: none; }
#lightbox figure { margin: 0; max-width: 100%; text-align: center; color: #fff; }
#lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 6px; }
#lightbox figcaption { margin-top: 10px; font-size: 14px; }

/* ---------------- small laptops / tablets in landscape ---------------- */
@media (max-width: 1200px) {
  #app { grid-template-columns: 320px 1fr; }
  #player { flex-wrap: wrap; gap: 8px 14px; }
  .when { flex: 1; min-width: 0; }
  .scrub { order: 3; flex-basis: 100%; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .tiles b { font-size: 15px; }
}

/* ---------------- small screens ---------------- */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; height: auto; }
  #stage { grid-row: 1; }
  #map-wrap { height: 60vh; }
  #journal { grid-row: 2; border-right: 0; overflow: visible; }
  .j-head { position: static; }
  #dash { padding: 10px 12px; }
  #player { flex-wrap: wrap; gap: 10px; }
  .when { min-width: 0; flex: 1; }
  .scrub { order: 3; flex-basis: 100%; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; }
  .tiles b { font-size: 15px; }
}
.sources[open] { padding-bottom: 12px; }
