/* ytsub — dark, calm, focused. No external assets. */

:root {
  --bg: #0a0c12;
  --surface: #12151f;
  --surface-2: #171b28;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ebf4;
  --muted: #8b93a7;
  --faint: #5d6478;
  --accent-a: #6366f1;
  --accent-b: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --violet: #a78bfa;
  --red: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(99, 102, 241, 0.14), transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, rgba(34, 211, 238, 0.08), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

::selection { background: rgba(99, 102, 241, 0.4); }

a { color: var(--accent-b); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- logo ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  user-select: none;
}
.logo .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.35);
}
.logo .name {
  background: linear-gradient(90deg, #fff, #b9c1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
}
button:hover { background: #1d2233; border-color: rgba(255, 255, 255, 0.24); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); }

.btn-danger:hover { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.5); color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }

input[type="text"], input[type="password"], input[type="search"], textarea, select {
  font: inherit;
  width: 100%;
  background: #0d1019;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select { cursor: pointer; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 30px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.login-card .logo { justify-content: center; margin-bottom: 8px; font-size: 24px; }
.login-card .tagline { color: var(--muted); font-size: 13.5px; margin: 0 0 26px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-card label { font-size: 12.5px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.login-card .btn-primary { margin-top: 8px; padding: 11px; }
.login-error {
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--red);
  font-size: 13.5px;
  text-align: left;
}
.login-error.show { display: block; }

/* ---------- app shell ---------- */
.shell { max-width: 1060px; margin: 0 auto; padding: 22px 20px 80px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.hero h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.hero p { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* composer */
.mode-switch {
  display: inline-flex;
  background: #0d1019;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 14px;
}
.mode-switch button {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13.5px;
}
.mode-switch button.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.url-row { display: flex; gap: 10px; }
.url-row input { flex: 1; }
.composer-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.composer-actions .btn-primary { padding: 10px 20px; }
.batch-note { color: var(--faint); font-size: 12.5px; }
#batch-input { display: none; min-height: 110px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* status / progress */
.status {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}
.status.show { display: flex; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-b);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  display: none;
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: rgba(248, 113, 113, 0.09);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--red);
}
.alert.show { display: block; }
.alert.info {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--amber);
}

/* video preview card */
.video-card {
  display: none;
  gap: 14px;
  margin-top: 16px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  align-items: stretch;
}
.video-card.show { display: flex; }
.video-thumb {
  position: relative;
  width: 168px;
  min-width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1019;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.video-title {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-sub { color: var(--muted); font-size: 12.5px; }
.video-meta select { font-size: 13.5px; padding: 8px 10px; }
.skeleton {
  background: linear-gradient(90deg, #171b28 25%, #1f2534 45%, #171b28 65%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
  color: transparent !important;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* badges */
.badges { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 0; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3.5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}
.badge.src-ytdlp-manual { color: var(--green); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.badge.src-ytdlp-auto { color: var(--amber); border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.badge.src-apify { color: var(--violet); border-color: rgba(167, 139, 250, 0.4); background: rgba(167, 139, 250, 0.08); }

/* result */
.result-title { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; margin: 2px 0 2px; }
.result-sub { color: var(--muted); font-size: 13.5px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.tabs {
  display: flex;
  gap: 2px;
  margin-top: 18px;
  border-bottom: 1px solid var(--border);
}
.tabs button {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  padding: 8px 14px;
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent-b); }
.transcript-box {
  margin-top: 14px;
  background: #0d1019;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.75;
  color: #d7dcea;
}
.transcript-box.md { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.transcript-box::-webkit-scrollbar { width: 10px; }
.transcript-box::-webkit-scrollbar-thumb { background: #232a3d; border-radius: 8px; border: 2px solid #0d1019; }

/* batch rows */
.batch-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.batch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.batch-row .b-url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.chip { font-size: 11.5px; font-weight: 700; padding: 2.5px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.chip.pending { color: var(--faint); border: 1px solid var(--border-strong); }
.chip.working { color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.4); animation: pulse 1.2s infinite; }
.chip.ok { color: var(--green); border: 1px solid rgba(52, 211, 153, 0.4); }
.chip.fail { color: var(--red); border: 1px solid rgba(248, 113, 113, 0.4); }
@keyframes pulse { 50% { opacity: 0.55; } }

/* history */
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.history-head h2 { font-size: 16.5px; margin: 0; }
.history-head input { max-width: 260px; }
.hist-list { display: flex; flex-direction: column; gap: 9px; }
.hist-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  align-items: center;
  transition: border-color 0.15s;
}
.hist-item:hover { border-color: var(--border-strong); }
.hist-thumb {
  width: 86px;
  min-width: 86px;
  aspect-ratio: 16/9;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1019;
  cursor: pointer;
}
.hist-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hist-meta { flex: 1; min-width: 0; cursor: pointer; }
.hist-title {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.hist-actions { display: flex; gap: 6px; }
.hist-actions button { padding: 6px 10px; font-size: 12.5px; }
.empty {
  color: var(--faint);
  text-align: center;
  padding: 26px 0 18px;
  font-size: 14px;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(16px);
  background: #1d2333;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* misc */
.hidden { display: none !important; }
@media (max-width: 640px) {
  .video-card { flex-direction: column; }
  .video-thumb { width: 100%; }
  .hist-item { flex-wrap: wrap; }
}
