/* ===== 리셋 & 변수 ===== */
:root {
  --bg: #0d0d0d;
  --bg-card: #161616;
  --bg-input: #1a1a1a;
  --border: #2a2a2a;
  --border-focus: #ff3c3c;
  --accent: #ff3c3c;
  --accent-dim: rgba(255, 60, 60, 0.12);
  --accent-hover: #ff5a5a;
  --text: #f0f0f0;
  --text-muted: #888;
  --text-sub: #555;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
}

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

html {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden { display: none !important; }

/* ===== 헤더 ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: auto;
}

/* ===== 메인 ===== */
main.container {
  flex: 1;
  padding-top: 56px;
  padding-bottom: 80px;
}

/* ===== 히어로 ===== */
.search-section {
  text-align: center;
  margin-bottom: 48px;
}

.hero-title {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
}

/* ===== 검색 박스 ===== */
.search-box {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.5;
}

.url-input {
  width: 100%;
  padding: 14px 40px 14px 42px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}

.url-input:focus {
  border-color: var(--border-focus);
}

.url-input::placeholder {
  color: var(--text-sub);
}

.btn-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  transition: color var(--transition);
}

.btn-clear:hover { color: var(--text-muted); }

.btn-fetch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), opacity var(--transition);
}

.btn-fetch:hover { background: var(--accent-hover); }
.btn-fetch:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.error-msg {
  margin-top: 12px;
  color: var(--accent);
  font-size: 13px;
}

/* ===== 영상 카드 ===== */
.video-card {
  display: flex;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.video-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 180px;
  height: 101px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #111;
}

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

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

.video-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.video-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-uploader, .video-views {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== 포맷 선택 ===== */
.format-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.format-toggle {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.fmt-btn {
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.fmt-btn.active {
  background: var(--accent);
  color: #fff;
}

.fmt-btn:hover:not(.active) { background: rgba(255,255,255,0.05); }

.quality-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quality-label {
  font-size: 12px;
  color: var(--text-muted);
}

.quality-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 10px;
  cursor: pointer;
  outline: none;
}

.quality-select:focus { border-color: var(--border-focus); }

.btn-download {
  margin-top: auto;
  padding: 11px 0;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-download:hover { background: var(--accent-hover); }

/* ===== 진행 ===== */
.progress-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  animation: fadeIn 0.25s ease;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-label { font-size: 14px; font-weight: 500; }
.progress-pct { font-size: 14px; color: var(--accent); font-weight: 600; }

.progress-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.btn-cancel {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-cancel:hover { border-color: var(--accent); color: var(--accent); }

/* ===== 완료 ===== */
.done-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  margin-bottom: 24px;
  animation: fadeIn 0.25s ease;
}

.done-icon {
  width: 56px;
  height: 56px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin: 0 auto 16px;
}

.done-text { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.done-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.done-actions { display: flex; justify-content: center; gap: 12px; }

.btn-save {
  display: inline-block;
  padding: 11px 24px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition);
}

.btn-save:hover { background: var(--accent-hover); }

.btn-again {
  padding: 11px 24px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-again:hover { border-color: var(--text-muted); color: var(--text); }

/* ===== 사용법 ===== */
.how-section {
  margin: 48px 0 40px;
}

.how-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-muted);
}

.how-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.how-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.step-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ===== 지원 사이트 ===== */
.support-section {
  margin-bottom: 40px;
}

.support-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.support-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.site-badge {
  padding: 5px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
}

.support-note {
  font-size: 12px;
  color: var(--text-sub);
}

/* ===== 푸터 ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
}

.site-footer p {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.footer-tech { color: var(--text-sub) !important; }

/* ===== 반응형 ===== */
@media (max-width: 600px) {
  main.container { padding-top: 32px; }
  .search-box { flex-direction: column; }
  .btn-fetch { width: 100%; justify-content: center; }

  .video-card { flex-direction: column; }
  .video-thumb-wrap { width: 100%; height: 180px; }

  .how-steps { grid-template-columns: 1fr; }
  .header-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
