:root {
  --bg-0: #050B1A; --bg-1: #0A1B2E; --teal: #0E4F5C; --cyan: #3EE6F0; --violet: #A78BFA;
  --text: #EAF6FA; --muted: #8FB3C2; --glass: rgba(255,255,255,0.06); --glass-border: rgba(160,230,255,0.16);
  --radius: 22px; --gutter: 16px; --tabs-h: 78px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(120% 70% at 70% -10%, #0F5563 0%, rgba(14,79,92,0) 60%),
              linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 70%);
  background-color: var(--bg-0); background-attachment: fixed;
  color: var(--text); font-family: Inter, system-ui, -apple-system, sans-serif; font-weight: 400;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
.caustics {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5; mix-blend-mode: screen;
  background:
    radial-gradient(40% 22% at 20% 8%, rgba(62,230,240,.16), transparent 70%),
    radial-gradient(30% 18% at 75% 4%, rgba(62,230,240,.12), transparent 70%),
    repeating-radial-gradient(circle at 40% -20%, rgba(120,240,255,.05) 0 2px, transparent 3px 26px);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(-3%, 2%, 0) scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .caustics, .pulse::before, .pulse::after { animation: none !important; } }

.app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 20px) var(--gutter) calc(var(--tabs-h) + 28px); }
.app.full { padding: 0; max-width: none; }

/* wordmark */
.brand { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 500; letter-spacing: -.01em; }
.brand svg { width: 34px; height: 20px; }
.brand b { font-weight: 300; }

h1 { font-size: 52px; line-height: 1; letter-spacing: -.03em; font-weight: 700; margin: 26px 0 10px; }
.sub { color: var(--muted); font-size: 16px; margin: 0 0 22px; }
.glass { background: linear-gradient(160deg, rgba(255,255,255,.09), rgba(255,255,255,.03));
  border: 1px solid var(--glass-border); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08); }

/* sparkline */
.spark { width: 100%; height: 150px; margin-bottom: 22px; }
.spark text, .chart text { fill: var(--muted); font: 12px Inter, sans-serif; }
.grid { stroke: rgba(160,230,255,.14); stroke-dasharray: 3 4; }

/* pills */
.pills { display: flex; gap: 10px; margin-bottom: 22px; }
.pill { padding: 10px 20px; border-radius: 999px; border: 1px solid var(--glass-border); background: var(--glass);
  color: var(--text); font: 500 15px Inter, sans-serif; cursor: pointer; }
.pill.on { border-color: var(--cyan); box-shadow: 0 0 18px rgba(62,230,240,.35), inset 0 0 12px rgba(62,230,240,.15); }

/* dive cards */
.cards { display: grid; gap: 14px; }
.card { display: grid; grid-template-columns: 112px 1fr; gap: 16px; padding: 14px; align-items: center; }
.thumb { width: 112px; height: 96px; border-radius: 14px; overflow: hidden; position: relative;
  background: radial-gradient(80% 80% at 30% 20%, #18707C, #0A2738); }
.thumb .tiles { position: absolute; }
.thumb .tiles img { position: absolute; width: 256px; height: 256px; }
.thumb .dot { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -100%); }
.card h3 { margin: 0 0 4px; font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.card .when { color: var(--muted); margin-bottom: 12px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-border); font-size: 14px; white-space: nowrap; }
.chip svg { width: 16px; height: 16px; stroke: var(--cyan); fill: none; stroke-width: 2; }
.chip.t svg { stroke: var(--violet); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty b { display: block; color: var(--text); font-size: 20px; margin-bottom: 6px; }

/* detail */
.back { display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.back svg { width: 26px; height: 26px; stroke: var(--text); fill: none; stroke-width: 2.4; }
.back h1 { margin: 0; font-size: 40px; }
.detail-sub { color: var(--muted); margin: 6px 0 22px 40px; font-size: 16px; }
.chart-card { padding: 16px 12px 10px; margin-bottom: 16px; }
.legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); padding: 0 6px 8px; align-items: center; }
.legend i { display: inline-block; width: 22px; height: 3px; border-radius: 2px; margin-right: 8px; vertical-align: middle; }
.legend .w { margin-left: auto; color: var(--text); }
.chart { width: 100%; height: 300px; display: block; }
.tiles2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tile { display: flex; gap: 14px; padding: 16px; align-items: center; min-width: 0; }
.tile svg { width: 30px; height: 30px; flex: none; stroke: var(--cyan); fill: none; stroke-width: 1.8; }
.tile.t svg { stroke: var(--violet); }
.tile small { display: block; color: var(--muted); font-size: 14px; }
.tile b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.mapcard { height: 230px; overflow: hidden; position: relative; margin-bottom: 18px; }
.mapcard .map { position: absolute; inset: 0; }
.footer { text-align: center; color: var(--muted); font-size: 14px; }

/* live */
.live { position: relative; min-height: 100vh; }
.live .map { position: fixed; inset: 0; }
.live.idle .map { filter: saturate(.6) brightness(.55); }
.live .top { position: fixed; left: 0; right: 0; top: 0; z-index: 3; display: flex; justify-content: space-between;
  align-items: center; padding: calc(env(safe-area-inset-top) + 20px) 20px 40px;
  background: linear-gradient(180deg, rgba(5,11,26,.75), transparent); }
.live .brand { font-size: 30px; }
.livepill { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-radius: 999px;
  border: 1.5px solid var(--cyan); color: var(--cyan); font-weight: 600; letter-spacing: .08em;
  background: rgba(5,30,40,.55); box-shadow: 0 0 24px rgba(62,230,240,.35); }
.livepill i { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); animation: blink 1.6s infinite; }
.livepill.off { border-color: var(--glass-border); color: var(--muted); box-shadow: none; }
.livepill.off i { background: var(--muted); animation: none; }
@keyframes blink { 50% { opacity: .25; } }
.sheet { position: fixed; left: 0; right: 0; bottom: var(--tabs-h); z-index: 3; max-width: 480px; margin: 0 auto;
  padding: 14px 24px 22px; border-radius: 30px 30px 0 0; border-bottom: none;
  background: linear-gradient(160deg, rgba(20,70,85,.72), rgba(10,27,46,.86) 60%, rgba(70,50,130,.5));
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.sheet .grab { width: 56px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 0 auto 16px; }
.sheet h2 { font-size: 36px; font-weight: 500; letter-spacing: -.02em; margin: 0 0 18px; }
.stats3 { display: grid; grid-template-columns: 1fr 1fr 128px; align-items: center; margin-bottom: 14px; }
.stats3 > div:not(.ring) { border-right: 1px solid var(--glass-border); padding-right: 10px; }
.stats3 > div:nth-child(2) { padding-left: 14px; }
.stats3 small { display: block; color: var(--muted); font-size: 15px; margin-bottom: 4px; }
.stats3 b { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.ring { position: relative; width: 128px; height: 128px; justify-self: end; }
.ring svg { width: 128px; height: 128px; transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .lbl small { color: var(--muted); font-size: 14px; }
.ring .lbl b { font-size: 24px; }
.ring.over .lbl b, .ring.over .lbl small { color: var(--violet); }
.meta { border-top: 1px solid var(--glass-border); padding: 12px 0; font-size: 16px; }
.note { border-top: 1px solid var(--glass-border); padding-top: 12px; color: #8FD6E6; font-style: italic; font-size: 15px; }
.note a { color: var(--cyan); font-style: normal; }
.pulse { position: relative; width: 70px; height: 70px; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(62,230,240,.35), rgba(62,230,240,0) 70%); animation: ping 2.4s infinite; }
.pulse::after { animation-delay: 1.2s; }
.pulse svg { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -60%);
  filter: drop-shadow(0 0 8px var(--cyan)); }
@keyframes ping { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.sitelabel { padding: 8px 16px; border-radius: 999px; background: rgba(5,20,35,.7); border: 1px solid rgba(255,255,255,.3);
  font-size: 15px; white-space: nowrap; }

/* tab bar */
.tabs { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; justify-content: space-around; align-items: center;
  background: linear-gradient(180deg, rgba(10,27,46,.92), rgba(5,11,26,.98)); border-top: 1px solid var(--glass-border); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 15px;
  padding: 8px 20px; position: relative; }
.tabs svg { width: 30px; height: 30px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tabs svg .fill { fill: currentColor; }
.tabs a.on { color: var(--cyan); text-shadow: 0 0 14px rgba(62,230,240,.6); }
.tabs a.on svg { filter: drop-shadow(0 0 6px rgba(62,230,240,.7)); }
.tabs a.on::after { content: ""; position: absolute; bottom: -4px; left: 18%; right: 18%; height: 2px; border-radius: 2px;
  background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }

/* admin */
.form { display: grid; gap: 14px; padding: 20px; margin-top: 24px; }
.form label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.form input, .form select { font: 500 18px Inter, sans-serif; color: var(--text); background: rgba(0,0,0,.25);
  border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px 14px; width: 100%; }
.btn { font: 600 18px Inter, sans-serif; padding: 16px; border-radius: 16px; border: none; cursor: pointer; color: #04202A;
  background: linear-gradient(90deg, var(--cyan), #7FDDF5); box-shadow: 0 0 24px rgba(62,230,240,.35); }
.btn.out { background: linear-gradient(90deg, var(--violet), #C4B5FD); }
.msg { color: var(--muted); font-size: 14px; min-height: 18px; }
.maplibregl-ctrl-attrib { font-size: 10px; background: rgba(5,11,26,.5) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }

@media (max-width: 380px) {
  h1 { font-size: 44px; } .stats3 { grid-template-columns: 1fr 1fr 108px; }
  .ring, .ring svg { width: 108px; height: 108px; } .stats3 b { font-size: 28px; } .sheet h2 { font-size: 30px; }
  .card { grid-template-columns: 92px 1fr; } .thumb { width: 92px; height: 84px; } .tile b { font-size: 20px; }
}
