:root {
  color-scheme: dark;
  --bg: #050505;
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #fe2c55;
  --page-bg:
    linear-gradient(rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.62)),
    url("./assets/posters/poster-1.svg") center / cover no-repeat;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  position: relative;
  width: min(100vw, 430px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
}

.topbar {
  position: absolute;
  inset: max(10px, env(safe-area-inset-top)) 14px auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-shell.profile-active .topbar,
.app-shell.favorites-active .topbar {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
}

.feed-tabs {
  display: flex;
  gap: 16px;
}

.topbar .ghost-button {
  position: absolute;
  left: 0;
}

.tab,
.ghost-button,
.nav-item {
  color: rgba(255, 255, 255, 0.74);
  background: transparent;
}

.tab {
  padding: 4px 0;
}

.tab.is-active {
  color: #fff;
  font-weight: 700;
}

.ghost-button {
  width: 32px;
  height: 32px;
  font-size: 24px;
}

.feed {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}

.feed::-webkit-scrollbar {
  display: none;
}

.video-card {
  position: relative;
  height: 100dvh;
  min-height: 620px;
  scroll-snap-align: start;
  overflow: hidden;
  background: #111;
}

.video-media,
.video-fallback,
.video-overlay {
  position: absolute;
  inset: 0;
}

.video-fallback[hidden] {
  display: none;
}

.video-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-fallback {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.24), transparent 24%),
    radial-gradient(circle at 78% 30%, rgba(255, 255, 255, 0.18), transparent 22%),
    linear-gradient(145deg, var(--from), var(--to));
  animation: drift 12s ease-in-out infinite alternate;
}

.video-overlay {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.36), transparent 28%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.72), transparent 48%);
}

.video-meta,
.fixed-video-meta {
  position: absolute;
  left: 16px;
  right: 86px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 2;
}

.author-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.author {
  font-size: 17px;
}

.caption {
  margin: 0;
  line-height: 1.45;
}

.action-rail,
.fixed-action-rail {
  position: absolute;
  right: 12px;
  bottom: calc(32px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.fixed-video-meta,
.fixed-action-rail {
  z-index: 10;
}

.avatar-button {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.95);
}

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

.action-button {
  display: grid;
  justify-items: center;
  gap: 5px;
  color: #fff;
  background: transparent;
}

.action-button span {
  font-size: 30px;
  line-height: 1;
}

.action-button small {
  font-size: 12px;
}

.like-button.is-liked span {
  color: var(--accent);
}

.favorite-button.is-favorited span {
  color: #ffd43b;
}

.empty-state {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  scroll-snap-align: start;
}

.is-hidden {
  display: none;
}

.video-card.is-hidden {
  display: none !important;
}

.profile-page .is-hidden {
  display: none !important;
}

.app-shell.favorites-active,
.app-shell.profile-active {
  background: var(--page-bg);
}

.feed.is-favorites-grid {
  background: var(--page-bg);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 220px;
  gap: 10px;
  align-content: start;
  padding:
    calc(122px + env(safe-area-inset-top))
    12px
    calc(18px + env(safe-area-inset-bottom));
  scroll-snap-type: none;
}

.favorite-summary {
  position: absolute;
  top: calc(76px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 11;
  padding: 0;
  color: #fff;
  font-size: 14px;
  background: transparent;
  backdrop-filter: none;
}

.feed.is-favorites-grid .video-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 40px;
  height: auto;
  min-height: 0;
  border-radius: 16px;
  scroll-snap-align: none;
  overflow: hidden;
}

.feed:not(.is-favorites-grid) .video-card {
  display: block;
}

.feed:not(.is-favorites-grid) .video-fallback {
  background: #000 !important;
}

.feed.is-favorites-grid .video-meta,
.feed.is-favorites-grid .action-rail {
  display: none;
}

.feed.is-favorites-grid .video-overlay {
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.18), transparent 45%);
}

.favorite-preview-caption {
  display: none;
}

.progress-wrap {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 3;
}

.progress-bar {
  width: 100%;
  height: 3px;
  margin: 0;
  accent-color: #fff;
}

.feed.is-favorites-grid .progress-wrap {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.feed.is-favorites-grid .video-media,
.feed.is-favorites-grid .video-fallback,
.feed.is-favorites-grid .video-overlay {
  position: static;
  grid-row: 1;
}

.feed.is-favorites-grid .video-media,
.feed.is-favorites-grid .video-fallback {
  width: 100%;
  height: 100%;
}

.feed.is-favorites-grid .favorite-preview-caption {
  display: -webkit-box;
  grid-row: 2;
  margin: 0;
  padding: 7px 8px 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.feed.is-favorites-grid .empty-state {
  grid-column: 1 / -1;
  height: auto;
  min-height: calc(100dvh - 160px);
}

.comment-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: min(58dvh, 520px);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  border-radius: 24px 24px 0 0;
  background: #171717;
  transform: translateY(100%);
  transition: transform 180ms ease;
}

.profile-page {
  position: absolute;
  inset: 0;
  z-index: 9;
  padding: calc(76px + env(safe-area-inset-top)) 16px 18px;
  background: var(--page-bg);
}

.profile-card {
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(24px);
}

.profile-card-empty {
  width: 100%;
  min-height: 220px;
  display: grid;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.profile-card-empty h2,
.profile-card-empty p {
  margin: 0;
}

.profile-card-empty p {
  color: var(--muted);
  line-height: 1.6;
}

.colorful-url {
  font-weight: 800;
  background: linear-gradient(90deg, #25f4ee, #ffffff, #fe2c55);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.account-panel {
  margin-top: 10px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.auth-tab {
  height: 34px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.08);
}

.auth-tab.is-active {
  color: #fff;
  background: rgba(254, 44, 85, 0.88);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form input {
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.auth-form button,
.user-panel button {
  height: 38px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
}

.auth-message {
  min-height: 18px;
  font-size: 12px;
}

.auth-message.is-success {
  color: #25f4ee;
}

.auth-message.is-error {
  color: #ff6b8a;
}

.user-panel {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.user-panel span {
  color: var(--muted);
  font-size: 13px;
}

.site-footnote {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  text-align: center;
}

.site-footnote p {
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.76;
}

.profile-card h2 {
  margin: 0 0 18px;
  font-size: 22px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  height: 38px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.08);
}

.auth-tab.is-active {
  color: #fff;
  background: var(--accent);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form span {
  color: var(--muted);
  font-size: 14px;
}

.auth-form input {
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  outline: 1px solid transparent;
  transition:
    background 160ms ease,
    outline-color 160ms ease;
}

.auth-form input:focus {
  background: rgba(255, 255, 255, 0.1);
  outline-color: rgba(254, 44, 85, 0.7);
}

.auth-form button,
#logoutButton {
  height: 44px;
  margin-top: 6px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(90deg, #ff3d67, #fe2c55);
  box-shadow: 0 10px 24px rgba(254, 44, 85, 0.28);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-bottom: 12px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.profile-header .profile-avatar {
  margin-bottom: 0;
}

.profile-header h2 {
  margin: 0 0 6px;
}

.profile-header p {
  margin: 0;
  color: var(--muted);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.profile-stats div {
  display: grid;
  gap: 4px;
  padding: 12px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
}

.profile-stats strong {
  font-size: 18px;
}

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

.profile-actions {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-actions button {
  height: 42px;
  border-radius: 14px;
  color: #fff;
  text-align: left;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.06);
}

.comment-sheet.is-open {
  transform: translateY(0);
}

.sheet-handle {
  align-self: center;
  width: 42px;
  height: 4px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.comment-list {
  flex: 1;
  overflow: auto;
  padding: 14px 0;
}

.comment-item {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.comment-body strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.comment-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.comment-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.comment-input-wrap input {
  flex: 1;
  color: #fff;
  border: 0;
  outline: 0;
  background: transparent;
}

@keyframes drift {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

@media (min-width: 431px) {
  body {
    display: grid;
    place-items: center;
  }

  .app-shell {
    height: min(100dvh, 900px);
    border-radius: 26px;
    box-shadow: 0 18px 80px rgba(0, 0, 0, 0.48);
  }
}
