/* openytdl - dark, glassy, quiet. */
:root {
  --bg: #0a0b10;
  --bg-2: #0e1018;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-solid: #14161f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ebf2;
  --muted: #8b91a6;
  --faint: #616779;
  --accent: #6d5efc;
  --accent-2: #22d3ee;
  --accent-soft: rgba(109, 94, 252, 0.16);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ambient background */
body::before {
  content: "";
  position: fixed;
  inset: -30%;
  z-index: -1;
  background:
    radial-gradient(42rem 42rem at 12% -5%, rgba(109, 94, 252, 0.22), transparent 60%),
    radial-gradient(38rem 38rem at 92% 8%, rgba(34, 211, 238, 0.14), transparent 62%),
    radial-gradient(46rem 46rem at 55% 110%, rgba(236, 72, 153, 0.10), transparent 60%);
  filter: blur(20px);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 2%, 0) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: var(--accent-2); }

/* ---------- layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 20px 90px; }

header.top {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 2px 22px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; }

.logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(109, 94, 252, 0.4);
}
.logo svg { width: 20px; height: 20px; }

.brand h1 {
  font-size: 19px; margin: 0; letter-spacing: -0.02em; font-weight: 650;
}
.brand span { display: block; font-size: 11.5px; color: var(--faint); font-weight: 500; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 11.5px; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.chip .dot.bad { background: var(--bad); }
.chip .dot.warn { background: var(--warn); }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.card.pad-0 { padding: 0; overflow: hidden; }

h2.section {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--faint); margin: 26px 4px 12px; font-weight: 650;
  display: flex; align-items: center; gap: 10px;
}
h2.section .count {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  letter-spacing: 0;
}
h2.section .spacer { margin-left: auto; }

/* ---------- url bar ---------- */
.urlbar { display: flex; gap: 10px; }

.input, .select, textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: rgba(0, 0, 0, 0.4);
}
.select { padding: 9px 11px; font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel); color: var(--text);
  font-size: 14px; font-weight: 560; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,0.08); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(109, 94, 252, 0.32);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), #8b5cf6); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn.danger:hover:not(:disabled) { border-color: rgba(248,113,113,0.5); color: var(--bad); background: rgba(248,113,113,0.08); }
.btn svg { width: 16px; height: 16px; flex: none; }

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

/* ---------- meta / preview ---------- */
.meta { display: flex; gap: 18px; }
.meta .thumb {
  width: 232px; aspect-ratio: 16/9; flex: none;
  border-radius: 11px; object-fit: cover;
  background: var(--panel-solid); border: 1px solid var(--border);
}
.meta .info { min-width: 0; flex: 1; }
.meta h3 {
  margin: 2px 0 8px; font-size: 18px; line-height: 1.3; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta .facts { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.tag.accent { background: var(--accent-soft); border-color: rgba(109,94,252,0.35); color: #c4bcff; }
.tag.live { background: rgba(248,113,113,0.14); border-color: rgba(248,113,113,0.4); color: #fca5a5; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: rgba(0,0,0,0.28); border-radius: 11px; border: 1px solid var(--border); }
.tab {
  flex: 1; padding: 8px 12px; border-radius: 8px; border: none;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 560;
  cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--accent-soft); color: #cfc8ff; box-shadow: inset 0 0 0 1px rgba(109,94,252,0.3); }
.tab:hover:not(.active) { color: var(--text); }

/* ---------- quality options ---------- */
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 10px; }

.opt {
  position: relative; text-align: left; cursor: pointer;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: rgba(0,0,0,0.22);
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
  font-family: inherit; color: var(--text);
}
.opt:hover { border-color: var(--border-strong); background: rgba(255,255,255,0.05); }
.opt.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), rgba(109,94,252,0.06));
  box-shadow: 0 0 0 1px rgba(109,94,252,0.35);
}
.opt .label { font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
.opt .detail { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.opt .star {
  position: absolute; top: 10px; right: 11px;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--accent-2); font-weight: 700;
}

/* ---------- editor-friendly toggle ---------- */
.check.editor-toggle {
  margin-bottom: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--border);
  font-size: 12.5px;
}
.check.editor-toggle:hover { border-color: var(--border-strong); }
.check.editor-toggle b { color: var(--text); font-weight: 620; }
.check.editor-toggle:has(input:checked) {
  border-color: var(--good);
  background: linear-gradient(180deg, rgba(52,211,153,0.10), rgba(52,211,153,0.03));
}

/* ---------- delivery mode ---------- */
.delivery { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }

.dopt {
  text-align: left; cursor: pointer; font-family: inherit; color: var(--text);
  padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: rgba(0, 0, 0, 0.22);
  transition: border-color 0.15s, background 0.15s;
}
.dopt:hover:not(:disabled) { border-color: var(--border-strong); background: rgba(255,255,255,0.05); }
.dopt.selected {
  border-color: var(--accent-2);
  background: linear-gradient(180deg, rgba(34,211,238,0.12), rgba(34,211,238,0.04));
  box-shadow: 0 0 0 1px rgba(34,211,238,0.3);
}
.dopt.off, .dopt:disabled { opacity: 0.42; cursor: not-allowed; }
.dopt .label { font-size: 13.5px; font-weight: 600; }
.dopt .detail { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- format table ---------- */
.tablewrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; padding: 9px 12px; color: var(--faint);
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  background: rgba(0,0,0,0.3); position: sticky; top: 0;
}
td { padding: 9px 12px; border-top: 1px solid var(--border); white-space: nowrap; }
tbody tr { cursor: pointer; transition: background 0.12s; }
tbody tr:hover { background: rgba(255,255,255,0.045); }
tbody tr.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
td.mono, .mono { font-family: var(--mono); font-size: 11.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.pill { font-size: 10px; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); }
.pill.av { color: var(--good); border-color: rgba(52,211,153,0.35); background: rgba(52,211,153,0.08); }
.pill.v  { color: #a5b4fc; border-color: rgba(165,180,252,0.3); background: rgba(165,180,252,0.08); }
.pill.a  { color: var(--warn); border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.08); }

/* ---------- advanced options ---------- */
details.adv { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
details.adv > summary {
  cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 560;
  list-style: none; display: flex; align-items: center; gap: 8px; user-select: none;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: "▸"; transition: transform 0.15s; color: var(--faint); }
details.adv[open] > summary::before { transform: rotate(90deg); }

.grid-opts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 18px; margin-top: 14px;
}
.field label { display: block; font-size: 11.5px; color: var(--faint); margin-bottom: 5px; font-weight: 560; }

.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); cursor: pointer; padding: 3px 0; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.check:hover { color: var(--text); }

/* ---------- jobs ---------- */
.job {
  display: flex; gap: 14px; align-items: center;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.job:last-child { border-bottom: none; }
.job .jthumb {
  width: 72px; aspect-ratio: 16/9; border-radius: 7px; object-fit: cover;
  background: var(--panel-solid); flex: none; border: 1px solid var(--border);
}
.job .jbody { flex: 1; min-width: 0; }
.job .jtitle {
  font-size: 13.5px; font-weight: 560; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.job .jmeta { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.job .jactions { display: flex; gap: 6px; flex: none; }

.bar { height: 5px; border-radius: 99px; background: rgba(255,255,255,0.07); overflow: hidden; margin-top: 8px; }
.bar > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}
.bar.indet > i {
  width: 32% !important;
  animation: slide 1.3s ease-in-out infinite;
}
@keyframes slide { 0% { margin-left: -32%; } 100% { margin-left: 100%; } }
.bar.done > i { background: linear-gradient(90deg, var(--good), #6ee7b7); }
.bar.error > i { background: linear-gradient(90deg, var(--bad), #fca5a5); }

.status { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); text-transform: capitalize; }
.status.running { color: var(--accent-2); border-color: rgba(34,211,238,0.35); background: rgba(34,211,238,0.08); }
.status.queued { color: var(--muted); }
.status.done { color: var(--good); border-color: rgba(52,211,153,0.35); background: rgba(52,211,153,0.08); }
.status.error { color: var(--bad); border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.08); }
.status.canceled { color: var(--faint); }

.log {
  font-family: var(--mono); font-size: 11px; line-height: 1.55;
  background: rgba(0,0,0,0.5); border: 1px solid var(--border); border-radius: 9px;
  padding: 11px 13px; max-height: 260px; overflow: auto; white-space: pre-wrap;
  color: var(--muted); margin: 0 16px 14px;
}

/* ---------- library ---------- */
.file {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.file:last-child { border-bottom: none; }
.file .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .fmeta { color: var(--faint); font-size: 11.5px; white-space: nowrap; font-family: var(--mono); }
.fileicon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--panel); flex: none; color: var(--muted); }
.fileicon svg { width: 15px; height: 15px; }

.empty { padding: 34px 20px; text-align: center; color: var(--faint); font-size: 13.5px; }
.empty svg { width: 34px; height: 34px; opacity: 0.4; display: block; margin: 0 auto 10px; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 9px; max-width: min(400px, calc(100vw - 40px));
}
.toast {
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  padding: 12px 15px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); animation: pop 0.22s ease;
  display: flex; gap: 10px; align-items: flex-start;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast b { display: block; margin-bottom: 2px; font-weight: 620; }
.toast span { color: var(--muted); font-size: 12.5px; word-break: break-word; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(5,6,10,0.7); backdrop-filter: blur(6px);
  z-index: 80; display: grid; place-items: center; padding: 20px;
  animation: pop 0.16s ease;
}
.modal {
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 20px; width: min(620px, 100%);
  box-shadow: var(--shadow); max-height: 84vh; overflow: auto;
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal p.sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: min(400px, 100%); padding: 32px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.02));
  border: 1px solid var(--border); border-radius: 18px;
  backdrop-filter: blur(16px); box-shadow: var(--shadow);
  animation: pop 0.3s ease;
}
.login-card .logo { width: 46px; height: 46px; border-radius: 13px; margin-bottom: 18px; }
.login-card .logo svg { width: 24px; height: 24px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
.login-card p.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.login-card .field { margin-bottom: 13px; }
.login-card .btn { width: 100%; margin-top: 8px; padding: 13px; }
.err {
  color: #fca5a5; font-size: 13px; margin-top: 13px; min-height: 18px;
  background: rgba(248,113,113,0.09); border: 1px solid rgba(248,113,113,0.25);
  border-radius: 8px; padding: 9px 12px; display: none;
}
.err.show { display: block; }
.login-foot { text-align: center; margin-top: 20px; font-size: 11.5px; color: var(--faint); }

kbd {
  font-family: var(--mono); font-size: 10.5px; padding: 1.5px 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; background: rgba(0,0,0,0.3); color: var(--muted);
}

@media (max-width: 720px) {
  .wrap { padding: 16px 14px 70px; }
  .meta { flex-direction: column; }
  .meta .thumb { width: 100%; }
  .urlbar { flex-direction: column; }
  .job .jthumb { display: none; }
  header.top .chip.hide-sm { display: none; }
}
