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

:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface2: #1c1c27;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #f0eeff;
  --muted: #7b7a96;
  --faint: #3d3c52;
  --accent: #7c6cff;
  --accent2: #a78bfa;
  --accent-glow: rgba(124,108,255,0.25);
  --green: #22d3a0;
  --green-bg: rgba(34,211,160,0.1);
  --red: #ff6b6b;
  --red-bg: rgba(255,107,107,0.1);
  --r: 16px;
  --r-sm: 10px;
}

html, body { height: 100%; }

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

body::after {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(124,108,255,0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 0 40px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.logo { display: flex; align-items: center; gap: 10px; }

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #5b4fcc);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.logo-text {
  font-size: 20px; font-weight: 900; letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, var(--accent2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--muted);
  letter-spacing: 1px; text-transform: uppercase; margin-top: -2px;
}

.header-badge {
  font-size: 11px; color: var(--green);
  background: var(--green-bg); padding: 4px 10px; border-radius: 20px;
  border: 1px solid rgba(34,211,160,0.2);
}

.hero { padding: 32px 20px 24px; text-align: center; }

.hero h1 {
  font-size: 28px; font-weight: 900; line-height: 1.2;
  margin-bottom: 8px; letter-spacing: -0.5px;
}

.hero h1 span {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.hero p { font-size: 14px; color: var(--muted); line-height: 1.6; }

.platforms-wrap { padding: 0 20px 16px; overflow-x: auto; scrollbar-width: none; }
.platforms-wrap::-webkit-scrollbar { display: none; }
.platforms { display: flex; gap: 8px; padding-bottom: 4px; }

.plt {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--surface); color: var(--muted);
  font-size: 13px; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: all .2s;
  font-family: 'Tajawal', sans-serif;
}

.plt.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.plt:not(.active):hover { color: var(--text); background: var(--surface2); }

.main-card {
  margin: 0 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r-sm); padding: 4px 4px 4px 12px;
  transition: border-color .2s;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrap input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 13px; color: var(--text);
  font-family: 'Space Mono', monospace;
  direction: ltr; text-align: left; padding: 8px 0;
}

.input-wrap input::placeholder {
  color: var(--faint); font-family: 'Tajawal', sans-serif;
  direction: rtl; text-align: right; font-size: 13px;
}

.btn-paste {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); padding: 6px; border-radius: 6px;
  transition: all .15s; display: flex;
}
.btn-paste:hover { color: var(--text); background: var(--border); }

.btn-analyze {
  background: linear-gradient(135deg, var(--accent), #5b4fcc);
  color: #fff; border: none; border-radius: var(--r-sm);
  padding: 10px 18px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: 'Tajawal', sans-serif;
  white-space: nowrap; transition: all .2s;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-analyze:hover { transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }
.btn-analyze:disabled { opacity: 0.5; transform: none; cursor: not-allowed; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.err-box {
  margin-top: 12px; padding: 10px 14px;
  background: var(--red-bg); border: 1px solid rgba(255,107,107,0.2);
  border-radius: var(--r-sm); font-size: 13px; color: var(--red); display: none;
}

.result-panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: none; }

.video-info { display: flex; gap: 12px; margin-bottom: 14px; }

.thumb-wrap {
  width: 68px; height: 68px; border-radius: var(--r-sm);
  overflow: hidden; flex-shrink: 0; background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); border: 1px solid var(--border); position: relative;
}

.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: none; position: absolute; }

.video-meta { flex: 1; min-width: 0; }
.video-title { font-size: 14px; font-weight: 700; line-height: 1.4; }
.video-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.formats-label {
  font-size: 11px; color: var(--muted); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .06em;
  font-family: 'Space Mono', monospace;
}

.formats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.format-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 12px; cursor: pointer;
  text-align: right; transition: all .2s; position: relative; overflow: hidden;
  font-family: 'Tajawal', sans-serif;
}

.format-btn:hover { border-color: var(--accent); background: rgba(124,108,255,0.08); }
.format-btn.downloading { border-color: var(--accent); background: rgba(124,108,255,0.12); }

.fmt-quality { font-size: 14px; font-weight: 700; color: var(--text); }
.fmt-info { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: 'Space Mono', monospace; }

.progress-panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: none; }

.prog-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; color: var(--muted); }
.prog-pct { font-family: 'Space Mono', monospace; color: var(--accent2); font-weight: 700; }

.prog-track { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.prog-bar {
  height: 100%; border-radius: 2px; width: 0%; transition: width .3s ease;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.prog-meta { font-size: 11px; color: var(--faint); font-family: 'Space Mono', monospace; }

.divider { height: 1px; background: var(--border); margin: 20px; }

.sites-section { padding: 0 20px; }

.sites-title {
  font-size: 11px; color: var(--faint); text-transform: uppercase;
  letter-spacing: .08em; font-family: 'Space Mono', monospace; margin-bottom: 12px;
}

.sites-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.site-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 8px; text-align: center; transition: all .2s;
}

.site-item:hover { border-color: var(--border2); background: var(--surface2); }
.site-item .site-icon { font-size: 20px; margin-bottom: 4px; }
.site-item .site-name { font-size: 10px; color: var(--muted); }

.history-section { padding: 0 20px; margin-top: 20px; display: none; }
.history-title {
  font-size: 11px; color: var(--faint); text-transform: uppercase;
  letter-spacing: .08em; font-family: 'Space Mono', monospace; margin-bottom: 12px;
}

.hist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 8px;
}

.hist-icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--muted);
}

.hist-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: 'Space Mono', monospace; }

.hist-done {
  font-size: 10px; padding: 3px 8px; border-radius: 20px;
  background: var(--green-bg); color: var(--green);
  flex-shrink: 0; margin-right: auto;
  border: 1px solid rgba(34,211,160,0.2);
}

.footer { text-align: center; padding: 24px 20px 0; font-size: 12px; color: var(--faint); }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent2); }

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

.app > * { animation: fadeUp .4s ease both; }
.header { animation-delay: 0s; }
.hero { animation-delay: .05s; }
.platforms-wrap { animation-delay: .1s; }
.main-card { animation-delay: .15s; }

@media (min-width: 481px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
