:root {
  --navy: #0b2942;
  --navy-2: #103a5c;
  --teal: #1fb6a6;
  --teal-d: #149587;
  --sky: #3aa0e3;
  --bg: #f3f6f9;
  --ink: #0d1b2a;
  --muted: #5b6b7b;
  --line: #dde6ee;
  --danger: #e23d3d;
  --ok: #1fa463;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(11, 41, 66, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--teal-d); text-decoration: none; }
h1, h2, h3 { line-height: 1.15; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { justify-content: center; }
.mt { margin-top: 14px; display: block; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; border: 0; cursor: pointer; font-weight: 600;
  padding: 12px 20px; border-radius: 10px; font-size: 1rem;
  transition: transform .05s ease, background .2s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-d); }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn-small { padding: 8px 14px; font-size: .9rem; border-radius: 8px; background: var(--navy); color:#fff; }
.btn-block { width: 100%; margin-top: 8px; background: var(--navy); color: #fff; }
.btn-block:hover { background: var(--navy-2); }
.btn-danger { background: var(--danger); }
.link { background: none; border: 0; color: var(--teal-d); cursor: pointer; font-weight: 600; padding: 0; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; }
.nav nav { display: flex; align-items: center; gap: 18px; }
.nav nav a { color: #dceaf5; font-weight: 600; }
.nav nav a.btn { color: #fff; }
.anchor { font-size: 1.25rem; }

/* Hero */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center;
  padding: 72px 24px; max-width: 1100px; margin: 0 auto;
}
.badge {
  display: inline-block; margin-bottom: 18px; padding: 6px 14px; border-radius: 999px;
  background: rgba(31,182,166,.12); color: var(--teal-d); font-weight: 700; font-size: .85rem;
  letter-spacing: .02em; border: 1px solid rgba(31,182,166,.3);
}
.hero-copy h1 { font-size: 3rem; margin: 0 0 16px; color: var(--navy); letter-spacing: -.5px; }
.lede { font-size: 1.25rem; color: var(--muted); max-width: 520px; }
.cta-row { display: flex; gap: 14px; margin: 28px 0 10px; flex-wrap: wrap; }
.fineprint { color: var(--muted); font-size: .95rem; }
.hero-card {
  background: linear-gradient(160deg, var(--navy), var(--navy-2));
  color: #cfe3f1; border-radius: 20px; padding: 28px; box-shadow: var(--shadow); text-align: center;
}
.watch-mock { position: relative; height: 200px; margin-bottom: 12px; }
.watch-mock .ring {
  position: absolute; inset: 50% auto auto 50%; width: 170px; height: 170px;
  transform: translate(-50%, -50%); border: 3px dashed var(--teal); border-radius: 50%;
  background: radial-gradient(circle, rgba(31,182,166,.18), transparent 70%);
}
.watch-mock .boat { position: absolute; left: 52%; top: 40%; font-size: 2rem; transform: translate(-50%,-50%); animation: sway 5s ease-in-out infinite; }
.watch-mock .anchor-dot { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; background: var(--teal); border-radius: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 0 4px rgba(31,182,166,.3); }
@keyframes sway { 0%,100% { left: 47%; top: 42%; } 50% { left: 57%; top: 38%; } }

/* Why it's easier */
.why { background: var(--navy); color: #fff; }
.why > h2 { font-size: 2rem; text-align: center; margin: 0 0 10px; max-width: 1100px; margin-inline: auto; padding-top: 56px; }
.why .section-lede { color: #9db6cc; max-width: 680px; }
.why .section-lede em { color: var(--teal); font-style: normal; font-weight: 700; }
.why-grid {
  max-width: 1100px; margin: 32px auto 0; padding: 0 24px 56px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
}
.why-card {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius); padding: 22px;
}
.why-icon { font-size: 1.8rem; display: block; margin-bottom: 10px; }
.why-card h3 { margin: 0 0 8px; font-size: 1.05rem; color: #fff; }
.why-card p { margin: 0; color: #b9cde0; font-size: .95rem; }

/* GPS sources */
.gps { max-width: 1100px; margin: 0 auto; padding: 56px 24px 40px; }
.gps h2 { font-size: 2rem; color: var(--navy); text-align: center; margin: 0 0 10px; }
.section-lede { max-width: 640px; margin: 0 auto; text-align: center; color: var(--muted); font-size: 1.1rem; }
.src-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 32px; }
.src {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.src:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.src-icon { font-size: 1.8rem; display: block; margin-bottom: 10px; }
.src h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--navy); }
.src p { margin: 0; color: var(--muted); font-size: .95rem; }

/* Features */
.features, .how { max-width: 1100px; margin: 0 auto; padding: 48px 24px; }
.features h2, .how h2 { font-size: 2rem; color: var(--navy); text-align: center; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 28px; }
.feature { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.feature h3 { margin: 0 0 8px; font-size: 1.1rem; }
.feature p { margin: 0; color: var(--muted); }

/* How */
.how { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); max-width: none; }
.steps { max-width: 760px; margin: 24px auto; list-style: none; padding: 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: center; background: var(--bg); border-radius: 12px; padding: 16px 18px; }
.steps span { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* ═══════════════ Web app — iOS-styled (scoped to .app) ═══════════════ */
body.app-page { background: #f2f2f7; }
.app {
  --ios-blue: #007aff; --ios-teal: #30b0c7; --ios-green: #34c759;
  --ios-red: #ff3b30; --ios-orange: #ff9500;
  --ios-label: #1c1c1e; --ios-secondary: #8a8a8e;
  --ios-card: #fff; --ios-fill: #e9e9ee; --ios-sep: #e4e4ea;
  max-width: 1180px; margin: 0 auto; padding: 18px 18px 32px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

/* Header */
.ios-header { text-align: center; padding: 4px 0 14px; }
.app-home { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.05rem; color: var(--ios-label); letter-spacing: .3px; }
.app-home .app-logo { width: 28px; height: 28px; border-radius: 7px; display: block; }
#heroIcon svg { width: 1em; height: 1em; vertical-align: -0.12em; display: inline-block; }
.alarm-banner .warn-ic { width: 1.05em; height: 1.05em; vertical-align: -0.15em; }
.bolt-ic { width: .9em; height: .9em; vertical-align: -0.1em; color: var(--ios-green); }
.pills { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: rgba(0,122,255,.14); color: var(--ios-blue); }
.pill.teal { background: rgba(48,176,199,.16); color: #1f8597; }
.pill.green { background: rgba(52,199,89,.18); color: #248a3d; }
.pill.red { background: rgba(255,59,48,.15); color: var(--ios-red); }
.pill.orange { background: rgba(255,149,0,.18); color: #b56b00; }
.pill.hidden { display: none; }
.sharecode-line { margin-top: 10px; font-size: .8rem; color: var(--ios-secondary); }
.sharecode-line b.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ios-label); }

/* Two-column body; left column is a stack of iOS cards */
.app-body { display: grid; grid-template-columns: 350px 1fr; gap: 18px; align-items: start; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.app .card { background: var(--ios-card); border-radius: 16px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-label { font-size: .72rem; font-weight: 800; letter-spacing: .5px; color: var(--ios-secondary); text-transform: uppercase; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-value { font-weight: 700; font-size: 1.05rem; color: var(--ios-label); }

/* Status hero (gradient, state-coloured) + swing radar */
.status-hero { border-radius: 20px; padding: 18px; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.status-hero.notarmed { background: linear-gradient(135deg, #007aff, #0f3a5c); }
.status-hero.holding  { background: linear-gradient(135deg, #34c759, #1a734d); }
.status-hero.dragging { background: linear-gradient(135deg, #ff3b30, #991a1a); animation: pulse-red 1.2s ease-in-out infinite; }
.status-hero.waiting  { background: linear-gradient(135deg, #ff9500, #ffb84d); }
.hero-main { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 108px; }
.hero-status { display: flex; align-items: center; gap: 6px; font-weight: 800; letter-spacing: 1px; font-size: .9rem; }
#heroIcon { font-size: 1.05rem; }
.hero-dist { display: flex; align-items: baseline; gap: 4px; margin-top: 6px; }
.hero-dist .num { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.hero-dist .unit { font-size: 1rem; opacity: .85; font-weight: 700; }
.hero-sub { font-size: .82rem; opacity: .9; margin-top: 6px; line-height: 1.35; }
.swing { flex: none; width: 104px; height: 104px; }
.status-hero.centered .hero-main { flex-direction: column; text-align: center; justify-content: center; }
.status-hero.centered .swing { display: none; }
.status-hero.centered .hero-status { flex-direction: column; gap: 8px; font-size: 1rem; }
.status-hero.centered #heroIcon { font-size: 2rem; }
.status-hero.centered .hero-sub { max-width: 34ch; margin-inline: auto; }
@keyframes pulse-red { 0%,100% { box-shadow: 0 4px 14px rgba(255,59,48,.3); } 50% { box-shadow: 0 4px 22px rgba(255,59,48,.65); } }

/* iOS segmented control */
.app .seg { display: flex; background: var(--ios-fill); border-radius: 9px; padding: 2px; gap: 2px; margin-top: 10px; }
.app .seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--ios-label); }
.app .seg button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.app .seg-wrap { flex-wrap: wrap; }
.app .seg-wrap button { flex: 1 1 40%; font-size: .82rem; }

/* Share code */
.app .code-row { display: flex; gap: 8px; margin-top: 10px; }
.app .code-row input {
  flex: 1; font: 700 1.1rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px;
  text-transform: uppercase; text-align: center; padding: 10px; border: 1px solid var(--ios-sep); border-radius: 10px; background: #fff;
}
.app .code-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

.app input[type=range] { width: 100%; accent-color: var(--ios-blue); margin-top: 8px; }
.mt { margin-top: 12px; display: block; }

/* Allowed-distance preset chips */
.presets { display: flex; gap: 8px; margin-top: 10px; }
.presets button { flex: 1; border: 0; background: var(--ios-fill); color: var(--ios-blue); font-weight: 700; font-size: .85rem; padding: 8px 0; border-radius: 8px; cursor: pointer; }
.presets button.active { background: rgba(0,122,255,.16); }

/* GPS status detail rows */
.detail-rows { display: flex; flex-direction: column; margin-top: 8px; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--ios-sep); font-size: .92rem; }
.detail-row:first-child { border-top: 0; }
.detail-row .k { color: var(--ios-secondary); }
.detail-row .v { font-weight: 600; color: var(--ios-label); }
.detail-row .v.green { color: var(--ios-green); }
.detail-row .v.red { color: var(--ios-red); }
.detail-row .v.orange { color: #b56b00; }

/* Source picker buttons + status pills */
.src-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.app .btn-small { width: 100%; padding: 10px; border-radius: 10px; background: var(--ios-fill); color: var(--ios-blue); font-weight: 700; font-size: .9rem; border: 0; cursor: pointer; }
.app .btn.disabled, .app .btn-small.disabled { opacity: .5; }
.src-status { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.src-pill { font-size: .7rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--ios-fill); color: var(--ios-secondary); }
.src-pill.live { background: rgba(52,199,89,.18); color: #248a3d; }
.src-pill.coarse { background: rgba(255,149,0,.18); color: #b56b00; }
.src-active { flex-basis: 100%; font-size: .8rem; color: var(--ios-secondary); margin-top: 2px; }
.src-active b { color: var(--ios-label); }
.app .status { font-size: .82rem; color: var(--ios-secondary); margin-top: 8px; }

/* Anchor actions */
.anchor-actions { display: flex; flex-direction: column; gap: 10px; }
.app .btn-action { width: 100%; padding: 14px; border-radius: 14px; font-size: 1rem; font-weight: 700; color: #fff; border: 0; cursor: pointer; }
.btn-green { background: var(--ios-green); }
.btn-red { background: var(--ios-red); }
.btn-blue { background: var(--ios-blue); }
.anchor-modes { display: flex; gap: 18px; justify-content: center; margin-top: 2px; }
.app .link { background: none; border: 0; color: var(--ios-blue); font-weight: 600; cursor: pointer; padding: 0; font-size: .92rem; }
.app .link.armed { color: var(--ios-red); text-decoration: underline; }

/* Sector zone */
label.checkbox { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--ios-label); cursor: pointer; margin-top: 12px; }
label.checkbox input { width: auto; accent-color: var(--ios-blue); }
.sector-fields .sub { display: block; font-size: .8rem; color: var(--ios-secondary); margin-top: 8px; font-weight: 600; }

/* Scope calculator */
.scope-panel { margin-top: 10px; padding: 12px; background: var(--ios-fill); border-radius: 12px; }
.scope-panel .sub { display: block; font-size: .8rem; color: var(--ios-secondary); margin-top: 8px; font-weight: 600; }
.scope-panel .seg { background: #fff; }
.scope-result { margin-top: 12px; font-weight: 700; color: var(--ios-label); }
.scope-result b { color: var(--ios-blue); }

/* Mooring-type picker */
.moorings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.moor { border: 1px solid var(--ios-sep); background: #fff; border-radius: 12px; padding: 6px 6px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.moor img { width: 100%; height: auto; border-radius: 8px; display: block; }
.moor span { font-size: .72rem; font-weight: 600; color: var(--ios-label); }
.moor.active { border-color: var(--ios-blue); box-shadow: 0 0 0 2px rgba(0,122,255,.25); }
.corridor-controls { margin-top: 12px; border-top: 1px solid var(--ios-sep); padding-top: 10px; }

/* Find My Boat HUD */
.findboat { position: fixed; inset: 0; z-index: 3000; background: #000; color: #fff; display: flex; flex-direction: column; padding: 20px; }
.fb-top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; letter-spacing: 2px; color: rgba(255,255,255,.7); font-size: .9rem; }
.fb-x { background: none; border: 0; color: rgba(255,255,255,.6); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.fb-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.fb-arrow { transition: transform .2s ease; }
.fb-dist { font-size: 3rem; font-weight: 800; }
.fb-bearing { color: rgba(255,255,255,.6); }
.fb-hint { text-align: center; color: rgba(255,255,255,.45); font-size: .85rem; padding: 0 24px 8px; }

/* Map markers (mirror the iOS map) */
.m-boat { width: 26px; height: 26px; border-radius: 50%; background: #007aff; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
.m-boat .m-dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.m-anchor { width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; }
.m-buoy { width: 22px; height: 22px; border-radius: 50%; background: #c2603a; border: 2px solid #fff; position: relative; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.m-buoy::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 3px; background: #fff; transform: translateY(-50%); }
.m-buoy::after { content: ""; position: absolute; left: 50%; top: -8px; width: 3px; height: 8px; background: #c2603a; transform: translateX(-50%); border-radius: 1px; }

/* Map */
.map-wrap { position: relative; border-radius: 16px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
#map { width: 100%; height: 78vh; min-height: 460px; background: #aadaff; }
.alarm-banner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: var(--ios-red); color: #fff; padding: 12px 18px; border-radius: 14px;
  display: flex; align-items: center; gap: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.2); font-size: 1rem;
  animation: pulse 1s ease-in-out infinite;
}
.alarm-banner .btn-small { width: auto; background: rgba(0,0,0,.25); color: #fff; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,59,48,.6); } 50% { box-shadow: 0 0 0 12px rgba(255,59,48,0); } }

/* Footer */
.foot { text-align: center; padding: 36px 24px; color: var(--muted); border-top: 1px solid var(--line); }
.foot a { font-weight: 600; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding: 40px 20px; }
  .hero-copy h1 { font-size: 2.2rem; }
  .grid { grid-template-columns: 1fr; }
  .src-grid { grid-template-columns: 1fr; }
  .why-grid { grid-template-columns: 1fr; }
  .app-body { grid-template-columns: 1fr; }
  #map { height: 56vh; }
  .nav nav a:not(.btn) { display: none; }
}

@media (min-width: 861px) and (max-width: 1024px) {
  .src-grid { grid-template-columns: repeat(2, 1fr); }
  .why-grid { grid-template-columns: repeat(2, 1fr); }
}
