:root {
  --bg: #f3faf6;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --text: #0f2a24;
  --muted: #5b7a71;
  --border: rgba(15, 118, 110, 0.14);
  --shadow: 0 10px 30px -12px rgba(15, 118, 110, 0.35);
  --accent: #0f766e;
  --accent-2: #f59e0b;
  --radius: 22px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07140f;
    --surface: rgba(20, 40, 33, 0.7);
    --surface-solid: #12261f;
    --text: #e8f6f0;
    --muted: #8fb0a4;
    --border: rgba(110, 231, 183, 0.14);
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
    --accent: #34d399;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

/* Floating colour blobs behind everything */
.blob { position: fixed; z-index: 0; border-radius: 50%; filter: blur(70px); opacity: .45; pointer-events: none; }
.blob-a { width: 320px; height: 320px; background: #34d399; top: -90px; right: -80px; animation: drift 14s ease-in-out infinite alternate; }
.blob-b { width: 280px; height: 280px; background: #fbbf24; bottom: -80px; left: -90px; animation: drift 18s ease-in-out infinite alternate-reverse; }
@keyframes drift { to { transform: translate(30px, 40px) scale(1.15); } }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.titles { flex: 1; min-width: 0; }
.titles h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.titles p { margin: 2px 0 0; font-size: .82rem; color: var(--muted); }
.back, .install {
  border: 0; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  box-shadow: 0 6px 16px -6px rgba(15, 118, 110, .7);
}
.back { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; }
.install { padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
[hidden] { display: none !important; }
.back:active, .install:active { transform: scale(.94); }

main {
  position: relative; z-index: 1;
  max-width: 760px; margin: 0 auto;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 40px);
}
.view { animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Plan grid on the homepage */
.hero {
  padding: 22px; margin-bottom: 20px; border-radius: var(--radius); color: #fff;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 60%, #fbbf24 140%);
  box-shadow: var(--shadow);
}
.hero h2 { margin: 0 0 4px; font-size: 1.5rem; }
.hero p { margin: 0; opacity: .92; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.plan-card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-solid); color: inherit; text-align: left; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i) * 60ms);
}
.plan-card:hover { transform: translateY(-4px); }
.plan-card:active { transform: scale(.97); }
.plan-thumb { aspect-ratio: 4 / 3; overflow: hidden; background: linear-gradient(135deg, #99f6e4, #fde68a); }
.plan-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.plan-thumb.empty { display: grid; place-items: center; font-size: 2.6rem; }
.plan-meta { padding: 12px 14px 14px; }
.plan-meta strong { display: block; font-size: 1.05rem; }
.plan-meta span { font-size: .8rem; color: var(--muted); }
.badge {
  position: absolute; right: 12px; bottom: 14px; min-width: 32px; height: 32px; padding: 0 9px;
  display: grid; place-items: center; border-radius: 999px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 4px 12px -2px rgba(249, 115, 22, .6);
}

/* Category list inside a plan */
.list { display: flex; flex-direction: column; gap: 12px; }
.cat-card {
  display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: inherit; font: inherit; text-align: left; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .2s ease;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i) * 70ms);
}
.cat-card:hover { transform: translateX(4px); }
.cat-card:active { transform: scale(.98); }
.cat-icon {
  flex: none; width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  font-size: 1.7rem; background: var(--tint);
}
.cat-body { flex: 1; min-width: 0; }
.cat-body strong { display: block; font-size: 1.1rem; }
.cat-body span { font-size: .82rem; color: var(--muted); }
.chev { color: var(--muted); font-size: 1.6rem; }
.section-title { margin: 22px 4px 10px; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }

/* Images in a category */
.shots { display: flex; flex-direction: column; gap: 16px; }
.shot {
  margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--surface-solid); box-shadow: var(--shadow); cursor: zoom-in;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 80ms);
}
.shot img { display: block; width: 100%; height: auto; min-height: 160px; }
.hint { text-align: center; color: var(--muted); font-size: .8rem; margin: 6px 0 14px; }

.empty-state, .error { text-align: center; padding: 48px 12px; color: var(--muted); }
.skeleton { height: 190px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-solid) 25%, var(--border) 50%, var(--surface-solid) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Fullscreen viewer */
.viewer { position: fixed; inset: 0; z-index: 100; background: #020a07; display: flex; flex-direction: column; animation: fade .2s ease; }
.viewer[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.viewer-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px; color: #fff; font-weight: 700;
}
.viewer-bar button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.1rem; cursor: pointer; }
.viewer-stage { flex: 1; overflow: auto; display: grid; place-items: center; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; cursor: zoom-in; user-select: none; }
.viewer-stage.zoomed { place-items: start; }
.viewer-stage.zoomed img { max-width: none; max-height: none; width: 220%; cursor: zoom-out; }
.nav { position: absolute; top: 50%; width: 44px; height: 64px; margin-top: -32px; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 2rem; cursor: pointer; }
.nav.prev { left: 0; border-radius: 0 16px 16px 0; }
.nav.next { right: 0; border-radius: 16px 0 0 16px; }
.nav[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Login */
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px 18px; }
.login-card {
  width: 100%; max-width: 380px; padding: 30px 26px 26px; text-align: center;
  border: 1px solid var(--border); border-radius: 28px; background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow); animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
.login-logo { border-radius: 24px; box-shadow: 0 12px 28px -10px rgba(15, 118, 110, .7); }
.login-card h1 { margin: 14px 0 2px; font-size: 1.6rem; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: .9rem; }
.login-card label { display: block; margin: 14px 4px 6px; text-align: left; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.login-card input {
  width: 100%; padding: 14px 16px; border-radius: 16px; font: inherit; font-size: 1rem; /* 16px+ stops iOS zoom */
  color: var(--text); background: var(--surface-solid); border: 1.5px solid var(--border); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(20, 184, 166, .2); }
.login-card button {
  width: 100%; margin-top: 22px; padding: 14px; border: 0; border-radius: 16px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 1rem; color: #fff;
  background: linear-gradient(135deg, #0f766e, #14b8a6); box-shadow: 0 10px 22px -8px rgba(15, 118, 110, .8);
}
.login-card button:active { transform: scale(.98); }
.login-card button:disabled { opacity: .7; cursor: wait; }
.login-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; font-size: .88rem; color: #b91c1c; background: rgba(239, 68, 68, .12); }
@media (prefers-color-scheme: dark) { .login-error { color: #fca5a5; } }
.login-card.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.logout { border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 700; font-size: .8rem; color: var(--muted); background: transparent; cursor: pointer; }

.login-card .install-link { margin-top: 12px; background: transparent; color: var(--accent); box-shadow: none; border: 1.5px solid var(--border); font-weight: 700; }
