/* YouTube Trending v2 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --border:   #2e2e2e;
  --accent:   #ff4444;
  --accent2:  #ff8800;
  --text:     #e8e8e8;
  --muted:    #888;
  --card-bg:  #1e1e1e;
  --radius:   10px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif;
  min-height: 100vh;
}

/* ── 헤더 ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 20px;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
  text-decoration: none;
}
.logo span { color: var(--text); }

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 9px 44px 9px 16px;
  color: var(--text);
  font-size: 0.93rem;
  outline: none;
  transition: border-color .2s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .btn-search {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
}
.search-wrap .btn-search:hover { color: var(--accent); }

/* ── 필터바 ── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  overflow-x: auto;
}
.filter-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-size: 0.8rem; color: var(--muted); }
.filter-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}
.filter-group select:focus { border-color: var(--accent); }
.filter-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

/* 칩 공통 */
.chip-group { display: flex; gap: 6px; }
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
  user-select: none;
}
.chip:hover   { border-color: var(--accent); color: var(--text); }
.chip.active  { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ── 날짜 바 ── */
.date-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  overflow-x: auto;
}
.date-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.date-bar-label { font-size: 0.78rem; color: var(--muted); margin-right: 4px; flex-shrink: 0; }
.date-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
}
.date-chip:hover  { border-color: var(--accent); color: var(--text); }
.date-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.date-chip.active span { color: #fff; }
.date-picker-btn {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}
.date-picker-btn:hover { border-color: var(--accent); color: var(--text); }

/* ── 커스텀 달력 팝업 ── */
.date-picker-popup {
  position: absolute;
  z-index: 1000;
  background: #0f1623;
  border: 1px solid #2a3347;
  border-radius: 14px;
  padding: 16px;
  width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  user-select: none;
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}
.cal-nav {
  background: #1e2d45;
  border: none;
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.cal-nav:hover { background: #2a3f5c; color: #e2e8f0; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dow {
  text-align: center;
  font-size: 0.7rem;
  color: #64748b;
  padding: 4px 0 6px;
  font-weight: 500;
}
.cal-dow.sun { color: #f87171; }
.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 2px 7px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #cbd5e1;
  transition: background .12s;
  min-height: 36px;
}
.cal-cell:hover { background: #1e2d45; }
.cal-cell.empty { cursor: default; pointer-events: none; }
.cal-cell.dimmed { color: #374151; cursor: default; pointer-events: none; }
.cal-cell.today > span {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.cal-cell.selected > span {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.cal-dot {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}

/* ── 추천 키워드 바 ── */
.keyword-bar {
  padding: 10px 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.keyword-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.keyword-bar-label { font-size: 0.78rem; color: var(--muted); flex-shrink: 0; margin-right: 2px; }
.kw-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  border: 1px solid #2a4a3a;
  background: #1a2e25;
  color: #5dbb8a;
  transition: all .15s;
  white-space: nowrap;
}
.kw-chip:hover { background: #5dbb8a; border-color: #5dbb8a; color: #000; }

/* ── 메인 ── */
.main { max-width: 1400px; margin: 0 auto; padding: 20px 20px 60px; }
.result-info { font-size: 0.82rem; color: var(--muted); margin-bottom: 16px; min-height: 18px; }

/* ── 그리드 ── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

/* ── 카드 ── */
.video-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform .2s, border-color .2s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.video-card:hover { transform: translateY(-3px); border-color: #444; }

/* 썸네일 */
.thumb-wrap {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  flex-shrink: 0;
}
.thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: #111;
}
.duration-badge {
  position: absolute;
  bottom: 6px; right: 8px;
  background: rgba(0,0,0,.85);
  color: #fff;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.ratio-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}
.ratio-badge.hot { background: var(--accent2); }

/* 카드 본문 */
.card-body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; gap: 8px; }

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  max-height: 2.5em;
  overflow: hidden;
  color: var(--text);
  word-break: break-word;
}

/* 채널 행 */
.card-channel {
  display: flex;
  align-items: center;
  gap: 7px;
}
.channel-icon {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
  flex-shrink: 0;
}
.channel-icon-placeholder {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #333;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  color: var(--muted);
  flex-shrink: 0;
}
.channel-name {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* 통계 */
.card-stats {
  display: flex;
  gap: 12px;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: auto;
  flex-wrap: wrap;
}
.stat { display: flex; align-items: center; gap: 3px; }
.stat strong { color: var(--text); font-weight: 600; }

/* 카드 하단 */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px 10px;
  font-size: 0.73rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.ratio-label { font-weight: 700; color: var(--accent); }
.ratio-label.hot { color: var(--accent2); }

/* ── 로딩 ── */
.loader { text-align: center; padding: 40px; color: var(--muted); }
.spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 빈 상태 ── */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty h3 { font-size: 1rem; color: var(--text); margin-bottom: 6px; }

/* ── 더보기 ── */
.load-more-wrap { text-align: center; margin-top: 28px; }
.btn-load-more {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 9px 28px;
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-load-more:hover { border-color: var(--accent); color: var(--accent); }
.btn-load-more:disabled { opacity: .4; cursor: not-allowed; }

/* ── 반응형 ── */
@media (max-width: 600px) {
  .video-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card-body { padding: 7px 8px 8px; }
  .card-title { font-size: 0.8rem; }
}
@media (max-width: 380px) {
  .video-grid { grid-template-columns: 1fr; }
}
