:root {
  color-scheme: dark;
  --fs-black: #000000;
  --fs-bg: #05070c;
  --fs-surface: rgba(8, 16, 28, 0.88);
  --fs-cyan: #48cae4;
  --fs-blue: #0077b6;
  --fs-deep: #023e8a;
  --fs-white: #ffffff;
  --fs-muted: #9bb0c4;
  --fs-gradient: linear-gradient(180deg, #48cae4 0%, #0077b6 58%, #023e8a 100%);
  --fs-primary: #00b4d8;
  --fs-danger: #f56c6c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--fs-bg);
  color: var(--fs-white);
}

button,
input {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--fs-primary);
  border-color: var(--fs-primary);
  color: var(--fs-white);
}

.btn-primary:hover:not(:disabled) {
  background: #48cae4;
  border-color: #48cae4;
}

.btn-plain {
  background: transparent;
  border-color: var(--fs-primary);
  color: var(--fs-primary);
}

.btn-plain:hover:not(:disabled) {
  background: rgba(0, 180, 216, 0.12);
}

.btn-danger-plain {
  background: transparent;
  border-color: var(--fs-danger);
  color: var(--fs-danger);
}

.btn-danger-plain:hover:not(:disabled) {
  background: rgba(245, 108, 108, 0.12);
}

.btn-text {
  height: 32px;
  padding: 0 8px;
  border: none;
  background: transparent;
}

.btn-text-danger {
  color: var(--fs-danger);
}

.btn-text-danger:hover:not(:disabled) {
  background: rgba(245, 108, 108, 0.1);
}

.btn-sm {
  height: 24px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: 3px;
}

.btn-lg {
  height: 48px;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 600;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.google-btn {
  width: 100%;
  background: #fff;
  color: #1f1f1f;
  border: none;
}

.google-btn:hover:not(:disabled),
.google-btn:focus {
  background: #f2f2f2;
  color: #1f1f1f;
}

.google-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
}

.google-icon svg {
  width: 20px;
  height: 20px;
}

.toast-wrap {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  min-width: 280px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #0a1420;
  border: 1px solid rgba(72, 202, 228, 0.18);
  color: #dceaf3;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}

.toast-success {
  border-color: rgba(103, 194, 58, 0.4);
}

.toast-warning {
  border-color: rgba(230, 162, 60, 0.45);
}

.toast-error {
  border-color: rgba(245, 108, 108, 0.45);
}

.dialog-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
}

.dialog-mask[hidden] {
  display: none !important;
}

.dialog {
  width: min(720px, 100%);
  overflow: hidden;
  border: 1px solid rgba(72, 202, 228, 0.16);
  border-radius: 8px;
  background: #0a1420;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dialog-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.dialog-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--fs-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fs-white);
}

.preview-video,
.result-image {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #000;
}

.result-image {
  object-fit: contain;
}

.loading-host {
  position: relative;
  min-height: 40px;
}

.loading-mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 12, 0.42);
}

.loading-mask[hidden] {
  display: none !important;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(72, 202, 228, 0.25);
  border-top-color: var(--fs-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  color: var(--fs-cyan);
}

.empty {
  padding: 48px 16px;
  color: var(--fs-muted);
  text-align: center;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
}

.pager-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: none;
  border-radius: 4px;
  background: #0a1420;
  color: #dceaf3;
  cursor: pointer;
}

.pager-btn:hover:not(:disabled) {
  color: var(--fs-primary);
}

.pager-btn.active {
  background: var(--fs-primary);
  color: var(--fs-white);
}

.pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pager-total {
  margin-left: 8px;
  color: var(--fs-muted);
  font-size: 13px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 20px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 108, 108, 0.35);
  border-radius: 6px;
  background: rgba(245, 108, 108, 0.12);
  color: #f89898;
  font-size: 14px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.home-page,
.login-page {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(72, 202, 228, 0.22), transparent 55%),
    radial-gradient(900px 500px at 110% 110%, rgba(2, 62, 138, 0.28), transparent 50%),
    var(--fs-bg);
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
  pointer-events: none;
}

.orb-a {
  width: 280px;
  height: 280px;
  background: var(--fs-cyan);
  top: 8%;
  left: 12%;
}

.orb-b {
  width: 240px;
  height: 240px;
  background: var(--fs-deep);
  right: 10%;
  bottom: 8%;
}

.login-page .orb {
  opacity: 0.5;
}

.login-page .orb-a {
  top: 12%;
  left: 18%;
}

.login-page .orb-b {
  right: 16%;
  bottom: 10%;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 28px;
  position: relative;
  z-index: 1;
  border-bottom: 1px solid rgba(72, 202, 228, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}

.user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--fs-deep);
  color: var(--fs-white);
  font-size: 14px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meta {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.meta span {
  color: var(--fs-muted);
  font-size: 12px;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  position: relative;
  z-index: 1;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.page-head p {
  margin: 0;
  color: var(--fs-muted);
}

.face-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.face-upload {
  cursor: pointer;
}

.face-thumb {
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(72, 202, 228, 0.28);
}

.face-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 24px;
}

.category-chip {
  height: 36px;
  padding: 0 16px;
  border: 1px solid rgba(72, 202, 228, 0.18);
  border-radius: 999px;
  background: var(--fs-surface);
  color: #dceaf3;
  cursor: pointer;
  text-decoration: none;
}

.category-chip.active,
.category-chip:hover,
.category-chip:focus,
.category-chip:active,
.category-chip:focus-visible {
  text-decoration: none;
  outline: none;
}

.category-chip.active {
  border-color: transparent;
  background: var(--fs-gradient);
  color: var(--fs-white);
}

.template-wrap {
  min-height: 320px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.template-card {
  overflow: hidden;
  border: 1px solid rgba(72, 202, 228, 0.16);
  border-radius: 14px;
  background: var(--fs-surface);
}

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--fs-black);
  cursor: pointer;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.play-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.template-card:hover .play-icon {
  opacity: 1;
}

.template-card h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
}

@media (hover: hover) {
  .swap-btn {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .template-card:hover .swap-btn:not(:disabled),
  .swap-btn.visible,
  .swap-btn.visible:disabled {
    opacity: 1;
    pointer-events: auto;
  }
}

button.btn.swap-btn:disabled:not(.visible) {
  opacity: 0;
  pointer-events: none;
}

.login-card,
.callback-card {
  width: 420px;
  max-width: 100%;
  position: relative;
  z-index: 1;
  padding: 40px 36px 32px;
  border: 1px solid rgba(72, 202, 228, 0.16);
  border-radius: 8px;
  background: var(--fs-surface);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.login-card .brand {
  display: block;
  text-align: center;
  margin-bottom: 28px;
}

.login-card .logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
}

.login-card h1,
.callback-card h2 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
}

.login-card .brand p,
.callback-card p {
  margin: 0;
  color: var(--fs-muted);
  line-height: 1.6;
}

.hint,
.legal {
  margin: 16px 0 0;
  text-align: center;
  color: var(--fs-muted);
  font-size: 12px;
  line-height: 1.6;
}

.callback-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fs-bg);
}

.callback-card {
  width: 360px;
  padding: 40px 28px;
  text-align: center;
}

.callback-card .spinner {
  margin: 0 auto;
  border-color: rgba(72, 202, 228, 0.25);
  border-top-color: var(--fs-cyan);
}

.callback-card h2 {
  margin: 16px 0 8px;
  font-size: 20px;
}

@media (max-width: 768px) {
  .page-head {
    flex-direction: column;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .meta {
    display: none;
  }
}
