*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --yt-red:      #FF0000;
  --yt-red-dark: #CC0000;
  --yt-black:    #0F0F0F;
  --yt-gray1:    #606060;
  --yt-gray2:    #AAAAAA;
  --yt-gray3:    #E5E5E5;
  --yt-bg:       #F9F9F9;
  --yt-white:    #FFFFFF;
  --yt-chip-bg:  #0F0F0F;
}
body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--yt-bg);
  color: var(--yt-black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── 헤더 ─────────────────────────────── */
.yt-header {
  background: var(--yt-white);
  border-bottom: 1px solid var(--yt-gray3);
  position: sticky; top: 0; z-index: 100;
}
.yt-header-inner {
  max-width: 1284px; margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; gap: 16px;
}
.yt-logo {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
}
.yt-logo-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 24px;
  background: var(--yt-red);
  border-radius: 6px;
}
.yt-logo-icon svg { width: 18px; height: 14px; }
.yt-logo-text {
  font-size: 18px; font-weight: 700; color: var(--yt-black); letter-spacing: -0.3px;
}
.yt-logo-sub {
  font-size: 9px; font-weight: 500; color: var(--yt-gray1);
  background: var(--yt-gray3); padding: 1px 5px; border-radius: 3px;
  align-self: flex-end; margin-bottom: 2px;
}
.yt-header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live-badge {
  display: none; align-items: center; gap: 5px;
  background: #FEE2E2; color: var(--yt-red);
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  border: 1px solid #FECACA;
}
.live-badge.visible { display: flex; }
.live-dot {
  width: 6px; height: 6px;
  background: var(--yt-red); border-radius: 50%;
  animation: blink 1.5s ease-in-out infinite;
}
.key-change-btn {
  display: none;
  font-size: 12px; font-weight: 500; color: var(--yt-gray1);
  background: none; border: 1px solid var(--yt-gray3);
  padding: 5px 12px; border-radius: 20px;
  cursor: pointer; transition: border-color .15s, color .15s;
  font-family: inherit;
}
.key-change-btn:hover { border-color: var(--yt-gray2); color: var(--yt-black); }
.key-change-btn.visible { display: block; }

/* ── 필터 바 ──────────────────────────── */
.filter-bar {
  background: var(--yt-white);
  border-bottom: 1px solid var(--yt-gray3);
  position: sticky; top: 56px; z-index: 90;
}
.filter-bar-inner {
  max-width: 1284px; margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex; align-items: center; gap: 20px;
  overflow-x: auto; white-space: nowrap;
  scrollbar-width: none;
}
.filter-bar-inner::-webkit-scrollbar { display: none; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 13px; color: var(--yt-gray1); font-weight: 500; white-space: nowrap; }
.chip-group { display: flex; gap: 8px; }
.chip {
  font-size: 13px; font-weight: 500;
  padding: 5px 14px; border-radius: 8px;
  border: none; cursor: pointer; transition: background .15s, color .15s;
  font-family: inherit; white-space: nowrap;
  background: var(--yt-gray3); color: var(--yt-black);
}
.chip:hover { background: #D9D9D9; }
.chip.active { background: var(--yt-chip-bg); color: var(--yt-white); }
.chip.active:hover { background: #333; }
.chip.red.active { background: var(--yt-red); color: var(--yt-white); }
.chip.red.active:hover { background: var(--yt-red-dark); }
.filter-divider { width: 1px; height: 24px; background: var(--yt-gray3); flex-shrink: 0; }

/* ── 메인 ─────────────────────────────── */
main {
  flex: 1;
  max-width: 1284px; margin: 0 auto; width: 100%;
  padding: 24px 24px 40px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ── API 키 섹션 ──────────────────────── */
.key-section {
  background: var(--yt-white);
  border: 1px solid var(--yt-gray3);
  border-left: 4px solid var(--yt-red);
  border-radius: 12px;
  overflow: hidden;
}
.key-form-area { padding: 20px 24px 16px; }
.key-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--yt-black);
  margin-bottom: 12px;
}
.key-section-title .yt-icon {
  width: 28px; height: 20px;
  background: var(--yt-red); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
}
.key-form-row { display: flex; gap: 10px; }
.key-input {
  flex: 1; min-width: 0;
  border: 1.5px solid var(--yt-gray3);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px; font-family: 'Courier New', monospace;
  color: var(--yt-black);
  outline: none; transition: border-color .15s;
}
.key-input:focus { border-color: var(--yt-red); }
.key-submit-btn {
  flex-shrink: 0;
  background: var(--yt-red); color: #fff;
  border: none; border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: background .15s;
  white-space: nowrap;
}
.key-submit-btn:hover { background: var(--yt-red-dark); }
.key-submit-btn:disabled { background: var(--yt-gray2); cursor: not-allowed; }
.key-hint { font-size: 11px; color: var(--yt-gray2); margin-top: 8px; }
.key-error {
  display: none;
  margin: 0 24px 12px;
  background: #FEF2F2; border: 1px solid #FECACA;
  color: #B91C1C; border-radius: 8px;
  padding: 10px 14px; font-size: 12px;
}

/* 발급 방법 안내 */
.guide-area {
  border-top: 1px solid #FEE2E2;
  background: #FFF8F8;
  padding: 20px 24px;
}
.guide-title {
  font-size: 13px; font-weight: 700; color: var(--yt-black);
  margin-bottom: 16px;
}
.guide-title span { color: var(--yt-gray1); font-weight: 400; }
.guide-steps { display: flex; flex-direction: column; gap: 16px; }
.guide-step { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--yt-red); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.step-name { font-size: 13px; font-weight: 600; color: var(--yt-black); }
.step-desc { font-size: 12px; color: var(--yt-gray1); margin-top: 2px; line-height: 1.6; }
.step-link {
  font-size: 12px; color: var(--yt-red);
  text-decoration: none; display: inline-block; margin-top: 4px;
}
.step-link:hover { text-decoration: underline; }
.quota-note {
  margin-top: 16px; padding: 10px 14px;
  background: #FEF9C3; border: 1px solid #FDE047;
  border-radius: 8px; font-size: 12px; color: #854D0E;
  line-height: 1.6;
}

/* 참고용 토글 */
.ref-section {
  display: none;
  background: var(--yt-white);
  border: 1px solid var(--yt-gray3);
  border-radius: 12px;
  overflow: hidden;
}
.ref-section.visible { display: block; }
.ref-toggle-btn {
  width: 100%; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--yt-gray1);
  background: none; border: none; cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.ref-toggle-btn:hover { background: var(--yt-bg); }
.ref-toggle-left { display: flex; align-items: center; gap: 8px; }
.guide-body-wrap { overflow: hidden; transition: max-height .3s ease; max-height: 0; }
.guide-body-inner {
  border-top: 1px solid var(--yt-gray3);
  background: var(--yt-bg);
  padding: 20px 24px;
}

/* ── 영상 섹션 헤더 ───────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
}
.section-title {
  font-size: 16px; font-weight: 700; color: var(--yt-black);
  display: flex; align-items: center; gap: 8px;
}
.section-count { font-size: 13px; font-weight: 400; color: var(--yt-gray1); }
.last-updated { font-size: 12px; color: var(--yt-gray2); }

/* ── 영상 그리드 ──────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.video-card {
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  transition: transform .15s;
}
.video-card:hover { transform: translateY(-2px); }
.video-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--yt-gray3);
  overflow: hidden;
  border-radius: 12px;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rank-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.75); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
}
.viral-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--yt-red);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
}
.video-info { padding: 10px 4px 4px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.video-title {
  font-size: 14px; font-weight: 600; color: var(--yt-black);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color .15s;
}
.video-card:hover .video-title { color: var(--yt-red); }
.video-channel { font-size: 12px; color: var(--yt-gray1); margin-top: 2px; }
.video-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--yt-gray2); }
.video-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; margin-top: 8px;
  background: var(--yt-gray3); border-radius: 8px; overflow: hidden;
}
.stat-cell { background: #F5F5F5; padding: 6px 4px; text-align: center; }
.stat-label { font-size: 10px; color: var(--yt-gray2); }
.stat-val { font-size: 12px; font-weight: 700; color: var(--yt-black); margin-top: 1px; }

/* ── 스켈레톤 ─────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #EBEBEB 25%, #F5F5F5 50%, #EBEBEB 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
.skel-thumb { aspect-ratio: 16/9; border-radius: 12px; }

/* ── 빈 / 에러 상태 ───────────────────── */
.empty-state {
  text-align: center; padding: 80px 20px; color: var(--yt-gray2);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .msg  { font-size: 15px; font-weight: 600; color: var(--yt-gray1); }
.empty-state .sub  { font-size: 13px; margin-top: 6px; }

.error-state { text-align: center; padding: 80px 20px; }
.error-state .icon  { font-size: 40px; margin-bottom: 12px; }
.error-state .title { font-size: 16px; font-weight: 700; color: var(--yt-black); margin-bottom: 8px; }
.error-state .msg   { font-size: 13px; color: var(--yt-gray1); max-width: 400px; margin: 0 auto 20px; }
.retry-btn {
  background: var(--yt-red); color: #fff;
  border: none; border-radius: 8px;
  padding: 10px 24px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.retry-btn:hover { background: var(--yt-red-dark); }

/* ── 푸터 ─────────────────────────────── */
footer {
  text-align: center; padding: 16px;
  font-size: 12px; color: var(--yt-gray2);
  border-top: 1px solid var(--yt-gray3);
  background: var(--yt-white);
}

/* ── 애니메이션 ───────────────────────── */
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:.2; } }
