/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --text: #1e1b4b;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --page-bg: #f8fafc;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(79,70,229,0.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Ad Containers ────────────────────────────────────────────── */
.ad-container {
  width: 100%;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-mid {
  margin: 24px auto;
  max-width: 900px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ── Header ───────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 36px 24px 24px;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 10px;
  gap: 12px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.dot { color: #818cf8; }
.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ── Language Switcher ────────────────────────────────────────── */
.lang-select {
  position: absolute;
  right: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
  white-space: nowrap;
}
.lang-select:hover,
.lang-select:focus { border-color: var(--primary); }

@media (max-width: 600px) {
  .lang-select {
    position: static;
    font-size: 0.78rem;
    padding: 5px 24px 5px 8px;
  }
}

/* ── Search Section ───────────────────────────────────────────── */
.search-section {
  max-width: 760px;
  margin: 0 auto 24px;
  padding: 0 16px;
}
.input-wrap {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 50px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.input-wrap:focus-within { border-color: var(--primary); }

.platform-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px 0 18px;
  flex-shrink: 0;
}
.platform-icons img { width: 20px; height: 20px; opacity: 0.7; }

#url-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: 16px 8px;
  background: transparent;
  color: var(--text);
  min-width: 0;
}
#url-input::placeholder { color: #9ca3af; }

/* 입력창 내 액션 버튼 (붙여넣기 / 지우기) */
.input-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 6px 4px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.input-action-btn:hover { color: var(--primary); background: var(--primary-light); }
.input-action-btn.hidden { display: none; }

.paste-btn {
  color: var(--primary);
  padding: 6px 10px;
  margin-right: 2px;
}
.paste-btn:hover { background: var(--primary-light); }

.paste-btn::before {
  content: '';
  display: block;
  width: 1px;
  height: 20px;
  background: var(--border);
  margin-right: 10px;
}

#search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 0 48px 48px 0;
  margin: 4px 4px 4px 0;
  transition: background .2s;
  white-space: nowrap;
}
#search-btn:hover { background: var(--primary-hover); }
#search-btn:disabled { opacity: .6; cursor: not-allowed; }

.spinner {
  width: 18px; height: 18px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-top: 10px;
}

/* ── Error ────────────────────────────────────────────────────── */
.error-box {
  max-width: 760px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  background: var(--error-bg);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--error);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
}

/* ── Result Section ───────────────────────────────────────────── */
.result-section {
  max-width: 760px;
  margin: 0 auto 32px;
  padding: 0 16px;
}
.result-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.video-info {
  display: flex;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.thumbnail-wrap {
  position: relative;
  flex-shrink: 0;
}
.thumbnail-wrap img {
  width: 180px;
  height: 101px;
  object-fit: cover;
  border-radius: 8px;
  background: #e5e7eb;
  display: block;
}
.duration-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.platform-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: capitalize;
}
.video-meta { flex: 1; min-width: 0; }
.video-meta h2 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-meta p { color: var(--text-secondary); font-size: 0.85rem; }

/* ── Formats ──────────────────────────────────────────────────── */
.formats-section { padding: 20px; }
.formats-section h3 { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 14px; }

.format-list { display: flex; flex-wrap: wrap; gap: 10px; }

.format-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--primary-light);
  color: var(--primary);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
  min-width: 100px;
  position: relative;
}
.format-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.format-btn.downloading { opacity: .7; cursor: not-allowed; }
.format-btn.audio-btn { background: #f0fdf4; color: #15803d; }
.format-btn.audio-btn:hover { background: #15803d; color: #fff; }

/* single 플랫폼 (Instagram, TikTok): 버튼 크게 */
.format-list--single .format-btn:not(.audio-btn) {
  min-width: 160px;
  padding: 16px 28px;
}
.format-list--single .format-icon { font-size: 1.8rem; }
.format-list--single .format-quality { font-size: 1.1rem; }

.format-quality { font-size: 1rem; font-weight: 700; }
.format-ext { font-size: 0.72rem; font-weight: 500; opacity: .8; text-transform: uppercase; }
.format-icon { font-size: 1.4rem; }

/* 노트 배지 (워터마크 없음 등) */
.fmt-note {
  font-size: 0.65rem;
  font-weight: 700;
  background: #dcfce7;
  color: #15803d;
  border-radius: 4px;
  padding: 1px 5px;
  margin-top: 2px;
}
.format-btn:hover .fmt-note { background: rgba(255,255,255,.25); color: #fff; }

/* ── How to Use ───────────────────────────────────────────────── */
.how-to {
  max-width: 760px;
  margin: 0 auto 40px;
  padding: 0 16px;
}
.how-to h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.steps { display: flex; gap: 16px; margin-bottom: 24px; }
.step {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.step-num {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.step p { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }

.supported-sites {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.supported-sites h3 { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.supported-sites p { font-size: 0.9rem; color: var(--text); }

/* ── Disclaimer ───────────────────────────────────────────────── */
.disclaimer-section {
  max-width: 760px;
  margin: 0 auto 24px;
  padding: 0 16px;
}
.disclaimer-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius);
  padding: 16px 20px;
}
.disclaimer-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
  padding-top: 2px;
}
.disclaimer-body {
  flex: 1;
  min-width: 0;
}
.disclaimer-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #92400e;
  margin: 0 0 6px 0;
}
.disclaimer-body p {
  font-size: 0.85rem;
  line-height: 1.75;
  color: #78350f;
  margin: 0;
}

/* ── Cookie Banner ────────────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e1b4b;
  color: #e0e7ff;
  z-index: 900;
  box-shadow: 0 -4px 20px rgba(0,0,0,.25);
}
.cookie-banner-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.cookie-text { flex: 1; min-width: 240px; }
.cookie-text strong { display: block; margin-bottom: 4px; font-size: 0.95rem; }
.cookie-text p { font-size: 0.83rem; line-height: 1.5; color: #c7d2fe; margin: 0; }
.cookie-text a { color: #a5b4fc; text-decoration: underline; }
.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-accept {
  background: #4f46e5; color: #fff;
  border: none; border-radius: 8px;
  padding: 9px 20px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: background .2s;
}
.cookie-accept:hover { background: #4338ca; }
.cookie-decline {
  background: transparent; color: #a5b4fc;
  border: 1px solid #4f46e5; border-radius: 8px;
  padding: 9px 16px; font-size: 0.9rem;
  cursor: pointer; transition: all .2s;
}
.cookie-decline:hover { background: rgba(79,70,229,.15); }

/* ── Footer ───────────────────────────────────────────────────── */
footer {
  margin-top: auto;
  text-align: center;
  padding: 20px 16px;
  border-top: 1px solid var(--border);
}
.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.footer-links a { font-size: 0.85rem; color: var(--primary); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.footer-links span { color: var(--border); }
.footer-copy { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.6; }

/* ── Admin Panel ──────────────────────────────────────────────── */
.admin-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.admin-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 480px;
  position: relative;
}
.admin-card h3 { font-size: 1.1rem; margin-bottom: 20px; }
.close-btn {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  font-size: 1.1rem; cursor: pointer; color: var(--text-secondary);
}
.admin-form { display: flex; flex-direction: column; gap: 14px; }
.admin-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; font-weight: 500; }
.admin-form input[type="text"],
.admin-form input[type="password"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color .2s;
}
.admin-form input:focus { border-color: var(--primary); }
.toggle-row { flex-direction: row !important; align-items: center; justify-content: space-between; }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #ccc; border-radius: 24px; cursor: pointer;
  transition: .3s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .3s;
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

.save-btn {
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px;
  padding: 10px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: background .2s;
}
.save-btn:hover { background: var(--primary-hover); }
.admin-msg { font-size: 0.85rem; text-align: center; min-height: 18px; }
.admin-msg.ok { color: var(--success); }
.admin-msg.err { color: var(--error); }

/* Cookies section */
.cookies-section { display: flex; flex-direction: column; gap: 8px; }
.cookies-header { display: flex; align-items: center; gap: 8px; }
.cookies-badge {
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: #f3f4f6; color: #6b7280;
}
.cookies-badge.active { background: #dcfce7; color: #16a34a; }
.cookies-badge.inactive { background: #fef2f2; color: #dc2626; }
.cookies-desc { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }
.cookies-desc a { color: var(--primary); }
.cookies-desc code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 0.8rem; }
.file-upload-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.upload-btn, .delete-btn {
  border: none; border-radius: 6px; padding: 7px 12px;
  font-size: 0.82rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.upload-btn { background: var(--primary); color: #fff; }
.upload-btn:hover { background: var(--primary-hover); }
.delete-btn { background: #fef2f2; color: var(--error); }
.delete-btn:hover { background: #fee2e2; }

/* ── Utility ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 32px 16px 20px; }
  .logo { font-size: 1.3rem; }
  .platform-icons { display: none; }
  .input-wrap { border-radius: 14px; }
  #search-btn { border-radius: 10px; padding: 12px 18px; margin: 4px; }
  #url-input { padding: 14px 12px; }
  .video-info { flex-direction: column; }
  .thumbnail-wrap img { width: 100%; height: auto; }
  .steps { flex-direction: column; }
}
