@property --h { syntax: "<number>"; inherits: true; initial-value: 104; }

:root {
  --h: 104;
  --bg: #051420;
  --bg2: #0a2436;
  --card: rgba(255, 255, 255, 0.055);
  --card-b: rgba(255, 255, 255, 0.09);
  --text: #eaf4fb;
  --muted: #8da7b8;
  --faint: #5d7a8c;
  --accent: hsl(var(--h) 82% 58%);
  --accent-soft: hsl(var(--h) 82% 58% / 0.16);
  --glow: hsl(var(--h) 90% 55% / 0.35);
  --good: #34d399;
  --ok: #fbbf24;
  --bad: #f87171;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  transition: --h 0.9s ease;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eaf5fb;
  --bg2: #d3e8f4;
  --card: rgba(255, 255, 255, 0.78);
  --card-b: rgba(10, 40, 60, 0.08);
  --text: #0b2233;
  --muted: #53707f;
  --faint: #7b94a3;
  --shadow: 0 10px 28px rgba(20, 60, 90, 0.12);
  color-scheme: light;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--glow), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#bubbles { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; opacity: 0.55; }

.app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:active { transform: scale(0.97); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; }
.chip-spot {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--card-b); backdrop-filter: blur(14px);
  text-align: left;
}
.chip-spot .pin { font-size: 17px; }
.chip-spot .name { flex: 1; min-width: 0; font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-spot .sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; margin-top: 1px; }
.chip-spot .chev { color: var(--muted); font-size: 12px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 16px; flex: none;
  display: grid; place-items: center; font-size: 18px;
  background: var(--card); border: 1px solid var(--card-b); backdrop-filter: blur(14px);
}

.species, .days { position: relative; }
.species { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; margin: 0 -16px; padding-inline: 16px; scroll-snap-type: x proximity; }
.species::-webkit-scrollbar { display: none; }
.pill {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--card); border: 1px solid var(--card-b); color: var(--muted);
  scroll-snap-align: start; transition: all 0.25s ease;
}
.pill.on { color: #04131d; background: var(--accent); border-color: transparent; box-shadow: 0 6px 20px var(--glow); }

/* hero */
.hero {
  position: relative; overflow: hidden; text-align: center;
  padding: 22px 16px 0; border-radius: 30px;
  background: linear-gradient(180deg, var(--card), transparent);
  border: 1px solid var(--card-b); box-shadow: var(--shadow);
}
.gauge-wrap { position: relative; width: 236px; height: 236px; margin: 0 auto; }
.gauge { width: 100%; height: 100%; overflow: visible; }
.gauge .track { fill: none; stroke: var(--card-b); stroke-width: 14; stroke-linecap: round; }
.gauge .prog {
  fill: none; stroke: url(#gg); stroke-width: 14; stroke-linecap: round;
  filter: drop-shadow(0 0 10px var(--glow));
  transition: stroke-dasharray 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.gauge .tick { stroke: var(--faint); stroke-width: 1.4; opacity: 0.55; }
.gauge .knob-g { transform-origin: 118px 118px; transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1); }
.gauge .knob { fill: #fff; filter: drop-shadow(0 0 8px var(--accent)); }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-num { font-size: 66px; font-weight: 800; letter-spacing: -2px; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.gauge-sub { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: 1.5px; text-transform: uppercase; }
.verdict { font-size: 27px; font-weight: 800; margin: 6px 0 2px; color: var(--accent); }
.verdict .emo { margin-right: 6px; }
.hero-date { color: var(--muted); font-size: 14px; }
.hero-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.tag { padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--card); border: 1px solid var(--card-b); color: var(--text); }
.tag.hl { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.windows { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.win { padding: 8px 14px; border-radius: 14px; font-size: 14px; font-weight: 700; background: linear-gradient(135deg, rgba(251, 191, 36, 0.22), rgba(251, 191, 36, 0.08)); border: 1px solid rgba(251, 191, 36, 0.35); color: #fcd34d; }
[data-theme="light"] .win { color: #9a6a00; }
.win small { font-weight: 600; opacity: 0.8; margin-left: 4px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.waves { position: relative; height: 56px; margin: 8px -16px 0; overflow: hidden; }
.waves svg { position: absolute; left: 0; bottom: 0; width: 200%; height: 100%; }
.waves .w1 { animation: drift 11s linear infinite; }
.waves .w2 { animation: drift 17s linear infinite reverse; }
.waves .w1 path { fill: var(--accent); opacity: 0.22; }
.waves .w2 path { fill: var(--accent); opacity: 0.14; }
@keyframes drift { to { transform: translateX(-50%); } }
.fish { position: absolute; bottom: 14px; left: -40px; font-size: 20px; opacity: 0.55; animation: swim 16s linear infinite; }
@keyframes swim { 0% { transform: translateX(0) translateY(0); } 50% { transform: translateX(300px) translateY(-6px); } 100% { transform: translateX(640px) translateY(2px); } }

/* generic card */
.card { padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--card-b); backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.card-h h2 { margin: 0; font-size: 16px; font-weight: 750; }
.card-h .sub { font-size: 12.5px; color: var(--muted); }

/* day strip */
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; scroll-snap-type: x proximity; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: none; width: 62px; padding: 10px 0 12px; border-radius: 18px; text-align: center;
  background: var(--card); border: 1px solid var(--card-b); scroll-snap-align: center; transition: all 0.25s ease;
}
.day .wd { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.day .dn { font-size: 18px; font-weight: 800; margin: 2px 0 8px; }
.day .ring { --v: 0; --c: #888; width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--card-b) 0); position: relative; }
.day .ring::before { content: ""; position: absolute; inset: 3.5px; border-radius: 50%; background: var(--bg2); }
.day .ring span { position: relative; }
.day.on { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 6px 20px var(--glow); }

/* chart */
.chart-box { position: relative; touch-action: pan-y; }
.chart-box svg { width: 100%; display: block; overflow: visible; }
.axis text { fill: var(--faint); font-size: 10.5px; }
.grid line { stroke: var(--card-b); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; filter: drop-shadow(0 0 6px var(--glow)); }
.chart-hit { fill: transparent; cursor: crosshair; }
.tip {
  position: absolute; top: -6px; pointer-events: none; transform: translate(-50%, -100%);
  padding: 8px 11px; border-radius: 12px; font-size: 12px; line-height: 1.35; white-space: nowrap;
  background: rgba(4, 18, 28, 0.94); color: #eaf4fb; border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0; transition: opacity 0.15s; z-index: 3;
}
.tip b { font-size: 14px; }
.readout { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 6px; padding: 10px 12px; border-radius: 14px; background: var(--card-b); font-size: 14px; }
.readout span { font-size: 12.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* factors */
.factor { padding: 11px 0; border-top: 1px solid var(--card-b); }
.factor:first-of-type { border-top: 0; padding-top: 2px; }
.f-top { display: flex; align-items: center; gap: 10px; }
.f-ico { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; background: var(--card-b); flex: none; }
.f-main { flex: 1; min-width: 0; }
.f-label { font-size: 14px; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.f-label em { font-style: normal; font-weight: 800; font-variant-numeric: tabular-nums; }
.f-val { font-size: 12px; color: var(--muted); margin-top: 1px; }
.bar { height: 6px; border-radius: 6px; background: var(--card-b); margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--c, var(--accent)); transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.f-note { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { padding: 14px; border-radius: 20px; background: var(--card); border: 1px solid var(--card-b); backdrop-filter: blur(14px); min-height: 118px; }
.tile .t-h { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.tile .t-v { font-size: 26px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .t-v small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.tile .t-s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.spark { width: 100%; height: 34px; margin-top: 6px; overflow: visible; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.compass { width: 52px; height: 52px; float: right; margin: -2px 0 0 6px; }
.compass .ring { fill: none; stroke: var(--card-b); stroke-width: 2; }
.compass .arrow { fill: var(--accent); transform-origin: 26px 26px; transition: transform 0.6s ease; }
.hour-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: -4px; }

/* moon */
.moon-row { display: flex; gap: 16px; align-items: center; }
.moon-svg { width: 76px; height: 76px; flex: none; filter: drop-shadow(0 0 14px rgba(180, 220, 255, 0.35)); }
.moon-info { flex: 1; min-width: 0; }
.moon-info h3 { margin: 0; font-size: 16px; }
.moon-info p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { padding: 5px 10px; border-radius: 10px; font-size: 12px; font-weight: 650; background: var(--card-b); }
.chip.major { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; }
[data-theme="light"] .chip.major { color: #0369a1; }

.cta { display: block; text-align: center; padding: 14px; border-radius: 18px; font-weight: 750; font-size: 15px; color: #04131d; background: var(--accent); box-shadow: 0 8px 24px var(--glow); text-decoration: none; }
.share-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.share-btn { width: 100%; padding: 13px; border-radius: 16px; font-weight: 700; font-size: 15px; background: var(--card); border: 1px solid var(--card-b); }
.foot { font-size: 11.5px; color: var(--faint); line-height: 1.55; text-align: center; padding: 4px 10px 0; }
.foot a { color: var(--muted); }

/* skeleton & errors */
.sk { background: linear-gradient(90deg, var(--card) 25%, var(--card-b) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 22px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.err { text-align: center; padding: 28px 18px; }
.err p { color: var(--muted); font-size: 14px; margin: 8px 0 16px; }
.err button { padding: 11px 22px; border-radius: 14px; background: var(--accent); color: #04131d; font-weight: 700; }

/* bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 8, 14, 0.55); opacity: 0; transition: opacity 0.25s; display: flex; align-items: flex-end; }
.sheet.open { opacity: 1; }
.sheet-body {
  width: 100%; max-width: 560px; margin: 0 auto; max-height: 82vh; display: flex; flex-direction: column;
  background: var(--bg2); border-radius: 26px 26px 0 0; border: 1px solid var(--card-b);
  transform: translateY(40px); transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.open .sheet-body { transform: none; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--faint); opacity: 0.5; margin: 10px auto 6px; }
.sheet-h { padding: 6px 18px 10px; font-size: 17px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.search { margin: 0 16px 10px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--card-b); background: var(--card); color: var(--text); font: inherit; outline: none; }
.spot-list { overflow-y: auto; padding: 0 12px 16px; }
.region { font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); padding: 14px 8px 6px; font-weight: 700; }
.spot-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 14px; text-align: left; }
.spot-row:hover, .spot-row.on { background: var(--card); }
.spot-row .k { font-size: 11.5px; color: var(--muted); }
.spot-row .n { font-weight: 650; font-size: 15px; }
.spot-row .ck { margin-left: auto; color: var(--accent); font-weight: 800; }
.locate { margin: 0 16px 8px; padding: 13px; border-radius: 16px; font-weight: 700; background: var(--accent-soft); color: var(--accent); width: calc(100% - 32px); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 30; padding: 11px 18px; border-radius: 14px; font-size: 13.5px; font-weight: 600; background: rgba(4, 18, 28, 0.95); color: #eaf4fb; border: 1px solid rgba(255, 255, 255, 0.12); opacity: 0; pointer-events: none; transition: all 0.3s; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #bubbles { display: none; }
}

/* tabs + views */
.view { display: flex; flex-direction: column; gap: 14px; }
.view[hidden], .icon-btn[hidden] { display: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--card); border: 1px solid var(--card-b); }
.seg button { padding: 10px; border-radius: 12px; font-weight: 700; font-size: 14.5px; color: var(--muted); transition: all 0.25s; }
.seg button.on { background: var(--accent); color: #04131d; box-shadow: 0 6px 18px var(--glow); }

/* diary */
.dtiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.dtiles div { text-align: center; padding: 12px 4px; border-radius: 16px; background: var(--card-b); }
.dtiles b { display: block; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dtiles span { font-size: 12px; color: var(--muted); }
.dline { font-size: 14px; margin-top: 8px; }
.dline.muted, .muted-s { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.insights { margin-top: 10px; padding: 12px; border-radius: 14px; background: var(--accent-soft); font-size: 13.5px; line-height: 1.5; display: grid; gap: 6px; }
.cta.add { border: 0; width: 100%; }
.catch { position: relative; display: flex; gap: 12px; padding: 12px; border-radius: 20px; background: var(--card); border: 1px solid var(--card-b); backdrop-filter: blur(14px); }
.c-thumb { width: 76px; height: 76px; border-radius: 14px; object-fit: cover; flex: none; display: block; }
.c-thumb.ph { display: grid; place-items: center; font-size: 30px; background: var(--card-b); }
.c-main { flex: 1; min-width: 0; padding-right: 26px; }
.c-t { font-weight: 750; font-size: 15px; }
.c-s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.c-n { font-size: 12.5px; margin-top: 6px; color: var(--muted); font-style: italic; }
.c-del { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 10px; font-size: 14px; opacity: 0.6; }
.catch .chips { margin-top: 6px; }

/* add-catch form */
.cform { display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 18px; overflow-y: auto; }
.cform label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.cform input, .cform select, .cform textarea { padding: 12px; border-radius: 12px; border: 1px solid var(--card-b); background: var(--card); color: var(--text); font: inherit; font-size: 15px; outline: none; width: 100%; }
.cform textarea { resize: none; }
.row3 { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr; gap: 8px; }
.photo-pick { display: grid !important; place-items: center; min-height: 92px; border-radius: 16px; border: 1.5px dashed var(--faint); background: var(--card); cursor: pointer; color: var(--text) !important; font-size: 15px !important; overflow: hidden; }
.photo-prev { width: 100%; max-height: 220px; object-fit: cover; display: block; }
.cform .cta { border: 0; margin-top: 4px; }
.cform .cta:disabled { opacity: 0.6; }

/* language switch + past days */
.lang-btn { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; border: 1px solid var(--card-b); background: var(--card); color: var(--muted); font: inherit; cursor: pointer; flex: none; }
.lang-btn b { font-size: 12px; font-weight: 800; padding: 6px 9px; border-radius: 999px; letter-spacing: .02em; }
.lang-btn b.on { background: var(--accent); color: #04121c; }
.day.past { opacity: .62; }
.day.past.on { opacity: 1; }
.day.past-btn { min-width: 64px; border-style: dashed; background: transparent; }
.day.past-btn .dn { color: var(--accent); }
.day .pb-s { font-size: 10.5px; line-height: 1.15; color: var(--muted); font-weight: 600; }

/* map picker */
.mappick { position: fixed; inset: 0; z-index: 25; background: var(--bg); }
.mappick[hidden] { display: none !important; }
#mapEl { position: absolute; inset: 0; }
.mp-pin { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 500; pointer-events: none; }
.mp-pin i { position: absolute; left: -15px; top: -42px; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; background: var(--accent); border: 3px solid #fff; transform: rotate(-45deg); box-shadow: 0 6px 14px rgba(0,0,0,.35); transition: transform .15s; }
.mp-pin i::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #fff; }
.mappick.moving .mp-pin i { transform: rotate(-45deg) translate(5px, -5px); }
.mp-close, .mp-loc { position: absolute; z-index: 600; top: calc(14px + env(safe-area-inset-top)); }
.mp-close { left: 14px; } .mp-loc { right: 14px; }
.mp-card { position: absolute; z-index: 600; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); padding: 14px 16px; border-radius: 22px; background: var(--bg2); border: 1px solid var(--card-b); box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.mp-t { font-weight: 800; font-size: 15px; } .mp-c { color: var(--muted); font-size: 12.5px; margin: 2px 0 10px; }
.mp-card .cta { width: 100%; }

/* favorites */
.spot-line { display: flex; align-items: center; gap: 2px; }
.spot-line .spot-row { flex: 1; min-width: 0; }
.star { flex: none; width: 44px; height: 44px; font-size: 22px; color: var(--muted); border-radius: 14px; }
.star.on, .mp-star.on { color: #fbbf24; }
.mp-actions { display: flex; gap: 10px; align-items: center; }
.mp-actions .cta { flex: 1; width: auto; }
.mp-star { font-size: 22px; }
