:root {
  --navy: #0e2a47;
  --navy-deep: #081a2e;
  --navy-2: #163c63;
  --gold: #c2a061;
  --gold-soft: #e0c896;
  --gold-deep: #a8854a;
  --bg: #f6f3ec;
  --bg-2: #efe9dc;
  --card: #ffffff;
  --text: #1b2733;
  --muted: #6c7888;
  --drop: #0f7b3a;
  --rise: #b33a3a;
  --line: #e7e0d2;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow: 0 6px 24px rgba(14, 42, 71, 0.08);
  --shadow-lift: 0 14px 38px rgba(14, 42, 71, 0.16);
  --hero-h: clamp(300px, 26vw, 460px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.2px; }

/* ---- Header ---- */
header {
  background: linear-gradient(135deg, var(--navy-deep), var(--navy) 60%, #14375c);
  color: #fff;
  padding: 18px 30px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; flex-direction: column; gap: 1px; }
.brand-eyebrow {
  font-size: 10.5px;
  letter-spacing: 3.4px;
  text-transform: uppercase;
  color: var(--gold-soft);
  font-weight: 500;
}
header h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1.05;
  color: #fff;
}
header .sub { font-size: 12.5px; color: #aebfd0; letter-spacing: 0.3px; margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 16px; }
#meta { font-size: 11.5px; color: #9fb2c6; letter-spacing: 0.3px; }
#refreshBtn {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none;
  color: var(--navy-deep);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 9px 18px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(194, 160, 97, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
#refreshBtn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(194, 160, 97, 0.45); }
#refreshBtn:disabled { opacity: 0.6; cursor: wait; transform: none; }

/* ---- Editorial tabs ---- */
#tabs {
  display: flex;
  gap: 2px;
  padding: 0 22px;
  background: var(--navy);
  flex-wrap: wrap;
}
.tab {
  background: none;
  color: #9fb4ca;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 18px 12px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #e7eef5; }
.tab.active { color: #fff; border-bottom-color: var(--gold); }

/* ---- Explore "All / Watched" segmented slider ---- */
.seg {
  display: inline-flex;
  gap: 4px;
  margin: 16px 30px 0;
  padding: 4px;
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}
.seg-btn {
  border: none;
  background: none;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--navy);
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover { color: var(--gold-deep); }
.seg-btn.active {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--navy-deep);
}
.seg-count { opacity: 0.75; font-weight: 500; }

/* ---- Hero banner (landing only) ---- */
#hero {
  position: relative;
  /* Height scales with viewport width so the crop ratio stays consistent.
     Anchor the crop to the BOTTOM so the vessel's waterline/hull is always in
     frame at any window size (the sky crops away first, never the ship). */
  height: var(--hero-h);
  background: url('/assets/hero-navigator.jpg') center bottom / cover no-repeat;
  overflow: hidden;
}
#hero.hidden { display: none; }
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(8, 26, 46, 0.82) 0%,
    rgba(8, 26, 46, 0.5) 42%,
    rgba(8, 26, 46, 0.12) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 clamp(30px, 6vw, 88px);
  color: #fff;
}
.hero-eyebrow {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold-soft);
  font-weight: 500;
  margin-bottom: 14px;
}
.hero-title {
  font-family: var(--serif);
  font-size: clamp(30px, 4.4vw, 52px);
  font-weight: 600;
  line-height: 1.05;
  margin: 0;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.4);
}
.hero-sub {
  font-size: 15px;
  color: #dde6ef;
  margin: 16px 0 0;
  max-width: 48ch;
  letter-spacing: 0.2px;
}
.hero-credit {
  position: absolute;
  right: 14px;
  bottom: 10px;
  font-size: 10px;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.7);
}
/* With the hero visible, let the chat size to its content so the input sits
   right under the intro (no dead space), and cap the log so long chats scroll
   while everything stays within the viewport. */
#hero:not(.hidden) ~ #advisorView {
  height: auto;
  min-height: 0;
}
#hero:not(.hidden) ~ #advisorView #chatLog {
  flex: 0 1 auto;
  min-height: 90px;
  max-height: calc(100vh - 110px - var(--hero-h) - 90px);
}

#filters {
  display: flex;
  gap: 10px;
  padding: 16px 30px;
  flex-wrap: wrap;
  align-items: center;
}
#filters select, #filters input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
}
#filters select:focus, #filters input:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }
#fMaxPrice { width: 110px; }
#count { font-size: 12px; color: var(--muted); margin-left: auto; letter-spacing: 0.4px; }

main {
  padding: 4px 30px 50px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.card-head { display: flex; justify-content: space-between; gap: 8px; }
.card .title {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--navy);
}
.card .hero { margin: 2px 0 0; font-size: 13px; color: var(--gold-deep); font-style: italic; font-family: var(--serif); letter-spacing: 0.2px; }
.star {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gold);
  line-height: 1;
}
.card-meta { font-size: 13px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--navy);
  padding: 3px 9px;
  border-radius: 2px;
  font-weight: 500;
}
.badge.dest { background: var(--navy); color: #fff; border-color: var(--navy); }
.badge.tag { background: var(--gold); color: var(--navy-deep); border-color: var(--gold); }
.route { font-size: 12px; color: var(--muted); letter-spacing: 0.2px; }

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
}
.price { font-family: var(--serif); font-size: 25px; font-weight: 600; color: var(--navy); }
.price small { font-size: 11px; font-weight: 400; color: var(--muted); font-family: var(--sans); }
.delta { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: 0.2px; }
.delta-cabin { font-weight: 400; color: var(--muted); font-size: 11px; }
.delta.drop { color: var(--drop); }
.delta.rise { color: var(--rise); }
.actions { display: flex; gap: 10px; align-items: center; }
.fares-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--navy);
}
.ext { font-size: 12px; color: var(--navy); }

.fares-panel { border-top: 1px dashed var(--line); padding-top: 8px; font-size: 13px; }
.fares-panel table { width: 100%; border-collapse: collapse; }
.fares-panel td { padding: 3px 0; }
.fares-panel td:last-child { text-align: right; font-weight: 600; }
.hidden { display: none; }

.offer-card { grid-column: 1 / -1; }
.offer-card h3 { margin: 0 0 6px; color: var(--navy); }
.offer-card .desc { font-size: 14px; line-height: 1.5; }
.offer-card .desc ul { padding-left: 20px; }

#advisorView {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 110px);
  max-width: 860px;
  margin: 0 auto;
  padding: 0 22px;
}
#advisorView.hidden { display: none; }
#chatLog {
  flex: 1;
  overflow-y: auto;
  padding: 18px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.msg.assistant .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.user .bubble {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.thinking { color: var(--muted); font-style: italic; }
.bubble .md-h { display: block; margin: 6px 0 2px; color: var(--navy); }
.bubble .md-table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 13px;
  width: 100%;
}
.bubble .md-table th, .bubble .md-table td {
  border: 1px solid var(--line);
  padding: 4px 8px;
  text-align: left;
}
.bubble .md-table th { background: #eef2f7; color: var(--navy); }
.bubble a { color: var(--navy); font-weight: 600; }
.msg.user .bubble a { color: var(--gold); }
#chatForm {
  display: flex;
  gap: 8px;
  padding: 12px 0 18px;
}
#chatInput {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}
#chatInput:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
#chatSend {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#voiceToggle {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 17px;
  cursor: pointer;
}
#voiceToggle:hover { border-color: var(--gold); }
#chatSend:disabled { opacity: 0.5; cursor: wait; }

#fleetView {
  display: flex;
  height: calc(100vh - 110px);
}
#fleetView.hidden { display: none; }
#fleetSidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#map { flex: 1; }

.status {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 14px;
  background: var(--navy-2);
  color: #cfdae6;
}
.status.live { background: #0f5132; color: #c8f0d8; }
.status.demo { background: #6b5413; color: #f5e6bd; }

.ship-card {
  background: var(--navy-2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}
.ship-card:hover { border-color: var(--gold); }
.ship-card h3 { margin: 0 0 4px; font-size: 15px; color: var(--gold); }
.ship-card .pos { font-size: 12px; color: #cfdae6; }
.ping-age { color: #c9a45c; }
.ping-age.live { color: #7be09b; }
.ship-card .voyage { font-size: 12px; margin-top: 8px; color: #e8eef5; line-height: 1.45; }
.ship-card .voyage .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8fa3b8;
  display: block;
}
.ship-card a { color: var(--gold); }
.ship-card .voyage .ext { display: inline-block; margin-top: 4px; font-size: 11px; }

.footnote { margin-top: auto; font-size: 11px; color: #8fa3b8; line-height: 1.5; }
.footnote a { color: #b9c6d4; }

.ship-icon {
  background: var(--gold);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.leaflet-popup-content { font-size: 13px; line-height: 1.5; }
.leaflet-popup-content b { color: var(--navy); }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 15px;
}
.note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
  background: #fdf6e7;
  border: 1px solid #ecd9ab;
  border-radius: 8px;
  padding: 10px 14px;
}

/* ---- Photo Contest ---- */
#contestView {
  padding: 16px 22px 48px;
  max-width: 1100px;
  margin: 0 auto;
}
#contestView.hidden { display: none; }
.contest-subtabs { display: flex; gap: 8px; margin-bottom: 14px; }
.subtab {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--navy);
}
.subtab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

#contestBanner { margin-bottom: 14px; }
#contestBanner .banner {
  background: var(--navy);
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
}
#contestBanner .banner .when { color: var(--gold); font-weight: 600; }
#contestBanner .banner.open { background: #eef2f7; color: var(--navy); border: 1px solid var(--line); }

#uploadPanel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 18px;
  padding: 4px 16px;
}
#uploadPanel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
  padding: 10px 0;
}
#contestForm { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; }
.file-drop {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  display: block;
}
.file-drop:hover { border-color: var(--gold); }
#photoPreview { max-height: 200px; max-width: 100%; border-radius: 8px; margin-top: 8px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
#contestForm input, #contestForm select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}
#subSend {
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}
#subSend:disabled { opacity: 0.6; cursor: wait; }
.sub-status { font-size: 13px; margin: 0; }
.sub-status.ok { color: var(--drop); }
.sub-status.held { color: #9a6b00; }
.sub-status.err { color: var(--rise); }

#contestGallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.photo-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.photo-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e9eef4;
}
.photo-card .pc-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.photo-card .pc-caption { font-weight: 600; color: var(--navy); font-size: 14px; }
.photo-card .pc-attr { font-size: 12px; color: var(--muted); }
.photo-card .pc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.like-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 6px;
}
.like-btn:hover { border-color: var(--gold); }
.like-btn.liked { background: var(--drop); color: #fff; border-color: var(--drop); }
.rank-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--navy);
  color: #fff;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.photo-card.rank-1 { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }

/* Winners */
#contestWinners.hidden { display: none; }
.winner-month { margin-bottom: 28px; }
.winner-month h3 { color: var(--navy); margin: 0 0 12px; }
.winner-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.annual-banner {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.annual-banner h2 { margin: 0 0 4px; color: var(--gold); }
/* Empty-state */
.contest-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 28px 8px 8px;
}
.contest-empty .ce-title {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--navy);
}
.contest-empty .ce-sub {
  margin: 0 auto 22px;
  max-width: 460px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.ce-ig-head {
  font-size: 14px;
  color: var(--muted);
  margin: 4px 0 14px;
}
.ce-ig-head a { color: var(--navy); font-weight: 600; }
.ce-instagram {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  max-width: 760px;
  margin: 0 auto 10px;
}
.ce-instagram .instagram-media { flex: 0 1 320px; }
.ce-ig-credit { font-size: 11px; color: var(--muted); margin: 0 0 22px; }
.ce-examples {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
  margin: 20px auto 26px;
  text-align: left;
}
.ce-card {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.ce-illus {
  position: relative;
  aspect-ratio: 4 / 3;
}
.ce-illus svg { display: block; width: 100%; height: 100%; }
.ce-photo { display: block; width: 100%; height: 100%; object-fit: cover; background: #e9eef4; }
.ce-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(14, 42, 71, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  z-index: 1;
}
.ce-cap {
  padding: 9px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ce-cap-title { font-weight: 600; font-size: 13px; color: var(--navy); }
.ce-cap-attr { font-size: 11px; color: var(--muted); }
.ce-cta {
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 24px;
  padding: 11px 26px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(201, 164, 92, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ce-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201, 164, 92, 0.5);
}
.ce-cta:active { transform: translateY(0); }

/* ---- Phones (≤640px) ---- */
@media (max-width: 640px) {
  /* Cards fill the screen in one column with even gutters */
  #results {
    grid-template-columns: 1fr;
    padding-left: 16px;
    padding-right: 16px;
  }
  #filters { padding-left: 16px; padding-right: 16px; }
  .seg { margin-left: 16px; margin-right: 16px; }

  /* Fleet: stack the map above the ship list instead of a side-by-side split
     that crushes the map to a sliver on narrow screens. */
  #fleetView { flex-direction: column; height: auto; }
  #map { order: 1; height: 55vh; min-height: 300px; }
  #fleetSidebar {
    order: 2;
    width: auto;
    overflow-y: visible;
  }

  /* Chat reads edge-to-edge on a phone */
  .bubble { max-width: 88%; }
}
