/* ===== Reset & Base ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-1: #0a0118;
  --bg-2: #1a0b2e;
  --bg-3: #16213e;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --text-dim: #a0a8c0;
  --text-faint: #6b7280;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-grad: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sarabun", "Noto Sans Thai", Roboto, sans-serif;
  background: var(--bg-1);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background: radial-gradient(ellipse at top, var(--bg-2) 0%, var(--bg-1) 50%),
              radial-gradient(ellipse at bottom, var(--bg-3) 0%, var(--bg-1) 50%);
  position: relative;
}

.bg-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  filter: blur(60px);
}

/* ===== Layout ===== */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 60px 24px 80px;
  position: relative;
  z-index: 1;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  margin-bottom: 40px;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 100px;
  font-size: 13px;
  color: #c4b5fd;
  margin-bottom: 20px;
  font-weight: 500;
}

.hero h1 {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -1.5px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 14px;
  line-height: 1.1;
}

.subtitle {
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 540px;
  margin: 0 auto;
}

.subtitle strong {
  color: var(--text);
  font-weight: 600;
}

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* ===== Platform Pills ===== */
.platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.platform-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  transform: translateY(-1px);
}

.platform-pill.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.platform-icon {
  font-size: 14px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

/* ===== URL Input ===== */
.url-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  overflow: hidden;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

#urlInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  min-width: 0;
}

#urlInput::placeholder {
  color: var(--text-faint);
}

.ghost-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  transition: color 0.2s;
}

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

/* ===== Buttons ===== */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--accent-grad);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-width: 130px;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.primary-btn.big {
  width: 100%;
  padding: 16px 24px;
  font-size: 16px;
  margin-top: 8px;
}

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

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

/* ===== Detected Badge ===== */
.detected-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
}

/* ===== Video Card ===== */
.video-card {
  animation: slideIn 0.3s ease;
}

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

.video-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

#thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;
}

.play-overlay:hover {
  background: rgba(139, 92, 246, 0.8);
  border-color: transparent;
  transform: translate(-50%, -50%) scale(1.1);
}

.video-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
  word-break: break-word;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-dim);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.platform-tag {
  padding: 3px 10px;
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.quality-option {
  cursor: pointer;
}

.quality-option input {
  display: none;
}

.quality-box {
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  text-align: center;
  transition: all 0.2s ease;
}

.quality-option:hover .quality-box {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.quality-option input:checked + .quality-box {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.q-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.q-desc {
  font-size: 11px;
  color: var(--text-faint);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  z-index: 100;
  animation: toastIn 0.3s ease;
  max-width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.toast.success { border-color: rgba(16, 185, 129, 0.5); }
.toast.error { border-color: rgba(239, 68, 68, 0.5); }
.toast.info { border-color: rgba(139, 92, 246, 0.5); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ===== Footer ===== */
.info-footer {
  margin-top: 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.info-footer details {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  text-align: left;
}

.info-footer summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
  outline: none;
}

.info-footer summary:hover {
  color: var(--text);
}

.tips {
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-dim);
}

.tips hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 12px 0;
}

.tips strong {
  color: var(--text);
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .container { padding: 40px 16px 60px; }
  .hero h1 { font-size: 36px; }
  .subtitle { font-size: 15px; }
  .card { padding: 20px; }
  .url-row { flex-direction: column; }
  .primary-btn { width: 100%; }
  .platforms { gap: 6px; }
  .platform-pill { font-size: 13px; padding: 8px 12px; }
  .video-title { font-size: 17px; }
  .quality-grid { grid-template-columns: repeat(2, 1fr); }
}
