/* ============================================================
   App layout, components, views, modals, animations
   ============================================================ */

#app {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-t) + 14px) 16px calc(96px + var(--safe-b));
  position: relative;
}

/* ---------- view transitions ---------- */
.view { animation: viewIn 0.18s var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
/* used only for data-refresh renders (not tab switches) */
::view-transition-old(root) { animation: vtOut 0.14s var(--ease) both; }
::view-transition-new(root) { animation: vtIn 0.18s var(--ease) both; }
@keyframes vtOut { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vtIn  { from { opacity: 0; transform: translateY(6px); } }

/* staggered entrance for lists — tight delays so long lists feel snappy */
.stagger > * { animation: viewIn 0.24s var(--ease) both; }
.stagger > *:nth-child(1){animation-delay:.01s}
.stagger > *:nth-child(2){animation-delay:.03s}
.stagger > *:nth-child(3){animation-delay:.06s}
.stagger > *:nth-child(4){animation-delay:.09s}
.stagger > *:nth-child(5){animation-delay:.11s}
.stagger > *:nth-child(6){animation-delay:.13s}
.stagger > *:nth-child(n+7){animation-delay:.15s}

/* ---------- header / profile hero ---------- */
.hero { padding: 20px; margin-bottom: 16px; }
.hero-row { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 58px; height: 58px; border-radius: 20px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
  color: #fff;
  background: linear-gradient(150deg, var(--violet), var(--magenta));
  box-shadow: var(--hl-top), 0 8px 22px -6px rgba(168,85,247,0.7);
  position: relative; overflow: hidden;
}
/* profile photo overlays the gradient+initials; hidden on error → initials show through */
.avatar-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; border-radius: inherit;
  transition: opacity 0.2s ease;
}
.hero h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.hero .sub { margin: 2px 0 0; color: var(--tx-2); font-size: 13.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-free { background: rgba(255,255,255,0.08); color: var(--tx-2); border: 1px solid var(--glass-border); }
.badge-premium {
  color: #2a1e06;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 6px 16px -6px rgba(233,200,134,0.7), var(--hl-top);
}

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 16px; }
.stat { padding: 15px 12px; text-align: center; }
.stat .n { font-size: 24px; font-weight: 760; letter-spacing: -0.03em; }
.stat .l { font-size: 11.5px; color: var(--tx-3); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .n.mint { color: var(--mint); }
.stat .n.sky  { color: var(--sky); }

/* ---------- section headings ---------- */
.sec-title { font-size: 13px; font-weight: 700; color: var(--tx-3);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 4px 10px; }

/* ---------- segmented control (protection level) ---------- */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 5px; gap: 4px; border-radius: var(--r-lg); }
.seg button {
  position: relative; z-index: 2; border: 0; background: transparent; cursor: pointer;
  color: var(--tx-2); font-weight: 660; font-size: 15px; padding: 15px 8px;
  font-family: inherit; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: color 0.16s var(--ease), transform 0.14s var(--ease);
}
.seg button:active { transform: scale(0.95); }
.seg button.on { color: #fff; font-weight: 750; font-size: 15.5px; }
.seg .thumb {
  position: absolute; z-index: 1; top: 5px; bottom: 5px; left: 5px;
  border-radius: 14px;
  background: var(--glass-brite);
  border: 1px solid var(--glass-border-strong);
  box-shadow: var(--hl-top), 0 8px 20px -6px rgba(0,0,0,0.7);
  transition: transform 0.22s var(--ease-snap), width 0.22s var(--ease),
              background 0.28s var(--ease), box-shadow 0.28s var(--ease);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border: 0; border-radius: var(--r-md);
  font-family: inherit; font-weight: 680; font-size: 15px; cursor: pointer;
  color: var(--tx-1); background: var(--glass-brite);
  border: 1px solid var(--glass-border-strong);
  box-shadow: var(--hl-top), var(--shadow-card);
  transition: transform 0.16s var(--ease), filter 0.2s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-gold {
  color: #2a1e06; border: 0;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: var(--hl-top), 0 14px 30px -12px rgba(233,200,134,0.7);
}
.btn-mint {
  color: #fff; border: 0;
  background: linear-gradient(135deg, var(--violet), var(--violet-2));
  box-shadow: var(--hl-top), 0 14px 32px -12px rgba(168,85,247,0.6);
}
.btn-ghost { background: var(--glass-bg-soft); }
.btn-row { display: grid; gap: 10px; grid-auto-flow: column; }

/* ---------- list cards (channels / groups) ---------- */
.card { padding: 15px 16px; margin-bottom: 11px; cursor: pointer;
  transition: transform 0.18s var(--ease); }
.card:active { transform: scale(0.985); }
.card-row { display: flex; align-items: center; gap: 13px; }
.card-ico {
  width: 46px; height: 46px; border-radius: 14px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 20px;
  background: var(--glass-bg-soft); border: 1px solid var(--glass-border);
}
.card-main { min-width: 0; flex: 1; }
.card-main h3 { margin: 0; font-size: 15.5px; font-weight: 660; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.card-meta { margin: 3px 0 0; font-size: 12.5px; color: var(--tx-3);
  display: flex; gap: 10px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot.ok { background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.dot.warn { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.chev { color: var(--tx-3); font-size: 19px; }

.pill { font-size: 11px; font-weight: 650; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.07); color: var(--tx-2); border: 1px solid var(--glass-border); }
.pill.mint   { color: var(--mint);    border-color: rgba(94,234,212,0.3);   background: rgba(94,234,212,0.08); }
.pill.warn   { color: var(--gold);    border-color: rgba(233,200,134,0.3);  background: rgba(233,200,134,0.08); }
.pill.violet { color: var(--violet);  border-color: rgba(168,85,247,0.35);  background: rgba(168,85,247,0.1); }
.pill.magenta{ color: var(--magenta); border-color: rgba(226,107,255,0.3);  background: rgba(226,107,255,0.08); }
.pill.coral  { color: var(--coral);   border-color: rgba(255,111,143,0.3);  background: rgba(255,111,143,0.08); }
.pill.sky    { color: var(--sky);     border-color: rgba(196,181,253,0.28); background: rgba(196,181,253,0.07); }

/* ---------- tabs (channels/groups switch) ---------- */
.subtabs { display: grid; grid-auto-flow: column; gap: 6px; padding: 5px; margin-bottom: 14px; }
.subtabs button { border: 0; background: transparent; color: var(--tx-2); cursor: pointer;
  font-family: inherit; font-weight: 650; font-size: 14px; padding: 9px; border-radius: 12px;
  transition: all var(--dur) var(--ease); }
.subtabs button.on { color: var(--tx-1); background: var(--glass-brite);
  border: 1px solid var(--glass-border-strong); box-shadow: var(--hl-top); }

/* ---------- premium CTA ---------- */
.cta-prem { padding: 20px; margin: 16px 0; position: relative; overflow: hidden; }
.cta-prem::before { content: ""; position: absolute; inset: 0;
  background: radial-gradient(80% 120% at 100% 0%, rgba(233,200,134,0.22), transparent 60%); }
.cta-prem h2 { margin: 0 0 4px; font-size: 18px; }
.cta-prem p { margin: 0 0 14px; color: var(--tx-2); font-size: 13.5px; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 46px 20px; }
.empty .big { font-size: 46px; margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; }
.empty p { color: var(--tx-3); font-size: 13.5px; margin: 0 0 18px; }

/* ---------- feature/tool grid ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.tool { padding: 18px 16px; cursor: pointer; transition: transform 0.18s var(--ease); }
.tool:active { transform: scale(0.97); }
.tool .ico { font-size: 26px; margin-bottom: 10px; }
.tool h3 { margin: 0 0 3px; font-size: 15px; }
.tool p { margin: 0; font-size: 12px; color: var(--tx-3); }

/* ---------- bottom navigation ---------- */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b)); z-index: 50;
  width: min(94vw, 460px);
  display: grid; grid-template-columns: repeat(4,1fr);
  padding: 8px; border-radius: 26px;
}
.nav .glass-fx { position: absolute; inset: 0; border-radius: 26px; z-index: -1; }
.nav button {
  position: relative; border: 0; background: transparent; cursor: pointer;
  color: var(--tx-3); font-family: inherit; padding: 8px 4px; border-radius: 18px;
  display: grid; justify-items: center; gap: 3px; transition: color 0.15s var(--ease);
}
.nav button .ti { font-size: 21px; line-height: 1; transition: transform 0.18s var(--ease-snap); }
.nav button .tl { font-size: 10.5px; font-weight: 650; }
.nav button.on { color: var(--tx-1); }
.nav button.on .ti { transform: translateY(-2px) scale(1.12); }
.nav .nthumb {
  position: absolute; z-index: -1; top: 8px; bottom: 8px; left: 8px;
  border-radius: 18px; background: var(--glass-brite);
  border: 1px solid var(--glass-border-strong); box-shadow: var(--hl-top);
  transition: transform 0.2s var(--ease-snap);
}

/* ---------- modal / sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 100; background: rgba(4,6,11,0.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.3s var(--ease); }
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 101;
  max-width: 540px; margin: 0 auto;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px 18px calc(24px + var(--safe-b));
  max-height: 88vh; overflow-y: auto;
  transform: translateY(100%); transition: transform 0.32s var(--ease);
  box-shadow: var(--shadow-pop);
}
.sheet.show { transform: translateY(0); }
.grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.22);
  margin: 4px auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 19px; }
.sheet .sub { color: var(--tx-2); font-size: 13.5px; margin: 0 0 16px; }

/* ---------- toggles (group settings) ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between;
  padding: 13px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .tt { font-size: 14.5px; font-weight: 550; }
.toggle-row .td { font-size: 11.5px; color: var(--tx-3); }
.sw { width: 50px; height: 30px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(255,255,255,0.12); position: relative; flex: 0 0 auto;
  transition: background var(--dur) var(--ease); }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform var(--dur) var(--ease-snap); }
.sw.on { background: linear-gradient(135deg, var(--violet), var(--magenta)); }
.sw.on::after { transform: translateX(20px); }
.sw:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- plan cards ---------- */
.plan { padding: 16px 18px; margin-bottom: 11px; cursor: pointer; position: relative;
  border: 1px solid var(--glass-border); transition: transform 0.18s var(--ease); }
.plan:active { transform: scale(0.99); }
.plan.sel { border-color: var(--gold); box-shadow: var(--shadow-card), 0 0 0 1px var(--gold), var(--hl-top); }
.plan .pn { font-size: 16px; font-weight: 700; }
.plan .pp { font-size: 26px; font-weight: 780; letter-spacing: -0.03em; margin: 4px 0; }
.plan .px { color: var(--tx-3); font-size: 12.5px; }
.plan .pbadge { position: absolute; top: 14px; right: 14px; }
.stars { color: var(--gold); font-weight: 650; }

/* ---------- payment method rows ---------- */
.pay-row { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 9px;
  cursor: pointer; transition: transform 0.16s var(--ease); }
.pay-row:active { transform: scale(0.98); }
.qr-wrap { text-align: center; padding: 18px; }
.qr-wrap img { width: 200px; height: 200px; border-radius: var(--r-md); background:#fff; padding:10px; }
.addr { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  word-break: break-all; padding: 12px 14px; border-radius: var(--r-sm);
  background: rgba(0,0,0,0.28); border: 1px solid var(--glass-border); margin: 12px 0; color: var(--tx-1); }

/* ---------- scan / fix animation ---------- */
.scan-stage { text-align: center; padding: 24px 10px; }
.ring { width: 170px; height: 170px; margin: 6px auto 18px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 34px; font-weight: 780; letter-spacing: -0.03em; }
.ring .emoji { position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 40px; animation: pulse 1.5s var(--ease) infinite; }
@keyframes pulse { 50% { transform: scale(1.14); opacity: 0.85; } }
.scan-task { color: var(--tx-2); font-size: 14px; min-height: 20px; }
.log { margin-top: 16px; text-align: left; font-size: 12.5px; max-height: 150px; overflow-y: auto; }
.log div { padding: 5px 2px; color: var(--tx-3); animation: viewIn 0.4s var(--ease) both; }
.log div b { color: var(--mint); }

.result-ok { text-align: center; padding: 8px 4px 4px; }
.result-ok .big { font-size: 54px; animation: pop 0.5s var(--ease-snap) both; }
@keyframes pop { from { transform: scale(0); } }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; top: calc(14px + var(--safe-t)); left: 0; right: 0; z-index: 200;
  display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { padding: 12px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  animation: toastIn 0.4s var(--ease-snap) both; max-width: 90vw; }
.toast.err { color: var(--coral); }
.toast.ok { color: var(--mint); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } }

/* ---------- skeleton ---------- */
.skel { border-radius: var(--r-md); background: linear-gradient(100deg,
  rgba(255,255,255,0.04) 30%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 70%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; height: 70px; margin-bottom: 11px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- misc ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; }
.mt8{margin-top:8px} .mt16{margin-top:16px} .mb8{margin-bottom:8px}
.center { text-align: center; }
.muted { color: var(--tx-3); font-size: 12.5px; }
a.link { color: var(--sky); text-decoration: none; font-weight: 600; }
