html { scroll-behavior: smooth; scroll-padding-top: 90px; }
/* Các khối đang chờ bay vào (lệch ngang) không được tạo thanh cuộn ngang trên điện thoại */
main, .footer { overflow-x: clip; }
html, body { overflow-x: clip; }
body.leaving .nav { transition: opacity 0.45s; opacity: 0; }
body.leaving main { transition: opacity 0.45s var(--ease), transform 0.45s var(--ease), filter 0.45s; opacity: 0; transform: scale(0.98); filter: blur(6px); }
.muted { color: var(--muted); }
.logo-soft { color: var(--muted); font-weight: 500; margin-left: 2px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Thanh tiến trình cuộn */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60;
  background: var(--grad);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}

/* ===== Nav ===== */
.nav {
  position: fixed; z-index: 50;
  top: 14px; left: 50%;
  width: min(1180px, calc(100% - 32px));
  transform: translateX(-50%);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.4s var(--ease), border-color 0.4s, backdrop-filter 0.4s, top 0.4s var(--ease);
  animation: drop-in 0.9s var(--ease) both;
}
.nav.scrolled { top: 10px; background: rgba(13, 11, 24, 0.62); border-color: var(--line); backdrop-filter: blur(18px) saturate(160%); }
.nav-links { display: flex; gap: 4px; }
.nav-links a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 500; transition: color 0.25s, background 0.25s; }
.nav-links a:hover { color: var(--text); background: var(--surface); }
@keyframes drop-in { from { opacity: 0; transform: translate(-50%, -30px); } }

/* ===== Hero: 2 cột — trái chữ + form, phải video không bị che ===== */
.hero { position: relative; min-height: 100svh; display: grid; align-items: center; overflow: hidden; }
.hero-bg { position: absolute; inset: 0; z-index: 0; }
/* Video nền toàn màn hình: chỉ làm tối nhẹ phía trái (chữ + form), phía phải để video lộ rõ */
.hero-bgvideo {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: saturate(1.15) brightness(0.78);
  transform: scale(calc(1.06 + var(--hp, 0) * 0.1)) translateY(calc(var(--hp, 0) * 50px));
  will-change: transform;
}
.hero-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 6, 13, 0.82) 0%, rgba(7, 6, 13, 0.55) 34%, rgba(7, 6, 13, 0.12) 62%, rgba(7, 6, 13, 0.08) 100%),
    linear-gradient(0deg, var(--bg) 0%, rgba(7, 6, 13, 0) 22%),
    linear-gradient(180deg, rgba(7, 6, 13, 0.55) 0%, rgba(7, 6, 13, 0) 18%);
}
.hero-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask: radial-gradient(70% 60% at 50% 40%, #000, transparent);
  mask: radial-gradient(70% 60% at 50% 40%, #000, transparent);
}
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.28; animation: float 14s ease-in-out infinite; }
.orb-1 { width: 460px; height: 460px; left: -140px; top: 6%; background: #7c3aed; }
.orb-2 { width: 380px; height: 380px; right: 10%; bottom: -120px; background: #0891b2; animation-delay: -6s; }
@keyframes float { 50% { transform: translate(60px, -40px) scale(1.1); } }

.hero-inner {
  position: relative; z-index: 2;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 112px 0 64px;
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  grid-template-areas: "copy media" "auth media";
  column-gap: 56px; row-gap: 28px;
  align-items: center;
}
.hero-copy { grid-area: copy; align-self: end; }
.hero-media { grid-area: media; position: relative; }
.auth-wrap { grid-area: auth; align-self: start; }

.chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 7px 14px 7px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.05); backdrop-filter: blur(10px);
  font-size: 13px; color: #d9d5f5;
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 12px var(--ok); animation: pulse 2.4s infinite; }
.hero-title { margin: 18px 0 14px; font-size: clamp(36px, 4.4vw, 58px); line-height: 1.06; letter-spacing: -0.035em; font-weight: 800; }
.hero-title .word { display: inline-block; white-space: nowrap; }
.hero-title .char {
  display: inline-block; opacity: 0; transform: translateY(0.7em) rotate(8deg); filter: blur(8px);
  animation: char-in 0.9s var(--ease) forwards; animation-delay: calc(0.35s + var(--i) * 22ms);
}
.hero-title .word:nth-last-child(-n + 3) .char { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes char-in { to { opacity: 1; transform: none; filter: none; } }
.hero-sub { max-width: 480px; font-size: 16.5px; color: #c9c5e4; margin: 0; }
.intro { opacity: 0; animation: fade-up 1s var(--ease) forwards; }
.chip.intro { animation-delay: 0.2s; }
.hero-sub.intro { animation-delay: 1.05s; }
@keyframes fade-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* Video: khung lớn, không phủ tối; quầng sáng phía sau lấy màu từ chính video */
.hero-ambient-unused {
  position: absolute; inset: 6% 4%; width: 92%; height: 88%; object-fit: cover;
  filter: blur(60px) saturate(1.6); opacity: 0.55; transform: scale(1.08);
  pointer-events: none; z-index: 0;
}
.media-frame {
  --rx: 0deg; --ry: 0deg;
  position: relative; z-index: 1;
  border-radius: 24px; padding: 8px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--line-strong);
  box-shadow: 0 50px 120px -40px rgba(124, 92, 255, 0.6), 0 20px 40px -20px rgba(0, 0, 0, 0.6);
  transform: perspective(1400px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.6s var(--ease);
  opacity: 0; animation: media-in 1.2s var(--ease) 0.5s forwards;
}
@keyframes media-in { from { opacity: 0; transform: perspective(1400px) translateY(40px) rotateX(10deg) scale(0.96); } to { opacity: 1; } }
.hero-video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 17px; background: #000; display: block; }
.media-progress { position: absolute; left: 22px; right: 22px; bottom: 16px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); overflow: hidden; pointer-events: none; }
.media-progress i { display: block; height: 100%; width: 100%; background: var(--grad); transform-origin: 0 50%; transform: scaleX(var(--vp, 0)); }
.hero-media .sound-btn { right: 22px; bottom: 30px; }

/* Nhãn nổi: chỉ chạm mép khung, không che nội dung */
.float-badge {
  position: absolute; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.35;
  background: rgba(18, 16, 31, 0.86); border: 1px solid var(--line-strong); backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
  opacity: 0;
}
.badge-lock { left: -22px; top: 26px; color: var(--ok); font-weight: 700; animation: badge-in 0.8s var(--ease-spring) 1.4s forwards, bob 5s ease-in-out 2.2s infinite; }
.badge-msg { right: -18px; bottom: -28px; max-width: 280px; animation: badge-in 0.8s var(--ease-spring) 1.8s forwards, bob 5s ease-in-out 2.8s infinite reverse; }
.badge-msg b { font-size: 13px; }
.badge-av { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: linear-gradient(135deg, #f472b6, #8b5cf6); }
@keyframes badge-in { from { opacity: 0; transform: translateY(14px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes bob { 50% { translate: 0 -6px; } }

/* ===== Thẻ đăng nhập ===== */
.auth-wrap { perspective: 1200px; opacity: 0; animation: auth-in 1.1s var(--ease) 0.8s forwards; }
@keyframes auth-in { from { opacity: 0; transform: translateY(40px) rotateX(12deg) scale(0.96); } to { opacity: 1; transform: none; } }
.auth {
  --rx: 0deg; --ry: 0deg;
  padding: 30px;
  border-radius: 26px;
  background: linear-gradient(160deg, rgba(30, 26, 52, 0.66), rgba(14, 12, 26, 0.74));
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.02) inset, 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease);
}
.auth-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-head .logo-mark { width: 44px; height: 44px; filter: drop-shadow(0 8px 20px rgba(124, 92, 255, 0.5)); }
.auth-head h2 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.auth-head p { margin: 2px 0 0; font-size: 14px; }

.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); margin-bottom: 20px; }
.tab { position: relative; z-index: 1; height: 38px; border-radius: 10px; font-weight: 600; color: var(--muted); transition: color 0.3s; }
.tab.active { color: #fff; }
.tab-ink {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  border-radius: 10px;
  background: var(--grad);
  box-shadow: 0 6px 20px -6px rgba(124, 92, 255, 0.8);
  transition: transform 0.5s var(--ease-spring);
}
.tabs[data-mode='register'] .tab-ink { transform: translateX(100%); }

#authForm { display: grid; gap: 14px; }
.email-field .domain-hint {
  position: absolute; left: calc(16px + var(--w, 0ch)); top: 25px; font-size: 15px; color: var(--faint);
  pointer-events: none; transition: opacity 0.2s;
}
.avail { margin: -6px 0 0; min-height: 0; font-size: 13px; font-weight: 600; }
.avail:empty { display: none; }
.avail[data-state='ok'] { color: var(--ok); }
.avail[data-state='taken'], .avail[data-state='bad'] { color: var(--danger); }
.avail[data-state='wait'] { color: var(--muted); }
.reg-only { display: grid; gap: 14px; animation: fade-up 0.5s var(--ease); }
.strength { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); }
.strength .bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; width: 120px; }
.strength i { height: 5px; border-radius: 4px; background: var(--line-strong); transition: background 0.35s, transform 0.35s var(--ease-spring); }
.strength[data-s='1'] i:nth-child(-n + 1) { background: var(--danger); }
.strength[data-s='2'] i:nth-child(-n + 2) { background: var(--warn); }
.strength[data-s='3'] i:nth-child(-n + 3) { background: #a3e635; }
.strength[data-s='4'] i { background: var(--ok); }
.form-error { min-height: 20px; margin: 0; font-size: 13.5px; color: var(--danger); }
.form-error:not(:empty) { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.submit { width: 100%; --h: 52px; font-size: 15.5px; }
.submit .arrow { transition: transform 0.35s var(--ease); }
.submit:hover .arrow { transform: translateX(4px); }
.submit.loading .arrow { display: none; }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 2px 0 0; font-size: 12.5px; color: var(--faint); }

/* ===== Marquee ===== */
.marquee { position: relative; z-index: 1; overflow: hidden; padding: 22px 0; border-block: 1px solid var(--line); background: var(--bg-2); }
.marquee-track { display: flex; gap: 34px; width: max-content; animation: marquee 32s linear infinite; font-size: 22px; font-weight: 700; color: var(--muted); letter-spacing: -0.01em; }
.marquee i { font-style: normal; color: rgb(var(--glow-color)); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ===== Section ===== */
.section { position: relative; z-index: 1; width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 130px 0 40px; }
.section-head { text-align: center; max-width: 720px; margin: 0 auto 64px; }
.section-head h2 { margin: 14px 0 12px; font-size: clamp(32px, 4.6vw, 54px); line-height: 1.08; letter-spacing: -0.03em; }
.section-head p { font-size: 17px; margin: 0; }
.eyebrow { display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgb(var(--glow-color)); background: rgba(var(--glow-color), 0.1); border: 1px solid rgba(var(--glow-color), 0.25); }

/* ===== Lưới tính năng ===== */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; perspective: 1400px; }
.feature {
  --rx: 0deg; --ry: 0deg;
  padding: 28px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  overflow: hidden;
  transform-style: preserve-3d;
}
.feature.in { transform: rotateX(var(--rx)) rotateY(var(--ry)); }
.feature.in.settled { transition: transform 0.5s var(--ease), opacity 0.3s, filter 0.3s; }
.feature:nth-child(1) { --fz: -8deg; }
.feature:nth-child(2) { --fz: 6deg; }
.feature:nth-child(3) { --fz: -4deg; }
.feature:nth-child(4) { --fz: 8deg; }
.feature:nth-child(5) { --fz: -5deg; }
.feature.big { grid-row: span 2; display: flex; flex-direction: column; }
.feature.wide { grid-column: span 2; }
.feature h3 { margin: 18px 0 8px; font-size: 21px; letter-spacing: -0.02em; }
.feature p { margin: 0; color: var(--muted); }
.f-ico { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; background: var(--grad-soft); border: 1px solid rgba(var(--glow-color), 0.3); color: #c4b5fd; transform: translateZ(30px); }
.f-ico svg { width: 24px; height: 24px; }
.mock-chat { margin-top: auto; padding-top: 28px; display: grid; gap: 10px; }
.mb { max-width: 80%; padding: 11px 15px; border-radius: 18px; font-size: 14px; animation: bubble 0.6s var(--ease-spring) both; }
.feature.in .mb:nth-child(1) { animation-delay: 0.5s; }
.feature.in .mb:nth-child(2) { animation-delay: 1.1s; }
.feature.in .mb:nth-child(3) { animation-delay: 1.7s; }
.feature:not(.in) .mb { animation-play-state: paused; }
.mb.in { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.mb.out { justify-self: end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.mb.typing { display: flex; gap: 5px; width: max-content; }
.mb.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.mb.typing i:nth-child(2) { animation-delay: 0.15s; }
.mb.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 30% { transform: translateY(-5px); opacity: 1; } 0%, 60%, 100% { opacity: 0.4; } }
@keyframes bubble { from { opacity: 0; transform: translateY(14px) scale(0.9); } }
.cipher-line { margin-top: 20px; padding: 14px 16px; border-radius: 14px; background: rgba(0, 0, 0, 0.35); border: 1px dashed var(--line-strong); }
code { font-family: ui-monospace, 'JetBrains Mono', Consolas, monospace; font-size: 14px; }
.cipher { color: #a5f3fc; word-break: break-all; }

/* ===== Bảo mật ===== */
.flow { display: grid; grid-template-columns: 1fr 70px 1fr 70px 1fr; align-items: center; gap: 10px; }
.flow-step { padding: 24px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); min-height: 170px; }
.step-n { font-size: 13px; font-weight: 800; color: rgb(var(--glow-color)); letter-spacing: 0.1em; }
.flow-step h4 { margin: 10px 0 14px; font-size: 18px; }
.flow-step code { display: block; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); min-height: 46px; }
.plain.ok { color: var(--ok); }
.flow-arrow { height: 2px; position: relative; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); overflow: hidden; }
.flow-arrow span { position: absolute; inset: 0; width: 40%; background: var(--grad); animation: beam 1.8s var(--ease) infinite; }
@keyframes beam { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.spec-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 30px; perspective: 1000px; }
.spec { padding: 20px 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.spec b { display: block; font-size: 18px; margin-bottom: 4px; }
.spec span { color: var(--muted); font-size: 14px; }

/* ===== Video 3D tự dựng thẳng theo cuộn ===== */
.story-stage { perspective: 1600px; }
.story-frame {
  --sp: 0;
  position: relative;
  border-radius: 28px;
  padding: 10px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line-strong);
  box-shadow: 0 60px 140px -40px rgba(124, 92, 255, 0.55);
  transform: rotateX(calc((1 - var(--sp)) * 32deg)) scale(calc(0.84 + var(--sp) * 0.16)) translateY(calc((1 - var(--sp)) * 60px));
  transform-origin: 50% 100%;
  will-change: transform;
}
.story-frame video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 20px; background: #000; }
.sound-btn {
  position: absolute; right: 26px; bottom: 26px;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.55); border: 1px solid var(--line-strong); backdrop-filter: blur(10px);
  color: #fff; transition: transform 0.3s var(--ease), background 0.3s;
}
.sound-btn:hover { transform: scale(1.08); background: rgba(124, 92, 255, 0.6); }
.sound-btn .wave { display: none; }
.sound-btn.on .wave { display: block; }
.sound-btn.on .mute { display: none; }

/* ===== CTA ===== */
.cta { padding-bottom: 120px; }
.cta-card { text-align: center; padding: 70px 30px; border-radius: 32px; background: radial-gradient(80% 120% at 50% 0%, rgba(124, 92, 255, 0.28), transparent 70%), var(--surface); border: 1px solid var(--line-strong); overflow: hidden; }
.cta-card h2 { font-size: clamp(30px, 4.4vw, 50px); letter-spacing: -0.03em; margin: 0 0 12px; }
.cta-card p { margin: 0 auto 30px; max-width: 520px; }

.footer { position: relative; z-index: 1; width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 40px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid var(--line); font-size: 14px; }
.footer .logo { font-size: 16px; }
.footer .logo-mark { width: 26px; height: 26px; }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .hero-inner { grid-template-columns: minmax(0, 1fr); grid-template-areas: "copy" "media" "auth"; row-gap: 36px; padding-top: 100px; }
  .badge-lock { left: 8px; top: -16px; }
  .badge-msg { right: 8px; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .feature.big { grid-row: auto; grid-column: span 2; }
  .flow { grid-template-columns: 1fr; }
  .flow-arrow { width: 2px; height: 40px; justify-self: center; background: linear-gradient(180deg, transparent, var(--line-strong), transparent); }
  .flow-arrow span { width: 100%; height: 40%; animation: beam-v 1.8s var(--ease) infinite; }
  .spec-grid { grid-template-columns: 1fr 1fr; }
}
@keyframes beam-v { from { transform: translateY(-100%); } to { transform: translateY(260%); } }
@media (max-width: 640px) {
  .nav-links { display: none; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature.big, .feature.wide { grid-column: auto; }
  .auth { padding: 22px; }
  .section { padding-top: 90px; }
  .footer { flex-direction: column; }
}

/* ===== Bước nhập mã PIN khi đăng nhập ===== */
#authForm.pin-mode > .field, #authForm.pin-mode > .avail, #authForm.pin-mode > .reg-only { display: none; }
.pin-step { display: grid; justify-items: center; gap: 14px; animation: fade-up 0.45s var(--ease); }
.pin-step-title { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; color: var(--ok); }
.otp { display: flex; gap: 10px; }
.otp input {
  width: 48px; height: 58px; border-radius: 14px; text-align: center; font-size: 24px; font-weight: 700;
  border: 1px solid var(--line-strong); background: var(--surface); outline: none; caret-color: rgb(var(--glow-color));
  -webkit-text-security: disc; transition: border-color 0.2s, box-shadow 0.2s, transform 0.25s var(--ease-spring);
}
.otp input:focus { border-color: rgba(var(--glow-color), 0.9); box-shadow: 0 0 0 4px rgba(var(--glow-color), 0.18); transform: translateY(-2px); }
.otp.shake { animation: shake 0.45s; }
.otp.ok input { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2); }
.link-btn { font-size: 13.5px; color: var(--muted); }
.link-btn:hover { color: var(--text); }
@media (max-width: 400px) { .otp { gap: 6px; } .otp input { width: 42px; height: 52px; } }
