/* =====================================================================
   base.css — Midnight Velvet design system: tokens / reset / shell /
   aurora background / topbar / tabbar / keyframes / reduced motion
   ===================================================================== */
:root {
  --bg: #0A0A14;
  --bg-2: #12121F;
  --primary: #FF3D7F;
  --secondary: #8B5CF6;
  --gold: #F7C948;
  --ok: #22C55E;
  --danger: #EF4444;
  --warn: #F59E0B;
  --info: #38BDF8;
  --text: #F3F4F8;
  --muted: #9AA0B4;
  --dim: #6B7190;
  --glass: rgba(255, 255, 255, .06);
  --glass-2: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --r-sm: 9px; --r: 14px; --r-lg: 18px; --r-xl: 24px;
  --pad: 14px;
  --topbar-h: 50px;
  --tabbar-h: 54px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, "SF Pro Display", "Segoe UI", Roboto, Inter, sans-serif;
  --font-num: "DIN Alternate", "Roboto Mono", "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --grad-brand: linear-gradient(135deg, var(--primary), var(--secondary));
  --grad-gold: linear-gradient(135deg, #FFE38A, var(--gold) 45%, #D9A72E);
  --dur: 1;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden; overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
.hide { display: none !important; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.brand-text-grad, .grad-text { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
::selection { background: rgba(255, 61, 127, .35); }

/* ---------- Ambient background: aurora + grain ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; filter: blur(60px) saturate(1.3); opacity: .85; }
.aurora i { position: absolute; border-radius: 50%; mix-blend-mode: screen; will-change: transform; animation: aurora 18s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { width: 60vmax; height: 60vmax; left: -20vmax; top: -30vmax; background: radial-gradient(circle, rgba(255, 61, 127, .55), transparent 65%); }
.aurora i:nth-child(2) { width: 55vmax; height: 55vmax; right: -20vmax; top: -25vmax; background: radial-gradient(circle, rgba(139, 92, 246, .6), transparent 65%); animation-delay: -6s; animation-duration: 22s; }
.aurora i:nth-child(3) { width: 40vmax; height: 40vmax; left: 20vmax; top: 10vmax; background: radial-gradient(circle, rgba(56, 189, 248, .25), transparent 65%); animation-delay: -12s; animation-duration: 26s; }
.aurora i:nth-child(4) { width: 50vmax; height: 50vmax; right: -10vmax; bottom: -30vmax; background: radial-gradient(circle, rgba(255, 61, 127, .25), transparent 65%); animation-delay: -3s; animation-duration: 30s; }
@keyframes aurora {
  0% { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
  33% { transform: translate3d(8vmax, 6vmax, 0) scale(1.15) rotate(20deg); }
  66% { transform: translate3d(-6vmax, 10vmax, 0) scale(.95) rotate(-15deg); }
  100% { transform: translate3d(4vmax, -4vmax, 0) scale(1.1) rotate(10deg); }
}
.grain { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .045; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* ---------- Shell (mobile first; centered 480px on desktop) ---------- */
.shell { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
@media (min-width: 560px) {
  body { background: radial-gradient(1200px 700px at 50% -10%, #1a1230 0%, var(--bg) 60%); }
  .shell { box-shadow: 0 0 0 1px var(--line), 0 40px 120px rgba(0, 0, 0, .6); background: rgba(10, 10, 20, .55); backdrop-filter: blur(4px); }
  .topbar, .tabbar { max-width: 480px; left: 50%; transform: translateX(-50%); }
}

/* ---------- Top bar ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; padding-top: var(--sat); background: linear-gradient(180deg, rgba(10, 10, 20, .92), rgba(10, 10, 20, .6)); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 61, 127, .5), rgba(139, 92, 246, .5), transparent); }
.topbar-in { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 var(--pad); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 32px; height: 32px; border-radius: 10px; background: var(--grad-brand); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(255, 61, 127, .35); overflow: hidden; flex: none; }
.brand-logo img, .brand-logo svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text b { font-size: 16px; font-weight: 800; letter-spacing: .3px; }
.brand-text small { font-size: 9px; letter-spacing: 1.6px; color: var(--muted); font-weight: 600; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar.sub .brand { display: none; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--text); background: var(--glass); border: 1px solid var(--line); transition: transform .2s var(--spring), background .2s; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { transform: scale(.9); background: var(--glass-2); }
.back-btn { margin-left: -4px; }
.tb-avatar { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: var(--grad-brand); display: grid; place-items: center; font-weight: 800; font-size: 14px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .15); }
.tb-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Main view ---------- */
.view { padding: calc(var(--topbar-h) + var(--sat)) 0 calc(var(--tabbar-h) + var(--sab) + 16px); min-height: 100vh; min-height: 100dvh; }
.view.no-tab { padding-bottom: calc(var(--sab) + 24px); }
.page { padding: 10px var(--pad) 0; animation: page-in .38s var(--ease-out) both; }
.page.from-left { animation-name: page-in-left; }
.page.pop { animation-name: page-pop; }
@keyframes page-in { from { opacity: 0; transform: translate3d(28px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes page-in-left { from { opacity: 0; transform: translate3d(-28px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes page-pop { from { opacity: 0; transform: translate3d(0, 14px, 0) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- Bottom tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tabbar-h) + var(--sab)); padding-bottom: var(--sab); display: flex; background: rgba(12, 12, 24, .82); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); border-top: 1px solid var(--line); }
.tabbar.hide-tab { display: none; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; position: relative; z-index: 1; letter-spacing: .2px; }
.tab-ic { width: 22px; height: 22px; transition: transform .35s var(--spring), color .25s; }
.tab-ic svg { width: 22px; height: 22px; }
.tab.on { color: var(--text); }
.tab.on .tab-ic { color: var(--primary); transform: translateY(-3px) scale(1.12); animation: tab-bounce .55s var(--spring); filter: drop-shadow(0 4px 10px rgba(255, 61, 127, .6)); }
@keyframes tab-bounce { 0% { transform: translateY(0) scale(1); } 45% { transform: translateY(-7px) scale(1.22); } 100% { transform: translateY(-3px) scale(1.12); } }
.tab-glow { position: absolute; top: 0; left: 0; width: 25%; height: 100%; pointer-events: none; transition: left .45s var(--spring); }
.tab-glow::before { content: ""; position: absolute; left: 50%; top: 0; width: 36px; height: 3px; border-radius: 0 0 4px 4px; background: var(--grad-brand); transform: translateX(-50%); box-shadow: 0 0 16px rgba(255, 61, 127, .8); }
.tab-glow::after { content: ""; position: absolute; left: 50%; top: 4px; width: 70px; height: 40px; border-radius: 50%; transform: translateX(-50%); background: radial-gradient(ellipse at top, rgba(255, 61, 127, .35), transparent 70%); }

/* ---------- Shared keyframes ---------- */
@keyframes fade-up { from { opacity: 0; transform: translate3d(0, 18px, 0); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: -600px 0; } 100% { background-position: 600px 0; } }
@keyframes pulse-dot { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: .7; } }
@keyframes ring-out { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(2.6); opacity: 0; } }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 61, 127, .45), 0 0 16px rgba(139, 92, 246, .25); } 50% { box-shadow: 0 0 0 8px rgba(255, 61, 127, 0), 0 0 30px rgba(139, 92, 246, .55); } }
@keyframes breathe-lock { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(247, 201, 72, .3)); } 50% { transform: scale(1.1); filter: drop-shadow(0 0 16px rgba(247, 201, 72, .8)); } }
@keyframes gold-shine { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes marquee { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-50%, 0, 0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes star-in { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 70% { transform: scale(1.3) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes float-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes glow-ring { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.9); opacity: 0; } }
.fade-up { animation: fade-up .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
.shake { animation: shake .45s ease; }

/* ---------- Reduced motion: everything off ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .aurora i { animation: none !important; }
  .fade-up, .page { opacity: 1 !important; transform: none !important; }
}
