*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f3f4f8;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #8a8f9c;
  --grad-start: #5c7cff;
  --grad-end: #8b5cf6;
  --tag-active: #ff3b5c;
  --tag-active-glow: rgba(255, 59, 92, 0.45);
  --nav-active: #22c55e;
  --fab-bg: rgba(45, 48, 58, 0.88);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 56px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  background: var(--bg);
}

/* 顶栏品牌 */
.top-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px 6px;
  background: #fff;
}

.brand-shield {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  position: relative;
}

.brand-shield::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* 搜索区渐变 */
.search-bar-wrap {
  padding: 10px 12px 14px;
  background: linear-gradient(135deg, var(--grad-start) 0%, var(--grad-end) 100%);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  padding: 0;
  overflow: hidden;
  background: #ddd;
  cursor: pointer;
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-field {
  flex: 1;
  min-width: 0;
}

.search-field input {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 20px;
  padding: 0 16px;
  font-size: 14px;
  background: #fff;
  outline: none;
}

.search-field input::placeholder {
  color: #aaa;
}

.search-submit {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.search-submit:active {
  background: rgba(255, 255, 255, 0.35);
}

/* 分类标签 */
.tags-section {
  position: relative;
  padding: 12px 40px 8px 12px;
  background: var(--bg);
}

.tags-section.collapsed .tags-grid {
  max-height: 88px;
  overflow: hidden;
}

.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: none;
  transition: max-height 0.25s ease;
}

.tag {
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #444;
  background: var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s;
}

.tag:active {
  transform: scale(0.97);
}

.tag.active {
  color: #fff;
  background: var(--tag-active);
  box-shadow: 0 0 0 1px var(--tag-active), 0 4px 14px var(--tag-active-glow);
  font-weight: 700;
}

.tags-toggle {
  position: absolute;
  right: 10px;
  top: 14px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tags-section.collapsed .tags-toggle svg {
  transform: rotate(180deg);
}

/* 视频网格 */
.feed {
  padding: 4px 10px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 10px;
}

.video-card {
  display: block;
  background: transparent;
}

.thumb-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 11;
  background: #cbd5e1;
}

.thumb-wrap img,
.thumb-wrap .thumb-ph {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-ph {
  background: linear-gradient(145deg, #64748b, #94a3b8);
}

.thumb-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.thumb-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 8px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  font-size: 11px;
  color: #fff;
}

.thumb-views {
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0.95;
}

.thumb-views svg {
  width: 12px;
  height: 12px;
  opacity: 0.9;
}

.video-title {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #222;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

/* 右侧浮条 */
.fab-rail {
  position: fixed;
  right: max(8px, calc(50% - 240px + 8px));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 72px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: 44px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--fab-bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.fab-item {
  border: none;
  background: transparent;
  color: #fff;
  padding: 10px 0 8px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.fab-item + .fab-item {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.fab-item:active {
  background: rgba(255, 255, 255, 0.08);
}

/* 底栏 */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: #fff;
  border-top: 1px solid #e8eaef;
  z-index: 100;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  padding-top: 6px;
}

.tab-icon {
  width: 22px;
  height: 22px;
}

.tab.active {
  color: var(--nav-active);
  font-weight: 600;
}

.tab.active .tab-icon {
  stroke: var(--nav-active);
}

/* 子页 */
.sub-page {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

.sub-header {
  text-align: center;
  padding: 14px;
  font-size: 17px;
  font-weight: 700;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.sub-main {
  padding: 24px 16px;
}

.empty-tip {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 32px;
}

.profile-name {
  font-size: 16px;
  font-weight: 600;
}

@media (min-width: 481px) {
  body {
    background: #e5e7eb;
  }
  .app {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
  }
}
