/* ────────────────────────────────────────────────────────────
   헬퍼비 vsource — YouTube 랭킹 대시보드
   CLAUDE.md 색상 표준 준수 (dark theme + Primary #1c2a2a)
   ──────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #1a1a1a;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Malgun Gothic", "Apple SD Gothic Neo", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-width: 400px;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ── Header ─────────────────────────────────────────────── */
.vs-header {
  background: #232328;
  border-bottom: 1px solid #2a2a30;
  position: sticky;
  top: 0;
  z-index: 10;
}

.vs-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.vs-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #FEDF68;
}

.vs-brand-text {
  font-size: 18px;
  font-weight: 700;
  color: #FEDF68;
  letter-spacing: -0.2px;
}
.vs-brand-text em {
  font-style: normal;
  color: #e0e0e0;
  font-weight: 500;
}

.vs-logo {
  flex-shrink: 0;
}

/* ── Country tabs ────────────────────────────────────────── */
.vs-country-tabs {
  display: inline-flex;
  gap: 4px;
  background: #1a1a1a;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #2a2a30;
}

.vs-tab {
  background: transparent;
  border: 1px solid transparent;
  color: #aaa;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.vs-tab:hover {
  color: #e0e0e0;
}
.vs-tab.active {
  color: #1c2a2a;
  border-color: #1c2a2a;
}
.vs-tab:focus-visible {
  outline: 2px solid #1c2a2a;
  outline-offset: 2px;
}

/* ── Main ───────────────────────────────────────────────── */
.vs-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.vs-intro {
  margin-bottom: 24px;
  padding: 0 4px;
}

.vs-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  color: #e0e0e0;
  letter-spacing: -0.3px;
}

.vs-subtitle {
  font-size: 13px;
  margin: 0;
  color: #888;
}

/* ── Grid (2 cols x 3 rows) ─────────────────────────────── */
.vs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 780px) {
  .vs-grid {
    grid-template-columns: 1fr;
  }
  .vs-header-inner {
    padding: 10px 14px;
  }
  .vs-main {
    padding: 20px 14px 32px;
  }
}

/* ── Card ───────────────────────────────────────────────── */
.vs-card {
  background: #2a2a30;
  border: 1px solid #2a2a30;
  border-radius: 10px;
  padding: 18px 18px 6px;
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

.vs-card-head {
  padding: 0 2px 12px;
  border-bottom: 1px solid #1a1a1a;
  margin-bottom: 10px;
}

.vs-card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 2px;
  color: #e0e0e0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.vs-card-sub {
  font-size: 11.5px;
  color: #888;
}

.vs-card-body {
  flex: 1;
  overflow: hidden;
}

/* live blinking dot */
.vs-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6C6E71;
  box-shadow: 0 0 0 0 rgba(126, 195, 255, 0.5);
  animation: vs-pulse 1.6s infinite;
}
@keyframes vs-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(126, 195, 255, 0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(126, 195, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(126, 195, 255, 0); }
}

/* ── Item list ──────────────────────────────────────────── */
.vs-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.vs-item {
  display: grid;
  grid-template-columns: 28px 44px 1fr;
  gap: 10px;
  padding: 8px 2px;
  align-items: center;
  border-bottom: 1px solid #232328;
}
.vs-item:last-child {
  border-bottom: 0;
}

.vs-rank {
  font-size: 13px;
  font-weight: 700;
  color: #888;
  text-align: center;
}
.vs-item:nth-child(-n+3) .vs-rank {
  color: #FEDF68;
}

.vs-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #1a1a1a;
  border: 1px solid #1a1a1a;
}
/* YouTube API Services III.C.1: 클릭 시 재생이 시작되는 썸네일은 최소 120x70.
   16:9 에서 폭 120 은 높이 67.5 라 미달 → 128x72 로 둔다. */
.vs-card[data-card="trending"] .vs-thumb,
.vs-card[data-card="live"] .vs-thumb {
  width: 128px;
  height: 72px;
  border-radius: 4px;
}
.vs-card[data-card="trending"] .vs-item,
.vs-card[data-card="live"] .vs-item {
  grid-template-columns: 28px 128px 1fr;
}

.vs-item-body {
  min-width: 0;
}

.vs-item-name {
  font-size: 13px;
  /* v1.7.4 fix (2026-07-09): 흰 배경 리스트 가독성 — #e0e0e0 는 사실상 안 보임 */
  color: #1c1c1e;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vs-item-metric {
  font-size: 11.5px;
  color: #444649;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ── Skeleton loader ────────────────────────────────────── */
.vs-skeleton-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.vs-skeleton-list li {
  height: 44px;
  margin: 8px 0;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    #232328 0%,
    #2f2f36 50%,
    #232328 100%
  );
  background-size: 400% 100%;
  animation: vs-shimmer 1.4s ease-in-out infinite;
}
@keyframes vs-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Error state ────────────────────────────────────────── */
.vs-error {
  padding: 32px 16px;
  text-align: center;
}
.vs-error-msg {
  font-size: 13px;
  color: #aaa;
  margin: 0 0 14px;
}
.vs-btn-retry {
  background: transparent;
  border: 1px solid #1c2a2a;
  color: #1c2a2a;
  padding: 6px 18px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.vs-btn-retry:hover {
  color: #6C6E71;
  border-color: #6C6E71;
}
.vs-btn-retry:focus-visible {
  outline: 2px solid #1c2a2a;
  outline-offset: 2px;
}

/* ── Empty state ────────────────────────────────────────── */
.vs-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 13px;
  color: #888;
}

/* ── Placeholder card (v1.3 예정) ───────────────────────── */
.vs-card-placeholder {
  opacity: 0.72;
}
.vs-card-placeholder .vs-card-title {
  color: #aaa;
}
.vs-placeholder-body {
  padding: 24px 16px;
  text-align: center;
  color: #888;
}
.vs-placeholder-icon {
  color: #555;
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.vs-placeholder-text {
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0;
}

/* ────────────────────────────────────────────────────────────
   v1.6 v2 페이지 신규 클래스 (insights / channel / favorites / settings)
   ──────────────────────────────────────────────────────────── */

/* ── 헤더 nav 확장 (auth.js renderAuthState 로그인 상태) ── */
.vs-auth-widget .vs-auth-nav {
  font-weight: 500;
}
.vs-auth-widget .vs-auth-nav:hover {
  background: rgba(28, 42, 42, 0.1);
}

/* ── 회원가입 유도 카드 (insights / channel 미로그인) ──── */
.vs-signup-cta {
  max-width: 560px;
  margin: 40px auto;
  background: #2a2a30;
  border: 1px solid #1c2a2a;
  border-radius: 10px;
  padding: 32px 28px;
  text-align: center;
}
.vs-signup-cta h2 {
  font-size: 18px;
  font-weight: 700;
  color: #e0e0e0;
  margin: 0 0 8px;
  letter-spacing: -0.3px;
}
.vs-signup-cta .vs-cta-sub {
  font-size: 12.5px;
  color: #888;
  margin: 0 0 18px;
  line-height: 1.5;
}
.vs-signup-cta .vs-cta-benefits {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}
.vs-signup-cta .vs-cta-benefits li {
  font-size: 13px;
  color: #e0e0e0;
  padding-left: 22px;
  position: relative;
  line-height: 1.5;
}
.vs-signup-cta .vs-cta-benefits li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1c2a2a;
}
.vs-signup-cta .vs-cta-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.vs-signup-cta .vs-cta-actions .vs-btn {
  width: auto;
  min-width: 130px;
  margin-top: 0;
}

/* ── 토스트 (favorites / settings) ──────────────────────── */
.vs-toast-host {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.vs-toast {
  background: #232328;
  border: 1px solid #1c2a2a;
  color: #1c2a2a;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  min-width: 200px;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: vs-toast-in 0.18s ease-out;
  pointer-events: auto;
}
.vs-toast.error {
  border-color: #8f4a4a;
  color: #d8a0a0;
}
.vs-toast.success {
  border-color: #4a7f4f;
  color: #a0d8a0;
}
@keyframes vs-toast-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 즐겨찾기 버튼 (channel / favorites) ────────────────── */
.vs-favorite-btn {
  background: transparent;
  border: 1px solid #1c2a2a;
  color: #1c2a2a;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.vs-favorite-btn:hover:not(:disabled) {
  background: rgba(28, 42, 42, 0.1);
  color: #6C6E71;
  border-color: #6C6E71;
}
.vs-favorite-btn.active {
  border-color: #FEDF68;
  color: #FEDF68;
}
.vs-favorite-btn.active:hover {
  background: rgba(254, 223, 104, 0.1);
}
.vs-favorite-btn:disabled {
  color: #555;
  border-color: #2a2a30;
  cursor: not-allowed;
}

/* ── Chart.js 컨테이너 ──────────────────────────────────── */
.vs-chart-container {
  position: relative;
  width: 100%;
  height: 320px;
  background: #2a2a30;
  border: 1px solid #2a2a30;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}
.vs-chart-fallback {
  padding: 32px 16px;
  text-align: center;
  color: #888;
  font-size: 12.5px;
  line-height: 1.55;
}

/* ── 인사이트 페이지 (year selector + top 100 grid) ────── */
.vs-insights-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.vs-insights-controls label {
  font-size: 12.5px;
  color: #aaa;
  font-weight: 500;
}
.vs-insights-controls select {
  background: #2a2a30;
  border: 1px solid #2a2a30;
  color: #e0e0e0;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.vs-insights-controls select:focus {
  outline: none;
  border-color: #1c2a2a;
}
.vs-insights-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .vs-insights-grid {
    grid-template-columns: 1fr;
  }
}
.vs-insights-status {
  padding: 24px 16px;
  text-align: center;
  color: #aaa;
  font-size: 13px;
  background: #2a2a30;
  border: 1px solid #2a2a30;
  border-radius: 8px;
}

/* ── 채널 페이지 헤더 카드 ─────────────────────────────── */
.vs-channel-hero {
  display: flex;
  gap: 20px;
  align-items: center;
  background: #2a2a30;
  border: 1px solid #2a2a30;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.vs-channel-hero .vs-channel-thumb {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid #1a1a1a;
  background: #1a1a1a;
  flex-shrink: 0;
}
.vs-channel-hero-body {
  flex: 1;
  min-width: 200px;
}
.vs-channel-hero-body h1 {
  font-size: 20px;
  font-weight: 700;
  color: #e0e0e0;
  margin: 0 0 6px;
  letter-spacing: -0.3px;
}
.vs-channel-hero-body .vs-channel-stats {
  display: flex;
  gap: 18px;
  font-size: 12.5px;
  color: #6C6E71;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.vs-channel-hero-body .vs-channel-stats span strong {
  color: #e0e0e0;
  font-weight: 600;
  margin-right: 4px;
}
.vs-channel-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 4px;
}
.vs-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid #1c2a2a;
  border-radius: 12px;
  color: #1c2a2a;
  font-size: 11.5px;
  font-weight: 500;
}
.vs-badge.growth-up { border-color: #4a7f4f; color: #a0d8a0; }
.vs-badge.growth-down { border-color: #8f4a4a; color: #d8a0a0; }

.vs-section-title {
  font-size: 15px;
  font-weight: 600;
  color: #e0e0e0;
  margin: 20px 0 10px;
}

/* ── 즐겨찾기 페이지 grid ──────────────────────────────── */
.vs-fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.vs-fav-card {
  background: #2a2a30;
  border: 1px solid #2a2a30;
  border-radius: 8px;
  padding: 14px;
  transition: border-color 0.15s;
}
.vs-fav-card:hover {
  border-color: #1c2a2a;
}
.vs-fav-card .vs-fav-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.vs-fav-card .vs-fav-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 1px solid #1a1a1a;
  flex-shrink: 0;
}
.vs-fav-card .vs-fav-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #e0e0e0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vs-fav-card .vs-fav-metric {
  font-size: 12px;
  color: #6C6E71;
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
}
.vs-fav-card .vs-fav-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.vs-fav-empty {
  padding: 48px 24px;
  text-align: center;
  color: #888;
  background: #2a2a30;
  border: 1px solid #2a2a30;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}

/* ── 설정 페이지 form ──────────────────────────────────── */
.vs-settings-card {
  max-width: 560px;
  margin: 0 auto;
  background: #232328;
  border: 1px solid #2a2a30;
  border-radius: 10px;
  padding: 28px;
}
.vs-settings-section {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #2a2a30;
}
.vs-settings-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}
.vs-settings-section h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: #e0e0e0;
  margin: 0 0 12px;
}
.vs-settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  color: #e0e0e0;
  gap: 12px;
  flex-wrap: wrap;
}
.vs-settings-row .vs-settings-key {
  color: #aaa;
  font-size: 12.5px;
}
.vs-settings-row .vs-settings-val {
  color: #e0e0e0;
  font-variant-numeric: tabular-nums;
}
.vs-radio-group {
  display: inline-flex;
  gap: 4px;
  background: #1a1a1a;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #2a2a30;
}
.vs-radio-group label {
  cursor: pointer;
}
.vs-radio-group input[type=radio] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.vs-radio-group span {
  display: inline-block;
  padding: 5px 12px;
  font-size: 12px;
  color: #aaa;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.vs-radio-group input[type=radio]:checked + span {
  color: #1c2a2a;
  border-color: #1c2a2a;
}
.vs-toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}
.vs-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.vs-toggle .vs-toggle-slider {
  position: absolute;
  inset: 0;
  background: #2a2a30;
  border: 1px solid #555;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.vs-toggle .vs-toggle-slider::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #888;
  transition: transform 0.15s, background 0.15s;
}
.vs-toggle input:checked + .vs-toggle-slider {
  border-color: #1c2a2a;
}
.vs-toggle input:checked + .vs-toggle-slider::before {
  transform: translateX(20px);
  background: #1c2a2a;
}

/* ── 반응형 ────────────────────────────────────────────── */
@media (max-width: 780px) {
  .vs-signup-cta { padding: 24px 20px; }
  .vs-signup-cta h2 { font-size: 16px; }
  .vs-channel-hero { padding: 16px; }
  .vs-channel-hero .vs-channel-thumb { width: 72px; height: 72px; }
  .vs-channel-hero-body h1 { font-size: 17px; }
  .vs-settings-card { padding: 20px; }
}

/* ── Footer ─────────────────────────────────────────────── */
.vs-footer {
  background: #232328;
  border-top: 1px solid #2a2a30;
  padding: 16px 20px;
  margin-top: 24px;
  text-align: center;
}
.vs-footer p {
  margin: 0;
  font-size: 11.5px;
  color: #888;
}
