:root {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255,255,255,.62);
  --line: rgba(255,255,255,.16);
  --accent: #fe2c55;
  --cyan: #25f4ee;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none; -webkit-user-select: none;
}
#app { position: fixed; inset: 0; overflow: hidden; }

/* ---------- top ---------- */
.topbar {
  position: absolute; z-index: 30; top: 0; left: 0; right: 0;
  padding: calc(var(--safe-t) + 8px) 12px 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
}
.tabs { display: flex; gap: 24px; }
.tab {
  background: none; border: 0; color: var(--muted);
  font-size: 17px; font-weight: 600; padding: 6px 2px 8px; position: relative;
}
.tab.active { color: #fff; }
.tab.active::after {
  content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 20px; height: 3px; border-radius: 3px; background: #fff;
}
.icon-btn {
  background: none; border: 0; color: #fff; padding: 4px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.search-btn { position: absolute; right: 14px; top: calc(var(--safe-t) + 12px); }

/* ---------- feed ---------- */
.feed {
  height: 100%; overflow-y: auto; overflow-x: hidden;
  scroll-snap-type: y mandatory; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
}
.feed::-webkit-scrollbar { display: none; }

.video-card {
  position: relative; height: 100%; width: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  overflow: hidden; background: #08080a;
}
.video-card video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
}
.video-card .veil {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.35) 0%, transparent 22%, transparent 55%, rgba(0,0,0,.72) 100%);
}
.center-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 66px; height: 66px; display: none; place-items: center; pointer-events: none;
  border-radius: 50%; background: rgba(0,0,0,.36);
}
.center-play.show { display: grid; }
.center-play svg { width: 34px; height: 34px; fill: #fff; margin-left: 3px; }
.video-error {
  position: absolute; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 30px;
}
.video-error.show { display: flex; }
.video-error p { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.6; }
.video-error button { background: #fff; color: #000; border: 0; border-radius: 20px; padding: 9px 20px; font-size: 14px; font-weight: 600; }

/* long press indicator */
.ff-badge {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.9);
  padding: 10px 18px; border-radius: 30px; background: rgba(0,0,0,.62);
  border: 1px solid rgba(255,255,255,.25); font-size: 20px; font-weight: 800;
  letter-spacing: .5px; opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none;
}
.ff-badge.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* right rail */
.rail {
  position: absolute; right: 8px; bottom: calc(78px + var(--safe-b)); z-index: 12;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.rail-item { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; color: #fff; padding: 0; cursor: pointer; }
.rail-item .circle {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.14); border: 2px solid #fff; overflow: hidden;
}
.rail-item .circle svg { width: 26px; height: 26px; fill: #fff; stroke: none; }
.rail-item .circle.avatar { font-size: 18px; font-weight: 700; background: linear-gradient(145deg, #ff6a88, #ff9068); }
.rail-item .count { font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.rail-item.liked .circle svg { fill: var(--accent); }
.rail-item.faved .circle svg { fill: #ffd93d; }

/* left info */
.meta {
  position: absolute; left: 14px; right: 74px; bottom: calc(80px + var(--safe-b)); z-index: 11;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.meta .author { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.meta .author small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.meta .desc {
  font-size: 13px; line-height: 1.45; color: rgba(255,255,255,.92);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta .stats {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 9px; font-size: 12px; color: var(--muted);
}
.meta .stats b { color: #fff; font-weight: 700; }
.meta .stats .heat { color: var(--accent); }
.meta .tags { margin-top: 6px; font-size: 12px; color: var(--cyan); }
.meta .clickable { cursor: pointer; }

/* progress */
.progress-wrap {
  position: absolute; left: 12px; right: 12px; bottom: calc(64px + var(--safe-b)); z-index: 14;
  height: 20px; display: flex; align-items: center; touch-action: none;
}
.progress-track {
  position: relative; width: 100%; height: 3px; border-radius: 3px;
  background: rgba(255,255,255,.32); transition: height .12s;
}
.progress-wrap.dragging .progress-track { height: 6px; }
.progress-buffer { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,255,255,.45); border-radius: 3px; }
.progress-played { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #fff; border-radius: 3px; }
.progress-thumb {
  position: absolute; top: 50%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border-radius: 50%; background: #fff; box-shadow: 0 0 5px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .12s;
}
.progress-wrap.dragging .progress-thumb, .progress-wrap:hover .progress-thumb { opacity: 1; }
.time-tip {
  position: absolute; bottom: 22px; left: 0; transform: translateX(-50%);
  background: rgba(0,0,0,.75); padding: 3px 8px; border-radius: 6px; font-size: 11px;
  white-space: nowrap; opacity: 0; pointer-events: none;
}
.progress-wrap.dragging .time-tip { opacity: 1; }

/* ---------- bottom nav ---------- */
.bottombar {
  position: absolute; z-index: 30; left: 0; right: 0; bottom: 0;
  height: calc(52px + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; align-items: center; justify-content: space-around;
  background: #000; border-top: 1px solid rgba(255,255,255,.08);
}
.nav-item {
  flex: 1; background: none; border: 0; color: rgba(255,255,255,.6);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; cursor: pointer;
}
.nav-item.active { color: #fff; }
.nav-item svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.plus { flex: 0 0 54px; }
.nav-item.plus span {
  width: 44px; height: 30px; border-radius: 9px; position: relative;
  background: #fff; box-shadow: -10px 0 0 -2px var(--cyan), 10px 0 0 -2px var(--accent);
}
.nav-item.plus span::before, .nav-item.plus span::after {
  content: ""; position: absolute; background: #000; border-radius: 2px;
}
.nav-item.plus span::before { width: 16px; height: 3px; left: 14px; top: 13.5px; }
.nav-item.plus span::after { width: 3px; height: 16px; left: 20.5px; top: 7px; }

/* ---------- loader / toast / search ---------- */
.loader, .empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 13px;
}
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty button { background: #fff; color: #000; border: 0; border-radius: 20px; padding: 8px 20px; font-weight: 600; }
.toast {
  position: absolute; z-index: 60; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(10px);
  background: rgba(0,0,0,.82); border: 1px solid var(--line); color: #fff; padding: 9px 16px;
  border-radius: 20px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  white-space: nowrap; max-width: 86vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.search-panel {
  position: absolute; z-index: 50; inset: 0; background: #0c0c0e; padding: calc(var(--safe-t) + 10px) 14px 14px;
}
.search-head { display: flex; align-items: center; gap: 8px; }
.search-head input {
  flex: 1; background: #1c1c1f; border: 1px solid #2a2a2e; color: #fff;
  border-radius: 22px; padding: 10px 14px; font-size: 14px; outline: none;
}
.search-go { background: var(--accent); color: #fff; border: 0; border-radius: 20px; padding: 10px 16px; font-size: 14px; font-weight: 600; }
.search-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.search-chips button {
  background: #1c1c1f; border: 1px solid #2a2a2e; color: rgba(255,255,255,.8);
  border-radius: 18px; padding: 7px 13px; font-size: 13px;
}

@media (min-width: 640px) {
  #app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 60px rgba(255,255,255,.08); }
}
