﻿/* ============================================================
   Factory base ??structural design system shared by all apps.
   Each app defines its identity in styles.css via CSS variables:
   --bg --bg-card --fg --fg-muted --fg-subtle --line --line-strong
   --accent --accent-2 --good --bad --font-display --font-body
   --radius --nav-cols
   ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden must always win over component display rules (upsell sheet etc.) */
[hidden] { display: none !important; }


html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  overscroll-behavior: none;
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: 0.01em;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

/* ?? Topbar ?? */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  padding: 12px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.brand-sub {
  display: block;
  margin-top: 5px;
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.lang-switch { display: flex; gap: 2px; border: 1px solid var(--line); padding: 2px; border-radius: var(--radius); }

.lang-btn {
  min-width: 26px; height: 26px; padding: 0 4px;
  border: none; background: transparent; color: var(--fg-subtle);
  font-size: 0.52rem; font-weight: 600; letter-spacing: 0.05em; cursor: pointer;
  border-radius: calc(var(--radius) - 2px);
}
.lang-btn.active { background: var(--fg); color: var(--bg); }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line); background: transparent; color: var(--fg);
  border-radius: var(--radius); cursor: pointer; font-size: 0.9rem;
}

.pro-pill {
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  font-size: 0.52rem; font-weight: 700; letter-spacing: 0.16em;
  padding: 7px 10px; border-radius: var(--radius); cursor: pointer;
}
.pro-pill.active { background: var(--accent); color: var(--bg); }

/* ?? Screens ?? */
.screen { display: none; padding: 24px 22px 12px; animation: rise 0.45s cubic-bezier(0.22,1,0.36,1); }
.screen.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: var(--font-display);
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--fg-muted);
  margin: 30px 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.section-title:first-child { margin-top: 0; }

/* ?? Stats grid ?? */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--bg-card); padding: 16px 15px; }
.stat .label { font-size: 0.55rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--fg-subtle); }
.stat .value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin-top: 6px; line-height: 1.1; }
.stat .sub { color: var(--fg-muted); font-size: 0.68rem; margin-top: 4px; }
.stat.wide { grid-column: 1 / -1; }

/* ?? Hero ?? */
.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 30px 22px 26px;
  text-align: center;
  margin-bottom: 20px;
}
.hero .hero-value { font-family: var(--font-display); font-size: 3.6rem; font-weight: 600; line-height: 1; letter-spacing: -0.01em; }
.hero .hero-label { margin-top: 10px; font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--fg-muted); }
.hero .hero-sub { margin-top: 8px; font-size: 0.74rem; color: var(--fg-muted); line-height: 1.5; }

/* ?? Lists ?? */
.list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { background: var(--bg-card); padding: 14px 16px; display: flex; align-items: center; gap: 13px; }
.row .icon { font-size: 1.15rem; width: 30px; text-align: center; flex-shrink: 0; }
.row .thumb { width: 40px; height: 40px; border-radius: calc(var(--radius) - 2px); object-fit: cover; flex-shrink: 0; background: var(--line); }
.row .body { flex: 1; min-width: 0; }
.row .body strong { display: block; font-size: 0.86rem; font-weight: 600; letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .body span { color: var(--fg-muted); font-size: 0.7rem; margin-top: 3px; display: block; line-height: 1.45; }
.row .metric { font-family: var(--font-display); font-size: 1rem; font-weight: 600; white-space: nowrap; text-align: right; }
.row .metric small { display: block; font-family: var(--font-body); font-size: 0.6rem; font-weight: 400; color: var(--fg-subtle); letter-spacing: 0.08em; margin-top: 2px; }
.row.tappable { cursor: pointer; }
.row.tappable:active { background: var(--bg); }

.pos { color: var(--good) !important; }
.neg { color: var(--bad) !important; }
.accent { color: var(--accent) !important; }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 99px;
  font-size: 0.56rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--line-strong); color: var(--fg-muted);
}
.badge.good { border-color: var(--good); color: var(--good); }
.badge.bad { border-color: var(--bad); color: var(--bad); }
.badge.accent { border-color: var(--accent); color: var(--accent); }

/* ?? Chips ?? */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 9px 15px; border: 1px solid var(--line); background: transparent; color: var(--fg-muted);
  font-family: var(--font-body); font-size: 0.6rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer; border-radius: 99px;
}
.chip.active { border-color: var(--accent); background: var(--accent); color: var(--bg); }

/* ?? Forms ?? */
.field-row { display: flex; gap: 10px; margin-bottom: 12px; }
.input, .select {
  width: 100%; padding: 13px 14px;
  border: 1px solid var(--line-strong); background: var(--bg-card); color: var(--fg);
  font-family: var(--font-body); font-size: 0.86rem; border-radius: var(--radius);
  appearance: none; outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }
.select { background-image: linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%), linear-gradient(135deg, var(--fg-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.btn {
  display: inline-block; width: 100%; text-align: center; padding: 14px 18px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--fg);
  font-family: var(--font-body); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer; border-radius: var(--radius);
}
.btn:active { opacity: 0.75; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn-ghost { border-color: var(--line); color: var(--fg-muted); }
.btn-danger { border-color: var(--bad); color: var(--bad); }

/* ?? Bottom nav ?? */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 430px; margin: 0 auto;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  border-top: 1px solid var(--line);
  padding: 12px 8px calc(12px + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: repeat(var(--nav-cols, 4), 1fr);
}
.nav-btn {
  background: none; border: none; color: var(--fg-subtle);
  font-family: var(--font-body); font-size: 0.5rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 6px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.nav-btn .dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
.nav-btn.active { color: var(--fg); }
.nav-btn.active .dot { background: var(--accent); }

/* ?? States ?? */
.loading, .empty {
  text-align: center; color: var(--fg-muted); padding: 30px 16px;
  font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
}

.note { font-size: 0.68rem; line-height: 1.65; color: var(--fg-muted); margin: 12px 0 0; }

/* ?? Ad slot (hidden until an ad network is wired) ?? */
.ad-slot { display: none; margin: 0 0 18px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.ad-slot.show { display: block; }
html.is-pro .ad-slot { display: none !important; }

/* ?? Sparkline ?? */
.sparkline { display: block; width: 100%; height: 30px; }
.sparkline polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sparkline.muted polyline { stroke: var(--fg-subtle); }

/* ?? Progress ring ?? */
.ring-wrap { position: relative; width: 240px; height: 240px; margin: 8px auto; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 7; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 0.6s cubic-bezier(0.22,1,0.36,1); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; }
.ring-center .big { font-family: var(--font-display); font-size: 2.4rem; font-weight: 600; line-height: 1; }
.ring-center .small { font-size: 0.58rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--fg-muted); }

/* ?? Paywall ?? */
.pro-tag {
  font-size: 0.48rem; font-weight: 800; letter-spacing: 0.18em;
  border: 1px solid var(--accent); color: var(--accent);
  padding: 2px 6px; border-radius: 3px; vertical-align: middle;
}

.locked-stack { position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.locked-rows { filter: blur(6px); opacity: 0.5; pointer-events: none; user-select: none; display: flex; flex-direction: column; gap: 1px; background: var(--line); }
.lock-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px;
  background: color-mix(in srgb, var(--bg) 30%, transparent);
}
.lock-overlay .btn { width: auto; padding: 12px 26px; }
.lock-icon svg { width: 20px; height: 20px; stroke: var(--fg); fill: none; stroke-width: 1.5; }

.locked-more {
  width: 100%; display: flex; align-items: center; gap: 13px; padding: 14px 16px;
  border: none; border-top: 1px solid var(--line); cursor: pointer;
  background: var(--bg-card); font-family: inherit; color: inherit; text-align: left;
}
.locked-more strong { display: block; font-size: 0.8rem; font-weight: 600; }
.locked-more span { color: var(--fg-muted); font-size: 0.66rem; margin-top: 2px; display: block; }
.locked-more .body { flex: 1; }
.locked-more svg { width: 16px; height: 16px; stroke: var(--fg-muted); fill: none; stroke-width: 1.5; flex-shrink: 0; }

.pricing-card {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px 22px 24px; text-align: center; margin-bottom: 8px;
  background: var(--bg-card);
}
.pricing-card.is-active { opacity: 0.55; }
.pitch-title { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; line-height: 1.2; }
.pitch-sub { font-size: 0.73rem; line-height: 1.65; color: var(--fg-muted); margin: 12px 0 18px; }
.price-row { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-bottom: 18px; }
.price-anchor { font-family: var(--font-display); font-size: 1rem; color: var(--fg-subtle); text-decoration: line-through; }
.price { font-family: var(--font-display); font-size: 2.5rem; font-weight: 600; line-height: 1; }
.price-note { font-size: 0.5rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-subtle); }
.trust { font-size: 0.54rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-subtle); margin: 13px 0 0; }
.perk-check { color: var(--accent); }

.activate-box { display: flex; flex-direction: column; gap: 10px; }
.activate-msg { font-size: 0.68rem; color: var(--fg-muted); margin: 0; min-height: 1.2em; }

/* ?? Upsell sheet ?? */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 430px; background: var(--bg); border-top: 1px solid var(--line-strong);
  border-radius: 18px 18px 0 0;
  padding: 28px 24px calc(24px + env(safe-area-inset-bottom, 0px)); text-align: center;
  animation: sheet-up 0.35s cubic-bezier(0.22,1,0.36,1);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.sheet-body { font-size: 0.73rem; line-height: 1.65; color: var(--fg-muted); margin: 11px 0 18px; }
.sheet-later { display: block; width: 100%; margin-top: 12px; background: none; border: none; color: var(--fg-subtle); font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase; cursor: pointer; padding: 8px; }

/* ?? Misc ?? */
.divider { height: 1px; background: var(--line); margin: 22px 0; border: none; }
.fav-btn { background: none; border: none; color: var(--fg-subtle); font-size: 0.95rem; cursor: pointer; padding: 4px 2px; line-height: 1; flex-shrink: 0; }
.fav-btn.faved { color: var(--accent); }

@media (min-width: 431px) {
  .bottom-nav, .topbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

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