/* Apple Inspired Design System - Light Mode */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 使用系统字体 (SF Pro) */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 加载状态 ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 999;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #0071e3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 14px;
  color: #86868b;
  font-weight: 500;
}

/* ===== 主内容区域 ===== */
.main-content {
  padding: 0 16px 100px 16px; /* 底部留出 Tab Bar 空间 */
  max-width: 100%;
  overflow-x: hidden;
}

/* ===== 搜索栏 ===== */
.search-header {
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: #f5f5f7;
  z-index: 100;
}

.search-bar {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  padding: 10px 14px;
  gap: 10px;
}

.search-icon {
  color: #86868b;
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 17px;
  color: #1d1d1f;
  outline: none;
}

.search-bar input::placeholder {
  color: #86868b;
}

/* ===== 标签筛选区 ===== */
.tags-section {
  padding: 8px 0 16px 0;
}

.tag-group-title {
  font-size: 13px;
  font-weight: 600;
  color: #86868b;
  margin: 16px 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-btn {
  background: #fff;
  color: #1d1d1f;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tag-btn:hover,
.tag-btn:active {
  background: #0071e3;
  color: #fff;
  transform: scale(1.02);
}

/* ===== 视频网格 ===== */
.content-section {
  padding-top: 8px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: #1d1d1f;
  margin: 8px 0 16px 0;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.video-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.video-card:hover,
.video-card:active {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.video-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

.video-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.video-rating {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 113, 227, 0.9);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.video-author {
  font-size: 12px;
  color: #86868b;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-info {
  padding: 12px;
}

.video-title {
  font-size: 14px;
  font-weight: 500;
  color: #1d1d1f;
  line-height: 1.4;
  max-height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== 分类网格 ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.category-card {
  position: relative;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease;
}

.category-card:hover {
  transform: scale(1.02);
}

.category-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}

.category-name {
  font-size: 16px;
  color: #fff;
  font-weight: 600;
}

/* ===== 女优网格 ===== */
.model-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.model-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  padding: 16px 12px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease;
}

.model-card:hover {
  transform: scale(1.02);
}

.model-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.model-name {
  font-size: 13px;
  color: #1d1d1f;
  text-align: center;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 16px;
}

.page-btn {
  background: #fff;
  color: #0071e3;
  border: none;
  padding: 10px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
}

.page-btn:hover,
.page-btn:active {
  background: #0071e3;
  color: #fff;
}

.page-btn.active {
  background: #0071e3;
  color: #fff;
}

.page-btn:disabled {
  background: rgba(0, 0, 0, 0.04);
  color: #86868b;
  cursor: not-allowed;
  box-shadow: none;
}

/* ===== 底部 Tab Bar (iOS 风格) ===== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 83px; /* iOS Tab Bar 标准高度 */
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-evenly;
  align-items: flex-start;
  padding-top: 8px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.1);
  z-index: 500;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  overflow-x: auto;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  transition: opacity 0.2s;
  flex-shrink: 0;
  min-width: 50px;
}

.tab-icon {
  color: #86868b;
  transition: color 0.2s;
}

.tab-label {
  font-size: 11px;
  color: #86868b;
  font-weight: 500;
  transition: color 0.2s;
}

.tab-item.active .tab-icon,
.tab-item.active .tab-label {
  color: #0071e3;
}

/* ===== 播放器弹窗 (iOS Sheet 风格) ===== */
.player-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 600;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.player-modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.player-sheet {
  width: 100%;
  max-width: 100%;
  background: #fff;
  border-radius: 12px 12px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
}

.player-title {
  font-size: 16px;
  font-weight: 600;
  color: #1d1d1f;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}

.close-btn {
  background: transparent;
  border: none;
  color: #86868b;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: #1d1d1f;
}

.player-container {
  background: #000;
  min-height: 200px;
  position: relative;
}

.player-container video {
  width: 100%;
  height: auto;
  max-height: 50vh;
  display: block;
}

.player-footer {
  padding: 16px;
}

/* 女主角区域 */
.player-models {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.model-btn {
  background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(238, 90, 90, 0.3);
}

.model-btn:hover,
.model-btn:active {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(238, 90, 90, 0.4);
}

.player-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.player-tags .tag-btn {
  background: rgba(0, 113, 227, 0.1);
  color: #0071e3;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.player-tags .tag-btn:hover,
.player-tags .tag-btn:active {
  background: #0071e3;
  color: #fff;
}

/* 分类标签特殊样式 */
.player-tags .tag-btn.category {
  background: linear-gradient(135deg, #5856d6, #4a4ab0);
  color: #fff;
}

.player-tags .tag-btn.category:hover,
.player-tags .tag-btn.category:active {
  background: linear-gradient(135deg, #6b69e0, #5856d6);
  transform: scale(1.05);
}

.hls-section {
  display: flex;
  gap: 8px;
}

.hls-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.04);
  border: none;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-btn {
  background: #0071e3;
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: #0077ed;
}

/* ===== 错误状态 ===== */
.error-state {
  text-align: center;
  padding: 48px 24px;
}

.error-text {
  color: #ff3b30;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 16px;
}

.error-btn {
  background: #0071e3;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

/* ===== 播放提示 ===== */
.play-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0071e3;
  color: #fff;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  z-index: 10;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* ===== Hanime 直接访问界面 ===== */
/* ===== Hanime 专用样式 ===== */
.hanime-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.hanime-card {
  /* 竖版封面比例 3:4 */
}

.hanime-card .video-thumb {
  aspect-ratio: 3/4;
}

.hanime-card .video-title {
  font-size: 12px;
  max-height: 32px;
  -webkit-line-clamp: 2;
}

.hanime-direct-container {
  padding: 20px 0;
}

.hanime-info-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.hanime-url-section {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.primary-btn {
  background: #0071e3;
  color: #fff;
  border: none;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.primary-btn:hover {
  background: #0077ed;
}

.hls-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 14px;
  border-radius: 10px;
  font-size: 15px;
  color: #1d1d1f;
  width: 100%;
}

.hls-input:focus {
  outline: none;
  border-color: #0071e3;
}

/* ===== Cookie 设置弹窗 ===== */
.cookie-content {
  padding: 16px;
}

.cookie-hint {
  font-size: 15px;
  color: #1d1d1f;
  margin-bottom: 12px;
}

.cookie-steps {
  font-size: 13px;
  color: #86868b;
  line-height: 1.6;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.04);
  padding: 12px;
  border-radius: 10px;
}

.cookie-input {
  width: 100%;
  min-height: 100px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: #1d1d1f;
  resize: vertical;
  font-family: monospace;
}

.cookie-input:focus {
  outline: none;
  border-color: #0071e3;
}

.cookie-status {
  margin-top: 12px;
  font-size: 14px;
  text-align: center;
}

.cookie-status.success {
  color: #34c759;
}

.cookie-status.error {
  color: #ff3b30;
}

/* ===== 响应式 ===== */
@media (min-width: 768px) {
  .video-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .category-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .model-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px 100px 24px;
  }
}

@media (min-width: 1024px) {
  .video-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .category-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .model-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .main-content {
    max-width: 1100px;
    padding: 0 32px 100px 32px;
  }

  .player-sheet {
    max-width: 600px;
    border-radius: 12px;
    margin: auto;
    max-height: 80vh;
  }

  .player-modal {
    align-items: center;
  }
}

/* ===== Safe Area 支持 (iOS) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .tab-bar {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .main-content {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
}