:root {
  --bg: #F6F3F1;
  --card: #FFFFFF;
  --ink: #17171A;
  --ink-2: #3A3A40;
  --muted: #8C8C93;
  --line: #ECE8E5;
  --accent: #FF6B35;
  --accent-2: #FF8F5E;
  --peach: #FFE7DB;
  --peach-2: #FFF3EC;
  --green: #2FA36B;
  --green-bg: #E5F6EC;
  --blue: #3B6FE0;
  --blue-bg: #E8EFFD;
  --amber: #C98A00;
  --amber-bg: #FFF4D6;
  --red: #D9473B;
  --red-bg: #FDEAE8;
  --dark: #1C1C1E;
  --dark-2: #2A2A2D;
  --dark-3: #3A3A3E;
  --dark-muted: #9A9AA1;
  --sea: #CFE4EE;
  --land: #F7F3EE;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 6px 24px rgba(40, 20, 10, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 68px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}
.view {
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 34px);
  outline: none;
  min-height: 100dvh;
}
.view.flush { padding: 0; }

/* ---------- Header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.topbar .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icon-chip {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); box-shadow: var(--shadow);
  border: 0; cursor: pointer; flex: none;
}
.icon-chip svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-chip.spin svg { animation: spin 0.9s linear infinite; }
.who small { display: block; color: var(--muted); font-size: 12px; }
.who b { font-size: 15px; font-weight: 600; }
h1.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 4px 2px 14px; }

/* ---------- Hero with ship ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #FFE3D4 0%, #FFF1E9 58%, #FFF6F1 100%);
  min-height: 168px;
  margin-bottom: 14px;
}
.hero-text { position: absolute; left: 18px; top: 16px; right: 18px; z-index: 2; }
.hero-text h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.hero-text p { font-size: 13px; color: var(--ink-2); margin-top: 3px; max-width: 70%; }
.hero .ship-scene { position: absolute; inset: auto 0 0 0; height: 118px; }

/* ---------- Ship scene (SVG animation) ---------- */
.ship-scene { width: 100%; display: block; }
.ship-scene svg { width: 100%; height: 100%; display: block; }
.ss-wave-back { animation: wave 9s linear infinite; }
.ss-wave-front { animation: wave 6s linear infinite; }
.ss-ship { animation: sail 16s ease-in-out infinite alternate; }
.ss-bob { animation: bob 3.2s ease-in-out infinite; transform-origin: 180px 92px; transform-box: view-box; }
.ss-smoke circle { animation: smoke 3s ease-out infinite; opacity: 0; transform-box: fill-box; transform-origin: center; }
.ss-smoke circle:nth-child(2) { animation-delay: 1s; }
.ss-smoke circle:nth-child(3) { animation-delay: 2s; }
.ss-gull { animation: gull 7s ease-in-out infinite; }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-180px); } }
@keyframes sail { from { transform: translateX(-34px); } to { transform: translateX(34px); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1.2deg); } 50% { transform: translateY(2.5px) rotate(1.2deg); } }
@keyframes smoke { 0% { opacity: .55; transform: translate(0, 0) scale(.6); } 100% { opacity: 0; transform: translate(-14px, -16px) scale(1.6); } }
@keyframes gull { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(10px, -4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ss-wave-back, .ss-wave-front, .ss-ship, .ss-bob, .ss-smoke circle, .ss-gull, .icon-chip.spin svg, .skeleton { animation: none !important; }
}

/* ---------- Search ---------- */
.search { display: flex; gap: 10px; margin-bottom: 16px; }
.search label { flex: 1; position: relative; }
.search input {
  width: 100%; height: 52px; border-radius: 26px; border: 0;
  background: var(--card); box-shadow: var(--shadow);
  padding: 0 16px 0 46px; font-size: 16px; color: var(--ink);
  text-transform: uppercase; letter-spacing: .02em;
  -webkit-appearance: none; appearance: none; outline: none;
}
.search input::placeholder { text-transform: none; letter-spacing: 0; color: var(--muted); }
.search input:focus { box-shadow: 0 0 0 2px var(--accent-2), var(--shadow); }
.search label svg { position: absolute; left: 16px; top: 15px; width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search .go {
  width: 52px; height: 52px; border-radius: 50%; border: 0; flex: none;
  background: var(--dark); display: grid; place-items: center; cursor: pointer;
}
.search .go svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.search .go:active { transform: scale(.96); }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.tile {
  background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-direction: column; gap: 2px; border: 0; text-align: left; cursor: pointer;
}
.tile b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.tile span { font-size: 13px; color: var(--muted); }
.tile.accent { background: var(--peach); }

/* ---------- Sections ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 10px; }
.section-head h3 { font-size: 17px; font-weight: 600; }
.section-head a, .section-head button { font-size: 13px; color: var(--muted); background: none; border: 0; padding: 4px 0; cursor: pointer; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card.link { display: block; cursor: pointer; }
.card.link:active { transform: scale(.99); }
.ship-head { display: flex; align-items: center; gap: 12px; }
.ship-ico {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: var(--peach-2); display: grid; place-items: center;
}
.ship-ico svg { width: 30px; height: 30px; }
.ship-head .t { flex: 1; min-width: 0; }
.ship-head .t b { display: block; font-size: 18px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-head .t small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 999px;
  background: #F1EEEC; color: var(--ink-2); white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.s-transit { background: var(--peach); color: #C9471B; }
.pill.s-arrived { background: var(--blue-bg); color: var(--blue); }
.pill.s-done { background: var(--green-bg); color: var(--green); }
.pill.s-planned { background: var(--amber-bg); color: var(--amber); }
.pill.s-problem { background: var(--red-bg); color: var(--red); }
.pill.s-pending { background: #F1EEEC; color: var(--muted); }

/* Big arrival date */
.eta-hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 14px 16px; border-radius: 18px; background: var(--peach-2); }
.eta-hero.done { background: var(--blue-bg); }
.eta-main { min-width: 0; display: flex; flex-direction: column; }
.eta-lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eta-date { font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--ink); }
.eta-sub { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.eta-late { font-size: 12px; font-weight: 700; color: #B86E00; background: var(--amber-bg); padding: 2px 8px; border-radius: 999px; }
.eta-count { flex: none; text-align: center; background: var(--accent); color: #fff; border-radius: 16px; padding: 10px 12px; min-width: 78px; }
.eta-count b { display: block; font-size: 30px; font-weight: 800; line-height: 1; }
.eta-count small { display: block; font-size: 12px; font-weight: 600; margin-top: 4px; opacity: .9; }
.eta-count.ok { background: var(--blue); }
.eta-note { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }
.eta-note .late { color: #B86E00; }
.row-eta { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 1px; }

/* Stepper */
.stepper { display: flex; align-items: center; margin: 22px 2px 8px; position: relative; }
.step { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative; background: #E9E5E2; }
.step svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.step.done { background: var(--accent); }
.step.now { background: #fff; box-shadow: 0 0 0 2px var(--accent); }
.step.now::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.step .tag {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; color: var(--accent); white-space: nowrap;
}
.bar { flex: 1; height: 0; border-top: 2px dotted #DAD5D1; margin: 0 4px; }
.bar.done { border-top: 2px dotted var(--accent); }
.step-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 0 -6px 12px; }
.step-labels span { width: 25%; text-align: center; }
.step-labels span:first-child { text-align: left; padding-left: 4px; }
.step-labels span:last-child { text-align: right; padding-right: 4px; }

.ends { display: flex; justify-content: space-between; gap: 12px; }
.ends div { min-width: 0; }
.ends div:last-child { text-align: right; }
.ends small { display: block; font-size: 12px; color: var(--muted); }
.ends b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* List rows */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; }
.row:active { background: var(--bg); }
.row + .row { border-top: 1px solid var(--line); border-radius: 0 0 16px 16px; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-size: 16px; font-weight: 600; }
.row .t small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 999px; padding: 9px 15px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--dark); color: #fff; }

/* Buttons */
.btn { border: 0; border-radius: 999px; padding: 13px 20px; font-weight: 600; font-size: 15px; cursor: pointer; }
.btn-dark { background: var(--dark); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--card); box-shadow: var(--shadow); }
.btn-block { display: block; width: 100%; }

/* States */
.state { text-align: center; padding: 8px 12px 20px; }
.state .ship-scene { height: 120px; margin: 0 -16px 8px; width: calc(100% + 32px); }
.state h2 { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.state p { color: var(--ink-2); font-size: 15px; margin-bottom: 16px; }
.state .btn + .btn { margin-top: 10px; }
.skeleton { background: linear-gradient(90deg, #EEEAE7 0%, #F7F4F2 50%, #EEEAE7 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-card { height: 170px; border-radius: var(--radius); margin-bottom: 14px; }
.sk-row { height: 64px; border-radius: 16px; margin-bottom: 8px; }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--peach-2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.notice svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; margin-top: 1px; }
.notice button { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; cursor: pointer; }

/* ---------- Tracking screen ---------- */
.track { position: relative; min-height: 100dvh; background: var(--card); }
.map-wrap { position: fixed; top: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; height: 46dvh; z-index: 0; background: var(--sea); }
.map { position: absolute; inset: 0; }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: end center; background: linear-gradient(180deg, #DDEBF0, #CFE3EA); }
.map-fallback .ship-scene { height: 130px; }
.map-top {
  position: absolute; z-index: 500; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-top) + 10px) 16px 0;
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
.map-top > * { pointer-events: auto; }
.map-top h1 { font-size: 18px; font-weight: 600; background: rgba(255,255,255,.9); padding: 8px 14px; border-radius: 999px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: var(--shadow); }
.sheet {
  position: relative; z-index: 2;
  margin-top: calc(46dvh - 26px);
  background: var(--card); color: var(--ink);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -8px 30px rgba(30, 40, 50, .10);
  padding: 10px 18px calc(var(--tabbar-h) + var(--safe-bottom) + 34px);
  min-height: calc(54dvh + 26px);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #E2DDD9; margin: 0 auto 16px; }
.sheet .lbl { font-size: 12px; color: var(--muted); display: block; }
.sheet .big { font-size: 24px; font-weight: 600; letter-spacing: .01em; }
.sheet .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet .head .right { text-align: right; }
.sheet .pill { margin-top: 4px; }
.sheet hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.facts div { min-width: 0; }
.facts b { display: block; font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.sheet h3 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.ctr-chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -18px 16px; padding: 0 18px; scrollbar-width: none; }
.ctr-chips button { flex: none; border: 0; border-radius: 999px; padding: 8px 13px; background: var(--bg); color: var(--ink); font-size: 13px; cursor: pointer; }
.ctr-chips button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; position: relative; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; left: 16px; top: 30px; bottom: 2px; border-left: 2px solid var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li.done::before { border-left-color: rgba(255,107,53,.45); }
.timeline .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); }
.timeline .dot svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.timeline li.done .dot { background: var(--peach); }
.timeline li.done .dot svg { stroke: var(--accent); }
.timeline b { display: block; font-size: 15px; font-weight: 500; }
.timeline small { display: block; font-size: 13px; color: var(--muted); }
.timeline .exp { color: #B86E00; font-weight: 500; }
.sheet .muted { color: var(--muted); font-size: 13px; }

/* Map (drawn from bundled coastline data, no tile service) */
.leaflet-container { font: inherit; background: var(--sea); }
.leaflet-control-attribution { font-size: 9px !important; background: rgba(255,255,255,.7) !important; }
.port-pin { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 4px solid var(--dark); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.port-pin.reached { border-color: var(--accent); }
.port-pin.dest { width: 22px; height: 22px; border: 6px solid var(--accent); box-shadow: 0 0 0 6px rgba(255,107,53,.22); }
.vessel-pin { width: 40px; height: 40px; border-radius: 50%; background: var(--dark); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.vessel-pin svg { width: 26px; height: 26px; }

/* ---------- Help ---------- */
.help dl { margin: 0; }
.help dt { margin-top: 12px; }
.help dd { margin: 4px 0 0; color: var(--ink-2); font-size: 15px; }
.help ol { padding-left: 20px; margin: 8px 0 0; color: var(--ink-2); }
.help li { margin-bottom: 6px; }
.help .card p { color: var(--ink-2); font-size: 15px; }
.help .card h3 { font-size: 17px; margin-bottom: 6px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; z-index: 1000;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 10px);
  width: calc(100% - 28px); max-width: 452px; height: var(--tabbar-h);
  background: var(--dark); border-radius: 34px;
  display: grid; grid-template-columns: 1fr 1fr 72px 1fr 1fr; align-items: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  padding: 0 6px;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; color: #8E8E94; font-size: 11px; font-weight: 500; padding: 8px 0; }
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: #fff; }
.tab[aria-current="page"] svg { fill: rgba(255,255,255,.12); }
.tab-fab {
  justify-self: center; width: 58px; height: 58px; border-radius: 50%; border: 4px solid var(--dark);
  background: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent);
}
.tab-fab svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.tab-fab:active { transform: scale(.95); }

/* ---------- Desktop note ---------- */
.desktop-note {
  position: fixed; inset: 0; z-index: 3000;
  background: linear-gradient(160deg, #FFE8DC, #F6F3F1 60%);
  display: grid; place-items: center; padding: 24px;
}
.desktop-card { max-width: 420px; text-align: center; background: var(--card); border-radius: 28px; padding: 28px 28px 30px; box-shadow: 0 20px 60px rgba(60, 30, 10, .12); }
.desktop-ship { height: 130px; margin: -8px -12px 10px; border-radius: 20px; overflow: hidden; background: linear-gradient(180deg, #FFE3D4, #FFF6F1); }
.desktop-card h1 { font-size: 24px; margin-bottom: 8px; }
.desktop-card p { color: var(--ink-2); margin-bottom: 14px; }
.desktop-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--bg); border-radius: 10px; padding: 8px 10px; word-break: break-all; }
body.desktop-preview { background: #EDE8E4; }
body.desktop-preview .app { box-shadow: 0 0 0 1px #E2DCD7, 0 30px 80px rgba(60, 30, 10, .12); }
